]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-11159: [mod_sofia] Set transport based on our next hop, so if route_uri is present...
authorAron Podrigal <aron@mongotel.com>
Fri, 11 May 2018 03:17:29 +0000 (03:17 +0000)
committerMike Jerris <mike@signalwire.com>
Thu, 9 May 2019 20:44:34 +0000 (14:44 -0600)
src/mod/endpoints/mod_sofia/sofia_glue.c

index d1431a1e57f153f89a666903deb02fe2bf0c7e17..35a2567db52771a4a5846c16e567b817eefd4f6c 100644 (file)
@@ -926,12 +926,21 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
                        rpid_domain = "cluecon.com";
                }
 
+               if (!zstr(tech_pvt->dest)) {
+                       dst = sofia_glue_get_destination(tech_pvt->dest);
+               }
+
                /*
                 * Ignore transport chanvar and uri parameter for gateway connections
                 * since all of them have been already taken care of in mod_sofia.c:sofia_outgoing_channel()
                 */
                if (tech_pvt->transport == SOFIA_TRANSPORT_UNKNOWN && zstr(tech_pvt->gateway_name)) {
-                       if ((p = (char *) switch_stristr("port=", url))) {
+                       if (dst && dst->route_uri) {
+                               p = dst->route_uri;
+                       } else {
+                               p = url;
+                       }
+                       if ((p = (char *) switch_stristr("port=", p))) {
                                p += 5;
                                tech_pvt->transport = sofia_glue_str2transport(p);
                        } else {
@@ -1079,7 +1088,9 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
                                                           || ((val = switch_channel_get_variable(channel, "sip_sticky_contact")) && switch_true(val)))) {
                        sofia_set_flag(tech_pvt, TFLAG_NAT);
                        tech_pvt->record_route = switch_core_session_strdup(tech_pvt->session, url_str);
-                       route_uri = tech_pvt->record_route;
+                       if (!dst || !dst->route_uri) {
+                               route_uri = tech_pvt->record_route;
+                       }
                        session_timeout = SOFIA_NAT_SESSION_TIMEOUT;
                        switch_channel_set_variable(channel, "sip_nat_detected", "true");
                }
@@ -1251,7 +1262,9 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
        }
 
        if (!zstr(tech_pvt->dest)) {
-               dst = sofia_glue_get_destination(tech_pvt->dest);
+               if (!dst) {
+                       dst = sofia_glue_get_destination(tech_pvt->dest);
+               }
 
                if (dst->route_uri) {
                        route_uri = sofia_overcome_sip_uri_weakness(tech_pvt->session, dst->route_uri, tech_pvt->transport, SWITCH_TRUE, NULL, NULL);