]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Well I'll be a son of a monkey's bitch, it was that bug
authorBrian West <brian@freeswitch.org>
Wed, 2 Dec 2009 01:58:05 +0000 (01:58 +0000)
committerBrian West <brian@freeswitch.org>
Wed, 2 Dec 2009 01:58:05 +0000 (01:58 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15748 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_reg.c

index be40f13a04606a6e34f11cbea7c94584254d4739..75ca4249adbf694e35ba9f14461222efb569f314 100644 (file)
@@ -2148,7 +2148,11 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
                                        } else if (!strcasecmp(var, "context")) {
                                                profile->context = switch_core_strdup(profile->pool, val);
                                        } else if (!strcasecmp(var, "local-network-acl")) {
-                                               profile->local_network = switch_core_strdup(profile->pool, val);
+                                               if (!strcasecmp(var, "none")) {
+                                                       profile->local_network = NULL;
+                                               } else {
+                                                       profile->local_network = switch_core_strdup(profile->pool, val);
+                                               }
                                        } else if (!strcasecmp(var, "force-register-domain")) {
                                                profile->reg_domain = switch_core_strdup(profile->pool, val);
                                        } else if (!strcasecmp(var, "force-subscription-domain")) {
@@ -2429,6 +2433,19 @@ switch_status_t config_sofia(int reload, char *profile_name)
                                sofia_set_pflag(profile, PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER);
                                sofia_set_pflag(profile, PFLAG_SQL_IN_TRANS);
 
+                               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");
@@ -2579,12 +2596,14 @@ switch_status_t config_sofia(int reload, char *profile_name)
                                                        if (!strcmp(val, "0.0.0.0")) {
                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid IP 0.0.0.0 replaced with %s\n", mod_sofia_globals.guess_ip);
                                                        } else if (!strcasecmp(val, "auto-nat")) {
-                                                               ip = mod_sofia_globals.auto_nat ? switch_core_get_variable("nat_public_addr") : mod_sofia_globals.guess_ip; 
+                                                               ip = NULL;
                                                        } else {
                                                                ip = strcasecmp(val, "auto") ? val : mod_sofia_globals.guess_ip;
+                                                               sofia_clear_pflag(profile, PFLAG_AUTO_NAT);
+                                                       }
+                                                       if (ip) {
+                                                               profile->extrtpip = switch_core_strdup(profile->pool, ip);
                                                        }
-                                                       sofia_set_pflag(profile, PFLAG_AUTO_NAT);
-                                                       profile->extrtpip = switch_core_strdup(profile->pool, ip);
                                                } else {
                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid ext-rtp-ip\n");
                                                }
@@ -2617,22 +2636,28 @@ switch_status_t config_sofia(int reload, char *profile_name)
                                                        if (!strcasecmp(val, "0.0.0.0")) {
                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid IP 0.0.0.0 replaced with %s\n", mod_sofia_globals.guess_ip);
                                                        } else if (!strcasecmp(val, "auto-nat")) {
-                                                               ip = mod_sofia_globals.auto_nat ? switch_core_get_variable("nat_public_addr") : mod_sofia_globals.guess_ip;
+                                                               ip = NULL;
                                                        } else if (strcasecmp(val, "auto")) {
                                                                switch_port_t port = 0;
                                                                if (sofia_glue_ext_address_lookup(profile, NULL, &myip, &port, val, profile->pool) == SWITCH_STATUS_SUCCESS) {
                                                                        ip = myip;
+                                                                       sofia_clear_pflag(profile, PFLAG_AUTO_NAT);
                                                                } else {
                                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to get external ip.\n");
                                                                }
                                                        }
-                                                       sofia_set_pflag(profile, PFLAG_AUTO_NAT);
-                                                       profile->extsipip = switch_core_strdup(profile->pool, ip);
+                                                       if (ip) {
+                                                               profile->extsipip = switch_core_strdup(profile->pool, ip);
+                                                       }
                                                } else {
                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid ext-sip-ip\n");
                                                }
                                        } else if (!strcasecmp(var, "local-network-acl")) {
-                                               profile->local_network = switch_core_strdup(profile->pool, val);
+                                               if (!strcasecmp(var, "none")) {
+                                                       profile->local_network = NULL;
+                                               } else {
+                                                       profile->local_network = switch_core_strdup(profile->pool, val);
+                                               }
                                        } else if (!strcasecmp(var, "force-register-domain")) {
                                                profile->reg_domain = switch_core_strdup(profile->pool, val);
                                        } else if (!strcasecmp(var, "force-register-db-domain")) {
index f68befee348580908fb19f0a1e651f955cec54ab..9515a8768aa42dd2e7774264f561999bddde3647 100644 (file)
@@ -1363,7 +1363,8 @@ void sofia_reg_handle_sip_i_register(nua_t *nua, sofia_profile_t *profile, nua_h
                goto end;
        }
        
-       if (is_nat && !sofia_glue_check_nat(profile, network_ip)) {
+       if (is_nat && profile->local_network && switch_check_network_list_ip(network_ip, profile->local_network)) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "IP %s is on local network, not seting NAT mode.\n", network_ip);
                is_nat = NULL;
        }