From 2c16a81dd57676db494994a72514ecda4bdd437d Mon Sep 17 00:00:00 2001 From: Alexei Gradinari Date: Mon, 4 Jul 2016 14:54:34 -0400 Subject: 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. ASTERISK-25471 #close Change-Id: I3fb7a15f5bc154079bd348c08b7ad1cdd2d5e514 --- res/res_pjsip.c | 12 ++++++++++++ res/res_pjsip/pjsip_configuration.c | 1 + res/res_pjsip_exten_state.c | 10 +++++++--- 3 files changed, 20 insertions(+), 3 deletions(-) (limited to 'res') diff --git a/res/res_pjsip.c b/res/res_pjsip.c index 07b82176a..de8eb3e8a 100644 --- a/res/res_pjsip.c +++ b/res/res_pjsip.c @@ -897,6 +897,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 @@ -1958,6 +1967,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 8791816c3..deddddf02 100644 --- a/res/res_pjsip/pjsip_configuration.c +++ b/res/res_pjsip/pjsip_configuration.c @@ -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"); diff --git a/res/res_pjsip_exten_state.c b/res/res_pjsip_exten_state.c index 69a458993..73a5af3b0 100644 --- a/res/res_pjsip_exten_state.c +++ b/res/res_pjsip_exten_state.c @@ -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( -- cgit v1.2.3