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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 6 17:21:14 CST 2010


Author: mmichelson
Date: Wed Jan  6 17:21:10 2010
New Revision: 238311

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=238311
Log:
Read Expires header on incoming cc subscriptions so we can act appropriately.

Among other things, this actually allows for us to cancel CC subscriptions.
Also removed some silly debugging messages.


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=238311&r1=238310&r2=238311
==============================================================================
--- team/group/CCSS/channels/chan_sip.c (original)
+++ team/group/CCSS/channels/chan_sip.c Wed Jan  6 17:21:10 2010
@@ -3615,9 +3615,7 @@
 	if (monitor_instance->subscription_pvt) {
 		monitor_instance->subscription_pvt->expiry = 0;
 		transmit_invite(monitor_instance->subscription_pvt, SIP_SUBSCRIBE, FALSE, 0, monitor_instance->subscribe_uri);
-		ast_log(LOG_NOTICE, "BEFORE!\n");
 		dialog_unref(monitor_instance->subscription_pvt, "Unref monitor instance ref of subscription pvt");
-		ast_log(LOG_NOTICE, "AFTER!\n");
 	}
 	if (monitor_instance->suspension_entry) {
 		ao2_ref(monitor_instance->suspension_entry, -1);
@@ -5214,9 +5212,7 @@
 
 	/* If this is a subscription, tell the phone that we got a timeout */
 	if (p->subscribed && p->subscribed != MWI_NOTIFICATION && p->subscribed != CALL_COMPLETION) {
-		ast_log(LOG_NOTICE, "DUNG?\n");
 		transmit_state_notify(p, AST_EXTENSION_DEACTIVATED, 1, TRUE);	/* Send last notification */
-		ast_log(LOG_NOTICE, "DUNG 2?\n");
 		p->subscribed = NONE;
 		append_history(p, "Subscribestatus", "timeout");
 		ast_debug(3, "Re-scheduled destruction of SIP subscription %s\n", p->callid ? p->callid : "<unknown>");
@@ -24143,18 +24139,44 @@
 	char *param_separator;
 	struct ast_cc_agent *agent;
 	struct sip_cc_agent_pvt *agent_pvt;
+	const char *expires_str = get_header(req, "Expires");
+	int expires = -1; /* Just need it to be non-zero */
+
+	if (!ast_strlen_zero(expires_str)) {
+		sscanf(expires_str, "%d", &expires);
+	}
 
 	if ((param_separator = strchr(uri, ';'))) {
 		*param_separator = '\0';
 	}
 
 	if (!(agent = find_sip_cc_agent_by_subscribe_uri(uri))) {
+		if (!expires) {
+			/* Typically, if a 0 Expires reaches us and we can't find
+			 * the corresponding agent, it means that the CC transaction
+			 * has completed and so the calling side is just trying to
+			 * clean up its subscription. We'll just respond with a 
+			 * 200 OK and be done with it
+			 */
+			transmit_response(p, "200 OK", req);
+			return 0;
+		}
 		ast_log(LOG_WARNING, "Invalid URI '%s' in CC subscribe\n", uri);
 		transmit_response(p, "404 Not Found", req);
 		return -1;
 	}
 
 	agent_pvt = agent->private_data;
+
+	if (!expires) {
+		/* We got sent a SUBSCRIBE and found an agent. This means that CC
+		 * is being canceled.
+		 */
+		ast_cc_failed(agent->core_id, "CC is being canceled\n");
+		transmit_response(p, "200 OK", req);
+		return 0;
+	}
+
 	agent_pvt->subscribe_pvt = dialog_ref(p, "SIP CC agent gains reference to subscription dialog");
 	ast_cc_agent_accept_request(agent->core_id, "SIP caller has requested CC via SUBSCRIBE");
 	p->subscribed = CALL_COMPLETION;




More information about the asterisk-commits mailing list