[Freeswitch-branches] [commit] r13563 - freeswitch/branches/brian/trunk/src

FreeSWITCH SVN brian at freeswitch.org
Tue Jun 2 17:33:59 PDT 2009


Author: brian
Date: Tue Jun  2 19:33:59 2009
New Revision: 13563

Log:
 merge trunk down 

Modified:
   freeswitch/branches/brian/trunk/src/switch_core.c
   freeswitch/branches/brian/trunk/src/switch_nat.c
   freeswitch/branches/brian/trunk/src/switch_xml.c

Modified: freeswitch/branches/brian/trunk/src/switch_core.c
==============================================================================
--- freeswitch/branches/brian/trunk/src/switch_core.c	(original)
+++ freeswitch/branches/brian/trunk/src/switch_core.c	Tue Jun  2 19:33:59 2009
@@ -1176,6 +1176,12 @@
 	runtime.flags = flags;
 	runtime.sps_total = 30;
 
+	*err = NULL;
+
+	if (console) {
+		runtime.console = stdout;
+	}
+
 	switch_find_local_ip(guess_ip, sizeof(guess_ip), &mask, AF_INET);
 	switch_core_set_variable("local_ip_v4", guess_ip);
 	switch_core_set_variable("local_mask_v4", inet_ntoa(*(struct in_addr *)&mask));
@@ -1188,25 +1194,21 @@
 
 	switch_event_init(runtime.memory_pool);
 
-	if (switch_test_flag((&runtime), SCF_USE_AUTO_NAT)) {
-		switch_nat_init(runtime.memory_pool);
-	}
-
 	if (switch_xml_init(runtime.memory_pool, err) != SWITCH_STATUS_SUCCESS) {
 		apr_terminate();
 		return SWITCH_STATUS_MEMERR;
 	}
 
-	switch_load_core_config("switch.conf");
-
+	if (switch_test_flag((&runtime), SCF_USE_AUTO_NAT)) {
+		switch_nat_init(runtime.memory_pool);
+	}
+	
 	switch_log_init(runtime.memory_pool, runtime.colorize_console);
-	switch_core_state_machine_init(runtime.memory_pool);
 
-	*err = NULL;
+	switch_load_core_config("switch.conf");
 
-	if (console) {
-		runtime.console = stdout;
-	}
+
+	switch_core_state_machine_init(runtime.memory_pool);
 
 	if (switch_test_flag((&runtime), SCF_USE_SQL)) {
 		switch_core_sqldb_start(runtime.memory_pool);

Modified: freeswitch/branches/brian/trunk/src/switch_nat.c
==============================================================================
--- freeswitch/branches/brian/trunk/src/switch_nat.c	(original)
+++ freeswitch/branches/brian/trunk/src/switch_nat.c	Tue Jun  2 19:33:59 2009
@@ -101,11 +101,11 @@
 
 static int init_pmp(void)
 {
-	int r = 0;
+	int r = 0, i = 0, max = 5;
 	natpmpresp_t response;
 	char *pubaddr = NULL;
 	fd_set fds;
-	struct timeval timeout;
+
 
 	initnatpmp(&nat_globals.natpmp);
 	r = sendpublicaddressrequest(&nat_globals.natpmp);
@@ -115,12 +115,16 @@
 	}
 
 	do {
+		struct timeval timeout = { 1, 0};
+		i++;
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Checking for PMP %d/%d\n", i, max);
+
 		FD_ZERO(&fds);
 		FD_SET(nat_globals.natpmp.s, &fds);
 		getnatpmprequesttimeout(&nat_globals.natpmp, &timeout);
 		select(FD_SETSIZE, &fds, NULL, NULL, &timeout);
 		r = readnatpmpresponseorretry(&nat_globals.natpmp, &response);
-	} while(r == NATPMP_TRYAGAIN);
+	} while(r == NATPMP_TRYAGAIN && i < max);
 
 	if (r < 0) {
 		goto end;
@@ -146,9 +150,13 @@
 
 	switch_find_local_ip(nat_globals.pvt_addr, sizeof(nat_globals.pvt_addr), NULL, AF_INET);
 
+
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Scanning for NAT\n");
+
 	init_pmp();
 
 	if (!nat_globals.nat_type) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Checking for UPnP\n");
 		init_upnp();
 	}
 	
@@ -156,8 +164,9 @@
 		switch_core_set_variable("nat_public_addr", nat_globals.pub_addr);
 		switch_core_set_variable("nat_private_addr", nat_globals.pvt_addr);
 		switch_core_set_variable("nat_type", nat_globals.nat_type == SWITCH_NAT_TYPE_PMP ? "pmp" : "upnp");
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "NAT detected type: %s\n", nat_globals.nat_type == SWITCH_NAT_TYPE_PMP ? "pmp" : "upnp");
 	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No PMP or uPNP NAT device detected!\n");
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No PMP or UPnP NAT detected!\n");
 	}
 }
 

Modified: freeswitch/branches/brian/trunk/src/switch_xml.c
==============================================================================
--- freeswitch/branches/brian/trunk/src/switch_xml.c	(original)
+++ freeswitch/branches/brian/trunk/src/switch_xml.c	Tue Jun  2 19:33:59 2009
@@ -1287,8 +1287,8 @@
 		char *bp = expand_vars(buf, ebuf, sizeof(ebuf), &cur, &err);
 		line++;
 		
-		if (err && stderr) {
-			fprintf(stderr, "Error [%s] in file %s line %d\n", err, file, line);
+		if (err) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error [%s] in file %s line %d\n", err, file, line);
 		}
 
 		/* we ignore <include> or </include> for the sake of validators as well as <?xml version="1.0"?> type stuff */



More information about the Freeswitch-branches mailing list