[asterisk-commits] branch jcollie/bug7131 r30392 - in
/team/jcollie/bug7131: ./ include/asterisk/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu May 25 13:54:53 MST 2006
Author: jcollie
Date: Thu May 25 15:54:53 2006
New Revision: 30392
URL: http://svn.digium.com/view/asterisk?rev=30392&view=rev
Log:
Merged revisions 30390 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
........
r30390 | file | 2006-05-25 15:51:27 -0500 (Thu, 25 May 2006) | 2 lines
Merge in branch which gives you the ability to set the hangup causecode using the Hangup application. (issue #7160 reported by kmilitzer branch by jcollie)
........
Modified:
team/jcollie/bug7131/ (props changed)
team/jcollie/bug7131/channel.c
team/jcollie/bug7131/include/asterisk/channel.h
team/jcollie/bug7131/pbx.c
Propchange: team/jcollie/bug7131/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu May 25 15:54:53 2006
@@ -1,1 +1,1 @@
-/trunk:1-30388
+/trunk:1-30390
Modified: team/jcollie/bug7131/channel.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/bug7131/channel.c?rev=30392&r1=30391&r2=30392&view=diff
==============================================================================
--- team/jcollie/bug7131/channel.c (original)
+++ team/jcollie/bug7131/channel.c Thu May 25 15:54:53 2006
@@ -116,52 +116,53 @@
/*! map AST_CAUSE's to readable string representations */
const struct ast_cause {
int cause;
+ const char *name;
const char *desc;
} causes[] = {
- { AST_CAUSE_UNALLOCATED, "Unallocated (unassigned) number" },
- { AST_CAUSE_NO_ROUTE_TRANSIT_NET, "No route to specified transmit network" },
- { AST_CAUSE_NO_ROUTE_DESTINATION, "No route to destination" },
- { AST_CAUSE_CHANNEL_UNACCEPTABLE, "Channel unacceptable" },
- { AST_CAUSE_CALL_AWARDED_DELIVERED, "Call awarded and being delivered in an established channel" },
- { AST_CAUSE_NORMAL_CLEARING, "Normal Clearing" },
- { AST_CAUSE_USER_BUSY, "User busy" },
- { AST_CAUSE_NO_USER_RESPONSE, "No user responding" },
- { AST_CAUSE_NO_ANSWER, "User alerting, no answer" },
- { AST_CAUSE_CALL_REJECTED, "Call Rejected" },
- { AST_CAUSE_NUMBER_CHANGED, "Number changed" },
- { AST_CAUSE_DESTINATION_OUT_OF_ORDER, "Destination out of order" },
- { AST_CAUSE_INVALID_NUMBER_FORMAT, "Invalid number format" },
- { AST_CAUSE_FACILITY_REJECTED, "Facility rejected" },
- { AST_CAUSE_RESPONSE_TO_STATUS_ENQUIRY, "Response to STATus ENQuiry" },
- { AST_CAUSE_NORMAL_UNSPECIFIED, "Normal, unspecified" },
- { AST_CAUSE_NORMAL_CIRCUIT_CONGESTION, "Circuit/channel congestion" },
- { AST_CAUSE_NETWORK_OUT_OF_ORDER, "Network out of order" },
- { AST_CAUSE_NORMAL_TEMPORARY_FAILURE, "Temporary failure" },
- { AST_CAUSE_SWITCH_CONGESTION, "Switching equipment congestion" },
- { AST_CAUSE_ACCESS_INFO_DISCARDED, "Access information discarded" },
- { AST_CAUSE_REQUESTED_CHAN_UNAVAIL, "Requested channel not available" },
- { AST_CAUSE_PRE_EMPTED, "Pre-empted" },
- { AST_CAUSE_FACILITY_NOT_SUBSCRIBED, "Facility not subscribed" },
- { AST_CAUSE_OUTGOING_CALL_BARRED, "Outgoing call barred" },
- { AST_CAUSE_INCOMING_CALL_BARRED, "Incoming call barred" },
- { AST_CAUSE_BEARERCAPABILITY_NOTAUTH, "Bearer capability not authorized" },
- { AST_CAUSE_BEARERCAPABILITY_NOTAVAIL, "Bearer capability not available" },
- { AST_CAUSE_BEARERCAPABILITY_NOTIMPL, "Bearer capability not implemented" },
- { AST_CAUSE_CHAN_NOT_IMPLEMENTED, "Channel not implemented" },
- { AST_CAUSE_FACILITY_NOT_IMPLEMENTED, "Facility not implemented" },
- { AST_CAUSE_INVALID_CALL_REFERENCE, "Invalid call reference value" },
- { AST_CAUSE_INCOMPATIBLE_DESTINATION, "Incompatible destination" },
- { AST_CAUSE_INVALID_MSG_UNSPECIFIED, "Invalid message unspecified" },
- { AST_CAUSE_MANDATORY_IE_MISSING, "Mandatory information element is missing" },
- { AST_CAUSE_MESSAGE_TYPE_NONEXIST, "Message type nonexist." },
- { AST_CAUSE_WRONG_MESSAGE, "Wrong message" },
- { AST_CAUSE_IE_NONEXIST, "Info. element nonexist or not implemented" },
- { AST_CAUSE_INVALID_IE_CONTENTS, "Invalid information element contents" },
- { AST_CAUSE_WRONG_CALL_STATE, "Message not compatible with call state" },
- { AST_CAUSE_RECOVERY_ON_TIMER_EXPIRE, "Recover on timer expiry" },
- { AST_CAUSE_MANDATORY_IE_LENGTH_ERROR, "Mandatory IE length error" },
- { AST_CAUSE_PROTOCOL_ERROR, "Protocol error, unspecified" },
- { AST_CAUSE_INTERWORKING, "Interworking, unspecified" },
+ { AST_CAUSE_UNALLOCATED, "UNALLOCATED", "Unallocated (unassigned) number" },
+ { AST_CAUSE_NO_ROUTE_TRANSIT_NET, "NO_ROUTE_TRANSIT_NET", "No route to specified transmit network" },
+ { AST_CAUSE_NO_ROUTE_DESTINATION, "NO_ROUTE_DESTINATION", "No route to destination" },
+ { AST_CAUSE_CHANNEL_UNACCEPTABLE, "CHANNEL_UNACCEPTABLE", "Channel unacceptable" },
+ { AST_CAUSE_CALL_AWARDED_DELIVERED, "CALL_AWARDED_DELIVERED", "Call awarded and being delivered in an established channel" },
+ { AST_CAUSE_NORMAL_CLEARING, "NORMAL_CLEARING", "Normal Clearing" },
+ { AST_CAUSE_USER_BUSY, "USER_BUSY", "User busy" },
+ { AST_CAUSE_NO_USER_RESPONSE, "NO_USER_RESPONSE", "No user responding" },
+ { AST_CAUSE_NO_ANSWER, "NO_ANSWER", "User alerting, no answer" },
+ { AST_CAUSE_CALL_REJECTED, "CALL_REJECTED", "Call Rejected" },
+ { AST_CAUSE_NUMBER_CHANGED, "NUMBER_CHANGED", "Number changed" },
+ { AST_CAUSE_DESTINATION_OUT_OF_ORDER, "DESTINATION_OUT_OF_ORDER", "Destination out of order" },
+ { AST_CAUSE_INVALID_NUMBER_FORMAT, "INVALID_NUMBER_FORMAT", "Invalid number format" },
+ { AST_CAUSE_FACILITY_REJECTED, "FACILITY_REJECTED", "Facility rejected" },
+ { AST_CAUSE_RESPONSE_TO_STATUS_ENQUIRY, "RESPONSE_TO_STATUS_ENQUIRY", "Response to STATus ENQuiry" },
+ { AST_CAUSE_NORMAL_UNSPECIFIED, "NORMAL_UNSPECIFIED", "Normal, unspecified" },
+ { AST_CAUSE_NORMAL_CIRCUIT_CONGESTION, "NORMAL_CIRCUIT_CONGESTION", "Circuit/channel congestion" },
+ { AST_CAUSE_NETWORK_OUT_OF_ORDER, "NETWORK_OUT_OF_ORDER", "Network out of order" },
+ { AST_CAUSE_NORMAL_TEMPORARY_FAILURE, "NORMAL_TEMPORARY_FAILURE", "Temporary failure" },
+ { AST_CAUSE_SWITCH_CONGESTION, "SWITCH_CONGESTION", "Switching equipment congestion" },
+ { AST_CAUSE_ACCESS_INFO_DISCARDED, "ACCESS_INFO_DISCARDED", "Access information discarded" },
+ { AST_CAUSE_REQUESTED_CHAN_UNAVAIL, "REQUESTED_CHAN_UNAVAIL", "Requested channel not available" },
+ { AST_CAUSE_PRE_EMPTED, "PRE_EMPTED", "Pre-empted" },
+ { AST_CAUSE_FACILITY_NOT_SUBSCRIBED, "FACILITY_NOT_SUBSCRIBED", "Facility not subscribed" },
+ { AST_CAUSE_OUTGOING_CALL_BARRED, "OUTGOING_CALL_BARRED", "Outgoing call barred" },
+ { AST_CAUSE_INCOMING_CALL_BARRED, "INCOMING_CALL_BARRED", "Incoming call barred" },
+ { AST_CAUSE_BEARERCAPABILITY_NOTAUTH, "BEARERCAPABILITY_NOTAUTH", "Bearer capability not authorized" },
+ { AST_CAUSE_BEARERCAPABILITY_NOTAVAIL, "BEARERCAPABILITY_NOTAVAIL", "Bearer capability not available" },
+ { AST_CAUSE_BEARERCAPABILITY_NOTIMPL, "BEARERCAPABILITY_NOTIMPL", "Bearer capability not implemented" },
+ { AST_CAUSE_CHAN_NOT_IMPLEMENTED, "CHAN_NOT_IMPLEMENTED", "Channel not implemented" },
+ { AST_CAUSE_FACILITY_NOT_IMPLEMENTED, "FACILITY_NOT_IMPLEMENTED", "Facility not implemented" },
+ { AST_CAUSE_INVALID_CALL_REFERENCE, "INVALID_CALL_REFERENCE", "Invalid call reference value" },
+ { AST_CAUSE_INCOMPATIBLE_DESTINATION, "INCOMPATIBLE_DESTINATION", "Incompatible destination" },
+ { AST_CAUSE_INVALID_MSG_UNSPECIFIED, "INVALID_MSG_UNSPECIFIED", "Invalid message unspecified" },
+ { AST_CAUSE_MANDATORY_IE_MISSING, "MANDATORY_IE_MISSING", "Mandatory information element is missing" },
+ { AST_CAUSE_MESSAGE_TYPE_NONEXIST, "MESSAGE_TYPE_NONEXIST", "Message type nonexist." },
+ { AST_CAUSE_WRONG_MESSAGE, "WRONG_MESSAGE", "Wrong message" },
+ { AST_CAUSE_IE_NONEXIST, "IE_NONEXIST", "Info. element nonexist or not implemented" },
+ { AST_CAUSE_INVALID_IE_CONTENTS, "INVALID_IE_CONTENTS", "Invalid information element contents" },
+ { AST_CAUSE_WRONG_CALL_STATE, "WRONG_CALL_STATE", "Message not compatible with call state" },
+ { AST_CAUSE_RECOVERY_ON_TIMER_EXPIRE, "RECOVERY_ON_TIMER_EXPIRE", "Recover on timer expiry" },
+ { AST_CAUSE_MANDATORY_IE_LENGTH_ERROR, "MANDATORY_IE_LENGTH_ERROR", "Mandatory IE length error" },
+ { AST_CAUSE_PROTOCOL_ERROR, "PROTOCOL_ERROR", "Protocol error, unspecified" },
+ { AST_CAUSE_INTERWORKING, "INTERWORKING", "Interworking, unspecified" },
};
@@ -477,6 +478,18 @@
return "Unknown";
}
+/*! \brief Convert a symbolic hangup cause to number */
+int ast_str2cause(const char *name)
+{
+ int x;
+
+ for (x = 0; x < sizeof(causes) / sizeof(causes[0]); x++)
+ if (strncasecmp(causes[x].name, name, strlen(causes[x].name)) == 0)
+ return causes[x].cause;
+
+ return -1;
+}
+
/*! \brief Gives the string form of a given channel state */
char *ast_state2str(int state)
{
Modified: team/jcollie/bug7131/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/jcollie/bug7131/include/asterisk/channel.h?rev=30392&r1=30391&r2=30392&view=diff
==============================================================================
--- team/jcollie/bug7131/include/asterisk/channel.h (original)
+++ team/jcollie/bug7131/include/asterisk/channel.h Thu May 25 15:54:53 2006
@@ -1011,6 +1011,13 @@
*/
const char *ast_cause2str(int state);
+/*! Convert the string form of a cause code to a number */
+/*!
+ * \param name string form of the cause
+ * Returns the cause code
+ */
+int ast_str2cause(const char *name);
+
/*! Gives the string form of a given channel state */
/*!
* \param state state to get the name of
Modified: team/jcollie/bug7131/pbx.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/bug7131/pbx.c?rev=30392&r1=30391&r2=30392&view=diff
==============================================================================
--- team/jcollie/bug7131/pbx.c (original)
+++ team/jcollie/bug7131/pbx.c Thu May 25 15:54:53 2006
@@ -343,7 +343,9 @@
{ "Hangup", pbx_builtin_hangup,
"Hang up the calling channel",
- " Hangup(): This application will hang up the calling channel.\n"
+ " Hangup([causecode]): This application will hang up the calling channel.\n"
+ "If a causecode is given the channel's hangup cause will be set to the given\n"
+ "value.\n"
},
{ "NoOp", pbx_builtin_noop,
@@ -5018,9 +5020,28 @@
*/
static int pbx_builtin_hangup(struct ast_channel *chan, void *data)
{
- /* Just return non-zero and it will hang up */
- if (!chan->hangupcause)
+ if (!ast_strlen_zero(data)) {
+ int cause;
+ char *endptr;
+
+ if ((cause = ast_str2cause(data)) > -1) {
+ chan->hangupcause = cause;
+ return -1;
+ }
+
+ cause = strtol((const char *) data, &endptr, 10);
+ if (cause != 0 || (data != endptr)) {
+ chan->hangupcause = cause;
+ return -1;
+ }
+
+ ast_log(LOG_NOTICE, "Invalid cause given to Hangup(): \"%s\"\n", (char *) data);
+ }
+
+ if (!chan->hangupcause) {
chan->hangupcause = AST_CAUSE_NORMAL_CLEARING;
+ }
+
return -1;
}
More information about the asterisk-commits
mailing list