[Asterisk-code-review] Allow Cisco phones to exchange presence information with Asterisk. (asterisk[master])

snuffy asteriskteam at digium.com
Tue Nov 5 20:59:49 CST 2019


snuffy has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/13162 )


Change subject: Allow Cisco phones to exchange presence information with Asterisk.
......................................................................

Allow Cisco phones to exchange presence information with Asterisk.

Cisco phones lie about what style of information they accept, add a
workaround to change our responses to something it can understand.

Asks for response in cpim-pidf+xml format, but can only process pidf+xml.

ASTERISK-28603

Change-Id: Ib5a2944de0e280d3c92eed42d91a0bcb0bcf387c
---
M res/res_pjsip_pubsub.c
1 file changed, 15 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/62/13162/1

diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c
index e26f250..74f1248 100644
--- a/res/res_pjsip_pubsub.c
+++ b/res/res_pjsip_pubsub.c
@@ -822,8 +822,12 @@
 	const struct ast_sip_subscription_handler *handler)
 {
 	pjsip_accept_hdr *accept_header = (pjsip_accept_hdr *) &rdata->msg_info.msg->hdr;
+	pjsip_user_agent_hdr *user_agent_header;
+	static const pj_str_t USER_AGENT = { "User-Agent", 10 };
+	char *user_agent = NULL;
 	char accept[AST_SIP_MAX_ACCEPT][64];
 	size_t num_accept_headers = 0;
+	size_t alloc_size = 0;
 
 	while ((accept_header = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_ACCEPT, accept_header->next)) &&
 		(num_accept_headers < AST_SIP_MAX_ACCEPT)) {
@@ -845,6 +849,17 @@
 		num_accept_headers = 1;
 	}
 
+	user_agent_header = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &USER_AGENT, NULL);
+	if (user_agent_header) {
+		alloc_size = pj_strlen(&user_agent_header->hvalue) + 1;
+		user_agent = ast_alloca(alloc_size);
+		ast_copy_pj_str(user_agent, &user_agent_header->hvalue, alloc_size);
+
+		if (strstr(user_agent,"Cisco"))
+			ast_copy_string(accept[0], "application/pidf+xml", sizeof(accept[0]));
+	}
+
+
 	return find_body_generator(accept, num_accept_headers, handler->body_type);
 }
 

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Ib5a2944de0e280d3c92eed42d91a0bcb0bcf387c
Gerrit-Change-Number: 13162
Gerrit-PatchSet: 1
Gerrit-Owner: snuffy <snuffy22 at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20191105/1c377415/attachment.html>


More information about the asterisk-code-review mailing list