<html>
<head>
<base href="https://wiki.asterisk.org/wiki">
<link rel="stylesheet" href="/wiki/s/en/2172/18/9/_/styles/combined.css?spaceKey=AST&forWysiwyg=true" type="text/css">
</head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
<h2><a href="https://wiki.asterisk.org/wiki/pages/viewpage.action?pageId=20185363">Who Hung Up?</a></h2>
<h4>Page <b>edited</b> by <a href="https://wiki.asterisk.org/wiki/display/~kmoore">Kinsey Moore</a>
</h4>
<div id="versionComment">
<b>Comment:</b>
add SIP translations<br />
</div>
<br/>
<h4>Changes (1)</h4>
<div id="page-diffs">
<table class="diff" cellpadding="0" cellspacing="0">
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" > <br>h2. SIP <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">The cause code translations for SIP are based in part on RFC3398. They can be found in the table below. <br>||SIP Response||Asterisk/ISDN Cause Code|| <br>|401|AST_CAUSE_CALL_REJECTED| <br>|403|AST_CAUSE_CALL_REJECTED| <br>|404|AST_CAUSE_UNALLOCATED| <br>|407|AST_CAUSE_CALL_REJECTED| <br>|408|AST_CAUSE_NO_USER_RESPONSE| <br>|409|AST_CAUSE_NORMAL_TEMPORARY_FAILURE| <br>|410|AST_CAUSE_NUMBER_CHANGED| <br>|420|AST_CAUSE_NO_ROUTE_DESTINATION| <br>|480|AST_CAUSE_NO_ANSWER| <br>|483|AST_CAUSE_NO_ANSWER| <br>|484|AST_CAUSE_INVALID_NUMBER_FORMAT| <br>|485|AST_CAUSE_UNALLOCATED| <br>|486|AST_CAUSE_BUSY| <br>|488|AST_CAUSE_BEARERCAPABILITY_NOTAVAIL| <br>|All Other 4xx|AST_CAUSE_INTERWORKING| <br>|500|AST_CAUSE_FAILURE| <br>|501|AST_CAUSE_FACILITY_REJECTED| <br>|502|AST_CAUSE_DESTINATION_OUT_OF_ORDER| <br>|504|AST_CAUSE_RECOVERY_ON_TIMER_EXPIRE| <br>|505|AST_CAUSE_INTERWORKING| <br>|All Other 5xx|AST_CAUSE_CONGESTION| <br>|600|AST_CAUSE_USER_BUSY| <br>|603|AST_CAUSE_CALL_REJECTED| <br>|604|AST_CAUSE_UNALLOCATED| <br>|606|AST_CAUSE_BEARERCAPABILITY_NOTAVAIL| <br>|All Other 6xx|AST_CAUSE_INTERWORKING| <br></td></tr>
</table>
</div> <h4>Full Content</h4>
<div class="notificationGreySide">
<h1><a name="WhoHungUp%3F-Overview"></a>Overview</h1>
<p>Usage of SIP_CAUSE has been known for a while now to impact performance in some situations due to the use of the MASTER_CHANNEL dialplan function which must scan through the channel list. Another issue with SIP_CAUSE is that it is too technology-specific. The HANGUPCAUSE hash resolves these issues by passing this data via control frames and creating a more generic mechanism that all channel technologies can share. This allows the channel and cause code information to move through Asterisk's core along with other control frames to the parent channel.</p>
<h1><a name="WhoHungUp%3F-DifferencesinUsage"></a>Differences in Usage</h1>
<p>HANGUPCAUSE may be used in any situation that calls for SIP_CAUSE as a drop-in replacement if only SIP channels are being called. If used with non-SIP channels, dialplan code using HANGUPCAUSE must be able to handle non-SIP cause codes or be able to safely ignore them. SIP_CAUSE has also been modified to use HANGUPCAUSE as its backend to take advantage of better performing code.</p>
<h1><a name="WhoHungUp%3F-Example"></a>Example</h1>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">[foo]
exten => s,1,Dial(SIP/bar)
exten => h,1,noop()
exten => h,n,set(HANGUPCAUSE_STRING=${HASHKEYS(HANGUPCAUSE)})
; start loop
exten => h,n(hu_begin),noop()
; check exit condition (no more array to check)
exten => h,n,gotoif($[${LEN(${HANGUPCAUSE_STRING})} = 0]?hu_exit)
; pull the next item
exten => h,n,set(ARRAY(item)=${HANGUPCAUSE_STRING})
exten => h,n,set(HANGUPCAUSE_STRING=${HANGUPCAUSE_STRING:${LEN(${item})}})
; display the channel ID and cause code
exten => h,n,noop(got channel ID ${item} with pvt cause ${HASH(HANGUPCAUSE,${item})})
; check exit condition (no more array to check)
exten => h,n,gotoif($[${LEN(${HANGUPCAUSE_STRING})} = 0]?hu_exit)
; we still have entries to process, so strip the leading comma
exten => h,n,set(HANGUPCAUSE_STRING=${HANGUPCAUSE_STRING:1})
; go back to the beginning of the loop
exten => h,n,goto(hu_begin)
exten => h,n(hu_exit),noop(All HANGUPCAUSE entries processed)</pre>
</div></div>
<h1><a name="WhoHungUp%3F-SupportforOtherChannelDrivers"></a>Support for Other Channel Drivers</h1>
<p>The implementation that HANGUPCAUSE and the modified SIP_CAUSE use is extensible to other channel technologies as well. The implementation for chan_sip, chan_iax2, and chan_dahdi (analog, PRI, SS7, and MFC/R2) is complete and committed.</p>
<h1><a name="WhoHungUp%3F-UnderstandingtheInformationProvided"></a>Understanding the Information Provided</h1>
<p>In an effort to allow consumers of this information to better understand what is available, translation facilities will be provided that allow conversion of cause codes from channel-specific terms to Asterisk/ISDN cause codes. This work is in progress.</p>
<h2><a name="WhoHungUp%3F-IAX2"></a>IAX2</h2>
<p>IAX2 already uses Asterisk/ISDN cause codes, so these are provided as-is.</p>
<h2><a name="WhoHungUp%3F-DAHDI"></a>DAHDI</h2>
<h3><a name="WhoHungUp%3F-ISDN"></a>ISDN</h3>
<p>Asterisk cause codes are a superset of ISDN cause codes. These are left unmodified.</p>
<h3><a name="WhoHungUp%3F-SS7"></a>SS7</h3>
<p>Asterisk cause codes are a superset of ISDN cause codes (which SS7 uses). These are left unmodified.</p>
<h3><a name="WhoHungUp%3F-Analog"></a>Analog</h3>
<p>Analog hangups will always present with AST_CAUSE_NORMAL_CLEARING (Normal Clearing). There is no way to get additional information for these channels.</p>
<h3><a name="WhoHungUp%3F-MFC%2FR2"></a>MFC/R2</h3>
<p>The mapping for MFC/R2 cause codes to Asterisk/ISDN cause codes can be found below.</p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>MFC/R2 Cause Code</th>
<th class='confluenceTh'>Asterisk/ISDN Cause Code</th>
</tr>
<tr>
<td class='confluenceTd'>OR2_CAUSE_BUSY_NUMBER</td>
<td class='confluenceTd'>AST_CAUSE_BUSY</td>
</tr>
<tr>
<td class='confluenceTd'>OR2_CAUSE_NETWORK_CONGESTION</td>
<td class='confluenceTd'>AST_CAUSE_CONGESTION</td>
</tr>
<tr>
<td class='confluenceTd'>OR2_CAUSE_OUT_OF_ORDER</td>
<td class='confluenceTd'>AST_CAUSE_DESTINATION_OUT_OF_ORDER</td>
</tr>
<tr>
<td class='confluenceTd'>OR2_CAUSE_UNALLOCATED_NUMBER</td>
<td class='confluenceTd'>AST_CAUSE_UNREGISTERED</td>
</tr>
<tr>
<td class='confluenceTd'>OR2_CAUSE_NO_ANSWER</td>
<td class='confluenceTd'>AST_CAUSE_NO_ANSWER</td>
</tr>
<tr>
<td class='confluenceTd'>OR2_CAUSE_NORMAL_CLEARING</td>
<td class='confluenceTd'>AST_CAUSE_NORMAL_CLEARING</td>
</tr>
<tr>
<td class='confluenceTd'>OR2_CAUSE_UNSPECIFIED</td>
<td class='confluenceTd'>AST_CAUSE_NOTDEFINED</td>
</tr>
</tbody></table>
</div>
<h2><a name="WhoHungUp%3F-SIP"></a>SIP</h2>
<p>The cause code translations for SIP are based in part on RFC3398. They can be found in the table below.</p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>SIP Response</th>
<th class='confluenceTh'>Asterisk/ISDN Cause Code</th>
</tr>
<tr>
<td class='confluenceTd'>401</td>
<td class='confluenceTd'>AST_CAUSE_CALL_REJECTED</td>
</tr>
<tr>
<td class='confluenceTd'>403</td>
<td class='confluenceTd'>AST_CAUSE_CALL_REJECTED</td>
</tr>
<tr>
<td class='confluenceTd'>404</td>
<td class='confluenceTd'>AST_CAUSE_UNALLOCATED</td>
</tr>
<tr>
<td class='confluenceTd'>407</td>
<td class='confluenceTd'>AST_CAUSE_CALL_REJECTED</td>
</tr>
<tr>
<td class='confluenceTd'>408</td>
<td class='confluenceTd'>AST_CAUSE_NO_USER_RESPONSE</td>
</tr>
<tr>
<td class='confluenceTd'>409</td>
<td class='confluenceTd'>AST_CAUSE_NORMAL_TEMPORARY_FAILURE</td>
</tr>
<tr>
<td class='confluenceTd'>410</td>
<td class='confluenceTd'>AST_CAUSE_NUMBER_CHANGED</td>
</tr>
<tr>
<td class='confluenceTd'>420</td>
<td class='confluenceTd'>AST_CAUSE_NO_ROUTE_DESTINATION</td>
</tr>
<tr>
<td class='confluenceTd'>480</td>
<td class='confluenceTd'>AST_CAUSE_NO_ANSWER</td>
</tr>
<tr>
<td class='confluenceTd'>483</td>
<td class='confluenceTd'>AST_CAUSE_NO_ANSWER</td>
</tr>
<tr>
<td class='confluenceTd'>484</td>
<td class='confluenceTd'>AST_CAUSE_INVALID_NUMBER_FORMAT</td>
</tr>
<tr>
<td class='confluenceTd'>485</td>
<td class='confluenceTd'>AST_CAUSE_UNALLOCATED</td>
</tr>
<tr>
<td class='confluenceTd'>486</td>
<td class='confluenceTd'>AST_CAUSE_BUSY</td>
</tr>
<tr>
<td class='confluenceTd'>488</td>
<td class='confluenceTd'>AST_CAUSE_BEARERCAPABILITY_NOTAVAIL</td>
</tr>
<tr>
<td class='confluenceTd'>All Other 4xx</td>
<td class='confluenceTd'>AST_CAUSE_INTERWORKING</td>
</tr>
<tr>
<td class='confluenceTd'>500</td>
<td class='confluenceTd'>AST_CAUSE_FAILURE</td>
</tr>
<tr>
<td class='confluenceTd'>501</td>
<td class='confluenceTd'>AST_CAUSE_FACILITY_REJECTED</td>
</tr>
<tr>
<td class='confluenceTd'>502</td>
<td class='confluenceTd'>AST_CAUSE_DESTINATION_OUT_OF_ORDER</td>
</tr>
<tr>
<td class='confluenceTd'>504</td>
<td class='confluenceTd'>AST_CAUSE_RECOVERY_ON_TIMER_EXPIRE</td>
</tr>
<tr>
<td class='confluenceTd'>505</td>
<td class='confluenceTd'>AST_CAUSE_INTERWORKING</td>
</tr>
<tr>
<td class='confluenceTd'>All Other 5xx</td>
<td class='confluenceTd'>AST_CAUSE_CONGESTION</td>
</tr>
<tr>
<td class='confluenceTd'>600</td>
<td class='confluenceTd'>AST_CAUSE_USER_BUSY</td>
</tr>
<tr>
<td class='confluenceTd'>603</td>
<td class='confluenceTd'>AST_CAUSE_CALL_REJECTED</td>
</tr>
<tr>
<td class='confluenceTd'>604</td>
<td class='confluenceTd'>AST_CAUSE_UNALLOCATED</td>
</tr>
<tr>
<td class='confluenceTd'>606</td>
<td class='confluenceTd'>AST_CAUSE_BEARERCAPABILITY_NOTAVAIL</td>
</tr>
<tr>
<td class='confluenceTd'>All Other 6xx</td>
<td class='confluenceTd'>AST_CAUSE_INTERWORKING</td>
</tr>
</tbody></table>
</div>
</div>
<div id="commentsSection" class="wiki-content pageSection">
<div style="float: right;" class="grey">
<a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=AST">Stop watching space</a>
<span style="padding: 0px 5px;">|</span>
<a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
<a href="https://wiki.asterisk.org/wiki/pages/viewpage.action?pageId=20185363">View Online</a>
|
<a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=20185363&revisedVersion=5&originalVersion=4">View Changes</a>
|
<a href="https://wiki.asterisk.org/wiki/pages/viewpage.action?pageId=20185363&showComments=true&showCommentArea=true#addcomment">Add Comment</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>