hack to fix udp sockets
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3377 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
dd824bbf81
commit
f8d3093f5c
|
@ -649,7 +649,7 @@ DoxyDefine(apr_status_t switch_socket_sendto(switcj_socket_t *sock,
|
||||||
* @param flags The flags to use
|
* @param flags The flags to use
|
||||||
* @param buf The buffer to use
|
* @param buf The buffer to use
|
||||||
* @param len The length of the available buffer
|
* @param len The length of the available buffer
|
||||||
*/
|
*
|
||||||
|
|
||||||
DoxyDefine(apr_status_t switch_socket_recvfrom(switch_sockaddr_t *from,
|
DoxyDefine(apr_status_t switch_socket_recvfrom(switch_sockaddr_t *from,
|
||||||
switch_socket_t *sock,
|
switch_socket_t *sock,
|
||||||
|
@ -657,6 +657,7 @@ DoxyDefine(apr_status_t switch_socket_recvfrom(switch_sockaddr_t *from,
|
||||||
char *buf,
|
char *buf,
|
||||||
apr_size_t *len);)
|
apr_size_t *len);)
|
||||||
#define switch_socket_recvfrom apr_socket_recvfrom
|
#define switch_socket_recvfrom apr_socket_recvfrom
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a file from an open file descriptor to a socket, along with
|
* Send a file from an open file descriptor to a socket, along with
|
||||||
|
|
|
@ -54,6 +54,11 @@ SWITCH_BEGIN_EXTERN_C
|
||||||
#define SWITCH_SMIN -32768
|
#define SWITCH_SMIN -32768
|
||||||
#define switch_normalize_to_16bit(n) if (n > SWITCH_SMAX) n = SWITCH_SMAX / 2; else if (n < SWITCH_SMIN) n = SWITCH_SMIN / 2;
|
#define switch_normalize_to_16bit(n) if (n > SWITCH_SMAX) n = SWITCH_SMAX / 2; else if (n < SWITCH_SMIN) n = SWITCH_SMIN / 2;
|
||||||
|
|
||||||
|
SWITCH_DECLARE(char *) switch_get_addr(char *buf, switch_size_t len, switch_sockaddr_t *in);
|
||||||
|
|
||||||
|
SWITCH_DECLARE(apr_status_t) switch_socket_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock,
|
||||||
|
apr_int32_t flags, char *buf,
|
||||||
|
apr_size_t *len);
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -272,14 +272,18 @@ static void handle_ice(switch_rtp_t *rtp_session, void *data, switch_size_t len)
|
||||||
switch_stun_packet_t *rpacket;
|
switch_stun_packet_t *rpacket;
|
||||||
char *remote_ip;
|
char *remote_ip;
|
||||||
switch_size_t bytes;
|
switch_size_t bytes;
|
||||||
|
char ipbuf[25];
|
||||||
|
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
rpacket = switch_stun_packet_build_header(SWITCH_STUN_BINDING_RESPONSE, packet->header.id, buf);
|
rpacket = switch_stun_packet_build_header(SWITCH_STUN_BINDING_RESPONSE, packet->header.id, buf);
|
||||||
switch_stun_packet_attribute_add_username(rpacket, username, 32);
|
switch_stun_packet_attribute_add_username(rpacket, username, 32);
|
||||||
switch_sockaddr_ip_get(&remote_ip, rtp_session->from_addr);
|
//switch_sockaddr_ip_get(&remote_ip, rtp_session->from_addr);
|
||||||
|
|
||||||
|
remote_ip = switch_get_addr(ipbuf, sizeof(ipbuf), rtp_session->from_addr);
|
||||||
|
|
||||||
|
|
||||||
switch_stun_packet_attribute_add_binded_address(rpacket, remote_ip, rtp_session->from_addr->port);
|
switch_stun_packet_attribute_add_binded_address(rpacket, remote_ip, rtp_session->from_addr->port);
|
||||||
bytes = switch_stun_packet_length(rpacket);
|
bytes = switch_stun_packet_length(rpacket);
|
||||||
|
|
||||||
switch_socket_sendto(rtp_session->sock, rtp_session->from_addr, 0, (void*)rpacket, &bytes);
|
switch_socket_sendto(rtp_session->sock, rtp_session->from_addr, 0, (void*)rpacket, &bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -866,9 +870,14 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
|
||||||
char *tx_host;
|
char *tx_host;
|
||||||
uint32_t old = rtp_session->remote_port;
|
uint32_t old = rtp_session->remote_port;
|
||||||
char *old_host;
|
char *old_host;
|
||||||
|
char bufa[30], bufb[30];
|
||||||
switch_sockaddr_ip_get(&tx_host, rtp_session->from_addr);
|
|
||||||
switch_sockaddr_ip_get(&old_host, rtp_session->remote_addr);
|
//switch_sockaddr_ip_get(&tx_host, rtp_session->from_addr);
|
||||||
|
//switch_sockaddr_ip_get(&old_host, rtp_session->remote_addr);
|
||||||
|
|
||||||
|
tx_host = switch_get_addr(bufa, sizeof(bufa), rtp_session->from_addr);
|
||||||
|
old_host = switch_get_addr(bufb, sizeof(bufb), rtp_session->remote_addr);
|
||||||
|
|
||||||
if (!switch_strlen_zero(tx_host) && rtp_session->from_addr->port > 0) {
|
if (!switch_strlen_zero(tx_host) && rtp_session->from_addr->port > 0) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Auto Changing port from %s:%u to %s:%u\n",
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Auto Changing port from %s:%u to %s:%u\n",
|
||||||
old_host, old, tx_host, rtp_session->from_addr->port);
|
old_host, old, tx_host, rtp_session->from_addr->port);
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
SWITCH_DECLARE(char *) switch_priority_name(switch_priority_t priority)
|
SWITCH_DECLARE(char *) switch_priority_name(switch_priority_t priority)
|
||||||
{
|
{
|
||||||
switch(priority) { /*lol*/
|
switch(priority) { /*lol*/
|
||||||
|
@ -50,6 +51,40 @@ SWITCH_DECLARE(char *) switch_priority_name(switch_priority_t priority)
|
||||||
|
|
||||||
static char RFC2833_CHARS[] = "0123456789*#ABCDF";
|
static char RFC2833_CHARS[] = "0123456789*#ABCDF";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SWITCH_DECLARE(char *) switch_get_addr(char *buf, switch_size_t len, switch_sockaddr_t *in)
|
||||||
|
{
|
||||||
|
uint8_t x, *i;
|
||||||
|
char *p = buf;
|
||||||
|
|
||||||
|
|
||||||
|
i = (uint8_t *) &in->sa.sin.sin_addr;
|
||||||
|
|
||||||
|
memset(buf, 0, len);
|
||||||
|
for(x =0; x < 4; x++) {
|
||||||
|
sprintf(p, "%u%s", i[x], x == 3 ? "" : ".");
|
||||||
|
p = buf + strlen(buf);
|
||||||
|
}
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
SWITCH_DECLARE(apr_status_t) switch_socket_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock,
|
||||||
|
apr_int32_t flags, char *buf,
|
||||||
|
apr_size_t *len)
|
||||||
|
{
|
||||||
|
apr_status_t r;
|
||||||
|
|
||||||
|
if ((r = apr_socket_recvfrom(from, sock, flags, buf, len)) == APR_SUCCESS) {
|
||||||
|
from->port = ntohs(from->sa.sin.sin_port);
|
||||||
|
//from->ipaddr_ptr = &(from->sa.sin.sin_addr);
|
||||||
|
//from->ipaddr_ptr = inet_ntoa(from->sa.sin.sin_addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(char) switch_rfc2833_to_char(int event)
|
SWITCH_DECLARE(char) switch_rfc2833_to_char(int event)
|
||||||
{
|
{
|
||||||
if (event > -1 && event < (int32_t) sizeof(RFC2833_CHARS)) {
|
if (event > -1 && event < (int32_t) sizeof(RFC2833_CHARS)) {
|
||||||
|
|
Loading…
Reference in New Issue