diff --git a/CHANGES b/CHANGES
index 6e6bec6d07..19a2830a4c 100644
--- a/CHANGES
+++ b/CHANGES
@@ -360,6 +360,17 @@ cdr_csv
post-1.8 CDR columns 'peeraccount', 'linkedid', and 'sequence'.
+------------------------------------------------------------------------------
+--- 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
index 0000000000..2358fdd593
--- /dev/null
+++ b/contrib/ast-db-manage/config/versions/9deac0ae4717_pjsip_add_subscribe_context.py
@@ -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')
diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h
index f9f9e2037e..db55992139 100644
--- a/include/asterisk/res_pjsip.h
+++ b/include/asterisk/res_pjsip.h
@@ -505,6 +505,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];
};
/*!
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index d99c1cf841..af2f93749f 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -900,6 +900,15 @@
mask with a slash ('/')
+
+ Context for incoming MESSAGE requests.
+
+ 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.
+
+
Authentication type
@@ -1964,6 +1973,9 @@
The number of active channels associated with this endpoint.
+
+
+
diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c
index 8a5ff416ad..a8b451767b 100644
--- a/res/res_pjsip/pjsip_configuration.c
+++ b/res/res_pjsip/pjsip_configuration.c
@@ -1859,6 +1859,7 @@ int ast_res_pjsip_initialize_configuration(void)
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");
diff --git a/res/res_pjsip_exten_state.c b/res/res_pjsip_exten_state.c
index 25b9bf1fe8..9bb53bfe31 100644
--- a/res/res_pjsip_exten_state.c
+++ b/res/res_pjsip_exten_state.c
@@ -412,9 +412,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;
}
@@ -432,7 +434,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(