[Freeswitch-svn] [commit] r13875 - freeswitch/trunk/src/mod/endpoints/mod_sofia

FreeSWITCH SVN anthm at freeswitch.org
Fri Jun 19 13:49:18 PDT 2009


Author: anthm
Date: Fri Jun 19 15:49:18 2009
New Revision: 13875

Log:
MODENDP-222

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c	Fri Jun 19 15:49:18 2009
@@ -1933,7 +1933,8 @@
 
 		
 		if (v_event && *v_event) {
-			switch_xml_t xparams[3];
+			short int xparams_type[6];
+			switch_xml_t xparams[6];
 			int i = 0;
 
 			switch_event_add_header_string(*v_event, SWITCH_STACK_BOTTOM, "sip_number_alias", number_alias);
@@ -1943,29 +1944,52 @@
 			switch_event_add_header_string(*v_event, SWITCH_STACK_BOTTOM, "user_name", username);
 			switch_event_add_header_string(*v_event, SWITCH_STACK_BOTTOM, "domain_name", domain_name);
 
-			if ((dparams = switch_xml_child(domain, "variables"))) {
-				xparams[i++] = dparams;
+			if ((uparams = switch_xml_child(user, "params"))) {
+				xparams_type[i] = 0;
+				xparams[i++] = uparams;
 			}
 
-			if (group && (gparams = switch_xml_child(group, "variables"))) {
+			if (group && (gparams = switch_xml_child(group, "params"))) {
+				xparams_type[i] = 0;
 				xparams[i++] = gparams;
 			}
 
+			if ((dparams = switch_xml_child(domain, "params"))) {
+				xparams_type[i] = 0;
+				xparams[i++] = dparams;
+			}
+
 			if ((uparams = switch_xml_child(user, "variables"))) {
+				xparams_type[i] = 1;
 				xparams[i++] = uparams;
 			}
 
-			if (i <= 3) {
+			if (group && (gparams = switch_xml_child(group, "variables"))) {
+				xparams_type[i] = 1;
+				xparams[i++] = gparams;
+			}
+
+			if ((dparams = switch_xml_child(domain, "variables"))) {
+				xparams_type[i] = 1;
+				xparams[i++] = dparams;
+			}
+
+			if (i <= 6) {
 				int j = 0;
 
 				for (j = 0; j < i; j++) {
-					for (param = switch_xml_child(xparams[j], "variable"); param; param = param->next) {
+					for (param = switch_xml_child(xparams[j], (xparams_type[j]?"variable":"param")); param; param = param->next) {
 						const char *var = switch_xml_attr_soft(param, "name");
 						const char *val = switch_xml_attr_soft(param, "value");
 						sofia_gateway_t *gateway_ptr = NULL;
 
-						if (!switch_strlen_zero(var) && !switch_strlen_zero(val)) {
-							switch_event_add_header_string(*v_event, SWITCH_STACK_BOTTOM, var, val);
+						if (!switch_strlen_zero(var) && !switch_strlen_zero(val) && (xparams_type[j] == 1 || !strncasecmp(var, "sip-",4) || !strcasecmp(var, "register-gateway")) ) {
+							if (!switch_event_get_header(*v_event, var)) {
+								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "event_add_header -> '%s' = '%s'\n",var, val);
+								switch_event_add_header_string(*v_event, SWITCH_STACK_BOTTOM, var, val);
+							} else {
+								continue;
+							}
 
 							if (!strcasecmp(var, "register-gateway")) {
 								if (!strcasecmp(val, "all")) {



More information about the Freeswitch-svn mailing list