mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-09 11:28:25 +00:00
core/dial: New channel variable FORWARDERNAME
Added a new channel variable FORWARDERNAME which indicates which channel was responsible for a forwarding requests received on dial attempt. Fixed a bug in the app_queue: FORWARD_CONTEXT is not used. ASTERISK-26059 #close Change-Id: I34e93e8c1b5e17776a77b319703c48c8ca48e7b2
This commit is contained in:
5
CHANGES
5
CHANGES
@@ -12,6 +12,11 @@
|
|||||||
--- Functionality changes from Asterisk 13.9.0 to Asterisk 13.10.0 -----------
|
--- 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
|
func_odbc
|
||||||
------------------
|
------------------
|
||||||
* Added new global option "single_db_connection".
|
* Added new global option "single_db_connection".
|
||||||
|
|||||||
@@ -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)
|
struct ast_party_id *forced_clid, struct ast_party_id *stored_clid)
|
||||||
{
|
{
|
||||||
char tmpchan[256];
|
char tmpchan[256];
|
||||||
|
char forwarder[AST_CHANNEL_NAME];
|
||||||
struct ast_channel *original = o->chan;
|
struct ast_channel *original = o->chan;
|
||||||
struct ast_channel *c = o->chan; /* the winner */
|
struct ast_channel *c = o->chan; /* the winner */
|
||||||
struct ast_channel *in = num->chan; /* the input channel */
|
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;
|
int cause;
|
||||||
struct ast_party_caller caller;
|
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));
|
ast_copy_string(tmpchan, ast_channel_call_forward(c), sizeof(tmpchan));
|
||||||
if ((stuff = strchr(tmpchan, '/'))) {
|
if ((stuff = strchr(tmpchan, '/'))) {
|
||||||
*stuff++ = '\0';
|
*stuff++ = '\0';
|
||||||
@@ -893,6 +895,7 @@ static void do_forward(struct chanlist *o, struct cause_args *num,
|
|||||||
ast_channel_lock_both(in, o->chan);
|
ast_channel_lock_both(in, o->chan);
|
||||||
ast_channel_inherit_variables(in, o->chan);
|
ast_channel_inherit_variables(in, o->chan);
|
||||||
ast_channel_datastore_inherit(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_max_forwards_decrement(o->chan);
|
||||||
ast_channel_unlock(in);
|
ast_channel_unlock(in);
|
||||||
ast_channel_unlock(o->chan);
|
ast_channel_unlock(o->chan);
|
||||||
|
|||||||
@@ -4827,16 +4827,22 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
|
|||||||
continue;
|
continue;
|
||||||
} else if (!ast_strlen_zero(ast_channel_call_forward(o->chan))) {
|
} else if (!ast_strlen_zero(ast_channel_call_forward(o->chan))) {
|
||||||
struct ast_channel *original = o->chan;
|
struct ast_channel *original = o->chan;
|
||||||
|
char forwarder[AST_CHANNEL_NAME];
|
||||||
char tmpchan[256];
|
char tmpchan[256];
|
||||||
char *stuff;
|
char *stuff;
|
||||||
char *tech;
|
char *tech;
|
||||||
|
|
||||||
ast_copy_string(tmpchan, ast_channel_call_forward(o->chan), sizeof(tmpchan));
|
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, '/'))) {
|
if ((stuff = strchr(tmpchan, '/'))) {
|
||||||
*stuff++ = '\0';
|
*stuff++ = '\0';
|
||||||
tech = tmpchan;
|
tech = tmpchan;
|
||||||
} else {
|
} 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;
|
stuff = tmpchan;
|
||||||
tech = "Local";
|
tech = "Local";
|
||||||
}
|
}
|
||||||
@@ -4868,6 +4874,7 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
|
|||||||
ast_channel_lock_both(o->chan, in);
|
ast_channel_lock_both(o->chan, in);
|
||||||
ast_channel_inherit_variables(in, o->chan);
|
ast_channel_inherit_variables(in, o->chan);
|
||||||
ast_channel_datastore_inherit(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_max_forwards_decrement(o->chan);
|
||||||
|
|
||||||
if (o->pending_connected_update) {
|
if (o->pending_connected_update) {
|
||||||
|
|||||||
@@ -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);
|
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, "BLINDTRANSFER", NULL);
|
||||||
pbx_builtin_setvar_helper(bridge_channel->chan, "ATTENDEDTRANSFER", 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. */
|
/* Wake up the bridge channel thread to reevaluate any interval timers. */
|
||||||
ast_queue_frame(bridge_channel->chan, &ast_null_frame);
|
ast_queue_frame(bridge_channel->chan, &ast_null_frame);
|
||||||
|
|||||||
@@ -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)
|
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 tmpchan[256];
|
||||||
|
char forwarder[AST_CHANNEL_NAME];
|
||||||
struct ast_channel *new_chan = NULL;
|
struct ast_channel *new_chan = NULL;
|
||||||
char *data, *type;
|
char *data, *type;
|
||||||
int cause = 0;
|
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 */
|
/* gather data and request the new forward channel */
|
||||||
ast_copy_string(tmpchan, ast_channel_call_forward(orig), sizeof(tmpchan));
|
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, '/'))) {
|
if ((data = strchr(tmpchan, '/'))) {
|
||||||
*data++ = '\0';
|
*data++ = '\0';
|
||||||
type = tmpchan;
|
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_set_flag(ast_channel_flags(new_chan), AST_FLAG_ORIGINATED);
|
||||||
|
|
||||||
ast_channel_lock_both(orig, new_chan);
|
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_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_party_redirecting_copy(ast_channel_redirecting(new_chan), ast_channel_redirecting(orig));
|
||||||
ast_channel_req_accountcodes(new_chan, orig, AST_CHANNEL_REQUESTOR_REPLACEMENT);
|
ast_channel_req_accountcodes(new_chan, orig, AST_CHANNEL_REQUESTOR_REPLACEMENT);
|
||||||
|
|||||||
14
main/dial.c
14
main/dial.c
@@ -411,16 +411,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 */
|
/*! \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];
|
char numsubst[AST_MAX_EXTENSION];
|
||||||
int res = 1;
|
int res = 1;
|
||||||
|
char forwarder[AST_CHANNEL_NAME];
|
||||||
|
|
||||||
/* If no owner channel exists yet execute pre-run */
|
/* If no owner channel exists yet execute pre-run */
|
||||||
if (!channel->owner && begin_dial_prerun(channel, chan, NULL, predial_string)) {
|
if (!channel->owner && begin_dial_prerun(channel, chan, NULL, predial_string)) {
|
||||||
return 0;
|
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 */
|
/* Copy device string over */
|
||||||
ast_copy_string(numsubst, channel->device, sizeof(numsubst));
|
ast_copy_string(numsubst, channel->device, sizeof(numsubst));
|
||||||
|
|
||||||
@@ -451,7 +459,7 @@ static int begin_dial(struct ast_dial *dial, struct ast_channel *chan, int async
|
|||||||
/* Iterate through channel list, requesting and calling each one */
|
/* Iterate through channel list, requesting and calling each one */
|
||||||
AST_LIST_LOCK(&dial->channels);
|
AST_LIST_LOCK(&dial->channels);
|
||||||
AST_LIST_TRAVERSE(&dial->channels, channel, list) {
|
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);
|
AST_LIST_UNLOCK(&dial->channels);
|
||||||
|
|
||||||
@@ -507,7 +515,7 @@ static int handle_call_forward(struct ast_dial *dial, struct ast_dial_channel *c
|
|||||||
channel->owner = NULL;
|
channel->owner = NULL;
|
||||||
|
|
||||||
/* Finally give it a go... send it out into the world */
|
/* 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_publish_dial_forward(chan, original, channel->owner, NULL, "CANCEL",
|
||||||
ast_channel_call_forward(original));
|
ast_channel_call_forward(original));
|
||||||
|
|||||||
Reference in New Issue
Block a user