]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
more nat fix
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 11 Mar 2014 21:12:43 +0000 (16:12 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 11 Mar 2014 21:12:43 +0000 (16:12 -0500)
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_reg.c

index 9a83370261e5659cfda8166dda3977cbd44b35f8..d395810616c3439df8f08cf45a4a3be75b537e94 100644 (file)
@@ -8213,7 +8213,24 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
        char *sql = NULL;
        char *acl_context = NULL;
        const char *r_sdp = NULL;
-       int broken_device = 0;
+       int is_tcp = 0, is_tls = 0;
+       const char *uparams = NULL;
+
+
+       if (sip && sip->sip_contact && sip->sip_contact->m_url && sip->sip_contact->m_url->url_params) {
+               uparams = sip->sip_contact->m_url->url_params;
+       } else {
+               uparams = NULL;
+       }
+
+       
+       if (uparams) {
+               if (switch_stristr("transport=tcp", uparams)) {
+                       is_tcp = 1;
+               } else if (switch_stristr("transport=tls", uparams)) {
+                       is_tls = 1;
+               }
+       }
 
        profile->ib_calls++;
 
@@ -8257,14 +8274,13 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
        }
 
 
-       if (!switch_check_network_list_ip(network_ip, profile->local_network) &&
-               profile->server_rport_level >= 2 && sip->sip_user_agent && sip->sip_user_agent->g_string &&
-               (!strncasecmp(sip->sip_user_agent->g_string, "Polycom", 7) || 
-                !strncasecmp(sip->sip_user_agent->g_string, "KIRK Wireless Server", 20) )) {
-               broken_device = 1;
-       }
-
-       if (sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION) || broken_device) {
+       if (sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION) || 
+               (sofia_test_pflag(profile, PFLAG_TLS_ALWAYS_NAT) && (is_tcp || is_tls)) || 
+               (!is_tcp && !is_tls && (zstr(network_ip) || !switch_check_network_list_ip(network_ip, profile->local_network)) && 
+                profile->server_rport_level >= 2 && sip->sip_user_agent && 
+                sip->sip_user_agent->g_string && 
+                (!strncasecmp(sip->sip_user_agent->g_string, "Polycom", 7) || !strncasecmp(sip->sip_user_agent->g_string, "KIRK Wireless Server", 20)))
+               ) {
                if (sip && sip->sip_via) {
                        const char *port = sip->sip_via->v_port;
                        const char *host = sip->sip_via->v_host;
index e2447f45a133010e17889eac8d9eca377b360319..cecde4986e6694526665b9bdd87e239c006538ef 100644 (file)
@@ -1469,7 +1469,8 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
                                to_user = force_user;
                        }
 
-                       if (profile->server_rport_level >= 2 && sip->sip_user_agent &&
+                       if (!is_tcp && !is_tls && (zstr(network_ip) || !switch_check_network_list_ip(network_ip, profile->local_network)) &&
+                               profile->server_rport_level >= 2 && sip->sip_user_agent &&
                                sip->sip_user_agent->g_string &&
                                ( !strncasecmp(sip->sip_user_agent->g_string, "Polycom", 7) || !strncasecmp(sip->sip_user_agent->g_string, "KIRK Wireless Server", 20) )) {
                                if (sip && sip->sip_via) {