<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/15321">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">chan_pjsip: Assign SIPDOMAIN after creating a channel<br><br>session->channel doesn't exist until chan_pjsip creates it, so intead of<br>setting a channel variable every new incoming call sets one and the same<br>global variable.<br><br>This patch moves the code to chan_pjsip so that SIPDOMAIN is set on<br>a newly created channel, it also removes a misleading reference to<br>channel->session used to fetch call pickup configuraion.<br><br>ASTERISK-29240<br><br>Change-Id: I90c9bbbed01f5d8863585631a29322ae4e046755<br>---<br>M channels/chan_pjsip.c<br>M res/res_pjsip_session.c<br>2 files changed, 16 insertions(+), 7 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c</span><br><span>index 0e61213..f37ec3d 100644</span><br><span>--- a/channels/chan_pjsip.c</span><br><span>+++ b/channels/chan_pjsip.c</span><br><span>@@ -2944,6 +2944,18 @@</span><br><span> }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static void set_sipdomain_variable(struct ast_sip_session *session)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip_sip_uri *sip_ruri = pjsip_uri_get_uri(session->request_uri);</span><br><span style="color: hsl(120, 100%, 40%);">+ size_t size = pj_strlen(&sip_ruri->host) + 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ char *domain = ast_alloca(size);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_pj_str(domain, &sip_ruri->host, size);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ pbx_builtin_setvar_helper(session->channel, "SIPDOMAIN", domain);</span><br><span style="color: hsl(120, 100%, 40%);">+ return;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*! \brief Function called when a request is received on the session */</span><br><span> static int chan_pjsip_incoming_request(struct ast_sip_session *session, struct pjsip_rx_data *rdata)</span><br><span> {</span><br><span>@@ -2995,6 +3007,9 @@</span><br><span> SCOPE_EXIT_LOG_RTN_VALUE(-1, LOG_ERROR, "%s: Failed to allocate new PJSIP channel on incoming SIP INVITE\n",</span><br><span> ast_sip_session_get_name(session));</span><br><span> }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ set_sipdomain_variable(session);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* channel gets created on incoming request, but we wait to call start</span><br><span> so other supplements have a chance to run */</span><br><span> SCOPE_EXIT_RTN_VALUE(0, "%s\n", ast_sip_session_get_name(session));</span><br><span>diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c</span><br><span>index e1fc32c..1025e15 100644</span><br><span>--- a/res/res_pjsip_session.c</span><br><span>+++ b/res/res_pjsip_session.c</span><br><span>@@ -3739,7 +3739,7 @@</span><br><span> */</span><br><span> AST_SIP_USER_OPTIONS_TRUNCATE_CHECK(session->exten);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- pickup_cfg = ast_get_chan_features_pickup_config(session->channel);</span><br><span style="color: hsl(120, 100%, 40%);">+ pickup_cfg = ast_get_chan_features_pickup_config(NULL); /* session->channel doesn't exist yet, using NULL */</span><br><span> if (!pickup_cfg) {</span><br><span> ast_log(LOG_ERROR, "%s: Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n",</span><br><span> ast_sip_session_get_name(session));</span><br><span>@@ -3751,12 +3751,6 @@</span><br><span> </span><br><span> if (!strcmp(session->exten, pickupexten) ||</span><br><span> ast_exists_extension(NULL, session->endpoint->context, session->exten, 1, NULL)) {</span><br><span style="color: hsl(0, 100%, 40%);">- size_t size = pj_strlen(&sip_ruri->host) + 1;</span><br><span style="color: hsl(0, 100%, 40%);">- char *domain = ast_alloca(size);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- ast_copy_pj_str(domain, &sip_ruri->host, size);</span><br><span style="color: hsl(0, 100%, 40%);">- pbx_builtin_setvar_helper(session->channel, "SIPDOMAIN", domain);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> /*</span><br><span> * Save off the INVITE Request-URI in case it is</span><br><span> * needed: CHANNEL(pjsip,request_uri)</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/15321">change 15321</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/c/asterisk/+/15321"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: I90c9bbbed01f5d8863585631a29322ae4e046755 </div>
<div style="display:none"> Gerrit-Change-Number: 15321 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: Ivan Poddubny <ivan.poddubny@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>