[asterisk-commits] mmichelson: branch mmichelson/rls-subscribe r417687 - /team/mmichelson/rls-su...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jun 30 15:21:20 CDT 2014


Author: mmichelson
Date: Mon Jun 30 15:21:16 2014
New Revision: 417687

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=417687
Log:
Add Require: eventlist to subscription refresh responses.

This also corrects the handling of the Require header addition
when accepting an incoming SUBSCRIBE.


Modified:
    team/mmichelson/rls-subscribe/res/res_pjsip_pubsub.c

Modified: team/mmichelson/rls-subscribe/res/res_pjsip_pubsub.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/rls-subscribe/res/res_pjsip_pubsub.c?view=diff&rev=417687&r1=417686&r2=417687
==============================================================================
--- team/mmichelson/rls-subscribe/res/res_pjsip_pubsub.c (original)
+++ team/mmichelson/rls-subscribe/res/res_pjsip_pubsub.c Mon Jun 30 15:21:16 2014
@@ -1316,9 +1316,20 @@
 	return sub->resource;
 }
 
+static pjsip_require_hdr *create_require_eventlist(pj_pool_t *pool)
+{
+	pjsip_require_hdr *require;
+
+	require = pjsip_require_hdr_create(pool);
+	pj_strdup2(pool, &require->values[0], "eventlist");
+	require->count = 1;
+
+	return require;
+}
+
 static int sip_subscription_accept(struct ast_sip_subscription *sub, pjsip_rx_data *rdata, int response)
 {
-	pjsip_require_hdr *require = NULL;
+	pjsip_hdr res_hdr;
 	
 	ast_assert(sub->type == SIP_SUBSCRIPTION_REAL);
 	
@@ -1327,14 +1338,13 @@
 		return 0;
 	}
 
+	pj_list_init(&res_hdr);
 	if (!AST_LIST_EMPTY(&sub->children)) {
 		/* If subscribing to a list, our response has to have a Require: eventlist header in it */
-		require = pjsip_require_hdr_create(rdata->tp_info.pool);
-		require->values[0] = pj_str("eventlist");
-		require->count = 1;
-	}
-
-	return pjsip_evsub_accept(sip_subscription_get_evsub(sub), rdata, response, (pjsip_hdr *)require) == PJ_SUCCESS ? 0 : -1;
+		pj_list_insert_before(&res_hdr, create_require_eventlist(rdata->tp_info.pool));
+	}
+
+	return pjsip_evsub_accept(sip_subscription_get_evsub(sub), rdata, response, &res_hdr) == PJ_SUCCESS ? 0 : -1;
 }
 
 static void subscription_datastore_destroy(void *obj)
@@ -2177,6 +2187,10 @@
 	if (sub->handler->notifier->notify_required(sub, reason)) {
 		*p_st_code = 500;
 	}
+
+	if (!AST_LIST_EMPTY(&sub->children)) {
+		pj_list_insert_before(res_hdr, create_require_eventlist(rdata->tp_info.pool));
+	}
 }
 
 static void pubsub_on_rx_notify(pjsip_evsub *evsub, pjsip_rx_data *rdata, int *p_st_code,




More information about the asterisk-commits mailing list