]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
clean up nat stuff more
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 14 May 2008 14:13:40 +0000 (14:13 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 14 May 2008 14:13:40 +0000 (14:13 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8395 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_glue.c

index fb4928693a54ed1c4375322f249ca757b0a43e02..170363c28537f4a556d7192a25cb557f5fae1920 100644 (file)
@@ -411,7 +411,8 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
                (val = switch_channel_get_variable(channel, "sip-force-contact")) || 
                ((val = switch_channel_get_variable(channel, "sip_sticky_contact")) && switch_true(val))) {
                sticky = tech_pvt->record_route;
-               session_timeout = 20;
+               session_timeout = SOFIA_NAT_SESSION_TIMEOUT;
+               switch_channel_set_variable(channel, "sip_nat_detected", "true");
        }
 
        
@@ -1107,6 +1108,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                                        (val = switch_channel_get_variable(channel, "sip-force-contact")) || 
                                        ((val = switch_channel_get_variable(channel, "sip_sticky_contact")) && switch_true(val))) {
                                        sticky = tech_pvt->record_route;
+                                       switch_channel_set_variable(channel, "sip_nat_detected", "true");
                                }
 
                                nua_respond(tech_pvt->nh,
index bc28ced9446958eeaf634d9f7625ba042e4c9147..9217cabbd6b0d246fa1bc3a1d55c5cd85e456a77 100644 (file)
@@ -45,7 +45,7 @@
 #ifdef SWITCH_HAVE_ODBC
 #include <switch_odbc.h>
 #endif
-
+#define SOFIA_NAT_SESSION_TIMEOUT 20
 #define SOFIA_MAX_ACL 100
 
 #define MODNAME "mod_sofia"
index b2e6edf2325be75146b455f17c903cac6276460a..26429ef40384c061f918c5c8a0f3f34bda2aedb8 100644 (file)
@@ -2727,10 +2727,14 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
        tech_pvt->remote_port = network_port;
 
        if (sip->sip_contact && sip->sip_contact->m_url) {
+               char tmp[35] = "";
                tech_pvt->record_route = switch_core_session_sprintf(session, "sip:%s@%s:%d", 
                                                                                                                         sip->sip_contact->m_url->url_user, 
                                                                                                                         tech_pvt->remote_ip,
                                                                                                                         tech_pvt->remote_port);
+               switch_channel_set_variable(channel, "sip_received_ip", tech_pvt->remote_ip);
+               snprintf(tmp, sizeof(tmp), "tech_pvt->remote_port");
+               switch_channel_set_variable(channel, "sip_received_port", tmp);
        }
 
        if (*key != '\0') {
@@ -3168,6 +3172,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
                                if (ok) {
                                        switch_set_flag(tech_pvt, TFLAG_NAT);
                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setting NAT mode based on acl %s\n", last_acl);
+                                       switch_channel_set_variable(channel, "sip_nat_detected", "true");
                                }
                        }
                }
index be6c945676395bd7b8cdc4d99e46f326ebe90318..b93ac107e118bae8f5fd19b412e21892e08e59cd 100644 (file)
@@ -1007,7 +1007,8 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
                        ((val = switch_channel_get_variable(channel, "sip_sticky_contact")) && switch_true(val))) {
                        tech_pvt->record_route = switch_core_session_strdup(tech_pvt->session, url_str);
                        sticky = tech_pvt->record_route;
-                       session_timeout = 20;
+                       session_timeout = SOFIA_NAT_SESSION_TIMEOUT;
+                       switch_channel_set_variable(channel, "sip_nat_detected", "true");
                }
 
 
@@ -1532,6 +1533,16 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
        if (tech_pvt->cng_pt) {
                flags |= SWITCH_RTP_FLAG_AUTO_CNG;
        }
+       
+       if (tech_pvt->rtp_session && switch_test_flag(tech_pvt, TFLAG_REINVITE)) {
+               const char *ip = switch_channel_get_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE);
+               const char *port = switch_channel_get_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE);
+
+               if (ip && port && !strcmp(ip, tech_pvt->adv_sdp_audio_ip) && atoi(port) == tech_pvt->remote_sdp_audio_port) {
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Audio params are unchanged.\n");
+                       goto video;
+               }
+       }
 
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "AUDIO RTP [%s] %s:%d->%s:%d codec: %u ms: %d\n",
                                          switch_channel_get_name(tech_pvt->channel),
@@ -1809,7 +1820,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
        }
 
        if (((m = sdp->sdp_media)) && m->m_mode == sdp_sendonly) {
-               sendonly = 1;
+               sendonly = 2; /* global sendonly always wins */
        }
 
        for (attr = sdp->sdp_attributes; attr; attr = attr->a_next) {
@@ -1819,7 +1830,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
 
                if ((!strcasecmp(attr->a_name, "sendonly")) || (!strcasecmp(attr->a_name, "inactive"))) {
                        sendonly = 1;
-               } else if (!strcasecmp(attr->a_name, "sendrecv")) {
+               } else if (sendonly < 2 && !strcasecmp(attr->a_name, "sendrecv")) {
                        sendonly = 0;
                } else if (!strcasecmp(attr->a_name, "ptime")) {
                        dptime = atoi(attr->a_value);
@@ -1840,7 +1851,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
                        if (!(stream = switch_channel_get_variable(tech_pvt->channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
                                stream = tech_pvt->profile->hold_music;
                        }
-
+                       
                        if (stream && strcasecmp(stream, "silence")) {
                                if (!strcasecmp(stream, "indicate_hold")) {
                                        switch_channel_set_flag(tech_pvt->channel, CF_SUSPEND);