[Freeswitch-svn] [commit] r9096 - in freeswitch/trunk/src: . include mod/endpoints/mod_sofia
Freeswitch SVN
anthm at freeswitch.org
Fri Jul 18 16:25:39 EDT 2008
Author: anthm
Date: Fri Jul 18 16:25:39 2008
New Revision: 9096
Modified:
freeswitch/trunk/src/include/switch_rtp.h
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
freeswitch/trunk/src/switch_rtp.c
Log:
update
Modified: freeswitch/trunk/src/include/switch_rtp.h
==============================================================================
--- freeswitch/trunk/src/include/switch_rtp.h (original)
+++ freeswitch/trunk/src/include/switch_rtp.h Fri Jul 18 16:25:39 2008
@@ -418,7 +418,8 @@
*/
SWITCH_DECLARE(void *) switch_rtp_get_private(switch_rtp_t *rtp_session);
-SWITCH_DECLARE(switch_status_t) switch_rtp_activate_stun_ping(switch_rtp_t *rtp_session, const char *stun_ip, uint32_t packet_count, switch_bool_t funny);
+SWITCH_DECLARE(switch_status_t) switch_rtp_activate_stun_ping(switch_rtp_t *rtp_session, const char *stun_ip, switch_port_t stun_port,
+ uint32_t packet_count, switch_bool_t funny);
/*!
\}
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Fri Jul 18 16:25:39 2008
@@ -426,6 +426,7 @@
char *record_route;
char *extrtpip;
char *stun_ip;
+ switch_port_t stun_port;
uint32_t stun_flags;
int crypto_tag;
unsigned char local_raw_key[SWITCH_RTP_MAX_CRYPTO_LEN];
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Fri Jul 18 16:25:39 2008
@@ -433,24 +433,38 @@
switch_port_t myport = *port;
const char *var;
int funny = 0;
+ switch_port_t stun_port = SWITCH_STUN_DEFAULT_PORT;
+ char *stun_ip = NULL;
if (!sourceip) {
return status;
}
if (!strncasecmp(sourceip, "stun:", 5)) {
- char *stun_ip = sourceip + 5;
- if (!stun_ip) {
+ char *p;
+ stun_ip = strdup(sourceip + 5);
+
+ if ((p = strchr(stun_ip, ':'))) {
+ int iport;
+ *p++ = '\0';
+ iport = atoi(p);
+ if (iport > 0) {
+ stun_port = iport;
+ }
+ }
+
+ if (switch_strlen_zero(stun_ip)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! NO STUN SERVER\n");
- return status;
+ goto out;
}
+
for (x = 0; x < 5; x++) {
if ((profile->pflags & PFLAG_FUNNY_STUN) ||
(tech_pvt && (var = switch_channel_get_variable(tech_pvt->channel, "funny_stun")) && switch_true(var))) {
error = "funny";
funny++;
}
- if ((status = switch_stun_lookup(ip, port, stun_ip, SWITCH_STUN_DEFAULT_PORT, &error, pool)) != SWITCH_STATUS_SUCCESS) {
+ if ((status = switch_stun_lookup(ip, port, stun_ip, stun_port, &error, pool)) != SWITCH_STATUS_SUCCESS) {
switch_yield(100000);
} else {
break;
@@ -458,18 +472,20 @@
}
if (status != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! %s:%d [%s]\n", stun_ip, SWITCH_STUN_DEFAULT_PORT, error);
- return status;
+ goto out;
}
if (!*ip) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! No IP returned\n");
- return SWITCH_STATUS_FALSE;
+ goto out;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Stun Success [%s]:[%d]\n", *ip, *port);
+ status = SWITCH_STATUS_SUCCESS;
if (tech_pvt) {
if (myport == *port && !strcmp(*ip, tech_pvt->profile->rtpip)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Stun Not Required ip and port match. [%s]:[%d]\n", *ip, *port);
} else {
tech_pvt->stun_ip = switch_core_session_strdup(tech_pvt->session, stun_ip);
+ tech_pvt->stun_port = stun_port;
tech_pvt->stun_flags |= STUN_FLAG_SET;
if (funny) {
tech_pvt->stun_flags |= STUN_FLAG_FUNNY;
@@ -478,8 +494,14 @@
}
} else {
*ip = sourceip;
+ status = SWITCH_STATUS_SUCCESS;
}
- return SWITCH_STATUS_SUCCESS;
+
+ out:
+
+ switch_safe_free(stun_ip);
+
+ return status;
}
@@ -1804,7 +1826,8 @@
if (stun_ping) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setting stun ping to %s:%d\n", tech_pvt->stun_ip, stun_ping);
- switch_rtp_activate_stun_ping(tech_pvt->rtp_session, tech_pvt->stun_ip, stun_ping, (tech_pvt->stun_flags & STUN_FLAG_FUNNY) ? 1 : 0);
+ switch_rtp_activate_stun_ping(tech_pvt->rtp_session, tech_pvt->stun_ip, tech_pvt->stun_port,
+ stun_ping, (tech_pvt->stun_flags & STUN_FLAG_FUNNY) ? 1 : 0);
}
if ((val = switch_channel_get_variable(tech_pvt->channel, "jitterbuffer_msec"))) {
Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c (original)
+++ freeswitch/trunk/src/switch_rtp.c Fri Jul 18 16:25:39 2008
@@ -194,6 +194,7 @@
int reading;
int writing;
char *stun_ip;
+ switch_port_t stun_port;
};
static int global_init = 0;
@@ -890,11 +891,12 @@
rtp_session->cng_pt = pt;
}
-SWITCH_DECLARE(switch_status_t) switch_rtp_activate_stun_ping(switch_rtp_t *rtp_session, const char *stun_ip, uint32_t packet_count, switch_bool_t funny)
+SWITCH_DECLARE(switch_status_t) switch_rtp_activate_stun_ping(switch_rtp_t *rtp_session, const char *stun_ip, switch_port_t stun_port,
+ uint32_t packet_count, switch_bool_t funny)
{
if (switch_sockaddr_info_get(&rtp_session->remote_stun_addr, stun_ip, SWITCH_UNSPEC,
- SWITCH_STUN_DEFAULT_PORT, 0, rtp_session->pool) != SWITCH_STATUS_SUCCESS || !rtp_session->remote_stun_addr) {
+ rtp_session->stun_port, 0, rtp_session->pool) != SWITCH_STATUS_SUCCESS || !rtp_session->remote_stun_addr) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error resolving stun ping addr\n");
return SWITCH_STATUS_FALSE;
@@ -904,6 +906,8 @@
rtp_session->funny_stun++;
}
+ rtp_session->stun_port = stun_port;
+
rtp_session->default_stuncount = packet_count;
rtp_session->stun_ip = switch_core_strdup(rtp_session->pool, stun_ip);
More information about the Freeswitch-svn
mailing list