diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index 2e2770fc56..59841d1bd7 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -4151,7 +4151,7 @@ static int dahdi_r2_cause_to_ast_cause(openr2_call_disconnect_cause_t cause) static void dahdi_r2_on_call_disconnect(openr2_chan_t *r2chan, openr2_call_disconnect_cause_t cause) { struct dahdi_pvt *p = openr2_chan_get_client_data(r2chan); - char cause_str[20]; + char cause_str[50]; struct ast_control_pvt_cause_code *cause_code; int datalen = sizeof(*cause_code); @@ -4164,7 +4164,7 @@ static void dahdi_r2_on_call_disconnect(openr2_chan_t *r2chan, openr2_call_disco return; } - snprintf(cause_str, sizeof(cause_str), "R2 DISCONNECT (%d)", dahdi_r2_cause_to_ast_cause(cause)); + snprintf(cause_str, sizeof(cause_str), "R2 DISCONNECT (%s)", openr2_proto_get_disconnect_string(cause)); datalen += strlen(cause_str); cause_code = alloca(datalen); ast_copy_string(cause_code->chan_name, ast_channel_name(p->owner), AST_CHANNEL_NAME); diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index ba662c9f31..ad6cdd15c1 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -10188,38 +10188,27 @@ static int socket_process_helper(struct iax2_thread *thread) } #endif - if (iaxs[fr->callno]->owner && (fh->type == AST_FRAME_IAX || fh->type == AST_FRAME_CONTROL)) { + if (iaxs[fr->callno]->owner && fh->type == AST_FRAME_IAX && + (fh->csub == IAX_COMMAND_HANGUP + || fh->csub == IAX_COMMAND_REJECT + || fh->csub == IAX_COMMAND_REGREJ + || fh->csub == IAX_COMMAND_TXREJ)) { struct ast_control_pvt_cause_code *cause_code; int data_size = sizeof(*cause_code); char subclass[40] = ""; /* get subclass text */ - if (fh->type == AST_FRAME_IAX) { - iax_frame_subclass2str(fh->csub, subclass, sizeof(subclass)); - } else { - struct ast_frame tmp_frame = {0,}; - tmp_frame.frametype = fh->type; - tmp_frame.subclass.integer = fh->csub; - ast_frame_subclass2str(&tmp_frame, subclass, sizeof(subclass), NULL, 0); - } + iax_frame_subclass2str(fh->csub, subclass, sizeof(subclass)); /* add length of "IAX2 " */ data_size += 5; - if (fh->type == AST_FRAME_CONTROL) { - /* add length of "Control " */ - data_size += 8; - } else if (fh->csub == IAX_COMMAND_HANGUP - || fh->csub == IAX_COMMAND_REJECT - || fh->csub == IAX_COMMAND_REGREJ - || fh->csub == IAX_COMMAND_TXREJ) { - /* for IAX hangup frames, add length of () and number */ - data_size += 3; - if (ies.causecode > 9) { - data_size++; - } - if (ies.causecode > 99) { - data_size++; - } + /* for IAX hangup frames, add length of () and number */ + data_size += 3; + if (ies.causecode > 9) { + data_size++; + } + if (ies.causecode > 99) { + data_size++; } /* add length of subclass */ data_size += strlen(subclass); @@ -10227,15 +10216,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); - if (fh->type == AST_FRAME_IAX && - (fh->csub == IAX_COMMAND_HANGUP - || fh->csub == IAX_COMMAND_REJECT - || fh->csub == IAX_COMMAND_REGREJ - || fh->csub == IAX_COMMAND_TXREJ)) { - snprintf(cause_code->code, data_size - sizeof(*cause_code) + 1, "IAX2 %s(%d)", subclass, ies.causecode); - } else { - snprintf(cause_code->code, data_size - sizeof(*cause_code) + 1, "IAX2 %s%s", (fh->type == AST_FRAME_CONTROL ? "Control " : ""), subclass); - } + 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); if (!iaxs[fr->callno]) { diff --git a/channels/sig_analog.c b/channels/sig_analog.c index 7c238d06e0..cf51e97270 100644 --- a/channels/sig_analog.c +++ b/channels/sig_analog.c @@ -2670,7 +2670,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_ pthread_t threadid; struct ast_channel *chan; struct ast_frame *f; - struct ast_control_pvt_cause_code *cause_code; + struct ast_control_pvt_cause_code *cause_code = NULL; int data_size = sizeof(*cause_code); char *subclass = NULL; @@ -2703,29 +2703,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_ ast_debug(1, "Got event %s(%d) on channel %d (index %d)\n", analog_event2str(res), res, p->channel, idx); - /* add length of "ANALOG " */ - data_size += 7; - if (res & (ANALOG_EVENT_PULSEDIGIT | ANALOG_EVENT_DTMFUP)) { - /* add length of "ANALOG_EVENT_" */ - data_size += 13; - if (res & ANALOG_EVENT_PULSEDIGIT) { - /* add length of "PULSEDIGIT" */ - data_size += 10; - } else { - /* add length of "DTMFUP" */ - data_size += 6; - } - - /* add length of " (c)" */ - data_size += 4; - - cause_code = alloca(data_size); - 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 ANALOG_EVENT_%s (%c)", - (res & ANALOG_EVENT_DTMFUP) ? "DTMFUP" : "PULSEDIGIT", res & 0xff); - ast_queue_control_data(ast, AST_CONTROL_PVT_CAUSE_CODE, cause_code, data_size); - analog_set_pulsedial(p, (res & ANALOG_EVENT_PULSEDIGIT) ? 1 : 0); ast_debug(1, "Detected %sdigit '%c'\n", (res & ANALOG_EVENT_PULSEDIGIT) ? "pulse ": "", res & 0xff); analog_confmute(p, 0); @@ -2736,14 +2714,6 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_ } if (res & ANALOG_EVENT_DTMFDOWN) { - /* add length of "ANALOG_EVENT_DTMFDOWN (c)" */ - data_size += 25; - - cause_code = alloca(data_size); - 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 ANALOG_EVENT_DTMFDOWN (%c)", res & 0xff); - ast_queue_control_data(ast, AST_CONTROL_PVT_CAUSE_CODE, cause_code, data_size); - ast_debug(1, "DTMF Down '%c'\n", res & 0xff); /* Mute conference */ analog_confmute(p, 1); @@ -2753,12 +2723,21 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_ return f; } - subclass = analog_event2str(res); - data_size += strlen(subclass); - cause_code = alloca(data_size); - 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); - ast_queue_control_data(ast, AST_CONTROL_PVT_CAUSE_CODE, cause_code, data_size); + switch (res) { + case ANALOG_EVENT_ALARM: + case ANALOG_EVENT_POLARITY: + case ANALOG_EVENT_ONHOOK: + /* add length of "ANALOG " */ + data_size += 7; + subclass = analog_event2str(res); + data_size += strlen(subclass); + cause_code = alloca(data_size); + 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; + default: + break; + } switch (res) { case ANALOG_EVENT_EC_DISABLED: @@ -2845,6 +2824,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_ analog_set_alarm(p, 1); analog_get_and_handle_alarms(p); case ANALOG_EVENT_ONHOOK: + ast_queue_control_data(ast, AST_CONTROL_PVT_CAUSE_CODE, cause_code, data_size); switch (p->sig) { case ANALOG_SIG_FXOLS: case ANALOG_SIG_FXOGS: @@ -3518,6 +3498,7 @@ winkflashdone: case AST_STATE_RING: /*!< Line is ringing */ if (p->hanguponpolarityswitch) { ast_debug(1, "HangingUp on polarity switch! channel %d\n", p->channel); + ast_queue_control_data(ast, AST_CONTROL_PVT_CAUSE_CODE, cause_code, data_size); ast_softhangup(p->owner, AST_SOFTHANGUP_EXPLICIT); p->polarity = POLARITY_IDLE; } else { diff --git a/channels/sig_pri.c b/channels/sig_pri.c index 0e9c90ea78..31438a9450 100644 --- a/channels/sig_pri.c +++ b/channels/sig_pri.c @@ -6635,8 +6635,6 @@ static void *pri_dchannel(void *vpri) pri_queue_control(pri, chanpos, AST_CONTROL_BUSY); } } - } else if (pri->pvts[chanpos]->owner) { - pri_queue_pvt_cause_data(pri, chanpos, "PRI PRI_EVENT_PROGRESS"); } if (!pri->pvts[chanpos]->progress @@ -7429,26 +7427,6 @@ static void *pri_dchannel(void *vpri) break; } - /* send tech-specific information for HANGUPCAUSE hash */ - if (chanpos > -1 && pri->pvts[chanpos]) { - switch (e->e) { - /* already handled above */ - case PRI_EVENT_PROGRESS: - case PRI_EVENT_HANGUP: - case PRI_EVENT_HANGUP_REQ: - break; - default: - sig_pri_lock_private(pri->pvts[chanpos]); - if (pri->pvts[chanpos]->owner) { - char *event_str = pri_event2str(e->e); - - snprintf(cause_str, sizeof(cause_str), "PRI %s", event_str); - pri_queue_pvt_cause_data(pri, chanpos, cause_str); - } - sig_pri_unlock_private(pri->pvts[chanpos]); - break; - } - } /* If a callid was set, we need to deref it and remove it from thread storage. */ if (callid) { callid = ast_callid_unref(callid); diff --git a/channels/sig_ss7.c b/channels/sig_ss7.c index 24de8057fe..6abca5433b 100644 --- a/channels/sig_ss7.c +++ b/channels/sig_ss7.c @@ -1328,28 +1328,6 @@ void *ss7_linkset(void *data) break; } - if (chanpos > -1) { - switch (e->e) { - /* handled above */ - case ISUP_EVENT_IAM: - case ISUP_EVENT_REL: - case ISUP_EVENT_RSC: - break; - default: - p = linkset->pvts[chanpos]; - sig_ss7_lock_private(p); - sig_ss7_lock_owner(linkset, chanpos); - if (p->owner) { - char *event_str = ss7_event2str(e->e); - - snprintf(cause_str, sizeof(cause_str), "SS7 %s", event_str); - ss7_queue_pvt_cause_data(p->owner, cause_str); - ast_channel_unlock(p->owner); - } - sig_ss7_unlock_private(p); - } - } - /* Call ID stuff needs to be cleaned up here */ if (callid) { callid = ast_callid_unref(callid);