From 0863bbcbaeb7ec3771f782412011586b7ab32231 Mon Sep 17 00:00:00 2001
From: Michael Jerris <mike@jerris.com>
Date: Mon, 7 Dec 2009 16:29:52 +0000
Subject: [PATCH] don't set auto-nat on ipv6 profiles

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15829 d0543943-73ff-0310-b7d9-9358b9ac24b2
---
 src/mod/endpoints/mod_sofia/sofia.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c
index a8b61d3e3f..e6c1f93aca 100644
--- a/src/mod/endpoints/mod_sofia/sofia.c
+++ b/src/mod/endpoints/mod_sofia/sofia.c
@@ -2435,17 +2435,6 @@ switch_status_t config_sofia(int reload, char *profile_name)
 
 				profile->local_network = "localnet.auto";
 
-				if (switch_core_get_variable("nat_type")) {
-					const char *ip = switch_core_get_variable("nat_public_addr");
-					if (ip) {
-						profile->extrtpip = switch_core_strdup(profile->pool, ip);
-						profile->extsipip = switch_core_strdup(profile->pool, ip);
-						sofia_set_pflag(profile, PFLAG_AUTO_NAT);
-						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "NAT detected setting external ip to %s\n", ip);
-					}
-				}
-
-
 				for (param = switch_xml_child(settings, "param"); param; param = param->next) {
 					char *var = (char *) switch_xml_attr_soft(param, "name");
 					char *val = (char *) switch_xml_attr_soft(param, "value");
@@ -2996,6 +2985,20 @@ switch_status_t config_sofia(int reload, char *profile_name)
 					profile->rtpip = switch_core_strdup(profile->pool, mod_sofia_globals.guess_ip);
 				}
 
+				if (switch_core_get_variable("nat_type")) {
+					const char *ip = switch_core_get_variable("nat_public_addr");
+					if (ip && !strchr(profile->sipip, ':')) {
+						if (!profile->extrtpip) {
+							profile->extrtpip = switch_core_strdup(profile->pool, ip);
+						}
+						if (!profile->extsipip) {
+							profile->extsipip = switch_core_strdup(profile->pool, ip);
+						}
+						sofia_set_pflag(profile, PFLAG_AUTO_NAT);
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "NAT detected setting external ip to %s\n", ip);
+					}
+				}
+
 				if (profile->nonce_ttl < 60) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting nonce TTL to 60 seconds\n");
 					profile->nonce_ttl = 60;