]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Remove unnecessary generation of informational cause frames
authorKinsey Moore <kmoore@digium.com>
Fri, 6 Jul 2012 22:03:44 +0000 (22:03 +0000)
committerKinsey Moore <kmoore@digium.com>
Fri, 6 Jul 2012 22:03:44 +0000 (22:03 +0000)
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.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369765 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_dahdi.c
channels/chan_iax2.c
channels/sig_analog.c
channels/sig_pri.c
channels/sig_ss7.c

index 2e2770fc567f7255554afd195825ab30e085324c..59841d1bd753df3882636e19dde22b2aa45cb5d8 100644 (file)
@@ -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);
index ba662c9f31b7ed64a164ca8f49aca3d171eac535..ad6cdd15c1c4681af11c6542ecefdfe75e9e5606 100644 (file)
@@ -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]) {
index 7c238d06e09763a66f9448bd3aca8566b69a2aeb..cf51e97270d964351466f6a653e70ff834b5130f 100644 (file)
@@ -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 {
index 0e9c90ea78cc0bd1e3581abce5ccee0e8f2c360f..31438a94506addddea4463f07764d7c491d43272 100644 (file)
@@ -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);
index 24de8057fe249469c0bc68970ae08a92277c534f..6abca5433be1cbfe63b707655e101aa85e5e0d18 100644 (file)
@@ -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);