<p>George Joseph <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/10480">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Benjamin Keith Ford: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pjsip: new endpoint's options to control Connected Line updates<br><br>This patch adds new options 'trust_connected_line' and 'send_connected_line'<br>to the endpoint.<br><br>The option 'trust_connected_line' is to control if connected line updates<br>are accepted from this endpoint.<br><br>The option 'send_connected_line' is to control if connected line updates<br>can be sent to this endpoint.<br><br>The default value is 'yes' for both options.<br><br>Change-Id: I16af967815efd904597ec2f033337e4333d097cd<br>---<br>M CHANGES<br>M channels/chan_pjsip.c<br>M configs/samples/pjsip.conf.sample<br>A contrib/ast-db-manage/config/versions/1ac563b350a8_add_pjsip_trust_send__connected_line.py<br>M include/asterisk/res_pjsip.h<br>M res/res_pjsip.c<br>M res/res_pjsip/pjsip_configuration.c<br>M res/res_pjsip_caller_id.c<br>8 files changed, 79 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/CHANGES b/CHANGES</span><br><span>index 45c964e..b191f40 100644</span><br><span>--- a/CHANGES</span><br><span>+++ b/CHANGES</span><br><span>@@ -12,6 +12,15 @@</span><br><span> --- Functionality changes from Asterisk 13.23.0 to Asterisk 13.24.0 ----------</span><br><span> ------------------------------------------------------------------------------</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+res_pjsip</span><br><span style="color: hsl(120, 100%, 40%);">+------------------</span><br><span style="color: hsl(120, 100%, 40%);">+ * New options 'trust_connected_line' and 'send_connected_line' have been</span><br><span style="color: hsl(120, 100%, 40%);">+ added to the endpoint. The option 'trust_connected_line' is to control</span><br><span style="color: hsl(120, 100%, 40%);">+ if connected line updates are accepted from this endpoint.</span><br><span style="color: hsl(120, 100%, 40%);">+ The option 'send_connected_line' is to control if connected line updates</span><br><span style="color: hsl(120, 100%, 40%);">+ can be sent to this endpoint.</span><br><span style="color: hsl(120, 100%, 40%);">+ The default value is 'yes' for both options.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> res_rtp_asterisk</span><br><span> ------------------</span><br><span> * The existing strictrtp option in rtp.conf has a new choice availabe, called</span><br><span>diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c</span><br><span>index 4da0361..5bbd025 100644</span><br><span>--- a/channels/chan_pjsip.c</span><br><span>+++ b/channels/chan_pjsip.c</span><br><span>@@ -1268,7 +1268,8 @@</span><br><span> struct ast_party_id connected_id;</span><br><span> int update_allowed = 0;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (!session->endpoint->id.send_pai && !session->endpoint->id.send_rpid) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!session->endpoint->send_connected_line</span><br><span style="color: hsl(120, 100%, 40%);">+ || (!session->endpoint->id.send_pai && !session->endpoint->id.send_rpid)) {</span><br><span> return 0;</span><br><span> }</span><br><span> </span><br><span>diff --git a/configs/samples/pjsip.conf.sample b/configs/samples/pjsip.conf.sample</span><br><span>index 7f78783..56e7849 100644</span><br><span>--- a/configs/samples/pjsip.conf.sample</span><br><span>+++ b/configs/samples/pjsip.conf.sample</span><br><span>@@ -608,6 +608,10 @@</span><br><span> ;direct_media_glare_mitigation=none ; Mitigation of direct media re INVITE</span><br><span> ; glare (default: "none")</span><br><span> ;direct_media_method=invite ; Direct Media method type (default: "invite")</span><br><span style="color: hsl(120, 100%, 40%);">+;trust_connected_line=yes ; Accept Connected Line updates from this endpoint</span><br><span style="color: hsl(120, 100%, 40%);">+ ; (default: "yes")</span><br><span style="color: hsl(120, 100%, 40%);">+;send_connected_line=yes ; Send Connected Line updates to this endpoint</span><br><span style="color: hsl(120, 100%, 40%);">+ ; (default: "yes")</span><br><span> ;connected_line_method=invite ; Connected line method type.</span><br><span> ; When set to "invite", check the remote's</span><br><span> ; Allow header and if UPDATE is allowed, send</span><br><span>diff --git a/contrib/ast-db-manage/config/versions/1ac563b350a8_add_pjsip_trust_send__connected_line.py b/contrib/ast-db-manage/config/versions/1ac563b350a8_add_pjsip_trust_send__connected_line.py</span><br><span>new file mode 100644</span><br><span>index 0000000..6ca6d23</span><br><span>--- /dev/null</span><br><span>+++ b/contrib/ast-db-manage/config/versions/1ac563b350a8_add_pjsip_trust_send__connected_line.py</span><br><span>@@ -0,0 +1,40 @@</span><br><span style="color: hsl(120, 100%, 40%);">+"""add pjsip trust/send _connected_line</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Revision ID: 1ac563b350a8</span><br><span style="color: hsl(120, 100%, 40%);">+Revises: 2bb1a85135ad</span><br><span style="color: hsl(120, 100%, 40%);">+Create Date: 2018-10-12 17:10:34.530282</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%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# revision identifiers, used by Alembic.</span><br><span style="color: hsl(120, 100%, 40%);">+revision = '1ac563b350a8'</span><br><span style="color: hsl(120, 100%, 40%);">+down_revision = '2bb1a85135ad'</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+from alembic import op</span><br><span style="color: hsl(120, 100%, 40%);">+import sqlalchemy as sa</span><br><span style="color: hsl(120, 100%, 40%);">+from sqlalchemy.dialects.postgresql import ENUM</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+AST_BOOL_NAME = 'ast_bool_values'</span><br><span style="color: hsl(120, 100%, 40%);">+# We'll just ignore the n/y and f/t abbreviations as Asterisk does not write</span><br><span style="color: hsl(120, 100%, 40%);">+# those aliases.</span><br><span style="color: hsl(120, 100%, 40%);">+AST_BOOL_VALUES = [ '0', '1',</span><br><span style="color: hsl(120, 100%, 40%);">+ 'off', 'on',</span><br><span style="color: hsl(120, 100%, 40%);">+ 'false', 'true',</span><br><span style="color: hsl(120, 100%, 40%);">+ 'no', 'yes' ]</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+def upgrade():</span><br><span style="color: hsl(120, 100%, 40%);">+ ############################# Enums ##############################</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ # ast_bool_values has already been created, so use postgres enum object</span><br><span style="color: hsl(120, 100%, 40%);">+ # type to get around "already created" issue - works okay with mysql</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_bool_values = ENUM(*AST_BOOL_VALUES, name=AST_BOOL_NAME, create_type=False)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ op.add_column('ps_endpoints', sa.Column('trust_connected_line', ast_bool_values))</span><br><span style="color: hsl(120, 100%, 40%);">+ op.add_column('ps_endpoints', sa.Column('send_connected_line', ast_bool_values))</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+def downgrade():</span><br><span style="color: hsl(120, 100%, 40%);">+ if op.get_context().bind.dialect.name == 'mssql':</span><br><span style="color: hsl(120, 100%, 40%);">+ op.drop_constraint('ck_ps_endpoints_trust_connected_line_ast_bool_values', 'ps_endpoints')</span><br><span style="color: hsl(120, 100%, 40%);">+ op.drop_constraint('ck_ps_endpoints_send_connected_line_ast_bool_values', 'ps_endpoints')</span><br><span style="color: hsl(120, 100%, 40%);">+ op.drop_column('ps_endpoints', 'trust_connected_line')</span><br><span style="color: hsl(120, 100%, 40%);">+ op.drop_column('ps_endpoints', 'send_connected_line')</span><br><span>diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h</span><br><span>index eb0905b..902cfe8 100644</span><br><span>--- a/include/asterisk/res_pjsip.h</span><br><span>+++ b/include/asterisk/res_pjsip.h</span><br><span>@@ -796,6 +796,10 @@</span><br><span> unsigned int accept_multiple_sdp_answers;</span><br><span> /*! Suppress Q.850 Reason headers on this endpoint */</span><br><span> unsigned int suppress_q850_reason_headers;</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! Do we accept connected line updates from this endpoint? */</span><br><span style="color: hsl(120, 100%, 40%);">+ unsigned int trust_connected_line;</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! Do we send connected line updates to this endpoint? */</span><br><span style="color: hsl(120, 100%, 40%);">+ unsigned int send_connected_line;</span><br><span> };</span><br><span> </span><br><span> /*! URI parameter for symmetric transport */</span><br><span>diff --git a/res/res_pjsip.c b/res/res_pjsip.c</span><br><span>index 93fa6a3..1f34c99 100644</span><br><span>--- a/res/res_pjsip.c</span><br><span>+++ b/res/res_pjsip.c</span><br><span>@@ -189,6 +189,12 @@</span><br><span> </enumlist></span><br><span> </description></span><br><span> </configOption></span><br><span style="color: hsl(120, 100%, 40%);">+ <configOption name="trust_connected_line"></span><br><span style="color: hsl(120, 100%, 40%);">+ <synopsis>Accept Connected Line updates from this endpoint</synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+ </configOption></span><br><span style="color: hsl(120, 100%, 40%);">+ <configOption name="send_connected_line"></span><br><span style="color: hsl(120, 100%, 40%);">+ <synopsis>Send Connected Line updates to this endpoint</synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+ </configOption></span><br><span> <configOption name="connected_line_method" default="invite"></span><br><span> <synopsis>Connected line method type</synopsis></span><br><span> <description></span><br><span>@@ -2120,6 +2126,12 @@</span><br><span> <parameter name="DirectMediaMethod"></span><br><span> <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='direct_media_method']/synopsis/node())"/></para></span><br><span> </parameter></span><br><span style="color: hsl(120, 100%, 40%);">+ <parameter name="TrustConnectedLine"></span><br><span style="color: hsl(120, 100%, 40%);">+ <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='trust_connected_line']/synopsis/node())"/></para></span><br><span style="color: hsl(120, 100%, 40%);">+ </parameter></span><br><span style="color: hsl(120, 100%, 40%);">+ <parameter name="SendConnectedLine"></span><br><span style="color: hsl(120, 100%, 40%);">+ <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='send_connected_line']/synopsis/node())"/></para></span><br><span style="color: hsl(120, 100%, 40%);">+ </parameter></span><br><span> <parameter name="ConnectedLineMethod"></span><br><span> <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='connected_line_method']/synopsis/node())"/></para></span><br><span> </parameter></span><br><span>diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c</span><br><span>index 477b317..3616dba 100644</span><br><span>--- a/res/res_pjsip/pjsip_configuration.c</span><br><span>+++ b/res/res_pjsip/pjsip_configuration.c</span><br><span>@@ -1778,6 +1778,8 @@</span><br><span> ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "identify_by", "username,ip", ident_handler, ident_to_str, NULL, 0, 0);</span><br><span> ast_sorcery_object_field_register(sip_sorcery, "endpoint", "direct_media", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.direct_media.enabled));</span><br><span> ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "direct_media_method", "invite", direct_media_method_handler, direct_media_method_to_str, NULL, 0, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sorcery_object_field_register(sip_sorcery, "endpoint", "trust_connected_line", "yes", OPT_YESNO_T, 1, FLDSET(struct ast_sip_endpoint, trust_connected_line));</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sorcery_object_field_register(sip_sorcery, "endpoint", "send_connected_line", "yes", OPT_YESNO_T, 1, FLDSET(struct ast_sip_endpoint, send_connected_line));</span><br><span> ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "connected_line_method", "invite", connected_line_method_handler, connected_line_method_to_str, NULL, 0, 0);</span><br><span> ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "direct_media_glare_mitigation", "none", direct_media_glare_mitigation_handler, direct_media_glare_mitigation_to_str, NULL, 0, 0);</span><br><span> ast_sorcery_object_field_register(sip_sorcery, "endpoint", "disable_direct_media_on_nat", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.direct_media.disable_on_nat));</span><br><span>diff --git a/res/res_pjsip_caller_id.c b/res/res_pjsip_caller_id.c</span><br><span>index d240496..24822bf 100644</span><br><span>--- a/res/res_pjsip_caller_id.c</span><br><span>+++ b/res/res_pjsip_caller_id.c</span><br><span>@@ -342,7 +342,8 @@</span><br><span> {</span><br><span> struct ast_party_id id;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (!session->endpoint->id.trust_inbound) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!session->endpoint->trust_connected_line</span><br><span style="color: hsl(120, 100%, 40%);">+ || !session->endpoint->id.trust_inbound) {</span><br><span> return;</span><br><span> }</span><br><span> </span><br><span>@@ -750,7 +751,10 @@</span><br><span> struct ast_party_id effective_id;</span><br><span> struct ast_party_id connected_id;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (!session->channel) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!session->channel</span><br><span style="color: hsl(120, 100%, 40%);">+ || (!session->endpoint->send_connected_line</span><br><span style="color: hsl(120, 100%, 40%);">+ && session->inv_session</span><br><span style="color: hsl(120, 100%, 40%);">+ && session->inv_session->state >= PJSIP_INV_STATE_EARLY)) {</span><br><span> return;</span><br><span> }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/10480">change 10480</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/10480"/><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: merged </div>
<div style="display:none"> Gerrit-Change-Id: I16af967815efd904597ec2f033337e4333d097cd </div>
<div style="display:none"> Gerrit-Change-Number: 10480 </div>
<div style="display:none"> Gerrit-PatchSet: 5 </div>
<div style="display:none"> Gerrit-Owner: Alexei Gradinari <alex2grad@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Alexei Gradinari <alex2grad@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 (1000185) </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>