[svn-commits] kmoore: trunk r418084 - in /trunk: ./ channels/ main/ res/ tests/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Sun Jul 6 20:22:47 CDT 2014
Author: kmoore
Date: Sun Jul 6 20:22:44 2014
New Revision: 418084
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=418084
Log:
CEL: Fix incorrect/missing extra field information
This corrects two issues with the extra field information in Asterisk
12+ in channel event logs.
It is possible to inject custom values into the dialstatus provided by
ast_channel_dial_type() Stasis messages that fall outside the
enumeration allowed for the DIALSTATUS channel variable. CEL now
filters for the allowed values and ignores other values.
The "hangupsource" extra field key is always blank if the far end
channel is a chan_pjsip channel. This is because the hangupsource is
never set for the pjsip channel driver. This change sets the
hangupsource whenever a hangup is queued for chan_pjsip channels.
This corrects an issue with the pjsip channel driver where the
hangupcause information was not being set properly.
Review: https://reviewboard.asterisk.org/r/3690/
........
Merged revisions 418071 from http://svn.asterisk.org/svn/asterisk/branches/12
Modified:
trunk/ (props changed)
trunk/channels/chan_pjsip.c
trunk/main/cel.c
trunk/res/res_pjsip_session.c
trunk/tests/test_cel.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.
Modified: trunk/channels/chan_pjsip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_pjsip.c?view=diff&rev=418084&r1=418083&r2=418084
==============================================================================
--- trunk/channels/chan_pjsip.c (original)
+++ trunk/channels/chan_pjsip.c Sun Jul 6 20:22:44 2014
@@ -1510,6 +1510,7 @@
int res = ast_sip_session_create_invite(session, &tdata);
if (res) {
+ ast_set_hangupsource(session->channel, ast_channel_name(session->channel), 0);
ast_queue_hangup(session->channel);
} else {
update_initial_connected_line(session);
@@ -1945,6 +1946,7 @@
chan_pjsip_remove_hold(ast_channel_uniqueid(session->channel));
+ ast_set_hangupsource(session->channel, ast_channel_name(session->channel), 0);
if (!ast_channel_hangupcause(session->channel) && session->inv_session) {
int cause = hangup_sip2cause(session->inv_session->cause);
@@ -2072,6 +2074,8 @@
static void chan_pjsip_incoming_response(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
{
struct pjsip_status_line status = rdata->msg_info.msg->line.status;
+ struct ast_control_pvt_cause_code *cause_code;
+ int data_size = sizeof(*cause_code);
if (!session->channel) {
return;
@@ -2095,6 +2099,21 @@
default:
break;
}
+
+ /* Build and send the tech-specific cause information */
+ /* size of the string making up the cause code is "SIP " number + " " + reason length */
+ data_size += 4 + 4 + pj_strlen(&status.reason);
+ cause_code = ast_alloca(data_size);
+ memset(cause_code, 0, data_size);
+
+ ast_copy_string(cause_code->chan_name, ast_channel_name(session->channel), AST_CHANNEL_NAME);
+
+ snprintf(cause_code->code, data_size - sizeof(*cause_code) + 1, "SIP %d %.*s", status.code,
+ (int) pj_strlen(&status.reason), pj_strbuf(&status.reason));
+
+ cause_code->ast_cause = hangup_sip2cause(status.code);
+ ast_queue_control_data(session->channel, AST_CONTROL_PVT_CAUSE_CODE, cause_code, data_size);
+ ast_channel_hangupcause_hash_set(session->channel, cause_code, data_size);
}
static int chan_pjsip_incoming_ack(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
Modified: trunk/main/cel.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/cel.c?view=diff&rev=418084&r1=418083&r2=418084
==============================================================================
--- trunk/main/cel.c (original)
+++ trunk/main/cel.c Sun Jul 6 20:22:44 2014
@@ -1270,6 +1270,35 @@
}
}
+static int is_valid_dialstatus(struct ast_multi_channel_blob *blob)
+{
+ const char *dialstatus = get_blob_variable(blob, "dialstatus");
+ int res = 0;
+
+ if (ast_strlen_zero(dialstatus)) {
+ res = 0;
+ } else if (!strcasecmp(dialstatus, "CHANUNAVAIL")) {
+ res = 1;
+ } else if (!strcasecmp(dialstatus, "CONGESTION")) {
+ res = 1;
+ } else if (!strcasecmp(dialstatus, "NOANSWER")) {
+ res = 1;
+ } else if (!strcasecmp(dialstatus, "BUSY")) {
+ res = 1;
+ } else if (!strcasecmp(dialstatus, "ANSWER")) {
+ res = 1;
+ } else if (!strcasecmp(dialstatus, "CANCEL")) {
+ res = 1;
+ } else if (!strcasecmp(dialstatus, "DONTCALL")) {
+ res = 1;
+ } else if (!strcasecmp(dialstatus, "TORTURE")) {
+ res = 1;
+ } else if (!strcasecmp(dialstatus, "INVALIDARGS")) {
+ res = 1;
+ }
+ return res;
+}
+
static void cel_dial_cb(void *data, struct stasis_subscription *sub,
struct stasis_message *message)
{
@@ -1298,11 +1327,9 @@
}
}
- if (ast_strlen_zero(get_blob_variable(blob, "dialstatus"))) {
- return;
- }
-
- save_dialstatus(blob);
+ if (is_valid_dialstatus(blob)) {
+ save_dialstatus(blob);
+ }
}
static void cel_generic_cb(
Modified: trunk/res/res_pjsip_session.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip_session.c?view=diff&rev=418084&r1=418083&r2=418084
==============================================================================
--- trunk/res/res_pjsip_session.c (original)
+++ trunk/res/res_pjsip_session.c Sun Jul 6 20:22:44 2014
@@ -2134,6 +2134,7 @@
if ((status != PJ_SUCCESS) || (pjmedia_sdp_neg_get_active_local(inv->neg, &local) != PJ_SUCCESS) ||
(pjmedia_sdp_neg_get_active_remote(inv->neg, &remote) != PJ_SUCCESS)) {
ast_channel_hangupcause_set(session->channel, AST_CAUSE_BEARERCAPABILITY_NOTAVAIL);
+ ast_set_hangupsource(session->channel, ast_channel_name(session->channel), 0);
ast_queue_hangup(session->channel);
return;
}
Modified: trunk/tests/test_cel.c
URL: http://svnview.digium.com/svn/asterisk/trunk/tests/test_cel.c?view=diff&rev=418084&r1=418083&r2=418084
==============================================================================
--- trunk/tests/test_cel.c (original)
+++ trunk/tests/test_cel.c Sun Jul 6 20:22:44 2014
@@ -773,6 +773,40 @@
return AST_TEST_PASS;
}
+AST_TEST_DEFINE(test_cel_dial_unanswered_filter)
+{
+ RAII_VAR(struct ast_channel *, chan_caller, NULL, safe_channel_release);
+ RAII_VAR(struct ast_channel *, chan_callee, NULL, safe_channel_release);
+ struct ast_party_caller caller = ALICE_CALLERID;
+
+ switch (cmd) {
+ case TEST_INIT:
+ info->name = __func__;
+ info->category = TEST_CATEGORY;
+ info->summary = "Test CEL for a dial that isn't answered";
+ info->description =
+ "Test CEL records for a channel that\n"
+ "performs a dial operation that isn't answered\n";
+ return AST_TEST_NOT_RUN;
+ case TEST_EXECUTE:
+ break;
+ }
+
+ CREATE_ALICE_CHANNEL(chan_caller, &caller);
+
+ EMULATE_DIAL(chan_caller, CHANNEL_TECH_NAME "/Bob");
+
+ START_DIALED(chan_caller, chan_callee);
+
+ ast_channel_state_set(chan_caller, AST_STATE_RINGING);
+ ast_channel_publish_dial(chan_caller, chan_callee, NULL, "NOT A VALID DIAL STATUS");
+ ast_channel_publish_dial(chan_caller, chan_callee, NULL, "NOANSWER");
+
+ HANGUP_CHANNEL(chan_caller, AST_CAUSE_NO_ANSWER, "NOANSWER");
+ HANGUP_CHANNEL(chan_callee, AST_CAUSE_NO_ANSWER, "");
+
+ return AST_TEST_PASS;
+}
AST_TEST_DEFINE(test_cel_dial_busy)
{
@@ -2040,6 +2074,7 @@
#endif
AST_TEST_UNREGISTER(test_cel_dial_unanswered);
+ AST_TEST_UNREGISTER(test_cel_dial_unanswered_filter);
AST_TEST_UNREGISTER(test_cel_dial_congestion);
AST_TEST_UNREGISTER(test_cel_dial_busy);
AST_TEST_UNREGISTER(test_cel_dial_unavailable);
@@ -2114,6 +2149,7 @@
#endif
AST_TEST_REGISTER(test_cel_dial_unanswered);
+ AST_TEST_REGISTER(test_cel_dial_unanswered_filter);
AST_TEST_REGISTER(test_cel_dial_congestion);
AST_TEST_REGISTER(test_cel_dial_busy);
AST_TEST_REGISTER(test_cel_dial_unavailable);
More information about the svn-commits
mailing list