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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Dec 28 14:29:25 CST 2009


Author: mmichelson
Date: Mon Dec 28 14:29:23 2009
New Revision: 236711

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=236711
Log:
Write the function to extract CC information from an INVITE response.


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=236711&r1=236710&r2=236711
==============================================================================
--- team/group/CCSS/channels/chan_sip.c (original)
+++ team/group/CCSS/channels/chan_sip.c Mon Dec 28 14:29:23 2009
@@ -1737,6 +1737,26 @@
 };
 
 static struct {
+	enum ast_cc_service_type service;
+	const char *service_string;
+} sip_cc_service_map [] = {
+	[AST_CC_CCBS] = {AST_CC_CCBS, "BS"},
+	[AST_CC_CCNR] = {AST_CC_CCNR, "NR"},
+	[AST_CC_CCNL] = {AST_CC_CCNL, "NL"},
+};
+
+static enum ast_cc_service_type service_string_to_service_type(const char * const service_string)
+{
+	enum ast_cc_service_type service;
+	for (service = AST_CC_CCBS; service <= AST_CC_CCNL; ++service) {
+		if (!strcasecmp(service_string, sip_cc_service_map[service].service_string)) {
+			return service;
+		}
+	}
+	return AST_CC_NONE;
+}
+
+static struct {
 	enum sip_cc_notify_state state;
 	const char *state_string;
 } sip_cc_notify_state_map [] = {
@@ -3782,9 +3802,55 @@
 	ao2_ref(monitor_instance, -1);
 }
 
-static int sip_get_cc_information(struct sip_request *req, char *subsribe_uri, size_t size, enum ast_cc_service_type *service)
-{
-	/* STUB */
+static int sip_get_cc_information(struct sip_request *req, char *subscribe_uri, size_t size, enum ast_cc_service_type *service)
+{
+	char *call_info = ast_strdupa(get_header(req, "Call-Info"));
+	char *uri;
+	char *purpose;
+	char *service_str;
+
+	if (ast_strlen_zero(call_info)) {
+		/* No Call-Info present. Definitely no CC offer */
+		return -1;
+	}
+
+	uri = strsep(&call_info, ";");
+
+	while ((purpose = strsep(&call_info, ";"))) {
+		if (!strncmp(purpose, "purpose=call-completion", 23)) {
+			break;
+		}
+	}
+	if (!purpose) {
+		/* We didn't find the appropriate purpose= parameter. Oh well */
+		return -1;
+	}
+
+	/* Okay, call-completion has been offered. Let's figure out what type of service this is */
+	while ((service_str = strsep(&call_info, ";"))) {
+		if (!strncmp(service_str, "m=", 2)) {
+			break;
+		}
+	}
+	if (!service_str) {
+		/* So they didn't offer a particular service, We'll just go with CCBS since it really
+		 * doesn't matter anyway
+		 */
+		service_str = "BS";
+	} else {
+		/* We already determined that there is an "m=" so no need to check
+		 * the result of this strsep
+		 */
+		strsep(&service_str, "=");
+	}
+
+	if ((*service = service_string_to_service_type(service_str)) == AST_CC_NONE) {
+		/* Invalid service offered */
+		return -1;
+	}
+
+	ast_copy_string(subscribe_uri, get_in_brackets(uri), size);
+
 	return 0;
 }
 




More information about the asterisk-commits mailing list