diff options
author | Matthew Jordan <mjordan@digium.com> | 2014-09-05 22:04:33 +0000 |
---|---|---|
committer | Matthew Jordan <mjordan@digium.com> | 2014-09-05 22:04:33 +0000 |
commit | d42b116925d4835f158f097150b4802b6feec83b (patch) | |
tree | 071dd60b2a39393ad4e3d6b5daf3173b76f36e00 /main/cdr.c | |
parent | 4499eb05d83b8ed54bff6f3e4deb1f7af3098531 (diff) |
main/cdrs: Preserve context/extension when executing a Macro or GoSub
The context/extension in a CDR is generally considered the destination of a
call. When looking at a 2-party call CDR, users will typically be presented
with the following:
context exten channel dest_channel app data
default 1000 SIP/8675309 SIP/1000 Dial SIP/1000,,20
However, if the Dial actually takes place in a Macro, the current behaviour
in 12 will result in the following CDR:
context exten channel dest_channel app data
macro-dial s SIP/8675309 SIP/1000 Dial SIP/1000,,20
The same is true of a GoSub:
context exten channel dest_channel app data
subs dial_stuff SIP/8675309 SIP/1000 Dial SIP/1000,,20
This generally makes the context/exten fields less than useful.
It isn't hard to preserve these values in the CDR state machine; however, we
need to have something that informs us when a channel is executing a
subroutine. Prior to this patch, there isn't anything that does this.
This patch solves this problem by adding a new channel flag,
AST_FLAG_SUBROUTINE_EXEC. This flag is set on a channel when it executes a
Macro or a GoSub. The CDR engine looks for this value when updating a Party A
snapshot; if the flag is present, we don't override the context/exten on the
main CDR object. In a funny quirk, executing a hangup handler must *not* abide
by this logic, as the endbeforehexten logic assumes that the user wants to see
data that occurs in hangup logic, which includes those subroutines. Since
those execute outside of a typical Dial operation (and will typically have
their own dedicated CDR anyway), this is unlikely to cause any heartburn.
Review: https://reviewboard.asterisk.org/r/3962/
ASTERISK-24254 #close
Reported by: tm1000, Tony Lewis
Tested by: Tony Lewis
........
Merged revisions 422718 from http://svn.asterisk.org/svn/asterisk/branches/12
........
Merged revisions 422719 from http://svn.asterisk.org/svn/asterisk/branches/13
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@422720 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/cdr.c')
-rw-r--r-- | main/cdr.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/main/cdr.c b/main/cdr.c index dcee00d01..5f2793ee8 100644 --- a/main/cdr.c +++ b/main/cdr.c @@ -692,6 +692,8 @@ struct cdr_object { AST_STRING_FIELD(bridge); /*!< The bridge the party A happens to be in. */ AST_STRING_FIELD(appl); /*!< The last accepted application party A was in */ AST_STRING_FIELD(data); /*!< The data for the last accepted application party A was in */ + AST_STRING_FIELD(context); /*!< The accepted context for Party A */ + AST_STRING_FIELD(exten); /*!< The accepted extension for Party A */ ); struct cdr_object *next; /*!< The next CDR object in the chain */ struct cdr_object *last; /*!< The last CDR object in the chain */ @@ -1115,8 +1117,8 @@ static struct ast_cdr *cdr_object_create_public_records(struct cdr_object *cdr) ast_copy_string(cdr_copy->uniqueid, party_a->uniqueid, sizeof(cdr_copy->uniqueid)); ast_copy_string(cdr_copy->lastapp, it_cdr->appl, sizeof(cdr_copy->lastapp)); ast_copy_string(cdr_copy->lastdata, it_cdr->data, sizeof(cdr_copy->lastdata)); - ast_copy_string(cdr_copy->dst, party_a->exten, sizeof(cdr_copy->dst)); - ast_copy_string(cdr_copy->dcontext, party_a->context, sizeof(cdr_copy->dcontext)); + ast_copy_string(cdr_copy->dst, it_cdr->exten, sizeof(cdr_copy->dst)); + ast_copy_string(cdr_copy->dcontext, it_cdr->context, sizeof(cdr_copy->dcontext)); /* Party B */ if (party_b) { @@ -1353,6 +1355,17 @@ static int base_process_party_a(struct cdr_object *cdr, struct ast_channel_snaps cdr_object_check_party_a_hangup(cdr); return 0; } + + /* + * Only record the context and extension if we aren't in a subroutine, or if + * we are executing hangup logic. + */ + if (!ast_test_flag(&snapshot->flags, AST_FLAG_SUBROUTINE_EXEC) + || ast_test_flag(&snapshot->softhangup_flags, AST_SOFTHANGUP_HANGUP_EXEC)) { + ast_string_field_set(cdr, context, snapshot->context); + ast_string_field_set(cdr, exten, snapshot->exten); + } + cdr_object_swap_snapshot(&cdr->party_a, snapshot); /* When Party A is originated to an application and the application exits, the stack |