[asterisk-commits] rmudgett: branch rmudgett/cel_accountcode r416648 - in /team/rmudgett/cel_acc...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jun 18 14:08:08 CDT 2014
Author: rmudgett
Date: Wed Jun 18 14:08:01 2014
New Revision: 416648
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=416648
Log:
accountcode propagation: Change accountcode propagation some more.
* Changed ast_request() to use the CHANNEL(peeraccount) before using the
CHANNEL(accountcode).
* Changed local channels(core unreal channels) to set the accountcode and
peeraccount values on channel creation and then propagate them to the ;2
channel when the ;1 channel is dialed.
* Fixed an off by one error in core_unreal channel creation.
Modified:
team/rmudgett/cel_accountcode/UPGRADE.txt
team/rmudgett/cel_accountcode/main/channel.c
team/rmudgett/cel_accountcode/main/core_unreal.c
Modified: team/rmudgett/cel_accountcode/UPGRADE.txt
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cel_accountcode/UPGRADE.txt?view=diff&rev=416648&r1=416647&r2=416648
==============================================================================
--- team/rmudgett/cel_accountcode/UPGRADE.txt (original)
+++ team/rmudgett/cel_accountcode/UPGRADE.txt Wed Jun 18 14:08:01 2014
@@ -23,14 +23,20 @@
From 12.3.1 to 12.4.0:
- - The accountcode propagation changed from simply setting the accountcode
- of the channel initiating the call onto the outgoing channel to setting
- the accountcode only if the outgoing channel doesn't already have one.
- In other words, if a channel already has an accountcode it will not be
- changed unless explicitly set by CHANNEL(accountcode) or an originate
- method that can specify an accountcode. The most visible effect the
- change has is if the channel driver is configured with an accountcode
- for new channels.
+ - The accountcode propagation changed from always using the calling
+ channel's CHANNEL(accountcode) value if present as the outgoing
+ channel's CHANNEL(accountcode) value to using the calling channel's
+ CHANNEL(peeraccount) or CHANNEL(accountcode) value if present to set an
+ empty outgoing channel's CHANNEL(accountcode) value. In other words,
+ if a channel already has an accountcode it will not be changed unless
+ explicitly set by CHANNEL(accountcode) or an originate method that can
+ specify an accountcode value. The change has two visible effects. One,
+ if the channel driver is configured with an accountcode for new
+ channels then those channels will always have that accountcode unless
+ explicitly changed. Two, the CHANNEL(peeraccount) value can be set
+ before Dial to set an empty accountcode on the outgoing channel. The
+ FollowMe and Queue applications already propagated the
+ CHANNEL(peeraccount) to the outgoing channel this way.
- The safe_asterisk script was previously not installed on top of an existing
version. This caused bug-fixes in that script not to be deployed. If your
Modified: team/rmudgett/cel_accountcode/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cel_accountcode/main/channel.c?view=diff&rev=416648&r1=416647&r2=416648
==============================================================================
--- team/rmudgett/cel_accountcode/main/channel.c (original)
+++ team/rmudgett/cel_accountcode/main/channel.c Wed Jun 18 14:08:01 2014
@@ -5972,13 +5972,22 @@
callid = ast_callid_unref(callid);
}
- /*
- * Set newly created channel accountcode to the same as the
- * requestor if it doesn't already have one.
- */
- if (ast_strlen_zero(ast_channel_accountcode(c))
- && !ast_strlen_zero(ast_channel_accountcode(requestor))) {
- ast_channel_accountcode_set(c, ast_channel_accountcode(requestor));
+ if (ast_strlen_zero(ast_channel_accountcode(c))) {
+ /* The newly created channel does not have an accountcode. */
+ if (!ast_strlen_zero(ast_channel_peeraccount(requestor))) {
+ /*
+ * Set it to the requestor's peeraccount. This allows the
+ * dialplan to indicate the accountcode to use when dialing
+ * by setting CHANNEL(peeraccount).
+ */
+ ast_channel_accountcode_set(c, ast_channel_peeraccount(requestor));
+ } else if (!ast_strlen_zero(ast_channel_accountcode(requestor))) {
+ /*
+ * Fallback to the historic propagation and set it to the
+ * requestor's accountcode.
+ */
+ ast_channel_accountcode_set(c, ast_channel_accountcode(requestor));
+ }
}
ast_channel_unlock(c);
Modified: team/rmudgett/cel_accountcode/main/core_unreal.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cel_accountcode/main/core_unreal.c?view=diff&rev=416648&r1=416647&r2=416648
==============================================================================
--- team/rmudgett/cel_accountcode/main/core_unreal.c (original)
+++ team/rmudgett/cel_accountcode/main/core_unreal.c Wed Jun 18 14:08:01 2014
@@ -36,6 +36,7 @@
#include "asterisk/causes.h"
#include "asterisk/channel.h"
+#include "asterisk/stasis_channels.h"
#include "asterisk/pbx.h"
#include "asterisk/musiconhold.h"
#include "asterisk/astobj2.h"
@@ -642,6 +643,8 @@
struct ast_var_t *varptr;
struct ast_var_t *clone_var;
+ ast_channel_stage_snapshot(semi2);
+
/*
* Note that cid_num and cid_name aren't passed in the
* ast_channel_alloc calls in ast_unreal_new_channels(). It's
@@ -656,6 +659,7 @@
ast_channel_language_set(semi2, ast_channel_language(semi1));
ast_channel_accountcode_set(semi2, ast_channel_accountcode(semi1));
+ ast_channel_peeraccount_set(semi2, ast_channel_peeraccount(semi1));
ast_channel_musicclass_set(semi2, ast_channel_musicclass(semi1));
ast_channel_cc_params_init(semi2, ast_channel_get_cc_config_params(semi1));
@@ -682,6 +686,8 @@
}
}
ast_channel_datastore_inherit(semi1, semi2);
+
+ ast_channel_stage_snapshot_done(semi2);
}
int ast_unreal_channel_push_to_bridge(struct ast_channel *ast, struct ast_bridge *bridge, unsigned int flags)
@@ -896,6 +902,8 @@
{
struct ast_channel *owner;
struct ast_channel *chan;
+ const char *accountcode = NULL;
+ const char *peeraccount = NULL;
struct ast_format fmt;
struct ast_assigned_ids id1 = {NULL, NULL};
struct ast_assigned_ids id2 = {NULL, NULL};
@@ -911,10 +919,27 @@
if (id1.uniqueid && ast_strlen_zero(id2.uniqueid)) {
char *uniqueid2;
- uniqueid2 = ast_alloca(strlen(id1.uniqueid) + 2);
+ uniqueid2 = ast_alloca(strlen(id1.uniqueid) + 3);
strcpy(uniqueid2, id1.uniqueid);/* Safe */
strcat(uniqueid2, ";2");/* Safe */
id2.uniqueid = uniqueid2;
+ }
+
+ if (requestor) {
+ ast_channel_lock((struct ast_channel *) requestor);
+ accountcode = ast_channel_accountcode(requestor);
+ if (!ast_strlen_zero(accountcode)) {
+ accountcode = ast_strdupa(accountcode);
+ } else {
+ accountcode = NULL;
+ }
+ peeraccount = ast_channel_peeraccount(requestor);
+ if (!ast_strlen_zero(peeraccount)) {
+ peeraccount = ast_strdupa(peeraccount);
+ } else {
+ peeraccount = NULL;
+ }
+ ast_channel_unlock((struct ast_channel *) requestor);
}
/*
@@ -924,9 +949,10 @@
* You can't pass linkedid to both allocations since if linkedid
* isn't set, then each channel will generate its own linkedid.
*/
- if (!(owner = ast_channel_alloc(1, semi1_state, NULL, NULL, NULL,
- exten, context, &id1, requestor, 0,
- "%s/%s-%08x;1", tech->type, p->name, (unsigned)generated_seqno))) {
+ owner = ast_channel_alloc(1, semi1_state, NULL, NULL, accountcode,
+ exten, context, &id1, requestor, 0,
+ "%s/%s-%08x;1", tech->type, p->name, (unsigned)generated_seqno);
+ if (!owner) {
ast_log(LOG_WARNING, "Unable to allocate owner channel structure\n");
return NULL;
}
@@ -940,6 +966,10 @@
ast_channel_tech_pvt_set(owner, p);
ast_format_cap_copy(ast_channel_nativeformats(owner), p->reqcap);
+
+ if (peeraccount) {
+ ast_channel_peeraccount_set(owner, peeraccount);
+ }
/* Determine our read/write format and set it on each channel */
ast_best_codec(p->reqcap, &fmt);
@@ -964,9 +994,10 @@
p->owner = owner;
ast_channel_unlock(owner);
- if (!(chan = ast_channel_alloc(1, semi2_state, NULL, NULL, NULL,
- exten, context, &id2, owner, 0,
- "%s/%s-%08x;2", tech->type, p->name, (unsigned)generated_seqno))) {
+ chan = ast_channel_alloc(1, semi2_state, NULL, NULL, accountcode,
+ exten, context, &id2, owner, 0,
+ "%s/%s-%08x;2", tech->type, p->name, (unsigned)generated_seqno);
+ if (!chan) {
ast_log(LOG_WARNING, "Unable to allocate chan channel structure\n");
ao2_ref(p, -1);
ast_channel_tech_pvt_set(owner, NULL);
More information about the asterisk-commits
mailing list