{"id":22,"date":"2010-07-08T00:46:27","date_gmt":"2010-07-08T03:46:27","guid":{"rendered":"http:\/\/blog.digavoip.com.br\/2010\/07\/08\/dialstatus-no-asterisk\/"},"modified":"2010-10-25T12:17:31","modified_gmt":"2010-10-25T15:17:31","slug":"dialstatus-no-asterisk","status":"publish","type":"post","link":"https:\/\/blog.abratel.com.br\/?p=22","title":{"rendered":"DialStatus no asterisk&#8230;"},"content":{"rendered":"<p>Redirecionamentos tratando o dialstatus:<br \/>\nColoquei ramal, mas pode ser feito ate com trunks sip como se fosse um simples backup de termina\u00e7\u00f5es quando falham..<\/p>\n<p>exten => _ramal,1,dial(ZAP\/Y,50,rtwW)<br \/>\nexten => _ramal,n,Goto(${DIALSTATUS})<br \/>\nexten => _ramal,n(CONGESTION),Dial(ZAP\/X,35,wrt)<br \/>\nexten => _ramal,n,Hangup<br \/>\nexten => _ramal,n(busy\/congestion),Dial(ZAP\/X,35,wrt)<br \/>\nexten => _ramal,n,Hangup<br \/>\nexten => _ramal,n(CHANUNAVAIL),Dial(ZAP\/X,35,wrt)<br \/>\nexten => _ramal,n,Hangup<\/p>\n<p>Pode-se fazer playbacks:<\/p>\n<p>exten => _9xx,1,NoCDR()<br \/>\nexten => _9xx,2,Dial(ZAP\/${EXTEN:1}r2,35,tTwW)<br \/>\nexten => _9xx,3,Goto(${DIALSTATUS})<\/p>\n<p>exten => _9xx,4(NOANSWER),playback(nao_atende)<br \/>\nexten => _9xx,5(NOANSWER),Dial(ZAP\/14&#038;ZAP\/30&#038;ZAP\/11,35,TtRwW)<br \/>\nexten => _9xx,6,Hangup<\/p>\n<p>exten => _9xx,6(BUSY),playback(direcionando_a_outro)<br \/>\nexten => _9xx,7(BUSY),Dial(ZAP\/14&#038;ZAP\/30&#038;ZAP\/11,35,TtRwW)<br \/>\nexten => _9xx,8,Hangup<\/p>\n<p>exten => _9xx,9(CHANUNAVAIL),playback(ramal_indisponivel)<br \/>\nexten => _9xx,10(CHANUNAVAIL),Dial(ZAP\/14&#038;ZAP\/30&#038;ZAP\/11,35,TtRwW)<br \/>\nexten => _9xx,11,Hangup<\/p>\n<p>Existem outros status e formas de utilidades como retirado de voip-info abaixo:<br \/>\nContains a text string signifying result of the last dial attempt: <\/p>\n<p>\u2022ANSWER: Call is answered. A successful dial. The caller reached the callee.<br \/>\n\u2022BUSY: Busy signal. The dial command reached its number but the number is busy.<br \/>\n\u2022NOANSWER: No answer. The dial command reached its number, the number rang for too long, then the dial timed out.<br \/>\n\u2022CANCEL: Call is cancelled. The dial command reached its number but the caller hung up before the callee picked up.<br \/>\n\u2022CONGESTION: Congestion. This status is usually a sign that the dialled number is not recognised.<br \/>\n\u2022CHANUNAVAIL: Channel unavailable. On SIP, peer may not be registered.<br \/>\n\u2022DONTCALL: Privacy mode, callee rejected the call<br \/>\n\u2022TORTURE: Privacy mode, callee chose to send caller to torture menu<br \/>\n\u2022INVALIDARGS: Error parsing Dial command arguments (added for Asterisk 1.4.1, SVN r53135-53136) <\/p>\n<p>A good idea is to use this in your dial plan, see example in goto documentation. <\/p>\n<p>Note: In order to obtain useful DIALSTATUS information when dialing a peer you will need to have qualify=yes in that peer&#8217;s definition (e.g. in sip.conf or iax.conf). <\/p>\n<p>\u2022CONGESTION &#8220;Congestion&#8221; 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) . <\/p>\n<p>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(<header_name>) 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,<channel-name>)}. <\/p>\n<p>There should really be a FAIL result so that it is possible to distinguish between &#8220;CONGESTION&#8221; and a genuine call setup failure, but there isn&#8217;t. <\/p>\n<p>IMHO this is slightly broken behaviour and means that &#8220;CONGESTION&#8221; is pretty meaningless, since it can mean any number of things.<br \/>\nSee Asterisk Bug #9743 where I raised this question but got told to go away. <\/p>\n<p>Consider the following situations:- <\/p>\n<p>\u2022You 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} <\/p>\n<p>\u2022Your 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 &#8220;Reorder&#8221; with the reorder tone &#8220;boop, boop, boop, boop&#8221; for every SIP call setup problem (not found, congestion etc.) The US &#8220;Reorder&#8221; tone is not customisable on this handset and it sounds too much like the UK &#8220;engaged&#8221; (busy) tone. Therefore the user has no way of telling what went wrong. <\/p>\n<p>\u2022You 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. <\/p>\n<p>${HANGUPCAUSE} <\/p>\n<p>\u2022It may be possible to get a more detailed response by checking the variable ${HANGUPCAUSE}.<br \/>\n\u2022See Asterisk variable HANGUPCAUSE<br \/>\n\u2022Note: Asterisk 1.8 will allow to read SIP response codes in the dialplan via {HASH(SIP_CAUSE,<channel-name>)} <\/p>\n<p>Example<br \/>\nThis macro is an example of how failover for two or more outgoing trunks can be managed <\/p>\n<p> [macro-safedial]<br \/>\n exten => s,1,Set(DIALSTART=${EPOCH})<br \/>\n ;exten => s,n,Dial(${ARG1},${ARG2},g,${ARG4})<br \/>\n exten => s,n,Dial(${ARG1},${ARG2},${ARG3},${ARG4})<br \/>\n exten => s,n,Goto(s-${DIALSTATUS},1) <\/p>\n<p> exten => s-CANCEL,1,Hangup<br \/>\n exten => s-NOANSWER,1,Set(DTIME=$[${EPOCH} &#8211; ${DIALSTART}])<br \/>\n ;watch out: DIALEDTIME can also be empty, next line is not perfect!<br \/>\n ;exten => s-NOANSWER,n,GotoIf($[&#8220;${DIALEDTIME}&#8221; = &#8220;0&#8221;]?here)<br \/>\n exten => s-NOANSWER,n,GotoIf($[&#8220;${DTIME}&#8221; = &#8220;0&#8221;]?here)<br \/>\n exten => s-NOANSWER,n,Hangup<br \/>\n exten => s-NOANSWER,n(here),Verbose(1,Need failover for &#8220;${ARG1}&#8221;)<br \/>\n exten => s-BUSY,1,Busy<br \/>\n exten => s-CHANUNAVAIL,1,Verbose(1,Need failover for &#8220;${ARG1}&#8221;)<br \/>\n exten => s-CONGESTION,1,Congestion<br \/>\n exten => _s-.,1,Congestion<br \/>\n exten => s-,1,Congestion <\/p>\n<p>The following is an example of a local Zap channel callout with SIP failover (ex. Zap channel is in use) <\/p>\n<p>[macro-localcallout]<br \/>\nexten => s,1,Dial(${ZAP\/1\/${ARG1},,T)<br \/>\nexten => s,n,NoOp( Dial Status: ${DIALSTATUS})<br \/>\nexten => s,n,Goto(s-${DIALSTATUS},1) <\/p>\n<p>exten => s-NOANSWER,1,Hangup<br \/>\nexten => s-CONGESTION,1,Congestion<br \/>\nexten => s-CANCEL,1,Hangup<br \/>\nexten => s-BUSY,1,Busy<br \/>\nexten => s-CHANUNAVAIL,1,SetCallerId(${CALLERIDNUM})<br \/>\nexten => s-CHANUNAVAIL,2,Dial(SIP\/sippeer\/${LOCALAREACODE}${ARG1},,T) <\/p>\n<p>oma et esyad<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Redirecionamentos tratando o dialstatus: Coloquei ramal, mas pode ser feito ate com trunks sip como se fosse um simples backup de termina\u00e7\u00f5es 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)&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts\/22"}],"collection":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=22"}],"version-history":[{"count":0,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts\/22\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=22"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=22"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=22"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}