[Freeswitch-svn] [commit] r13565 - freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia
FreeSWITCH SVN
brian at freeswitch.org
Wed Jun 3 06:42:37 PDT 2009
Author: brian
Date: Wed Jun 3 08:42:37 2009
New Revision: 13565
Log:
adding sanity checking if local_network happens to never be set.
Modified:
freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia.c
freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
Modified: freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia.c Wed Jun 3 08:42:37 2009
@@ -4489,7 +4489,8 @@
tech_pvt->remote_ip = switch_core_session_strdup(session, network_ip);
tech_pvt->remote_port = network_port;
- if (sofia_test_pflag(profile, PFLAG_AUTO_NAT) && !switch_check_network_list_ip(tech_pvt->remote_ip, profile->local_network)) {
+ if (sofia_test_pflag(profile, PFLAG_AUTO_NAT) && profile->local_network &&
+ !switch_check_network_list_ip(tech_pvt->remote_ip, profile->local_network)) {
sofia_transport_t transport = sofia_glue_url2transport(sip->sip_contact->m_url);
tech_pvt->user_via = switch_core_session_sprintf(session, "SIP/2.0/%s %s;rport", sofia_glue_transport2str(transport),
profile->extsipip);
@@ -4689,11 +4690,25 @@
if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
tech_pvt->reply_contact = switch_core_session_sprintf(session, "<sip:%s@%s>", user, host);
} else {
-
const char *url;
- if ((url = (sofia_glue_transport_has_tls(transport)) ? profile->tls_url :
- (switch_check_network_list_ip(tech_pvt->remote_ip, profile->local_network)) ? profile->url : profile->public_url)) {
+ if (sofia_test_pflag(profile, PFLAG_AUTO_NAT) && profile->local_network &&
+ !switch_check_network_list_ip(tech_pvt->remote_ip, profile->local_network)) {
+
+ if (sofia_glue_transport_has_tls(transport)) {
+ url = profile->tls_public_url;
+ } else {
+ url = profile->public_url;
+ }
+
+ if (strchr(url, '>')) {
+ tech_pvt->reply_contact = switch_core_session_sprintf(session, "%s;transport=%s", url,
+ sofia_glue_transport2str(transport));
+ } else {
+ tech_pvt->reply_contact = switch_core_session_sprintf(session, "<%s;transport=%s>", profile->url,
+ sofia_glue_transport2str(transport));
+ }
+ } else if ((url = (sofia_glue_transport_has_tls(transport)) ? profile->tls_url : profile->url)) {
if (strchr(url, '>')) {
tech_pvt->reply_contact = switch_core_session_sprintf(session, "%s;transport=%s", url, sofia_glue_transport2str(transport));
} else {
@@ -4706,8 +4721,24 @@
}
} else {
const char *url;
-
- if ((url = (sofia_glue_transport_has_tls(transport)) ? profile->tls_url : profile->url)) {
+
+ if (sofia_test_pflag(profile, PFLAG_AUTO_NAT) && profile->local_network &&
+ !switch_check_network_list_ip(tech_pvt->remote_ip, profile->local_network)) {
+
+ if (sofia_glue_transport_has_tls(transport)) {
+ url = profile->tls_public_url;
+ } else {
+ url = profile->public_url;
+ }
+
+ if (strchr(url, '>')) {
+ tech_pvt->reply_contact = switch_core_session_sprintf(session, "%s;transport=%s", url,
+ sofia_glue_transport2str(transport));
+ } else {
+ tech_pvt->reply_contact = switch_core_session_sprintf(session, "<%s;transport=%s>", url,
+ sofia_glue_transport2str(transport));
+ }
+ } else if ((url = (sofia_glue_transport_has_tls(transport)) ? profile->tls_url : profile->url)) {
if (strchr(url, '>')) {
tech_pvt->reply_contact = switch_core_session_sprintf(session, "%s;transport=%s", url, sofia_glue_transport2str(transport));
} else {
@@ -4718,7 +4749,7 @@
}
}
}
-
+
if (sip->sip_contact && sip->sip_contact->m_url) {
const char *contact_uri = url_set_chanvars(session, sip->sip_contact->m_url, sip_contact);
if (!channel_name) {
Modified: freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Wed Jun 3 08:42:37 2009
@@ -666,15 +666,14 @@
}
if (switch_channel_direction(tech_pvt->channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
- if (tech_pvt->remote_ip && sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT) &&
+ if (tech_pvt->remote_ip && sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT) && tech_pvt->profile->local_network &&
!switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) {
tech_pvt->adv_sdp_audio_ip = switch_core_session_strdup(tech_pvt->session, tech_pvt->profile->extrtpip);
} else {
tech_pvt->adv_sdp_audio_ip = switch_core_session_strdup(tech_pvt->session, ip);
}
} else {
-
- if (tech_pvt->remote_ip && sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT) &&
+ if (tech_pvt->remote_ip && sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT) && tech_pvt->profile->local_network &&
!switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) {
tech_pvt->adv_sdp_audio_ip = switch_core_session_strdup(tech_pvt->session, tech_pvt->profile->extrtpip);
} else {
@@ -716,11 +715,12 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "No RTP ports available!\n");
return SWITCH_STATUS_FALSE;
}
- sdp_port = tech_pvt->local_sdp_video_port;
+ sdp_port = tech_pvt->local_sdp_video_port;
if (tech_pvt->profile->extrtpip) {
- if (sofia_glue_ext_address_lookup(tech_pvt->profile, tech_pvt, &ip, &sdp_port, tech_pvt->profile->extrtpip, switch_core_session_get_pool(tech_pvt->session)) !=
+ if (sofia_glue_ext_address_lookup(tech_pvt->profile, tech_pvt, &ip, &sdp_port, tech_pvt->profile->extrtpip,
+ switch_core_session_get_pool(tech_pvt->session)) !=
SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_FALSE;
}
@@ -728,7 +728,8 @@
tech_pvt->adv_sdp_video_port = sdp_port;
- if (sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT) && !switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) {
+ if (sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT) && tech_pvt->profile->local_network &&
+ !switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) {
switch_nat_add_mapping((switch_port_t)sdp_port, SWITCH_NAT_UDP);
}
@@ -1285,7 +1286,7 @@
const char* format;
const char *alt = NULL;
- if (sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT)) {
+ if (sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT) && tech_pvt->profile->local_network) {
sipip = (switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network))
? tech_pvt->profile->sipip : tech_pvt->profile->extsipip;
} else {
@@ -1399,7 +1400,8 @@
}
}
- if (sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT) && !switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) {
+ if (sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT) && tech_pvt->profile->local_network &&
+ !switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) {
const char *transport = sofia_glue_transport2str(tech_pvt->transport);
tech_pvt->user_via = switch_core_session_sprintf(session, "SIP/2.0/%s %s;rport",
transport, tech_pvt->profile->extsipip);
@@ -1417,7 +1419,7 @@
char *ip_addr;
char *ipv6;
- if (sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT)) {
+ if (sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT) && tech_pvt->profile->local_network) {
ip_addr = (switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network))
? tech_pvt->profile->sipip : tech_pvt->profile->extsipip;
} else {
@@ -1438,7 +1440,7 @@
if (sofia_glue_transport_has_tls(tech_pvt->transport)) {
tech_pvt->invite_contact = tech_pvt->profile->tls_url;
} else {
- if (sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT) &&
+ if (sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT) && tech_pvt->profile->local_network &&
!switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) {
tech_pvt->invite_contact = tech_pvt->profile->public_url;
} else {
@@ -1692,7 +1694,7 @@
switch_mutex_lock(tech_pvt->sofia_mutex);
caller_profile = switch_channel_get_caller_profile(channel);
- if (sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT)) {
+ if (sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT) && tech_pvt->profile->local_network) {
sipip = (switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network))
? tech_pvt->profile->sipip : tech_pvt->profile->extsipip;
contact_url = tech_pvt->profile->public_url;
@@ -1829,7 +1831,7 @@
switch_rtp_release_port(tech_pvt->profile->rtpip, tech_pvt->local_sdp_audio_port);
}
- if (tech_pvt->local_sdp_audio_port > 0 && sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT) &&
+ if (tech_pvt->local_sdp_audio_port > 0 && sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT) && tech_pvt->profile->local_network &&
!switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) {
switch_nat_del_mapping((switch_port_t)tech_pvt->local_sdp_audio_port, SWITCH_NAT_UDP);
}
@@ -1840,7 +1842,7 @@
switch_rtp_release_port(tech_pvt->profile->rtpip, tech_pvt->local_sdp_video_port);
}
- if (tech_pvt->local_sdp_video_port > 0 && sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT) &&
+ if (tech_pvt->local_sdp_video_port > 0 && sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT) && tech_pvt->profile->local_network &&
!switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) {
switch_nat_del_mapping((switch_port_t)tech_pvt->local_sdp_video_port, SWITCH_NAT_UDP);
}
Modified: freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
==============================================================================
--- freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c (original)
+++ freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c Wed Jun 3 08:42:37 2009
@@ -1417,13 +1417,17 @@
}
}
- id = switch_mprintf("sip:%s@%s", sub_to_user, switch_check_network_list_ip(network_ip, profile->local_network) ? sub_to_host : profile->extsipip);
+ id = switch_mprintf("sip:%s@%s", sub_to_user, (profile->local_network && switch_check_network_list_ip(network_ip, profile->local_network))
+ ? sub_to_host : profile->extsipip);
contact = sofia_glue_get_url_from_contact(o_contact, 1);
if (sofia_test_pflag(profile, PFLAG_AUTO_NAT) && !switch_check_network_list_ip(network_ip, profile->local_network)) {
char *ptr = NULL;
const char *transport_str = NULL;
+
+ id = switch_mprintf("sip:%s@%s", sub_to_user, profile->extsipip);
+
if ((ptr = sofia_glue_find_parameter(o_contact, "transport="))) {
sofia_transport_t transport = sofia_glue_str2transport(ptr);
transport_str = sofia_glue_transport2str(transport);
@@ -1443,6 +1447,7 @@
}
} else {
contact_str = profile->url;
+ id = switch_mprintf("sip:%s@%s", sub_to_user, sub_to_host);
}
if ((route = strstr(contact, ";fs_path=")) && (route = strdup(route + 9))) {
More information about the Freeswitch-svn
mailing list