summaryrefslogtreecommitdiff
path: root/channels/chan_iax2.c
diff options
context:
space:
mode:
authorKinsey Moore <kmoore@digium.com>2012-07-06 22:03:44 +0000
committerKinsey Moore <kmoore@digium.com>2012-07-06 22:03:44 +0000
commitdb59a3f12399fad704fb8977ab980f372c073068 (patch)
treed49fc35070b46d5eb377d69bbba7e60a8e1027dd /channels/chan_iax2.c
parent49aa47171b03dd0425d7afa200e12870c1beddae (diff)
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. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369765 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_iax2.c')
-rw-r--r--channels/chan_iax2.c47
1 files changed, 14 insertions, 33 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index ba662c9f3..ad6cdd15c 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]) {