[asterisk-dev] Wrong SIP to SIP SIP Cause mapping

Pavel Troller patrol at sinus.cz
Fri May 25 11:33:41 CDT 2012

> ----- Original Message -----
> > From: "Pavel Troller" <patrol at sinus.cz>
> > To: "Asterisk Developers Mailing List" <asterisk-dev at lists.digium.com>
> > Sent: Friday, May 25, 2012 10:59:24 AM
> > Subject: Re: [asterisk-dev] Wrong SIP to SIP SIP Cause mapping
> > 
> > Hi!
> > 
> > Oh, Mamma mia, Alex is right!!!!
> >   I've just tested a void public number through PRI and I've got CC=1
> >   -
> > Unallocated number.
> >   Then I dialled the same number through SIP trunk and I've got
> >   CC=34,
> > but on the SIP the response code was really 404 Not Found, which is
> > equivalent to 1 - Unallocated number.
> >   Something is really broken here! Of course I'm paying attention to
> > $HANGUPCAUSE and I'm handling it in my own intercept scripts, and
> > they
> > are proved OK, so the problem must be in wrong $HANGUPCAUSE contents.
> >   It's 1.8 branch.
> >   I hope I will find the cause soon and I'll post it here.
> >     With regards, Pavel.
> > 
> As has already been pointed out, Asterisk is a B2BUA, not a proxy.  There
> is no guarantee that a response from one UA will be 'passed through'
> Asterisk to another UA.  I won't weigh in on whether or not this qualifies
> as a bug or merely a change in behavior.  The fact that Asterisk is not a
> proxy gives weight to this being not a bug; that being said, there is a
> definite difference between a 4xx and a 5xx response, which would give some
> weight to this being a bug.
> The change in behavior was mostly likely introduced by r351130.  This fixed
> some issues wherein, on a response to a 404, merely queueing a congestion
> control frame was not sufficient to tear down the channel.  The congestion
> control frame was replaced with an explicit channel hang up with a cause of
> AST_CAUSE_CONGESTION, which maps to a SIP response type of "503".
  We (or at least not I) are not speaking about passing SIP cause to another
UA, I'm talking just and only about the HANGUPCAUSE variable.
  Formerly it was set to AST_CAUSE_UNALLOCATED. Please be so kind and look at
chan_sip.c, around line 6066, function hangup_sip2cause():
    case 404:       /* Not found */
  There is the CORRECT mapping of 404 to Cause Value.
  And now look at the same source, around line 20378 (1.8 branch):

        case 404: /* Not found */
                xmitres = transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, FALSE);
                if (p->owner && !req->ignore) {
                        ast_set_hangupsource(p->owner, p->owner->name, 0);
                        ast_queue_hangup_with_cause(p->owner, AST_CAUSE_CONGESTION);

  An evidently _!_INCORRECT_!_ cause code is used there.
  Btw, the same problem is with the 403 Forbidden, which should return 
21 (Call Rejected), but returns 34 (Congestion) again.
  WHY ???
  Please fix these evidently incorrect cause values, according to the perfectly
correct mapping function, which is already present in the sources and ready to be
  With regards, Pavel

More information about the asterisk-dev mailing list