Add HANGUPCAUSE hash support for analog and PRI DAHDI subtechs

This is part of the DAHDI support for the Asterisk 11 "Who Hung Up?"
project and covers the implementation for the technologies implemented
in sig_analog.c and sig_pri.c. Tested on a local machine to verify
protocol and cause information is available.

Review: https://reviewboard.asterisk.org/r/1953/
(issue SWP-4222)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369185 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Kinsey Moore
2012-06-22 15:10:38 +00:00
parent dee5d6b9e5
commit 1ab47ac137
2 changed files with 108 additions and 1 deletions

View File

@@ -2663,6 +2663,9 @@ 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;
int data_size = sizeof(*cause_code);
char *subclass = NULL;
ast_debug(1, "%s %d\n", __FUNCTION__, p->channel);
@@ -2693,7 +2696,29 @@ 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);
@@ -2704,6 +2729,14 @@ 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);
@@ -2713,6 +2746,13 @@ 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_EC_DISABLED:
ast_verb(3, "Channel %d echo canceler disabled due to CED detection\n", p->channel);