summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES5
-rw-r--r--apps/app_dial.c3
-rw-r--r--apps/app_queue.c9
-rw-r--r--main/bridge_channel.c3
-rw-r--r--main/channel.c3
-rw-r--r--main/dial.c14
6 files changed, 32 insertions, 5 deletions
diff --git a/CHANGES b/CHANGES
index 6ffefbf35..608a4a4b3 100644
--- a/CHANGES
+++ b/CHANGES
@@ -331,6 +331,11 @@ cdr_csv
--- Functionality changes from Asterisk 13.9.0 to Asterisk 13.10.0 -----------
------------------------------------------------------------------------------
+Core
+------------------
+ * A channel variable FORWARDERNAME is now set which indicates which channel
+ was responsible for a forwarding requests received on dial attempt.
+
func_odbc
------------------
* Added new global option "single_db_connection".
diff --git a/apps/app_dial.c b/apps/app_dial.c
index 5e034d3eb..1f019d6c8 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -834,6 +834,7 @@ static void do_forward(struct chanlist *o, struct cause_args *num,
struct ast_party_id *forced_clid, struct ast_party_id *stored_clid)
{
char tmpchan[256];
+ char forwarder[AST_CHANNEL_NAME];
struct ast_channel *original = o->chan;
struct ast_channel *c = o->chan; /* the winner */
struct ast_channel *in = num->chan; /* the input channel */
@@ -842,6 +843,7 @@ static void do_forward(struct chanlist *o, struct cause_args *num,
int cause;
struct ast_party_caller caller;
+ ast_copy_string(forwarder, ast_channel_name(c), sizeof(forwarder));
ast_copy_string(tmpchan, ast_channel_call_forward(c), sizeof(tmpchan));
if ((stuff = strchr(tmpchan, '/'))) {
*stuff++ = '\0';
@@ -895,6 +897,7 @@ static void do_forward(struct chanlist *o, struct cause_args *num,
ast_channel_lock_both(in, o->chan);
ast_channel_inherit_variables(in, o->chan);
ast_channel_datastore_inherit(in, o->chan);
+ pbx_builtin_setvar_helper(o->chan, "FORWARDERNAME", forwarder);
ast_max_forwards_decrement(o->chan);
ast_channel_unlock(in);
ast_channel_unlock(o->chan);
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 165924e0c..45297f5f2 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -4854,16 +4854,22 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
continue;
} else if (!ast_strlen_zero(ast_channel_call_forward(o->chan))) {
struct ast_channel *original = o->chan;
+ char forwarder[AST_CHANNEL_NAME];
char tmpchan[256];
char *stuff;
char *tech;
ast_copy_string(tmpchan, ast_channel_call_forward(o->chan), sizeof(tmpchan));
+ ast_copy_string(forwarder, ast_channel_name(o->chan), sizeof(forwarder));
if ((stuff = strchr(tmpchan, '/'))) {
*stuff++ = '\0';
tech = tmpchan;
} else {
- snprintf(tmpchan, sizeof(tmpchan), "%s@%s", ast_channel_call_forward(o->chan), ast_channel_context(o->chan));
+ const char *forward_context;
+ ast_channel_lock(o->chan);
+ forward_context = pbx_builtin_getvar_helper(o->chan, "FORWARD_CONTEXT");
+ snprintf(tmpchan, sizeof(tmpchan), "%s@%s", ast_channel_call_forward(o->chan), forward_context ? forward_context : ast_channel_context(o->chan));
+ ast_channel_unlock(o->chan);
stuff = tmpchan;
tech = "Local";
}
@@ -4895,6 +4901,7 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
ast_channel_lock_both(o->chan, in);
ast_channel_inherit_variables(in, o->chan);
ast_channel_datastore_inherit(in, o->chan);
+ pbx_builtin_setvar_helper(o->chan, "FORWARDERNAME", forwarder);
ast_max_forwards_decrement(o->chan);
if (o->pending_connected_update) {
diff --git a/main/bridge_channel.c b/main/bridge_channel.c
index 6766dff8e..3ba61aa33 100644
--- a/main/bridge_channel.c
+++ b/main/bridge_channel.c
@@ -2162,9 +2162,10 @@ int bridge_channel_internal_push_full(struct ast_bridge_channel *bridge_channel,
ast_bridge_publish_enter(bridge, bridge_channel->chan, swap ? swap->chan : NULL);
- /* Clear any BLINDTRANSFER and ATTENDEDTRANSFER since the transfer has completed. */
+ /* Clear any BLINDTRANSFER,ATTENDEDTRANSFER and FORWARDERNAME since the transfer has completed. */
pbx_builtin_setvar_helper(bridge_channel->chan, "BLINDTRANSFER", NULL);
pbx_builtin_setvar_helper(bridge_channel->chan, "ATTENDEDTRANSFER", NULL);
+ pbx_builtin_setvar_helper(bridge_channel->chan, "FORWARDERNAME", NULL);
/* Wake up the bridge channel thread to reevaluate any interval timers. */
ast_queue_frame(bridge_channel->chan, &ast_null_frame);
diff --git a/main/channel.c b/main/channel.c
index 852de1aef..f654e4d25 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -5663,6 +5663,7 @@ static void call_forward_inherit(struct ast_channel *new_chan, struct ast_channe
struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, struct ast_format_cap *cap, struct outgoing_helper *oh, int *outstate)
{
char tmpchan[256];
+ char forwarder[AST_CHANNEL_NAME];
struct ast_channel *new_chan = NULL;
char *data, *type;
int cause = 0;
@@ -5670,6 +5671,7 @@ struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_chan
/* gather data and request the new forward channel */
ast_copy_string(tmpchan, ast_channel_call_forward(orig), sizeof(tmpchan));
+ ast_copy_string(forwarder, ast_channel_name(orig), sizeof(forwarder));
if ((data = strchr(tmpchan, '/'))) {
*data++ = '\0';
type = tmpchan;
@@ -5713,6 +5715,7 @@ struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_chan
ast_set_flag(ast_channel_flags(new_chan), AST_FLAG_ORIGINATED);
ast_channel_lock_both(orig, new_chan);
+ pbx_builtin_setvar_helper(new_chan, "FORWARDERNAME", forwarder);
ast_party_connected_line_copy(ast_channel_connected(new_chan), ast_channel_connected(orig));
ast_party_redirecting_copy(ast_channel_redirecting(new_chan), ast_channel_redirecting(orig));
ast_channel_req_accountcodes(new_chan, orig, AST_CHANNEL_REQUESTOR_REPLACEMENT);
diff --git a/main/dial.c b/main/dial.c
index bac191e06..7677c5a7d 100644
--- a/main/dial.c
+++ b/main/dial.c
@@ -454,16 +454,24 @@ int ast_dial_prerun(struct ast_dial *dial, struct ast_channel *chan, struct ast_
}
/*! \brief Helper function that does the beginning dialing per-appended channel */
-static int begin_dial_channel(struct ast_dial_channel *channel, struct ast_channel *chan, int async, const char *predial_string)
+static int begin_dial_channel(struct ast_dial_channel *channel, struct ast_channel *chan, int async, const char *predial_string, struct ast_channel *forwarder_chan)
{
char numsubst[AST_MAX_EXTENSION];
int res = 1;
+ char forwarder[AST_CHANNEL_NAME];
/* If no owner channel exists yet execute pre-run */
if (!channel->owner && begin_dial_prerun(channel, chan, NULL, predial_string)) {
return 0;
}
+ if (forwarder_chan) {
+ ast_copy_string(forwarder, ast_channel_name(forwarder_chan), sizeof(forwarder));
+ ast_channel_lock(channel->owner);
+ pbx_builtin_setvar_helper(channel->owner, "FORWARDERNAME", forwarder);
+ ast_channel_unlock(channel->owner);
+ }
+
/* Copy device string over */
ast_copy_string(numsubst, channel->device, sizeof(numsubst));
@@ -494,7 +502,7 @@ static int begin_dial(struct ast_dial *dial, struct ast_channel *chan, int async
/* Iterate through channel list, requesting and calling each one */
AST_LIST_LOCK(&dial->channels);
AST_LIST_TRAVERSE(&dial->channels, channel, list) {
- success += begin_dial_channel(channel, chan, async, predial_string);
+ success += begin_dial_channel(channel, chan, async, predial_string, NULL);
}
AST_LIST_UNLOCK(&dial->channels);
@@ -550,7 +558,7 @@ static int handle_call_forward(struct ast_dial *dial, struct ast_dial_channel *c
channel->owner = NULL;
/* Finally give it a go... send it out into the world */
- begin_dial_channel(channel, chan, chan ? 0 : 1, predial_string);
+ begin_dial_channel(channel, chan, chan ? 0 : 1, predial_string, original);
ast_channel_publish_dial_forward(chan, original, channel->owner, NULL, "CANCEL",
ast_channel_call_forward(original));