]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip_pubsub: RLS 'uri' list attribute mismatch with SUBSCRIBE request
authorAlexei Gradinari <alex2grad@gmail.com>
Tue, 15 Mar 2022 17:24:18 +0000 (13:24 -0400)
committerKevin Harwell <kharwell@digium.com>
Wed, 23 Mar 2022 23:12:42 +0000 (18:12 -0500)
When asterisk generates the RLMI part of NOTIFY request,
the asterisk uses the local contact uri instead of the URI to which
the SUBSCRIBE request is sent.
Because of this mismatch some IP phones (for example Cisco 5XX) ignore
this list.

According
https://datatracker.ietf.org/doc/html/rfc4662#section-5.2
  The first mandatory <list> attribute is "uri", which contains the uri
  that corresponds to the list. Typically, this is the URI to which
  the SUBSCRIBE request was sent.
https://datatracker.ietf.org/doc/html/rfc4662#section-5.3
  The "uri" attribute identifies the resource to which the <resource>
  element corresponds. Typically, this will be a SIP URI that, if
  subscribed to, would return the state of the resource.

This patch makes asterisk to generate URI using SUBSCRIBE request URI.

ASTERISK-29961 #close

Change-Id: I1fcfc08fd589677f40608c59a4e143c45ee05f6c

res/res_pjsip_pubsub.c

index 21174aeaa4a6952f935ad37f2a5c63377c34a510..1d136955bf3e90afa4f18e38bbfe53a38e9872d9 100644 (file)
@@ -1257,7 +1257,14 @@ static struct ast_sip_subscription *allocate_subscription(const struct ast_sip_s
                const char *resource, const char *display_name, struct sip_subscription_tree *tree)
 {
        struct ast_sip_subscription *sub;
-       pjsip_sip_uri *contact_uri;
+       pjsip_msg *msg;
+       pjsip_sip_uri *request_uri;
+
+       msg = ast_sip_mod_data_get(tree->dlg->mod_data, pubsub_module.id, MOD_DATA_MSG);
+       if (!msg) {
+               ast_log(LOG_ERROR, "No dialog message saved for SIP subscription. Cannot allocate subscription for resource %s\n", resource);
+               return NULL;
+       }
 
        sub = ast_calloc(1, sizeof(*sub) + strlen(resource) + 1);
        if (!sub) {
@@ -1280,8 +1287,8 @@ static struct ast_sip_subscription *allocate_subscription(const struct ast_sip_s
        }
 
        sub->uri = pjsip_sip_uri_create(tree->dlg->pool, PJ_FALSE);
-       contact_uri = pjsip_uri_get_uri(tree->dlg->local.contact->uri);
-       pjsip_sip_uri_assign(tree->dlg->pool, sub->uri, contact_uri);
+       request_uri = pjsip_uri_get_uri(msg->line.req.uri);
+       pjsip_sip_uri_assign(tree->dlg->pool, sub->uri, request_uri);
        pj_strdup2(tree->dlg->pool, &sub->uri->user, resource);
 
        /* If there is any persistence information available for this subscription that was persisted