update
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9096 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
047e3dd7ae
commit
8639738e4b
|
@ -418,7 +418,8 @@ SWITCH_DECLARE(void) switch_rtp_set_cng_pt(switch_rtp_t *rtp_session, switch_pay
|
|||
*/
|
||||
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);
|
||||
|
||||
/*!
|
||||
\}
|
||||
|
|
|
@ -426,6 +426,7 @@ struct private_object {
|
|||
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];
|
||||
|
|
|
@ -433,24 +433,38 @@ switch_status_t sofia_glue_ext_address_lookup(sofia_profile_t *profile, private_
|
|||
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) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! NO STUN SERVER\n");
|
||||
return status;
|
||||
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");
|
||||
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 @@ switch_status_t sofia_glue_ext_address_lookup(sofia_profile_t *profile, private_
|
|||
}
|
||||
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 @@ switch_status_t sofia_glue_ext_address_lookup(sofia_profile_t *profile, private_
|
|||
}
|
||||
} else {
|
||||
*ip = sourceip;
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
out:
|
||||
|
||||
switch_safe_free(stun_ip);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1804,7 +1826,8 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
|
|||
|
||||
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"))) {
|
||||
|
|
|
@ -194,6 +194,7 @@ struct switch_rtp {
|
|||
int reading;
|
||||
int writing;
|
||||
char *stun_ip;
|
||||
switch_port_t stun_port;
|
||||
};
|
||||
|
||||
static int global_init = 0;
|
||||
|
@ -890,11 +891,12 @@ SWITCH_DECLARE(void) switch_rtp_set_cng_pt(switch_rtp_t *rtp_session, switch_pay
|
|||
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 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_stun_ping(switch_rtp_t *rtp_
|
|||
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);
|
||||
|
|
Loading…
Reference in New Issue