From: Jeff Peeler Date: Mon, 9 Aug 2010 20:04:30 +0000 (+0000) Subject: Prevent loss of Caller ID information set on local channel after masquerade. X-Git-Tag: 1.4.36-rc1~3^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5be00864eea46410f7398ac24761532dd10f17f1;p=thirdparty%2Fasterisk.git Prevent loss of Caller ID information set on local channel after masquerade. Caller ID set on the channel before a masquerade occurs when using a local channel would cause the information to be lost. The problem was that the information was set on a channel destined to be hung up. The somewhat confusing fix is to detect if any Caller ID has been set on the channel and if so preswap the Caller ID data so that basically the masquerade puts the data back. (closes issue #17138) Reported by: kobaz Review: https://reviewboard.asterisk.org/r/847/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@281390 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_local.c b/channels/chan_local.c index 81f16eadf7..7fa6968ccf 100644 --- a/channels/chan_local.c +++ b/channels/chan_local.c @@ -294,6 +294,26 @@ static void check_bridge(struct local_pvt *p) p->chan->audiohooks = p->owner->audiohooks; p->owner->audiohooks = audiohooks_swapper; } + + /* If any Caller ID was set, preserve it after masquerade like above. We must check + * to see if Caller ID was set because otherwise we'll mistakingly copy info not + * set from the dialplan and will overwrite the real channel Caller ID. The reason + * for this whole preswapping action is because the Caller ID is set on the channel + * thread (which is the to be masqueraded away local channel) before both local + * channels are optimized away. + */ + if (p->owner->cid.cid_dnid || p->owner->cid.cid_num || + p->owner->cid.cid_name || p->owner->cid.cid_ani || + p->owner->cid.cid_rdnis || p->owner->cid.cid_pres || + p->owner->cid.cid_ani2 || p->owner->cid.cid_ton || + p->owner->cid.cid_tns) { + + struct ast_callerid tmpcid; + tmpcid = p->owner->cid; + p->owner->cid = p->chan->_bridge->cid; + p->chan->_bridge->cid = tmpcid; + } + ast_app_group_update(p->chan, p->owner); ast_channel_masquerade(p->owner, p->chan->_bridge); ast_set_flag(p, LOCAL_ALREADY_MASQED);