<p>Alexei Gradinari has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/9558">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_dial: remove pending CONNECTED LINE updates before initialize calls<br><br>Alice calls Bob.<br>Alice does an attended transfer to Charlie.<br>The Caller ID is modified to some ID using either CALLERID function<br>or Dial options 'o([x])' on outgoing context before Dial Charlie's endpoint.<br>But the From: header contains "Alice" on INVITE to Charlie,<br>and not what is set before.<br><br>The app Dial initially correctly sets CONNECTED LINE on outgoing channels<br>as CALLERID of the originating channel.<br>But then the app Dial reads pending CONNECTED LINE update on the originating<br>channel and sets CONNECTED LINE on outgoing channels with this data.<br><br>The processed pending CONNECTED LINE update already sets CALLERID<br>on originating channel, so all pending CONNECTED LINE updates<br>have to be ignored and removed before initialize outgoing calls.<br><br>ASTERISK-27980 #close<br><br>Change-Id: I346652661949b6611c23e431ede0dbea1be3017a<br>---<br>M apps/app_dial.c<br>M apps/app_followme.c<br>M apps/app_queue.c<br>M include/asterisk/channel.h<br>M main/channel.c<br>5 files changed, 49 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/58/9558/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_dial.c b/apps/app_dial.c</span><br><span>index ea7ddd1..b1a9e46 100644</span><br><span>--- a/apps/app_dial.c</span><br><span>+++ b/apps/app_dial.c</span><br><span>@@ -2234,6 +2234,10 @@</span><br><span> pbx_builtin_setvar_helper(chan, "DIALEDTIME", "");</span><br><span> ast_channel_stage_snapshot_done(chan);</span><br><span> max_forwards = ast_max_forwards_get(chan);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Remove all pending CONNECTED LINE updates */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_remove_queue_connected_line_frames(chan);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> ast_channel_unlock(chan);</span><br><span> </span><br><span> if (max_forwards <= 0) {</span><br><span>diff --git a/apps/app_followme.c b/apps/app_followme.c</span><br><span>index 43b95e7..c557138 100644</span><br><span>--- a/apps/app_followme.c</span><br><span>+++ b/apps/app_followme.c</span><br><span>@@ -1332,6 +1332,8 @@</span><br><span> </span><br><span> ast_channel_lock(chan);</span><br><span> max_forwards = ast_max_forwards_get(chan);</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Remove all pending CONNECTED LINE updates */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_remove_queue_connected_line_frames(chan);</span><br><span> ast_channel_unlock(chan);</span><br><span> </span><br><span> if (max_forwards <= 0) {</span><br><span>diff --git a/apps/app_queue.c b/apps/app_queue.c</span><br><span>index f783ac9..fea03e0 100644</span><br><span>--- a/apps/app_queue.c</span><br><span>+++ b/apps/app_queue.c</span><br><span>@@ -7918,6 +7918,8 @@</span><br><span> </span><br><span> ast_channel_lock(chan);</span><br><span> max_forwards = ast_max_forwards_get(chan);</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Remove all pending CONNECTED LINE updates */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_remove_queue_connected_line_frames(chan);</span><br><span> ast_channel_unlock(chan);</span><br><span> </span><br><span> if (max_forwards <= 0) {</span><br><span>diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h</span><br><span>index d709159..143230f 100644</span><br><span>--- a/include/asterisk/channel.h</span><br><span>+++ b/include/asterisk/channel.h</span><br><span>@@ -1948,6 +1948,18 @@</span><br><span> */</span><br><span> int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*!</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief remove all control CONNECTED LINE frames from channel's pending read queue.</span><br><span style="color: hsl(120, 100%, 40%);">+ * \since 13.23.0</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param chan channel to remove frames</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \note this function assumes chan is locked</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \retval number of frames removed</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+int ast_remove_queue_connected_line_frames(struct ast_channel *chan);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> </span><br><span> /*!</span><br><span> * \brief Reads a frame</span><br><span>diff --git a/main/channel.c b/main/channel.c</span><br><span>index ca50d46..9d18ffd 100644</span><br><span>--- a/main/channel.c</span><br><span>+++ b/main/channel.c</span><br><span>@@ -4414,6 +4414,35 @@</span><br><span> return __ast_read(chan, 0);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*!</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief remove all control CONNECTED LINE frames from channel's pending read queue.</span><br><span style="color: hsl(120, 100%, 40%);">+ * \since 13.23.0</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param chan channel to remove frames</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \note this function assumes chan is locked</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \retval number of frames removed</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+int ast_remove_queue_connected_line_frames(struct ast_channel *chan)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ int cnt = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_frame *f;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (chan && !AST_LIST_EMPTY(ast_channel_readq(chan))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_LIST_TRAVERSE_SAFE_BEGIN(ast_channel_readq(chan), f, frame_list) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (f->frametype == AST_FRAME_CONTROL && f->subclass.integer==AST_CONTROL_CONNECTED_LINE) {</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_LIST_REMOVE_CURRENT(frame_list);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_frfree(f);</span><br><span style="color: hsl(120, 100%, 40%);">+ cnt++;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_LIST_TRAVERSE_SAFE_END;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return cnt;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> struct ast_frame *ast_read_noaudio(struct ast_channel *chan)</span><br><span> {</span><br><span> return __ast_read(chan, 1);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/9558">change 9558</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/9558"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I346652661949b6611c23e431ede0dbea1be3017a </div>
<div style="display:none"> Gerrit-Change-Number: 9558 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Alexei Gradinari <alex2grad@gmail.com> </div>