[asterisk-commits] mmichelson: branch group/CCSS r239432 - /team/group/CCSS/channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jan 12 10:18:03 CST 2010


Author: mmichelson
Date: Tue Jan 12 10:17:59 2010
New Revision: 239432

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=239432
Log:
Fix a few issues with regards to transmitting SIP PUBLISH requests.

* Fix PIDF xml to be correct
* Adjust transmit_invite to put the proper headers in a PUBLISH when we
  retransmit it for authentication. I likely will be adjusting the transmit_publish
  function in the near future to call transmit_invite to actually transmit the
  PUBLISH.

For now, I'm having an XML parsing error on the side that receives the PUBLISH and it
is quite annoying.


Modified:
    team/group/CCSS/channels/chan_sip.c

Modified: team/group/CCSS/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/channels/chan_sip.c?view=diff&rev=239432&r1=239431&r2=239432
==============================================================================
--- team/group/CCSS/channels/chan_sip.c (original)
+++ team/group/CCSS/channels/chan_sip.c Tue Jan 12 10:17:59 2010
@@ -3724,10 +3724,10 @@
 	/* We'll make this a bare-bones pidf body. In state_notify_build_xml, the PIDF
 	 * body gets a lot more extra junk that isn't necessary, so we'll leave it out here.
 	 */
-	ast_str_append(&body, 0, "<?xml version= \"1.0\"?>\n");
+	ast_str_append(&body, 0, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
 	/* XXX Need to come up with an entity name to put in here. */
 	ast_str_append(&body, 0, "<presence xmlns=\"urn:ietf:params:xml:ns:pidf\" entity=\"?????\">\n");
-	ast_str_append(&body, 0, "<tuple id=\"%s\"\n", tuple_id);
+	ast_str_append(&body, 0, "<tuple id=\"%s\">\n", tuple_id);
 	ast_str_append(&body, 0, "<status><basic>%s</basic></status>\n", state == CC_OPEN ? "open" : "closed");
 	ast_str_append(&body, 0, "</tuple>\n");
 	ast_str_append(&body, 0, "</presence>\n");
@@ -12485,6 +12485,7 @@
 {
 	struct sip_pvt *pvt;
 	struct sip_request req;
+	int expires;
 	char expires_str[10];
 
 	if (!(pvt = sip_alloc(NULL, NULL, 0, SIP_PUBLISH, NULL))) {
@@ -12511,7 +12512,9 @@
 
 	add_header(&req, "Event", epa_entry->static_data->name);
 
-	snprintf(expires_str, sizeof(expires_str), "%d", publish_type == SIP_PUBLISH_REMOVE ? 0 : DEFAULT_PUBLISH_EXPIRES);
+	expires = (publish_type == SIP_PUBLISH_REMOVE) ? 0 : DEFAULT_PUBLISH_EXPIRES;
+	snprintf(expires_str, sizeof(expires_str), "%d", expires);
+	pvt->expiry = expires;
 	add_header(&req, "Expires", expires_str);
 
 	if (publish_type != SIP_PUBLISH_INITIAL) {
@@ -12521,6 +12524,8 @@
 	if (publish_type == SIP_PUBLISH_INITIAL || publish_type == SIP_PUBLISH_MODIFY) {
 		add_line(&req, epa_entry->body);
 	}
+
+	initialize_initreq(pvt, &req);
 
 	/* Bump refcount for sip_pvt's reference */
 	ao2_ref(epa_entry, +1);
@@ -12668,6 +12673,17 @@
 		add_header_contentLength(&req, ast_str_strlen(p->notify->content));
 		if (ast_str_strlen(p->notify->content))
 			add_line(&req, ast_str_buffer(p->notify->content));
+	} else if (sipmethod == SIP_PUBLISH) {
+		/* XXX This would need to be modified in case other event packages get PUBLISH
+		 * support at any point. This can easily be done by checking the epa_entry->static_data->event
+		 */
+		char expires[SIPBUFSIZE];
+		snprintf(expires, sizeof(expires), "%d", p->expiry);
+		add_header(&req, "Event", "call-completion");
+		add_header(&req, "Expires", expires);
+		add_header(&req, "Content-Type", "application/pidf+xml");
+		add_header_contentLength(&req, strlen(p->epa_entry->body));
+		add_line(&req, p->epa_entry->body);
 	} else {
 		add_header_contentLength(&req, 0);
     }




More information about the asterisk-commits mailing list