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);
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);
}
#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);
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]) {
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;
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);
}
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);
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:
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:
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 {
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
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);
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);