DialStatus no asterisk…

Redirecionamentos tratando o dialstatus:
Coloquei ramal, mas pode ser feito ate com trunks sip como se fosse um simples backup de terminações quando falham..

exten => _ramal,1,dial(ZAP/Y,50,rtwW)
exten => _ramal,n,Goto(${DIALSTATUS})
exten => _ramal,n(CONGESTION),Dial(ZAP/X,35,wrt)
exten => _ramal,n,Hangup
exten => _ramal,n(busy/congestion),Dial(ZAP/X,35,wrt)
exten => _ramal,n,Hangup
exten => _ramal,n(CHANUNAVAIL),Dial(ZAP/X,35,wrt)
exten => _ramal,n,Hangup

Pode-se fazer playbacks:

exten => _9xx,1,NoCDR()
exten => _9xx,2,Dial(ZAP/${EXTEN:1}r2,35,tTwW)
exten => _9xx,3,Goto(${DIALSTATUS})

exten => _9xx,4(NOANSWER),playback(nao_atende)
exten => _9xx,5(NOANSWER),Dial(ZAP/14&ZAP/30&ZAP/11,35,TtRwW)
exten => _9xx,6,Hangup

exten => _9xx,6(BUSY),playback(direcionando_a_outro)
exten => _9xx,7(BUSY),Dial(ZAP/14&ZAP/30&ZAP/11,35,TtRwW)
exten => _9xx,8,Hangup

exten => _9xx,9(CHANUNAVAIL),playback(ramal_indisponivel)
exten => _9xx,10(CHANUNAVAIL),Dial(ZAP/14&ZAP/30&ZAP/11,35,TtRwW)
exten => _9xx,11,Hangup

Existem outros status e formas de utilidades como retirado de voip-info abaixo:
Contains a text string signifying result of the last dial attempt:

•ANSWER: Call is answered. A successful dial. The caller reached the callee.
•BUSY: Busy signal. The dial command reached its number but the number is busy.
•NOANSWER: No answer. The dial command reached its number, the number rang for too long, then the dial timed out.
•CANCEL: Call is cancelled. The dial command reached its number but the caller hung up before the callee picked up.
•CONGESTION: Congestion. This status is usually a sign that the dialled number is not recognised.
•CHANUNAVAIL: Channel unavailable. On SIP, peer may not be registered.
•DONTCALL: Privacy mode, callee rejected the call
•TORTURE: Privacy mode, callee chose to send caller to torture menu
•INVALIDARGS: Error parsing Dial command arguments (added for Asterisk 1.4.1, SVN r53135-53136)

A good idea is to use this in your dial plan, see example in goto documentation.

Note: In order to obtain useful DIALSTATUS information when dialing a peer you will need to have qualify=yes in that peer’s definition (e.g. in sip.conf or iax.conf).

•CONGESTION “Congestion” is a bit misleading. Unfortunately at this time (2007-05-17), Dial() returns DIALSTATUS=CONGESTION for pretty much every call setup problem. The reasoning behind this is that Dial() can be used for multiple protocols (Zap,SIP,IAX etc.) and so it is limited to the lowest common denominator and is unable to return the protocol specific information (i.e. SIP 404 response) .

There is also currently no way to look at a SIP response in the dialplan, even though it is reported on the debug console (if debug level >3). Even though you can see every other SIP header with ${SIP_HEADER() you cannot see the actual response code. However, Asterisk 1.8 will allow to read SIP response codes in the dialplan via {HASH(SIP_CAUSE,)}.

There should really be a FAIL result so that it is possible to distinguish between “CONGESTION” and a genuine call setup failure, but there isn’t.

IMHO this is slightly broken behaviour and means that “CONGESTION” is pretty meaningless, since it can mean any number of things.
See Asterisk Bug #9743 where I raised this question but got told to go away.

Consider the following situations:-

•You have a number of SIP <-> ISDN gateways or service providers which have a finite number of channels. You want the ability to detect genuine congestion so that you can fail over to another channel on another gateway. Asterisk returns CONGESTION for every type of call failure including Congestion, so this is impossible to implement with ${DIALSTATUS}

•Your handset/clients are not capable of displaying the SIP error response to the user, so you need to return inband a tone. For example, Cisco 7960 SIP image unhelpfully displays “Reorder” with the reorder tone “boop, boop, boop, boop” for every SIP call setup problem (not found, congestion etc.) The US “Reorder” tone is not customisable on this handset and it sounds too much like the UK “engaged” (busy) tone. Therefore the user has no way of telling what went wrong.

•You want to provide a more consistent experience rather than relying on the handset to do the right thing with the SIP error code. Answer() before calling Dial() to get asterisk to go in-band and then use Playtones() Wait() to play country specific call progress tones.

${HANGUPCAUSE}

•It may be possible to get a more detailed response by checking the variable ${HANGUPCAUSE}.
•See Asterisk variable HANGUPCAUSE
•Note: Asterisk 1.8 will allow to read SIP response codes in the dialplan via {HASH(SIP_CAUSE,)}

Example
This macro is an example of how failover for two or more outgoing trunks can be managed

[macro-safedial]
exten => s,1,Set(DIALSTART=${EPOCH})
;exten => s,n,Dial(${ARG1},${ARG2},g,${ARG4})
exten => s,n,Dial(${ARG1},${ARG2},${ARG3},${ARG4})
exten => s,n,Goto(s-${DIALSTATUS},1)

exten => s-CANCEL,1,Hangup
exten => s-NOANSWER,1,Set(DTIME=$[${EPOCH} – ${DIALSTART}])
;watch out: DIALEDTIME can also be empty, next line is not perfect!
;exten => s-NOANSWER,n,GotoIf($[“${DIALEDTIME}” = “0”]?here)
exten => s-NOANSWER,n,GotoIf($[“${DTIME}” = “0”]?here)
exten => s-NOANSWER,n,Hangup
exten => s-NOANSWER,n(here),Verbose(1,Need failover for “${ARG1}”)
exten => s-BUSY,1,Busy
exten => s-CHANUNAVAIL,1,Verbose(1,Need failover for “${ARG1}”)
exten => s-CONGESTION,1,Congestion
exten => _s-.,1,Congestion
exten => s-,1,Congestion

The following is an example of a local Zap channel callout with SIP failover (ex. Zap channel is in use)

[macro-localcallout]
exten => s,1,Dial(${ZAP/1/${ARG1},,T)
exten => s,n,NoOp( Dial Status: ${DIALSTATUS})
exten => s,n,Goto(s-${DIALSTATUS},1)

exten => s-NOANSWER,1,Hangup
exten => s-CONGESTION,1,Congestion
exten => s-CANCEL,1,Hangup
exten => s-BUSY,1,Busy
exten => s-CHANUNAVAIL,1,SetCallerId(${CALLERIDNUM})
exten => s-CHANUNAVAIL,2,Dial(SIP/sippeer/${LOCALAREACODE}${ARG1},,T)

oma et esyad

Deixe um comentário