[Asterisk-code-review] res_pjsip_pubsub: RLS 'uri' list attribute mismatch with SUBSCRIBE re... (asterisk[18])

Kevin Harwell asteriskteam at digium.com
Wed Mar 23 18:12:54 CDT 2022


Kevin Harwell has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/18233 )

Change subject: res_pjsip_pubsub: RLS 'uri' list attribute mismatch with SUBSCRIBE request
......................................................................

res_pjsip_pubsub: RLS 'uri' list attribute mismatch with SUBSCRIBE request

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
---
M res/res_pjsip_pubsub.c
1 file changed, 10 insertions(+), 3 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Benjamin Keith Ford: Looks good to me, approved
  Kevin Harwell: Approved for Submit



diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c
index 21174ae..1d13695 100644
--- a/res/res_pjsip_pubsub.c
+++ b/res/res_pjsip_pubsub.c
@@ -1257,7 +1257,14 @@
 		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 @@
 	}
 
 	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

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18233
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 18
Gerrit-Change-Id: I1fcfc08fd589677f40608c59a4e143c45ee05f6c
Gerrit-Change-Number: 18233
Gerrit-PatchSet: 2
Gerrit-Owner: Alexei Gradinari <alex2grad at gmail.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220323/3029e94a/attachment-0001.html>


More information about the asterisk-code-review mailing list