[Freeswitch-svn] [commit] r13546 - freeswitch/trunk/src/mod/applications/mod_lcr

FreeSWITCH SVN rupa at freeswitch.org
Tue Jun 2 09:38:30 PDT 2009


Author: rupa
Date: Tue Jun  2 11:38:29 2009
New Revision: 13546

Log:
MODAPP-281 - add extra sip headers


Modified:
   freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c

Modified: freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c	Tue Jun  2 11:38:29 2009
@@ -132,6 +132,7 @@
 	
 	switch_bool_t reorder_by_rate;
 	switch_bool_t quote_in_list;
+	switch_bool_t info_in_headers;
 };
 typedef struct profile_obj profile_t;
 
@@ -219,7 +220,7 @@
 	return number;
 }
 
-static char *get_bridge_data(switch_memory_pool_t *pool, char *dialed_number, char *caller_id, lcr_route cur_route)
+static char *get_bridge_data(switch_memory_pool_t *pool, char *dialed_number, char *caller_id, lcr_route cur_route, profile_t *profile)
 {
 	size_t lstrip;
 	size_t  tstrip;
@@ -228,6 +229,7 @@
 	char *orig_destination_number = NULL; 
 	char *codec = NULL;
 	char *cid = NULL;
+	char *header = NULL;
 
 	orig_destination_number = destination_number = switch_core_strdup(pool, dialed_number);
 	
@@ -261,9 +263,16 @@
 								  do_cid(pool, cur_route->cid, caller_id));
 	}
 	
-	data = switch_core_sprintf(pool, "[lcr_carrier=%s,lcr_rate=%s%s%s]%s%s%s%s%s"
+	header = "";
+	if (profile->info_in_headers) {
+		header = switch_core_sprintf(pool, ",sip_h_X-LCR-INFO=lcr_rate=%s;lcr_carrier=%s",
+									  cur_route->rate_str, 
+									  cur_route->carrier_name);
+	}
+	
+	data = switch_core_sprintf(pool, "[lcr_carrier=%s,lcr_rate=%s%s%s%s]%s%s%s%s%s"
 								, cur_route->carrier_name, cur_route->rate_str
-								, codec, cid
+								, codec, cid, header
 								, cur_route->gw_prefix, cur_route->prefix
 								, destination_number, cur_route->suffix, cur_route->gw_suffix);
 			
@@ -546,7 +555,7 @@
 	if (argc > LCR_CID_PLACE) {
 		additional->cid = switch_core_strdup(pool, switch_str_nil(argv[LCR_CID_PLACE]));
 	}
-	additional->dialstring = get_bridge_data(pool, cbt->lookup_number, cbt->cid, additional);
+	additional->dialstring = get_bridge_data(pool, cbt->lookup_number, cbt->cid, additional, cbt->profile);
 
 	if (cbt->head == NULL) {
 		key = switch_core_sprintf(pool, "%s:%s", additional->gw_prefix, additional->gw_suffix);
@@ -783,6 +792,7 @@
 			switch_stream_handle_t *thisorder = NULL;
 			char *reorder_by_rate = NULL;
 			char *quote_in_list = NULL;
+			char *info_in_headers = NULL;
 			char *id_s = NULL;
 			char *custom_sql = NULL;
 			int argc, x = 0;
@@ -835,6 +845,8 @@
 					custom_sql = val;
 				} else if (!strcasecmp(var, "reorder_by_rate") && !switch_strlen_zero(val)) {
 					reorder_by_rate = val;
+				} else if (!strcasecmp(var, "info_in_headers") && !switch_strlen_zero(val)) {
+					info_in_headers = val;
 				} else if (!strcasecmp(var, "quote_in_list") && !switch_strlen_zero(val)) {
 					quote_in_list = val;
 				}
@@ -913,6 +925,10 @@
 					profile->reorder_by_rate = switch_true(reorder_by_rate);
 				}
 				
+				if (!switch_strlen_zero(info_in_headers)) {
+					profile->info_in_headers = switch_true(info_in_headers);
+				}
+				
 				if (!switch_strlen_zero(quote_in_list)) {
 					profile->quote_in_list = switch_true(quote_in_list);
 				}
@@ -1207,7 +1223,7 @@
 			current = cb_struct.head;
 			while (current) {
 
-				dialstring = get_bridge_data(pool, cb_struct.lookup_number, cb_struct.cid, current);
+				dialstring = get_bridge_data(pool, cb_struct.lookup_number, cb_struct.cid, current, cb_struct.profile);
 
 				stream->write_function(stream, " | %s", current->digit_str);
 				str_repeat((maximum_lengths.digit_str - current->digit_len), " ", stream);
@@ -1300,6 +1316,8 @@
 				}
 				stream->write_function(stream, " Reorder rate:\t%s\n", 
 										profile->reorder_by_rate ? "enabled" : "disabled");
+				stream->write_function(stream, " Info in headers:\t%s\n", 
+										profile->info_in_headers ? "enabled" : "disabled");
 				stream->write_function(stream, " Quote IN() List:\t%s\n", 
 										profile->quote_in_list ? "enabled" : "disabled");
 				stream->write_function(stream, "\n");



More information about the Freeswitch-svn mailing list