[svn-commits] mmichelson: branch group/CCSS r236754 - /team/group/CCSS/channels/chan_sip.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Dec 28 16:47:16 CST 2009


Author: mmichelson
Date: Mon Dec 28 16:47:14 2009
New Revision: 236754

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=236754
Log:
Finish the handle_cc_notify function.


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=236754&r1=236753&r2=236754
==============================================================================
--- team/group/CCSS/channels/chan_sip.c (original)
+++ team/group/CCSS/channels/chan_sip.c Mon Dec 28 16:47:14 2009
@@ -21283,23 +21283,44 @@
 
 static int handle_cc_notify(struct sip_pvt *pvt, struct sip_request *req)
 {
-	/* Let's map this out
-	 *
-	 * We need to find the appropriate sip_monitor_instance. Unfortunately, we don't have
-	 * a core_id. We'll have to do a bit of an ao2_callback using the sip_pvt in order
-	 * to do this correctly.
-	 *
-	 * After finding the sip_monitor_instance, we can then check the body to find whether
-	 * the status is "queued" or "ready" and act accordingly
-	 */
 	struct sip_monitor_instance *monitor_instance = ao2_callback(sip_monitor_instances, 0,
 			find_sip_monitor_instance_by_subscription_pvt, pvt);
+	const char *status = get_body(req, "status", ':');
+	char *uri;
 
 	if (!monitor_instance) {
+		transmit_response(pvt, "400 Bad Request", req);
 		return -1;
 	}
-	
-	/* XXX STUB */
+
+	if (ast_strlen_zero(status)) {
+		ao2_ref(monitor_instance, -1);
+		transmit_response(pvt, "400 Bad Request", req);
+		return -1;
+	}
+
+	if (!strcmp(status, "queued")) {
+		/* We've been told that we're queued. This is the endpoint's way of telling
+		 * us that it has accepted our CC request. We need to alert the core of this
+		 * development
+		 */
+		ast_cc_monitor_request_acked(monitor_instance->core_id, "SIP endpoint accepted request");
+		transmit_response(pvt, "200 OK", req);
+		ao2_ref(monitor_instance, -1);
+		return 0;
+	}
+
+	/* It's open! Yay! */
+	uri = get_body(req, "URI", ':');
+	if (ast_strlen_zero(uri)) {
+		uri = get_in_brackets((char *)get_header(req, "From"));
+	}
+
+	ast_copy_string(monitor_instance->notify_uri, uri, sizeof(monitor_instance->notify_uri));
+	ast_cc_monitor_callee_available(monitor_instance->monitor);
+	ao2_ref(monitor_instance, -1);
+	transmit_response(pvt, "200 OK", req);
+
 	return 0;
 }
 




More information about the svn-commits mailing list