Cause Codes

From aa-asterisk.org.uk wiki
Jump to: navigation, search

ISDN (Q.850) cause codes are returned when a channel disconnects, which shows you the reason for the disconnection or why the call failed. To help you diagnose problems with calls, they appear in the verbose debug on the Asterisk CLI as well as being stored in the ${HANGUPCAUSE} variable.

The following table shows common cause codes and their SIP code equivalent if defined by RFC 3398. Asterisk always stores cause codes internally and translates to SIP codes where required if talking to chan_sip. However please note that the SIP code to cause code translation often does not work well as there are far fewer SIP codes than there are cause codes and many SIP codes have multiple cause code equivalents.

Modern SIP implementations can send Q.850 cause codes by way of a Reason: header in the SIP INVITE or BYE message. The format is as follows:

Reason: Q.850;cause=1;text="UNALLOCATED_NUMBER"

where the cause parameter is the cause code, and the text parameter is an optional parameter for a description. Asterisk versions earlier than 1.6.0 are believed not to support this but rather use a proprietary X-Asterisk-HangupCauseCode: header, but FreeSWITCH does support this header and interoperates correctly with Revtel, which seems to pass back the right information to the PSTN.

To enable the use of the Reason: header on Asterisk 1.6, set the use_q850_reason parameter in sip.conf to yes

Q.850 cause code table

Cause code (ISUP) SIP Equivalent Definition
1 404 Not Found Unallocated (unassigned) number
2 404 Not found no route to network
3 404 Not found no route to destination
16 BYE or CANCEL (*) normal call clearing
17 486 Busy here user busy
18 408 Request Timeout no user responding
19 480 Temporarily unavailable no answer from the user
20 480 Temporarily unavailable subscriber absent
21 403 Forbidden (+) call rejected
22 410 Gone number changed (w/o diagnostic)
22 301 Moved Permanently number changed (w/ diagnostic)
23 410 Gone redirection to new destination
26 404 Not Found (=) non-selected user clearing
27 502 Bad Gateway destination out of order
28 484 Address incomplete address incomplete
29 501 Not implemented facility rejected
31 480 Temporarily unavailable normal unspecified
34 503 Service unavailable no circuit available
38 503 Service unavailable network out of order
41 503 Service unavailable temporary failure
42 503 Service unavailable switching equipment congestion
47 503 Service unavailable resource unavailable
55 403 Forbidden incoming calls barred within CUG
57 403 Forbidden bearer capability not authorized
58 503 Service unavailable bearer capability not presently
65 488 Not Acceptable Here bearer capability not implemented
70 488 Not Acceptable Here only restricted digital avail
79 501 Not implemented service or option not implemented
87 403 Forbidden user not member of CUG
88 503 Service unavailable incompatible destination
102 504 Gateway timeout recovery of timer expiry
111 500 Server internal error protocol error
127 500 Server internal error interworking unspecified

(*) ISDN Cause 16 will usually result in a BYE or CANCEL.

(+) If the cause location is 'user' than the 6xx code could be given rather than the 4xx code (i.e., 403 becomes 603).

(=) ANSI procedure - in ANSI networks, 26 is overloaded to signify 'misrouted ported number'. Presumably, a number portability dip should have been performed by a prior network. Otherwise cause 26 is usually not used in ISUP procedures.

See also

External Links

  • RFC3398 – Integrated Services Digital Network (ISDN) User Part (ISUP) to Session Initiation Protocol (SIP) Mapping