[asterisk-commits] kmoore: trunk r369765 - /trunk/channels/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jul 6 17:03:48 CDT 2012
Author: kmoore
Date: Fri Jul 6 17:03:44 2012
New Revision: 369765
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=369765
Log:
Remove unnecessary generation of informational cause frames
It is not necessary to generate information cause code frames on every
protocol event that occurs. This removes all the instances where the
frame was not conveying a cause code and was instead just conveying a
protocol-specific message. This also corrects the generation of the
message associated with disconnects for MFC/R2 to use the MFC/R2
specific text for the disconnect cause.
Modified:
trunk/channels/chan_dahdi.c
trunk/channels/chan_iax2.c
trunk/channels/sig_analog.c
trunk/channels/sig_pri.c
trunk/channels/sig_ss7.c
Modified: trunk/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_dahdi.c?view=diff&rev=369765&r1=369764&r2=369765
==============================================================================
--- trunk/channels/chan_dahdi.c (original)
+++ trunk/channels/chan_dahdi.c Fri Jul 6 17:03:44 2012
@@ -4151,7 +4151,7 @@
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 @@
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);
Modified: trunk/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=369765&r1=369764&r2=369765
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Fri Jul 6 17:03:44 2012
@@ -10188,54 +10188,35 @@
}
#endif
- if (iaxs[fr->callno]->owner && (fh->type == AST_FRAME_IAX || fh->type == AST_FRAME_CONTROL)) {
- 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);
- }
-
- /* 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++;
- }
- }
- /* add length of subclass */
- data_size += strlen(subclass);
-
- 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 &&
+ 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)) {
- 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);
- }
+ struct ast_control_pvt_cause_code *cause_code;
+ int data_size = sizeof(*cause_code);
+ char subclass[40] = "";
+
+ /* get subclass text */
+ iax_frame_subclass2str(fh->csub, subclass, sizeof(subclass));
+
+ /* add length of "IAX2 " */
+ data_size += 5;
+ /* 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);
+
+ cause_code = alloca(data_size);
+ ast_copy_string(cause_code->chan_name, ast_channel_name(iaxs[fr->callno]->owner), AST_CHANNEL_NAME);
+
+ 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]) {
Modified: trunk/channels/sig_analog.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sig_analog.c?view=diff&rev=369765&r1=369764&r2=369765
==============================================================================
--- trunk/channels/sig_analog.c (original)
+++ trunk/channels/sig_analog.c Fri Jul 6 17:03:44 2012
@@ -2670,7 +2670,7 @@
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 @@
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 @@
}
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 @@
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 @@
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 @@
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 {
Modified: trunk/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sig_pri.c?view=diff&rev=369765&r1=369764&r2=369765
==============================================================================
--- trunk/channels/sig_pri.c (original)
+++ trunk/channels/sig_pri.c Fri Jul 6 17:03:44 2012
@@ -6635,8 +6635,6 @@
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 @@
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);
Modified: trunk/channels/sig_ss7.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sig_ss7.c?view=diff&rev=369765&r1=369764&r2=369765
==============================================================================
--- trunk/channels/sig_ss7.c (original)
+++ trunk/channels/sig_ss7.c Fri Jul 6 17:03:44 2012
@@ -1328,28 +1328,6 @@
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);
More information about the asterisk-commits
mailing list