]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
pjsip: new endpoint's options to control Connected Line updates
authorAlexei Gradinari <alex2grad@gmail.com>
Fri, 12 Oct 2018 21:46:29 +0000 (17:46 -0400)
committerRichard Mudgett <rmudgett@digium.com>
Tue, 30 Oct 2018 15:40:32 +0000 (10:40 -0500)
This patch adds new options 'trust_connected_line' and 'send_connected_line'
to the endpoint.

The option 'trust_connected_line' is to control if connected line updates
are accepted from this endpoint.

The option 'send_connected_line' is to control if connected line updates
can be sent to this endpoint.

The default value is 'yes' for both options.

Change-Id: I16af967815efd904597ec2f033337e4333d097cd

CHANGES
channels/chan_pjsip.c
configs/samples/pjsip.conf.sample
contrib/ast-db-manage/config/versions/1ac563b350a8_add_pjsip_trust_send__connected_line.py [new file with mode: 0644]
include/asterisk/res_pjsip.h
res/res_pjsip.c
res/res_pjsip/pjsip_configuration.c
res/res_pjsip_caller_id.c

diff --git a/CHANGES b/CHANGES
index bd1a7a794f1cf78043c55643c6852b55b2186372..e00c16f0fdbbf9c09f4d2813fa422bf3933f3464 100644 (file)
--- a/CHANGES
+++ b/CHANGES
 --- Functionality changes from Asterisk 16.0.0 to Asterisk 16.1.0 ------------
 ------------------------------------------------------------------------------
 
+res_pjsip
+------------------
+ * New options 'trust_connected_line' and 'send_connected_line' have been
+   added to the endpoint. The option 'trust_connected_line' is to control
+   if connected line updates are accepted from this endpoint.
+   The option 'send_connected_line' is to control if connected line updates
+   can be sent to this endpoint.
+   The default value is 'yes' for both options.
+
 res_rtp_asterisk
 ------------------
  * The existing strictrtp option in rtp.conf has a new choice availabe, called
index 21941ebfd6366715b6e5ceb6bd25dc69ac1b9b30..8e4e40ceb9726512c7e556fc092099e713d96e01 100644 (file)
@@ -1380,7 +1380,8 @@ static int is_colp_update_allowed(struct ast_sip_session *session)
        struct ast_party_id connected_id;
        int update_allowed = 0;
 
