[asterisk-bugs] [JIRA] (ASTERISK-23484) HANGUPCAUSE can't get any information on a hungup inbound channel unless called with no arguments, plus unaffected by use_q850_reason

art (JIRA) noreply at issues.asterisk.org
Tue Oct 27 07:33:33 CDT 2015


    [ https://issues.asterisk.org/jira/browse/ASTERISK-23484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=228023#comment-228023 ] 

art edited comment on ASTERISK-23484 at 10/27/15 7:32 AM:
----------------------------------------------------------

I also stumbled to this bug. It seem that if you get 404 response with Q.850 reason asterisk will overwrite it with reason code 1 (=404). If you get response code 500 with Q.850 reason header, asterisk will use it as reason code.

I tried to figure where it overwrite it, but there seems to be so many possibilities and I think asterisk has to set it 1/404 to handle correctly sip messages in call. 

Note, HANGUPCAUSE is channel variable and HANGUPCAUSE(chan,tech) is dialplan function.

My current way to resolve this is to add few channel variables, which I can then access from dialplan, through hangup handlers:

I modified handle_response function in chan_sip.c (around line number 23709 in asterisk 11.7.0):
{code}
if (rp && sscanf(rp + 6, "%30d", &cause) == 1) {
         ast_channel_hangupcause_set(owner, cause & 0x7f);
         pbx_builtin_setvar_helper(owner , "Q850REASONTEXT" , ast_cause2str(cause)); // added
         char buf[20]; // added
         snprintf(buf, sizeof(buf), "%d", ast_channel_hangupcause(p->owner)); // added
         pbx_builtin_setvar_helper(owner , "Q850REASONCODE" , buf); // added
         if (req->debug)
                  ast_verbose("Using Reason header for cause code: %d\n", ast_channel_hangupcause(owner));
}
{code}


was (Author: art):
I also stumbled to this bug. It seem that if you get 404 response with Q.850 reason asterisk will overwrite it with reason code 1 (=404). If you get response code 500 with Q.850 reason header, asterisk will use it as reason code.

I tried to figure where it overwrite it, but there seems to be so many possibilities and I think asterisk has to set it 1/404 to handle correctly sip messages in call. 

Note, HANGUPCAUSE is channel variable and HANGUPCAUSE(chan,tech) is dialplan function.

My current way to resolve this is to add few channel variables, which I can then access from dialplan, through hangup handlers:

I modified handle_response function in chan_sip.c (around line number 23709 in asterisk 11.7.0):
{code}
if (rp && sscanf(rp + 6, "%30d", &cause) == 1) {
         ast_channel_hangupcause_set(owner, cause & 0x7f);
         pbx_builtin_setvar_helper(owner , "Q850REASONTEXT" , ast_cause2str(cause)); // added
         char buf[20]; // added
         snprintf(buf, sizeof(buf), "%d", ast_channel_hangupcause(p->owner)); // added
         pbx_builtin_setvar_helper(owner , "Q850REASONCODE" , buf); // added
         if (req->debug)
                  ast_verbose("Using Reason header for cause code: %d\n", ast_channel_hangupcause(owner));
         }
{code}

> HANGUPCAUSE can't get any information on a hungup inbound channel unless called with no arguments, plus unaffected by use_q850_reason
> -------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: ASTERISK-23484
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-23484
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Channels/chan_sip/General, Channels/General, Functions/func_hangupcause
>    Affects Versions: SVN, 11.8.1
>         Environment: Ubuntu 13.04; x86_64; Kernal 3.8.0-27-generic
>            Reporter: Nick Adams
>         Attachments: myDebugLog
>
>
> My provider returns SIP 404 response for a Q.850 code of 3 ("No route to destination"). I want Asterisk to prioritise the Q.850 Reason code instead of using the SIP 404 when populating the HANGUPCAUSE variable as the Q.850 code gives me more detail and greater control in my dialplan.
> I've set "use_q850_reason=yes" in sip.conf and Asterisk correctly identifies the Reason header:
> {quote}
> SIP/2.0 404 Not Found
> Via: SIP/2.0/UDP 172.X.X.X:5060;branch=z9hG4bK728b99fd;rport=5060
> Max-Forwards: 68
> From: "Anonymous" <sip:anonymous at anonymous.invalid>;tag=as31832f10
> To: <sip:614XXXXXXXX at 172.X.X.X:5060>;tag=Ztm3ZB2Xr0jgp
> Call-ID: 59a1c91a4be33a1b2fc4a90f5c5e8224 at 172.X.X.X:5060
> CSeq: 102 INVITE
> User-Agent: FreeSWITCH-mod_sofia/1.2.10+git~20130624T144607Z~998ae35dbf
> Accept: application/sdp
> Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, NOTIFY
> Supported: timer, precondition, path, replaces
> Allow-Events: talk, hold, conference, refer
> Reason: Q.850;cause=3;text="NO_ROUTE_DESTINATION"
> Content-Length: 0
> <------------->
> --- (14 headers 0 lines) ---
> Using Reason header for cause code: 3
> {quote}
> I use the below dialplan to originate the call into:
> {quote}
> exten => s,1,Dial(SIP/MyProvider/614xxxxxxxx,30,g)
> exten => s,n,NoOp(DEBUG1:HANGUPCAUSE=$\{HANGUPCAUSE\} DIALSTATUS=$\{DIALSTATUS\})
> exten => s,n,Hangup
> exten => t,1,Hangup
> exten => h,1,NoOp(DEBUG2: HANGUPCAUSE=$\{HANGUPCAUSE\} DIALSTATUS=$\{DIALSTATUS\})
> {quote}
> Despite Asterisk correctly extracting the Reason code ("3"), the HANGUPCAUSE returns "1":
> {quote}
> Executing [614XXXXXX at CallSpooler:2] NoOp("Local/614XXXXXX at CallSpooler-00000001;2", "DEBUG1:  HANGUPCAUSE=1 DIALSTATUS=CHANUNAVAIL") in new stack
> -- Executing [h at CallSpooler:1] NoOp("Local/614XXXXXX at CallSpooler-00000000;2", "DEBUG2: HANGUPCAUSE=1 DIALSTATUS=CHANUNAVAIL") in new stack
> {quote}
> The expectation is that the HANGUPCAUSE variable should be set to "3" however it seems to be set to "1". I'm not sure if there is a conflict between the HANGUPCAUSE of the Local channel as opposed to the SIP channel however the Q.850 reason seems to be clobbered.



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list