]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip: Added "subscribe_context" to endpoint 45/3145/4
authorAlexei Gradinari <alex2grad@gmail.com>
Mon, 4 Jul 2016 18:54:34 +0000 (14:54 -0400)
committerAlexei Gradinari <alex2grad@gmail.com>
Tue, 5 Jul 2016 16:59:27 +0000 (12:59 -0400)
If specified, incoming SUBSCRIBE requests will be searched for the matching
extension in the indicated context. If no "subscribe_context" is specified,
then the "context" setting is used.

ASTERISK-25471 #close

Change-Id: I3fb7a15f5bc154079bd348c08b7ad1cdd2d5e514

CHANGES
contrib/ast-db-manage/config/versions/9deac0ae4717_pjsip_add_subscribe_context.py [new file with mode: 0644]
include/asterisk/res_pjsip.h
res/res_pjsip.c
res/res_pjsip/pjsip_configuration.c
res/res_pjsip_exten_state.c

diff --git a/CHANGES b/CHANGES
index 55ec3292a1247a91eb1a5aebe2ba7e8a4b79359a..eed57247318e80a5138187b80c4be89392b74c9a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -8,6 +8,17 @@
 ===
 ==============================================================================
 
+------------------------------------------------------------------------------
+--- Functionality changes from Asterisk 13.10.0 to Asterisk 13.11.0 ----------
+------------------------------------------------------------------------------
+
+res_pjsip
+------------------
+ * Added "subscribe_context" to endpoint.
+   If specified, incoming SUBSCRIBE requests will be searched for the matching
+   extension in the indicated context. If no "subscribe_context" is specified,
+   then the "context" setting is used.
+
 ------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 13.9.0 to Asterisk 13.10.0 -----------
 ------------------------------------------------------------------------------
diff --git a/contrib/ast-db-manage/config/versions/9deac0ae4717_pjsip_add_subscribe_context.py b/contrib/ast-db-manage/config/versions/9deac0ae4717_pjsip_add_subscribe_context.py
new file mode 100644 (file)
index 0000000..2358fdd
--- /dev/null
@@ -0,0 +1,21 @@
+"""pjsip_add_subscribe_context
+
+Revision ID: 9deac0ae4717
+Revises: ef7efc2d3964
+Create Date: 2016-07-04 12:11:28.117788
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '9deac0ae4717'
+down_revision = 'ef7efc2d3964'
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def upgrade():
+    op.add_column('ps_endpoints', sa.Column('subscribe_context', sa.String(40)))
+
+def downgrade():
+    op.drop_column('ps_endpoints', 'subscribe_context')
index 5b830ea2e6db346b5a007dfee94240d352b1806b..de223de0113792d70cb4001566498b3e0c87f2f2 100644 (file)
@@ -503,6 +503,8 @@ struct ast_sip_endpoint_subscription_configuration {
        unsigned int minexpiry;
        /*! Message waiting configuration */
        struct ast_sip_mwi_configuration mwi;
+       /* Context for SUBSCRIBE requests */
+       char context[AST_MAX_CONTEXT];
 };
 
 /*!
index 07b82176a5fd0f0dcf4bfe7741f8a4e5943fb718..de8eb3e8a4da844788072c548aaefbaa14da7039 100644 (file)
                                                mask with a slash ('/')
                                        </para></description>
                                </configOption>
+                               <configOption name="subscribe_context">
+                                       <synopsis>Context for incoming MESSAGE requests.</synopsis>
+                                       <description><para>
+                                               If specified, incoming SUBSCRIBE requests will be searched for the matching
+                                               extension in the indicated context.
+                                               If no <replaceable>subscribe_context</replaceable> is specified,
+                                               then the <replaceable>context</replaceable> setting is used.
+                                       </para></description>
+                               </configOption>
                        </configObject>
                        <configObject name="auth">
                                <synopsis>Authentication type</synopsis>
                                <parameter name="ActiveChannels">
                                        <para>The number of active channels associated with this endpoint.</para>
                                </parameter>
+                               <parameter name="SubscribeContext">
+                                       <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='subscribe_context']/synopsis/node())"/></para>
+                               </parameter>
                        </syntax>
                </managerEventInstance>
        </managerEvent>
index 8791816c31742ca31a5bfd4cab185261828f1687..deddddf02b0e80dbf3508cc47dc8493492d17b22 100644 (file)
@@ -1861,6 +1861,7 @@ int ast_res_pjsip_initialize_configuration(const struct ast_module_info *ast_mod
        ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "contact_deny", "", endpoint_acl_handler, NULL, NULL, 0, 0);
        ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "contact_permit", "", endpoint_acl_handler, NULL, NULL, 0, 0);
        ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "contact_acl", "", endpoint_acl_handler, contact_acl_to_str, NULL, 0, 0);
+       ast_sorcery_object_field_register(sip_sorcery, "endpoint", "subscribe_context", "", OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct ast_sip_endpoint, subscription.context));
 
        if (ast_sip_initialize_sorcery_transport()) {
                ast_log(LOG_ERROR, "Failed to register SIP transport support with sorcery\n");
index 69a458993907506afbca44977745d2c783d92bb7..73a5af3b0e92d213a4d4c2a04f9b3a66b8a78fbf 100644 (file)
@@ -352,9 +352,11 @@ static void subscription_shutdown(struct ast_sip_subscription *sub)
 static int new_subscribe(struct ast_sip_endpoint *endpoint,
                const char *resource)
 {
-       if (!ast_exists_extension(NULL, endpoint->context, resource, PRIORITY_HINT, NULL)) {
+       const char *context = S_OR(endpoint->subscription.context, endpoint->context);
+
+       if (!ast_exists_extension(NULL, context, resource, PRIORITY_HINT, NULL)) {
                ast_log(LOG_NOTICE, "Extension state subscription failed: Extension %s does not exist in context '%s' or has no associated hint\n",
-                       resource, endpoint->context);
+                       resource, context);
                return 404;
        }
 
@@ -372,7 +374,9 @@ static int subscription_established(struct ast_sip_subscription *sip_sub)
                return -1;
        }
 
-       ast_copy_string(exten_state_sub->context, endpoint->context, sizeof(exten_state_sub->context));
+       ast_copy_string(exten_state_sub->context,
+               S_OR(endpoint->subscription.context, endpoint->context),
+               sizeof(exten_state_sub->context));
        ast_copy_string(exten_state_sub->exten, resource, sizeof(exten_state_sub->exten));
 
        if ((exten_state_sub->id = ast_extension_state_add_destroy_extended(