Klaus Darilion
2009-Jan-14 13:02 UTC
[asterisk-users] evaluate SIP response codes in dialplan
Hi! Is it somehow possible to evaluate the SIP response code inside the dialplan? I have an Asterisk server which forwards requests to various PSTN gateways with SIP. If the Dial() attempt is not successful I want to differ at least these 3 options: - called destination is busy (486): e.g. activate auto-redial - called destination does not exist, unassigned number (404) - gateway is broken, error, circuit busy (e.g. 503) 486 is mapped to DIALSTATUS=BUSY but both 503 and 404 is mapped to DIALSTATUS=CONGESTION As when Asterisk forwards the response with SIP to the caller the same response code is used, I suspect this information must be stored somewhere inside the channel variable. So, are there any means to access it? thanks klaus
Philipp Kempgen
2009-Jan-14 14:06 UTC
[asterisk-users] evaluate SIP response codes in dialplan
Klaus Darilion schrieb:> Is it somehow possible to evaluate the SIP response code inside the > dialplan?No. Part of the reasoning is that Asterisk is meant to be a multi- protocol PBX, not a SIP softswitch. Philipp Kempgen -- AMOOCON 2009, May 4-5, Rostock / Germany -> http://www.amoocon.de Asterisk: http://the-asterisk-book.com - http://das-asterisk-buch.de AMOOMA GmbH - Bachstr. 126 - 56566 Neuwied -> http://www.amooma.de Gesch?ftsf?hrer: Stefan Wintermeyer, Handelsregister: Neuwied B14998 --
Philipp Kempgen
2009-Jan-14 14:07 UTC
[asterisk-users] evaluate SIP response codes in dialplan
Philipp Kempgen schrieb:> Klaus Darilion schrieb: >> Is it somehow possible to evaluate the SIP response code inside the >> dialplan? > > No.But if I remember correctly I have seen patches for that somewhere. Maybe on the bug tracker. Philipp Kempgen -- AMOOCON 2009, May 4-5, Rostock / Germany -> http://www.amoocon.de Asterisk: http://the-asterisk-book.com - http://das-asterisk-buch.de AMOOMA GmbH - Bachstr. 126 - 56566 Neuwied -> http://www.amooma.de Gesch?ftsf?hrer: Stefan Wintermeyer, Handelsregister: Neuwied B14998 --
Alex Balashov
2009-Jan-14 14:17 UTC
[asterisk-users] evaluate SIP response codes in dialplan
The simple answer is that Asterisk is too high-level. But you can change the response handlers in chan_sip.c to set various channel variables to achieve what you want pretty easily. Klaus Darilion wrote:> Hi! > > Is it somehow possible to evaluate the SIP response code inside the > dialplan? > > I have an Asterisk server which forwards requests to various PSTN > gateways with SIP. If the Dial() attempt is not successful I want to > differ at least these 3 options: > - called destination is busy (486): e.g. activate auto-redial > - called destination does not exist, unassigned number (404) > - gateway is broken, error, circuit busy (e.g. 503) > > 486 is mapped to DIALSTATUS=BUSY > but both 503 and 404 is mapped to DIALSTATUS=CONGESTION > > As when Asterisk forwards the response with SIP to the caller the same > response code is used, I suspect this information must be stored > somewhere inside the channel variable. So, are there any means to access it? > > thanks > klaus > > _______________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users-- Alex Balashov Evariste Systems Web : http://www.evaristesys.com/ Tel : (+1) (678) 954-0670 Direct : (+1) (678) 954-0671 Mobile : (+1) (678) 237-1775
Take a look (if it still exists) at the Asterisk B2BUA project. It has a patch that adds direct access to SIP response codes. It takes a little modification of the patch file to use in some of the newer asterisks (and to strip out the one codec option that's somewhat irrelevant), but it's a good starting spot. N. Klaus Darilion wrote:> Hi! > > Is it somehow possible to evaluate the SIP response code inside the > dialplan? > > I have an Asterisk server which forwards requests to various PSTN > gateways with SIP. If the Dial() attempt is not successful I want to > differ at least these 3 options: > - called destination is busy (486): e.g. activate auto-redial > - called destination does not exist, unassigned number (404) > - gateway is broken, error, circuit busy (e.g. 503) > > 486 is mapped to DIALSTATUS=BUSY > but both 503 and 404 is mapped to DIALSTATUS=CONGESTION > > As when Asterisk forwards the response with SIP to the caller the same > response code is used, I suspect this information must be stored > somewhere inside the channel variable. So, are there any means to access it? > > thanks > klaus > > _______________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users >
Klaus Darilion
2009-Jan-14 16:30 UTC
[asterisk-users] evaluate SIP response codes in dialplan
Philipp Kempgen schrieb:> Klaus Darilion schrieb: >> Is it somehow possible to evaluate the SIP response code inside the >> dialplan? > > No. > Part of the reasoning is that Asterisk is meant to be a multi- > protocol PBX, not a SIP softswitch.This is IMO a stupid limitation. There are dozens of ISDN cause codes, dozens of SIP response codes and similar in other protocols, but Dial() only exports BUSY or CONGESTION ...... thanks klaus
Joshua Colp
2009-Jan-14 16:42 UTC
[asterisk-users] evaluate SIP response codes in dialplan
----- "Klaus Darilion" <klaus.mailinglists at pernau.at> wrote:> Philipp Kempgen schrieb: > > Klaus Darilion schrieb: > >> Is it somehow possible to evaluate the SIP response code inside the > > >> dialplan? > > > > No. > > Part of the reasoning is that Asterisk is meant to be a multi- > > protocol PBX, not a SIP softswitch. > > This is IMO a stupid limitation. There are dozens of ISDN cause codes, > > dozens of SIP response codes and similar in other protocols, but > Dial() > only exports BUSY or CONGESTION ...... >Right, app_dial condenses down the information it gets into some basic string representations. You can also access a more specific Q.931 representation by using the ${HANGUPCAUSE} dialplan variable. While this is not the SIP response code this gives you more information. You can also control the SIP response code by passing a Q.931 value to the Hangup() application itself. Unfortunately the mappings of SIP response code <-> Q.931 are hard coded in chan_sip though so that is where you can find what maps to what. -- Joshua Colp Digium, Inc. | Software Developer 445 Jan Davis Drive NW - Huntsville, AL 35806 - USA Check us out at: www.digium.com & www.asterisk.org
Klaus Darilion
2009-Jan-15 08:18 UTC
[asterisk-users] evaluate SIP response codes in dialplan
Joshua Colp schrieb:> ----- "Klaus Darilion" <klaus.mailinglists at pernau.at> wrote: > >> Philipp Kempgen schrieb: >>> Klaus Darilion schrieb: >>>> Is it somehow possible to evaluate the SIP response code inside >>>> the dialplan? >>> No. Part of the reasoning is that Asterisk is meant to be a >>> multi- protocol PBX, not a SIP softswitch. >> This is IMO a stupid limitation. There are dozens of ISDN cause >> codes, >> >> dozens of SIP response codes and similar in other protocols, but >> Dial() only exports BUSY or CONGESTION ...... >> > > Right, app_dial condenses down the information it gets into some > basic string representations. You can also access a more specific > Q.931 representation by using the ${HANGUPCAUSE} dialplan variable. > While this is not the SIP response code this gives you more > information. You can also control the SIP response code by passing aI see. I thought HANGUPCAUSE works only with zaptel. I will give it a try. thanks klaus> Q.931 value to the Hangup() application itself. Unfortunately the > mappings of SIP response code <-> Q.931 are hard coded in chan_sip > though so that is where you can find what maps to what. >
Johansson Olle E
2009-Jan-15 08:22 UTC
[asterisk-users] evaluate SIP response codes in dialplan
14 jan 2009 kl. 14.02 skrev Klaus Darilion:> Hi! > > Is it somehow possible to evaluate the SIP response code inside the > dialplan? > > I have an Asterisk server which forwards requests to various PSTN > gateways with SIP. If the Dial() attempt is not successful I want to > differ at least these 3 options: > - called destination is busy (486): e.g. activate auto-redial > - called destination does not exist, unassigned number (404) > - gateway is broken, error, circuit busy (e.g. 503) > > 486 is mapped to DIALSTATUS=BUSY > but both 503 and 404 is mapped to DIALSTATUS=CONGESTION > > As when Asterisk forwards the response with SIP to the caller the same > response code is used, I suspect this information must be stored > somewhere inside the channel variable. So, are there any means to > access it?Check the HANGUPCAUSE, it's much more detailed than DIALSTATUS. We do map the SIP (and all other protocol errors in various channel drivers) codes to ISDN hangup causes, which gives you much more information about why a call failed. The conversion we're using follows the RFC, and where that doesn't cover it, Cisco's documentation. /Olle