[asterisk-commits] oej: branch oej/earl-grey-sip2cause-configurable-1.8 r376756 - in /team/oej/e...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Nov 28 12:54:35 CST 2012
Author: oej
Date: Wed Nov 28 12:54:31 2012
New Revision: 376756
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=376756
Log:
Adding conversion the other way.
Modified:
team/oej/earl-grey-sip2cause-configurable-1.8/channels/sip/include/sip2cause.h
team/oej/earl-grey-sip2cause-configurable-1.8/channels/sip/include/sip_utils.h
team/oej/earl-grey-sip2cause-configurable-1.8/channels/sip/sip2cause.c
Modified: team/oej/earl-grey-sip2cause-configurable-1.8/channels/sip/include/sip2cause.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/earl-grey-sip2cause-configurable-1.8/channels/sip/include/sip2cause.h?view=diff&rev=376756&r1=376755&r2=376756
==============================================================================
--- team/oej/earl-grey-sip2cause-configurable-1.8/channels/sip/include/sip2cause.h (original)
+++ team/oej/earl-grey-sip2cause-configurable-1.8/channels/sip/include/sip2cause.h Wed Nov 28 12:54:31 2012
@@ -28,7 +28,7 @@
int hangup_sip2cause(int cause);
/*! \brief Convert ISDN or Asterisk-specific cause code to SIP response code */
-const char *hangup_cause2sip(int cause);
+char *hangup_cause2sip(int cause);
/*! \brief Initialized sip2cause tables */
void sip2cause_init(void);
Modified: team/oej/earl-grey-sip2cause-configurable-1.8/channels/sip/include/sip_utils.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/earl-grey-sip2cause-configurable-1.8/channels/sip/include/sip_utils.h?view=diff&rev=376756&r1=376755&r2=376756
==============================================================================
--- team/oej/earl-grey-sip2cause-configurable-1.8/channels/sip/include/sip_utils.h (original)
+++ team/oej/earl-grey-sip2cause-configurable-1.8/channels/sip/include/sip_utils.h Wed Nov 28 12:54:31 2012
@@ -42,42 +42,4 @@
*/
const char *find_closing_quote(const char *start, const char *lim);
-
-/*! \brief Convert SIP hangup causes to Asterisk hangup causes */
-int hangup_sip2cause(int cause);
-
-/*! \brief Convert Asterisk hangup causes to SIP codes
-\verbatim
- Possible values from causes.h
- AST_CAUSE_NOTDEFINED AST_CAUSE_NORMAL AST_CAUSE_BUSY
- AST_CAUSE_FAILURE AST_CAUSE_CONGESTION AST_CAUSE_UNALLOCATED
-
- In addition to these, a lot of PRI codes is defined in causes.h
- ...should we take care of them too ?
-
- Quote RFC 3398
-
- ISUP Cause value SIP response
- ---------------- ------------
- 1 unallocated number 404 Not Found
- 2 no route to network 404 Not found
- 3 no route to destination 404 Not found
- 16 normal call clearing --- (*)
- 17 user busy 486 Busy here
- 18 no user responding 408 Request Timeout
- 19 no answer from the user 480 Temporarily unavailable
- 20 subscriber absent 480 Temporarily unavailable
- 21 call rejected 403 Forbidden (+)
- 22 number changed (w/o diagnostic) 410 Gone
- 22 number changed (w/ diagnostic) 301 Moved Permanently
- 23 redirection to new destination 410 Gone
- 26 non-selected user clearing 404 Not Found (=)
- 27 destination out of order 502 Bad Gateway
- 28 address incomplete 484 Address incomplete
- 29 facility rejected 501 Not implemented
- 31 normal unspecified 480 Temporarily unavailable
-\endverbatim
-*/
-const char *hangup_cause2sip(int cause);
-
#endif
Modified: team/oej/earl-grey-sip2cause-configurable-1.8/channels/sip/sip2cause.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/earl-grey-sip2cause-configurable-1.8/channels/sip/sip2cause.c?view=diff&rev=376756&r1=376755&r2=376756
==============================================================================
--- team/oej/earl-grey-sip2cause-configurable-1.8/channels/sip/sip2cause.c (original)
+++ team/oej/earl-grey-sip2cause-configurable-1.8/channels/sip/sip2cause.c Wed Nov 28 12:54:31 2012
@@ -105,6 +105,25 @@
sip2causelookup.table = newsip2cause(604, /* Does not exist anywhere */ AST_CAUSE_UNALLOCATED, "", sip2causelookup.table);
sip2causelookup.table = newsip2cause(606, /* Not acceptable */ AST_CAUSE_BEARERCAPABILITY_NOTAVAIL, "", sip2causelookup.table);
+ /* Add the reverse table */
+ cause2siplookup.table = newsip2cause(404, AST_CAUSE_UNALLOCATED, "404 Not Found", NULL);
+ cause2siplookup.table = newsip2cause(404, AST_CAUSE_NO_ROUTE_DESTINATION, "404 Not Found", cause2siplookup.table);
+ cause2siplookup.table = newsip2cause(404, AST_CAUSE_NO_ROUTE_TRANSIT_NET, "404 Not Found", cause2siplookup.table);
+ cause2siplookup.table = newsip2cause(503, AST_CAUSE_CONGESTION, "503 Service Unavailable", cause2siplookup.table);
+ cause2siplookup.table = newsip2cause(503, AST_CAUSE_SWITCH_CONGESTION, "503 Service Unavailable", cause2siplookup.table);
+ cause2siplookup.table = newsip2cause(408, AST_CAUSE_NO_USER_RESPONSE, "408 Request Timeout", cause2siplookup.table);
+ cause2siplookup.table = newsip2cause(480, AST_CAUSE_NO_ANSWER, "480 Temporarily unavailable", cause2siplookup.table);
+ cause2siplookup.table = newsip2cause(480, AST_CAUSE_UNREGISTERED, "480 Temporarily unavailable", cause2siplookup.table);
+ cause2siplookup.table = newsip2cause(403, AST_CAUSE_CALL_REJECTED, "403 Forbidden", cause2siplookup.table);
+ cause2siplookup.table = newsip2cause(410, AST_CAUSE_NUMBER_CHANGED, "410 Gone", cause2siplookup.table);
+ cause2siplookup.table = newsip2cause(480, AST_CAUSE_NORMAL_UNSPECIFIED, "480 Temporarily unavailable", cause2siplookup.table);
+ cause2siplookup.table = newsip2cause(484, AST_CAUSE_INVALID_NUMBER_FORMAT, "484 Address Incomplete", cause2siplookup.table);
+ cause2siplookup.table = newsip2cause(486, AST_CAUSE_USER_BUSY, "486 Busy here", cause2siplookup.table);
+ cause2siplookup.table = newsip2cause(500, AST_CAUSE_FAILURE, "500 Server internal failure", cause2siplookup.table);
+ cause2siplookup.table = newsip2cause(501, AST_CAUSE_FACILITY_REJECTED, "501 Not implemented", cause2siplookup.table);
+ cause2siplookup.table = newsip2cause(503, AST_CAUSE_CHAN_NOT_IMPLEMENTED, "503 Service unavailable", cause2siplookup.table);
+ cause2siplookup.table = newsip2cause(502, AST_CAUSE_DESTINATION_OUT_OF_ORDER, "502 Bad gateway", cause2siplookup.table);
+ cause2siplookup.table = newsip2cause(488, AST_CAUSE_BEARERCAPABILITY_NOTAVAIL, "488 Not Acceptable Here", cause2siplookup.table);
}
@@ -185,49 +204,15 @@
31 normal unspecified 480 Temporarily unavailable
\endverbatim
*/
-const char *hangup_cause2sip(int cause)
-{
- switch (cause) {
- case AST_CAUSE_UNALLOCATED: /* 1 */
- case AST_CAUSE_NO_ROUTE_DESTINATION: /* 3 IAX2: Can't find extension in context */
- case AST_CAUSE_NO_ROUTE_TRANSIT_NET: /* 2 */
- return "404 Not Found";
- case AST_CAUSE_CONGESTION: /* 34 */
- case AST_CAUSE_SWITCH_CONGESTION: /* 42 */
- return "503 Service Unavailable";
- case AST_CAUSE_NO_USER_RESPONSE: /* 18 */
- return "408 Request Timeout";
- case AST_CAUSE_NO_ANSWER: /* 19 */
- case AST_CAUSE_UNREGISTERED: /* 20 */
- return "480 Temporarily unavailable";
- case AST_CAUSE_CALL_REJECTED: /* 21 */
- return "403 Forbidden";
- case AST_CAUSE_NUMBER_CHANGED: /* 22 */
- return "410 Gone";
- case AST_CAUSE_NORMAL_UNSPECIFIED: /* 31 */
- return "480 Temporarily unavailable";
- case AST_CAUSE_INVALID_NUMBER_FORMAT:
- return "484 Address incomplete";
- case AST_CAUSE_USER_BUSY:
- return "486 Busy here";
- case AST_CAUSE_FAILURE:
- return "500 Server internal failure";
- case AST_CAUSE_FACILITY_REJECTED: /* 29 */
- return "501 Not Implemented";
- case AST_CAUSE_CHAN_NOT_IMPLEMENTED:
- return "503 Service Unavailable";
- /* Used in chan_iax2 */
- case AST_CAUSE_DESTINATION_OUT_OF_ORDER:
- return "502 Bad Gateway";
- case AST_CAUSE_BEARERCAPABILITY_NOTAVAIL: /* Can't find codec to connect to host */
- return "488 Not Acceptable Here";
-
- case AST_CAUSE_NOTDEFINED:
- default:
- ast_debug(1, "AST hangup cause %d (no match found in SIP)\n", cause);
- return NULL;
- }
-
- /* Never reached */
- return 0;
-}
+char *hangup_cause2sip(int cause)
+{
+ struct sip2causestruct *s2c = cause2siplookup.table;
+ while (s2c) {
+ if (s2c->cause == cause) {
+ return s2c->reason;
+ }
+ s2c = s2c->next;
+ }
+ ast_debug(1, "AST hangup cause %d (no match found in SIP)\n", cause);
+ return NULL;
+}
More information about the asterisk-commits
mailing list