-       if (!session->endpoint->id.send_pai && !session->endpoint->id.send_rpid) {
+       if (!session->endpoint->send_connected_line
+               || (!session->endpoint->id.send_pai && !session->endpoint->id.send_rpid)) {
                return 0;
        }
 
index fa16557dd5c4c00af815b41249537e4010ecba93..969fdebc190b155a93ada66f58fd6bb07244adc9 100644 (file)
 ;direct_media_glare_mitigation=none     ; Mitigation of direct media re INVITE
                                         ; glare (default: "none")
 ;direct_media_method=invite     ; Direct Media method type (default: "invite")
+;trust_connected_line=yes       ; Accept Connected Line updates from this endpoint
+                                ; (default: "yes")
+;send_connected_line=yes        ; Send Connected Line updates to this endpoint
+                                ; (default: "yes")
 ;connected_line_method=invite   ; Connected line method type.
                                 ; When set to "invite", check the remote's
                                 ; Allow header and if UPDATE is allowed, send
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
new file mode 100644 (file)
index 0000000..6ca6d23
--- /dev/null
@@ -0,0 +1,40 @@
+"""add pjsip trust/send _connected_line
+
+Revision ID: 1ac563b350a8
+Revises: 2bb1a85135ad
+Create Date: 2018-10-12 17:10:34.530282
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '1ac563b350a8'
+down_revision = '2bb1a85135ad'
+
+from alembic import op
+import sqlalchemy as sa
+from sqlalchemy.dialects.postgresql import ENUM
+
+AST_BOOL_NAME = 'ast_bool_values'
+# We'll just ignore the n/y and f/t abbreviations as Asterisk does not write
+# those aliases.
+AST_BOOL_VALUES = [ '0', '1',
+                    'off', 'on',
+                    'false', 'true',
+                    'no', 'yes' ]
+
+def upgrade():
+    ############################# Enums ##############################
+
+    # ast_bool_values has already been created, so use postgres enum object
+    # type to get around "already created" issue - works okay with mysql
+    ast_bool_values = ENUM(*AST_BOOL_VALUES, name=AST_BOOL_NAME, create_type=False)
+
+    op.add_column('ps_endpoints', sa.Column('trust_connected_line', ast_bool_values))
+    op.add_column('ps_endpoints', sa.Column('send_connected_line', ast_bool_values))
+
+def downgrade():
+    if op.get_context().bind.dialect.name == 'mssql':
+        op.drop_constraint('ck_ps_endpoints_trust_connected_line_ast_bool_values', 'ps_endpoints')
+        op.drop_constraint('ck_ps_endpoints_send_connected_line_ast_bool_values', 'ps_endpoints')
+    op.drop_column('ps_endpoints', 'trust_connected_line')
+    op.drop_column('ps_endpoints', 'send_connected_line')
index d9e6f2e18900a44a7f9174b271bd1825d3e7079a..dc15b7a8e0864fd23476221d581a9ffb8222fbd1 100644 (file)
@@ -814,6 +814,10 @@ struct ast_sip_endpoint {
        unsigned int notify_early_inuse_ringing;
        /*! Suppress Q.850 Reason headers on this endpoint */
        unsigned int suppress_q850_reason_headers;
+       /*! Do we accept connected line updates from this endpoint? */
+       unsigned int trust_connected_line;
+       /*! Do we send connected line updates to this endpoint? */
+       unsigned int send_connected_line;
 };
 
 /*! URI parameter for symmetric transport */
index c2e77cba2f53e15d48d36feae2171effefd57739..f5b8cf6d225c917b6a2ffea9acfcc0f0b268251d 100644 (file)
                                                </enumlist>
                                        </description>
                                </configOption>
+                               <configOption name="trust_connected_line">
+                                       <synopsis>Accept Connected Line updates from this endpoint</synopsis>
+                               </configOption>
+                               <configOption name="send_connected_line">
+                                       <synopsis>Send Connected Line updates to this endpoint</synopsis>
+                               </configOption>
                                <configOption name="connected_line_method" default="invite">
                                        <synopsis>Connected line method type</synopsis>
                                        <description>
                                <parameter name="DirectMediaMethod">
                                        <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>
                                </parameter>
+                               <parameter name="TrustConnectedLine">
+                                       <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>
+                               </parameter>
+                               <parameter name="SendConnectedLine">
+                                       <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>
+                               </parameter>
                                <parameter name="ConnectedLineMethod">
                                        <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>
                                </parameter>
index ee37fc2e9f6bf99cb7c84b016a2e2402714283c9..b4624ebdd08f88fb88a1e0897ccb4fc3a2efaab1 100644 (file)
@@ -1819,6 +1819,8 @@ int ast_res_pjsip_initialize_configuration(void)
        ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "identify_by", "username,ip", ident_handler, ident_to_str, NULL, 0, 0);
        ast_sorcery_object_field_register(sip_sorcery, "endpoint", "direct_media", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.direct_media.enabled));
        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);
+       ast_sorcery_object_field_register(sip_sorcery, "endpoint", "trust_connected_line", "yes", OPT_YESNO_T, 1, FLDSET(struct ast_sip_endpoint, trust_connected_line));
+       ast_sorcery_object_field_register(sip_sorcery, "endpoint", "send_connected_line", "yes", OPT_YESNO_T, 1, FLDSET(struct ast_sip_endpoint, send_connected_line));
        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);
        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);
        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));
index 2481a3f529eb6da1fa30787f70370374ca241dbe..1a5fa3c7876c39e58405e50797b919fe1d95c5ad 100644 (file)
@@ -341,7 +341,8 @@ static void update_incoming_connected_line(struct ast_sip_session *session, pjsi
 {
        struct ast_party_id id;
 
-       if (!session->endpoint->id.trust_inbound) {
+       if (!session->endpoint->trust_connected_line
+               || !session->endpoint->id.trust_inbound) {
                return;
        }
 
@@ -749,7 +750,10 @@ static void caller_id_outgoing_response(struct ast_sip_session *session, pjsip_t
        struct ast_party_id effective_id;
        struct ast_party_id connected_id;
 
-       if (!session->channel) {
+       if (!session->channel
+               || (!session->endpoint->send_connected_line
+                       && session->inv_session
+                       && session->inv_session->state >= PJSIP_INV_STATE_EARLY)) {
                return;
        }