summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
authorKinsey Moore <kmoore@digium.com>2012-07-20 15:48:55 +0000
committerKinsey Moore <kmoore@digium.com>2012-07-20 15:48:55 +0000
commitcb9756daa2042d6e5b91290def004b0f0c9eb168 (patch)
tree9ea585c25213ade435c83c95a055082f1e291f2a /channels
parent499a445af213b1cbce99db9219f041ef053fbc18 (diff)
Add hangupcause translation support
The HANGUPCAUSE hash (trunk only) meant to replace SIP_CAUSE has now been replaced with the HANGUPCAUSE and HANGUPCAUSE_KEYS dialplan functions to better facilitate access to the AST_CAUSE translations for technology-specific cause codes. The HangupCauseClear application has also been added to remove this data from the channel. (closes issue SWP-4738) Review: https://reviewboard.asterisk.org/r/2025/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370316 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_dahdi.c3
-rw-r--r--channels/chan_iax2.c3
-rw-r--r--channels/chan_sip.c1
-rw-r--r--channels/sig_analog.c2
-rw-r--r--channels/sig_pri.c9
-rw-r--r--channels/sig_ss7.c9
6 files changed, 17 insertions, 10 deletions
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c
index a394ec89c..28212e5ee 100644
--- a/channels/chan_dahdi.c
+++ b/channels/chan_dahdi.c
@@ -4182,6 +4182,7 @@ static void dahdi_r2_on_call_disconnect(openr2_chan_t *r2chan, openr2_call_disco
snprintf(cause_str, sizeof(cause_str), "R2 DISCONNECT (%s)", openr2_proto_get_disconnect_string(cause));
datalen += strlen(cause_str);
cause_code = alloca(datalen);
+ cause_code->ast_cause = dahdi_r2_cause_to_ast_cause(cause);
ast_copy_string(cause_code->chan_name, ast_channel_name(p->owner), AST_CHANNEL_NAME);
ast_copy_string(cause_code->code, cause_str, datalen + 1 - sizeof(*cause_code));
ast_queue_control_data(p->owner, AST_CONTROL_PVT_CAUSE_CODE, cause_code, datalen);
@@ -7640,7 +7641,7 @@ static enum ast_bridge_result dahdi_bridge(struct ast_channel *c0, struct ast_ch
switch (f ? f->frametype : AST_FRAME_CONTROL) {
case AST_FRAME_CONTROL:
if (f && f->subclass.integer == AST_CONTROL_PVT_CAUSE_CODE) {
- ast_channel_hangupcause_hash_set((who == c0) ? c1 : c0, f->data.ptr);
+ ast_channel_hangupcause_hash_set((who == c0) ? c1 : c0, f->data.ptr, f->datalen);
break;
}
*fo = f;
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 199834ddf..8efad88c8 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -5653,7 +5653,7 @@ static enum ast_bridge_result iax2_bridge(struct ast_channel *c0, struct ast_cha
other = (who == c0) ? c1 : c0; /* the 'other' channel */
if ((f->frametype == AST_FRAME_CONTROL)) {
if (f->subclass.integer == AST_CONTROL_PVT_CAUSE_CODE) {
- ast_channel_hangupcause_hash_set(other, f->data.ptr);
+ ast_channel_hangupcause_hash_set(other, f->data.ptr, f->datalen);
} else if (!(flags & AST_BRIDGE_IGNORE_SIGS)
&& (f->subclass.integer != AST_CONTROL_SRCUPDATE)) {
*fo = f;
@@ -10239,6 +10239,7 @@ static int socket_process_helper(struct iax2_thread *thread)
cause_code = alloca(data_size);
ast_copy_string(cause_code->chan_name, ast_channel_name(iaxs[fr->callno]->owner), AST_CHANNEL_NAME);
+ cause_code->ast_cause = ies.causecode;
snprintf(cause_code->code, data_size - sizeof(*cause_code) + 1, "IAX2 %s(%d)", subclass, ies.causecode);
iax2_queue_control_data(fr->callno, AST_CONTROL_PVT_CAUSE_CODE, cause_code, data_size);
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 9d57ad5bd..9c2d75d3f 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -27004,6 +27004,7 @@ static int handle_incoming(struct sip_pvt *p, struct sip_request *req, struct as
snprintf(cause_code->code, data_size - sizeof(*cause_code) + 1, "SIP %s", REQ_OFFSET_TO_STR(req, rlPart2));
+ cause_code->ast_cause = hangup_sip2cause(respid);
if (global_store_sip_cause) {
cause_code->emulate_sip_cause = 1;
}
diff --git a/channels/sig_analog.c b/channels/sig_analog.c
index f40932f27..608f82b27 100644
--- a/channels/sig_analog.c
+++ b/channels/sig_analog.c
@@ -2735,6 +2735,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
subclass = analog_event2str(res);
data_size += strlen(subclass);
cause_code = alloca(data_size);
+ cause_code->ast_cause = AST_CAUSE_NORMAL_CLEARING;
ast_copy_string(cause_code->chan_name, ast_channel_name(ast), AST_CHANNEL_NAME);
snprintf(cause_code->code, data_size - sizeof(*cause_code) + 1, "ANALOG %s", subclass);
break;
@@ -2826,6 +2827,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
case ANALOG_EVENT_ALARM:
analog_set_alarm(p, 1);
analog_get_and_handle_alarms(p);
+ cause_code->ast_cause = AST_CAUSE_NETWORK_OUT_OF_ORDER;
case ANALOG_EVENT_ONHOOK:
ast_queue_control_data(ast, AST_CONTROL_PVT_CAUSE_CODE, cause_code, data_size);
switch (p->sig) {
diff --git a/channels/sig_pri.c b/channels/sig_pri.c
index f6d7b0867..30d11e755 100644
--- a/channels/sig_pri.c
+++ b/channels/sig_pri.c
@@ -1277,7 +1277,7 @@ static void pri_queue_control(struct sig_pri_span *pri, int chanpos, int subclas
*
* \return Nothing
*/
-static void pri_queue_pvt_cause_data(struct sig_pri_span *pri, int chanpos, const char *cause)
+static void pri_queue_pvt_cause_data(struct sig_pri_span *pri, int chanpos, const char *cause, int ast_cause)
{
struct ast_channel *chan;
struct ast_control_pvt_cause_code *cause_code;
@@ -1287,6 +1287,7 @@ static void pri_queue_pvt_cause_data(struct sig_pri_span *pri, int chanpos, cons
if (chan) {
int datalen = sizeof(*cause_code) + strlen(cause);
cause_code = alloca(datalen);
+ cause_code->ast_cause = ast_cause;
ast_copy_string(cause_code->chan_name, ast_channel_name(chan), AST_CHANNEL_NAME);
ast_copy_string(cause_code->code, cause, datalen + 1 - sizeof(*cause_code));
ast_queue_control_data(chan, AST_CONTROL_PVT_CAUSE_CODE, cause_code, datalen);
@@ -6638,7 +6639,7 @@ static void *pri_dchannel(void *vpri)
if (e->proceeding.cause > -1) {
if (pri->pvts[chanpos]->owner) {
snprintf(cause_str, sizeof(cause_str), "PRI PRI_EVENT_PROGRESS (%d)", e->proceeding.cause);
- pri_queue_pvt_cause_data(pri, chanpos, cause_str);
+ pri_queue_pvt_cause_data(pri, chanpos, cause_str, e->proceeding.cause);
}
ast_verb(3, "PROGRESS with cause code %d received\n", e->proceeding.cause);
@@ -6944,7 +6945,7 @@ static void *pri_dchannel(void *vpri)
int do_hangup = 0;
snprintf(cause_str, sizeof(cause_str), "PRI PRI_EVENT_HANGUP (%d)", e->hangup.cause);
- pri_queue_pvt_cause_data(pri, chanpos, cause_str);
+ pri_queue_pvt_cause_data(pri, chanpos, cause_str, e->hangup.cause);
/* Queue a BUSY instead of a hangup if our cause is appropriate */
ast_channel_hangupcause_set(pri->pvts[chanpos]->owner, e->hangup.cause);
@@ -7099,7 +7100,7 @@ static void *pri_dchannel(void *vpri)
int do_hangup = 0;
snprintf(cause_str, sizeof(cause_str), "PRI PRI_EVENT_HANGUP_REQ (%d)", e->hangup.cause);
- pri_queue_pvt_cause_data(pri, chanpos, cause_str);
+ pri_queue_pvt_cause_data(pri, chanpos, cause_str, e->hangup.cause);
ast_channel_hangupcause_set(pri->pvts[chanpos]->owner, e->hangup.cause);
switch (ast_channel_state(pri->pvts[chanpos]->owner)) {
diff --git a/channels/sig_ss7.c b/channels/sig_ss7.c
index 6abca5433..810a0d5f2 100644
--- a/channels/sig_ss7.c
+++ b/channels/sig_ss7.c
@@ -384,12 +384,13 @@ static void sig_ss7_queue_control(struct sig_ss7_linkset *ss7, int chanpos, int
*
* \return Nothing
*/
-static void ss7_queue_pvt_cause_data(struct ast_channel *owner, const char *cause)
+static void ss7_queue_pvt_cause_data(struct ast_channel *owner, const char *cause, int ast_cause)
{
struct ast_control_pvt_cause_code *cause_code;
int datalen = sizeof(*cause_code) + strlen(cause);
cause_code = alloca(datalen);
+ cause_code->ast_cause = ast_cause;
ast_copy_string(cause_code->chan_name, ast_channel_name(owner), AST_CHANNEL_NAME);
ast_copy_string(cause_code->code, cause, datalen + 1 - sizeof(*cause_code));
ast_queue_control_data(owner, AST_CONTROL_PVT_CAUSE_CODE, cause_code, datalen);
@@ -915,7 +916,7 @@ void *ss7_linkset(void *data)
sig_ss7_lock_owner(linkset, chanpos);
p->ss7call = NULL;
if (p->owner) {
- ss7_queue_pvt_cause_data(p->owner, "SS7 ISUP_EVENT_RSC");
+ ss7_queue_pvt_cause_data(p->owner, "SS7 ISUP_EVENT_RSC", AST_CAUSE_INTERWORKING);
ast_softhangup_nolock(p->owner, AST_SOFTHANGUP_DEV);
ast_channel_unlock(p->owner);
}
@@ -973,7 +974,7 @@ void *ss7_linkset(void *data)
}
p->call_level = SIG_SS7_CALL_LEVEL_GLARE;
if (p->owner) {
- ss7_queue_pvt_cause_data(p->owner, "SS7 ISUP_EVENT_IAM (glare)");
+ ss7_queue_pvt_cause_data(p->owner, "SS7 ISUP_EVENT_IAM (glare)", AST_CAUSE_NORMAL_CLEARING);
ast_channel_hangupcause_set(p->owner, AST_CAUSE_NORMAL_CLEARING);
ast_softhangup_nolock(p->owner, AST_SOFTHANGUP_DEV);
ast_channel_unlock(p->owner);
@@ -1119,7 +1120,7 @@ void *ss7_linkset(void *data)
sig_ss7_lock_owner(linkset, chanpos);
if (p->owner) {
snprintf(cause_str, sizeof(cause_str), "SS7 ISUP_EVENT_REL (%d)", e->rel.cause);
- ss7_queue_pvt_cause_data(p->owner, cause_str);
+ ss7_queue_pvt_cause_data(p->owner, cause_str, e->rel.cause);
ast_channel_hangupcause_set(p->owner, e->rel.cause);
ast_softhangup_nolock(p->owner, AST_SOFTHANGUP_DEV);