summaryrefslogtreecommitdiff
path: root/channels/chan_sip.c
diff options
context:
space:
mode:
authorKinsey Moore <kmoore@digium.com>2012-05-14 19:44:27 +0000
committerKinsey Moore <kmoore@digium.com>2012-05-14 19:44:27 +0000
commitb5a6de76fc71e3f604761885dd844975a11893ee (patch)
tree5a8f74f510374ec3768b4e778a797b529133cb8a /channels/chan_sip.c
parentfef9a32fb410b47da4cb195f0af2f63f8cac0f03 (diff)
Commit framework for HANGUPCAUSE (replacement for SIP_CAUSE)
This is the starting point for the Asterisk 11: Who Hung Up work and provides a framework which will allow channel drivers to report the types of hangup cause information available in SIP_CAUSE without incurring the overhead of the MASTER_CHANNEL dialplan function. The initial implementation only includes cause generation for chan_sip and does not include cause code translation utilities. This change deprecates SIP_CAUSE and replaces its method of reporting cause codes with the new framework. This change also deprecates the 'storesipcause' option in sip.conf. Review: https://reviewboard.asterisk.org/r/1822/ (Closes issue SWP-4221) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@366408 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r--channels/chan_sip.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index f6fb2af7c..0cf12acd0 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -7093,6 +7093,7 @@ static int sip_indicate(struct ast_channel *ast, int condition, const void *data
break;
case AST_CONTROL_UPDATE_RTP_PEER: /* Absorb this since it is handled by the bridge */
break;
+ case AST_CONTROL_PVT_CAUSE_CODE: /* these should be handled by the code in channel.c */
case -1:
res = -1;
break;
@@ -26113,28 +26114,29 @@ static int handle_incoming(struct sip_pvt *p, struct sip_request *req, struct as
ast_debug(1, "Ignoring out of order response %u (expecting %u)\n", seqno, p->ocseq);
return -1;
} else {
- char causevar[256], causeval[256];
-
if ((respid == 200) || ((respid >= 300) && (respid <= 399))) {
extract_uri(p, req);
}
- handle_response(p, respid, e + len, req, seqno);
+ if (p->owner) {
+ struct ast_control_pvt_cause_code *cause_code;
+ int data_size = sizeof(*cause_code);
+ /* size of the string making up the cause code is "SIP " + cause length */
+ data_size += 4 + strlen(REQ_OFFSET_TO_STR(req, rlPart2));
+ cause_code = alloca(data_size);
- if (global_store_sip_cause && p->owner) {
- struct ast_channel *owner = p->owner;
+ ast_copy_string(cause_code->chan_name, ast_channel_name(p->owner), AST_CHANNEL_NAME);
- snprintf(causevar, sizeof(causevar), "MASTER_CHANNEL(HASH(SIP_CAUSE,%s))", ast_channel_name(owner));
- snprintf(causeval, sizeof(causeval), "SIP %s", REQ_OFFSET_TO_STR(req, rlPart2));
+ snprintf(cause_code->code, data_size - sizeof(*cause_code) + 1, "SIP %s", REQ_OFFSET_TO_STR(req, rlPart2));
- ast_channel_ref(owner);
- sip_pvt_unlock(p);
- ast_channel_unlock(owner);
- *nounlock = 1;
- pbx_builtin_setvar_helper(owner, causevar, causeval);
- ast_channel_unref(owner);
- sip_pvt_lock(p);
+ if (global_store_sip_cause) {
+ cause_code->emulate_sip_cause = 1;
+ }
+
+ ast_queue_control_data(p->owner, AST_CONTROL_PVT_CAUSE_CODE, cause_code, data_size);
}
+
+ handle_response(p, respid, e + len, req, seqno);
}
return 0;
}
@@ -29882,6 +29884,9 @@ static int reload_config(enum channelreloadreason reason)
}
} else if (!strcasecmp(v->name, "storesipcause")) {
global_store_sip_cause = ast_true(v->value);
+ if (global_store_sip_cause) {
+ ast_log(LOG_WARNING, "Usage of SIP_CAUSE is deprecated. Please use HANGUPCAUSE instead.\n");
+ }
} else if (!strcasecmp(v->name, "qualifygap")) {
if (sscanf(v->value, "%30d", &global_qualify_gap) != 1) {
ast_log(LOG_WARNING, "Invalid qualifygap '%s' at line %d of %s\n", v->value, v->lineno, config);