1
0
mirror of https://github.com/coturn/coturn.git synced 2025-10-26 12:31:00 +01:00

optional SCTP support added

This commit is contained in:
mom040267 2015-03-15 06:10:49 +00:00
parent 61239f9aa8
commit 1b279a2a5f
14 changed files with 70 additions and 24 deletions

View File

@ -1,3 +1,7 @@
3/15/2015 Oleg Moskalenko <mom040267@gmail.com>
Version 4.4.3.1 'Ardee West':
- SCTP support compilation option;
2/28/2015 Oleg Moskalenko <mom040267@gmail.com> 2/28/2015 Oleg Moskalenko <mom040267@gmail.com>
Version 4.4.2.3 'Ardee West': Version 4.4.2.3 'Ardee West':
- bandwidth control fixed; - bandwidth control fixed;

12
configure vendored
View File

@ -1157,12 +1157,22 @@ if [ -z "${LDCONFIG}" ] ; then
fi fi
fi fi
###############################
# SCTP
###############################
if [ -z "${TURN_SCTP}" ] ; then
echo "no SCTP support"
else
echo "compiling with native SCTP client-side support (in place of TCP)"
TURN_SCTP="-DTURN_SCTP"
fi
############################### ###############################
# So, what we have now: # So, what we have now:
############################### ###############################
OSCFLAGS="${OSCFLAGS} ${TURN_NO_THREAD_BARRIERS} ${TURN_NO_DTLS} ${TURN_NO_GCM} ${TURN_NO_TLS} -DINSTALL_PREFIX=${PREFIX} -DTURNDB=${TURNDBDIR}/turndb" OSCFLAGS="${OSCFLAGS} ${TURN_SCTP} ${TURN_NO_THREAD_BARRIERS} ${TURN_NO_DTLS} ${TURN_NO_GCM} ${TURN_NO_TLS} -DINSTALL_PREFIX=${PREFIX} -DTURNDB=${TURNDBDIR}/turndb"
if ! [ -z "${TURN_ACCEPT_RPATH}" ] ; then if ! [ -z "${TURN_ACCEPT_RPATH}" ] ; then
if [ -z "${TURN_DISABLE_RPATH}" ] ; then if [ -z "${TURN_DISABLE_RPATH}" ] ; then

View File

@ -2,7 +2,7 @@
# Common settings script. # Common settings script.
TURNVERSION=4.4.2.3 TURNVERSION=4.4.3.1
BUILDDIR=~/rpmbuild BUILDDIR=~/rpmbuild
ARCH=`uname -p` ARCH=`uname -p`
TURNSERVER_SVN_URL=http://coturn.googlecode.com/svn TURNSERVER_SVN_URL=http://coturn.googlecode.com/svn

View File

@ -1,5 +1,5 @@
Name: turnserver Name: turnserver
Version: 4.4.2.3 Version: 4.4.3.1
Release: 0%{dist} Release: 0%{dist}
Summary: Coturn TURN Server Summary: Coturn TURN Server
@ -288,6 +288,8 @@ fi
%{_includedir}/turn/client/TurnMsgLib.h %{_includedir}/turn/client/TurnMsgLib.h
%changelog %changelog
* Sun Mar 15 2015 Oleg Moskalenko <mom040267@gmail.com>
- Sync to 4.4.3.1
* Sat Feb 28 2015 Oleg Moskalenko <mom040267@gmail.com> * Sat Feb 28 2015 Oleg Moskalenko <mom040267@gmail.com>
- Sync to 4.4.2.3 - Sync to 4.4.2.3
* Wed Feb 18 2015 Oleg Moskalenko <mom040267@gmail.com> * Wed Feb 18 2015 Oleg Moskalenko <mom040267@gmail.com>

View File

@ -74,7 +74,7 @@ static int udp_create_server_socket(server_type* server,
if(make_ioa_addr((const u08bits*)local_address, port, server_addr)<0) return -1; if(make_ioa_addr((const u08bits*)local_address, port, server_addr)<0) return -1;
udp_fd = socket(server_addr->ss.sa_family, SOCK_DGRAM, 0); udp_fd = socket(server_addr->ss.sa_family, RELAY_DGRAM_SOCKET_TYPE, RELAY_DGRAM_SOCKET_PROTOCOL);
if (udp_fd < 0) { if (udp_fd < 0) {
perror("socket"); perror("socket");
return -1; return -1;

View File

@ -474,7 +474,7 @@ static int create_new_connected_udp_socket(
dtls_listener_relay_server_type* server, ioa_socket_handle s) dtls_listener_relay_server_type* server, ioa_socket_handle s)
{ {
evutil_socket_t udp_fd = socket(s->local_addr.ss.sa_family, SOCK_DGRAM, 0); evutil_socket_t udp_fd = socket(s->local_addr.ss.sa_family, CLIENT_DGRAM_SOCKET_TYPE, CLIENT_DGRAM_SOCKET_PROTOCOL);
if (udp_fd < 0) { if (udp_fd < 0) {
perror("socket"); perror("socket");
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "%s: Cannot allocate new socket\n", TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "%s: Cannot allocate new socket\n",
@ -751,7 +751,7 @@ static int create_server_socket(dtls_listener_relay_server_type* server, int rep
{ {
ioa_socket_raw udp_listen_fd = -1; ioa_socket_raw udp_listen_fd = -1;
udp_listen_fd = socket(server->addr.ss.sa_family, SOCK_DGRAM, 0); udp_listen_fd = socket(server->addr.ss.sa_family, CLIENT_DGRAM_SOCKET_TYPE, CLIENT_DGRAM_SOCKET_PROTOCOL);
if (udp_listen_fd < 0) { if (udp_listen_fd < 0) {
perror("socket"); perror("socket");
return -1; return -1;
@ -830,7 +830,7 @@ static int reopen_server_socket(dtls_listener_relay_server_type* server, evutil_
return create_server_socket(server,1); return create_server_socket(server,1);
} }
ioa_socket_raw udp_listen_fd = socket(server->addr.ss.sa_family, SOCK_DGRAM, 0); ioa_socket_raw udp_listen_fd = socket(server->addr.ss.sa_family, CLIENT_DGRAM_SOCKET_TYPE, CLIENT_DGRAM_SOCKET_PROTOCOL);
if (udp_listen_fd < 0) { if (udp_listen_fd < 0) {
perror("socket"); perror("socket");
FUNCEND; FUNCEND;

View File

@ -1690,7 +1690,11 @@ static void set_network_engine(void)
turn_params.net_engine_version = NEV_UDP_SOCKET_PER_ENDPOINT; turn_params.net_engine_version = NEV_UDP_SOCKET_PER_ENDPOINT;
#if defined(SO_REUSEPORT) #if defined(SO_REUSEPORT)
#if defined(__linux__) || defined(__LINUX__) || defined(__linux) || defined(linux__) || defined(LINUX) || defined(__LINUX) || defined(LINUX__) #if defined(__linux__) || defined(__LINUX__) || defined(__linux) || defined(linux__) || defined(LINUX) || defined(__LINUX) || defined(LINUX__)
if(CLIENT_STREAM_SOCKET_PROTOCOL == IPPROTO_IP) {
turn_params.net_engine_version = NEV_UDP_SOCKET_PER_THREAD; turn_params.net_engine_version = NEV_UDP_SOCKET_PER_THREAD;
} else {
turn_params.net_engine_version = NEV_UDP_SOCKET_PER_SESSION;
}
#else /* BSD ? */ #else /* BSD ? */
turn_params.net_engine_version = NEV_UDP_SOCKET_PER_SESSION; turn_params.net_engine_version = NEV_UDP_SOCKET_PER_SESSION;
#endif /* Linux */ #endif /* Linux */

View File

@ -892,14 +892,14 @@ int set_socket_options(ioa_socket_handle s)
/* <<== Socket options helpers */ /* <<== Socket options helpers */
ioa_socket_handle create_unbound_ioa_socket(ioa_engine_handle e, int family, SOCKET_TYPE st, SOCKET_APP_TYPE sat) ioa_socket_handle create_unbound_relay_ioa_socket(ioa_engine_handle e, int family, SOCKET_TYPE st, SOCKET_APP_TYPE sat)
{ {
evutil_socket_t fd = -1; evutil_socket_t fd = -1;
ioa_socket_handle ret = NULL; ioa_socket_handle ret = NULL;
switch (st){ switch (st){
case UDP_SOCKET: case UDP_SOCKET:
fd = socket(family, SOCK_DGRAM, 0); fd = socket(family, RELAY_DGRAM_SOCKET_TYPE, RELAY_DGRAM_SOCKET_PROTOCOL);
if (fd < 0) { if (fd < 0) {
perror("UDP socket"); perror("UDP socket");
return NULL; return NULL;
@ -907,7 +907,7 @@ ioa_socket_handle create_unbound_ioa_socket(ioa_engine_handle e, int family, SOC
set_sock_buf_size(fd, UR_CLIENT_SOCK_BUF_SIZE); set_sock_buf_size(fd, UR_CLIENT_SOCK_BUF_SIZE);
break; break;
case TCP_SOCKET: case TCP_SOCKET:
fd = socket(family, SOCK_STREAM, 0); fd = socket(family, RELAY_STREAM_SOCKET_TYPE, RELAY_STREAM_SOCKET_PROTOCOL);
if (fd < 0) { if (fd < 0) {
perror("TCP socket"); perror("TCP socket");
return NULL; return NULL;
@ -1016,7 +1016,7 @@ int create_relay_ioa_sockets(ioa_engine_handle e,
if (port >= 0 && even_port > 0) { if (port >= 0 && even_port > 0) {
IOA_CLOSE_SOCKET(*rtcp_s); IOA_CLOSE_SOCKET(*rtcp_s);
*rtcp_s = create_unbound_ioa_socket(e, relay_addr.ss.sa_family, UDP_SOCKET, RELAY_RTCP_SOCKET); *rtcp_s = create_unbound_relay_ioa_socket(e, relay_addr.ss.sa_family, UDP_SOCKET, RELAY_RTCP_SOCKET);
if (*rtcp_s == NULL) { if (*rtcp_s == NULL) {
perror("socket"); perror("socket");
IOA_CLOSE_SOCKET(*rtp_s); IOA_CLOSE_SOCKET(*rtp_s);
@ -1052,7 +1052,7 @@ int create_relay_ioa_sockets(ioa_engine_handle e,
IOA_CLOSE_SOCKET(*rtp_s); IOA_CLOSE_SOCKET(*rtp_s);
*rtp_s = create_unbound_ioa_socket(e, relay_addr.ss.sa_family, *rtp_s = create_unbound_relay_ioa_socket(e, relay_addr.ss.sa_family,
(transport == STUN_ATTRIBUTE_TRANSPORT_TCP_VALUE) ? TCP_SOCKET : UDP_SOCKET, (transport == STUN_ATTRIBUTE_TRANSPORT_TCP_VALUE) ? TCP_SOCKET : UDP_SOCKET,
RELAY_SOCKET); RELAY_SOCKET);
if (*rtp_s == NULL) { if (*rtp_s == NULL) {
@ -1224,7 +1224,7 @@ static void connect_eventcb(struct bufferevent *bev, short events, void *ptr)
ioa_socket_handle ioa_create_connecting_tcp_relay_socket(ioa_socket_handle s, ioa_addr *peer_addr, connect_cb cb, void *arg) ioa_socket_handle ioa_create_connecting_tcp_relay_socket(ioa_socket_handle s, ioa_addr *peer_addr, connect_cb cb, void *arg)
{ {
ioa_socket_handle ret = create_unbound_ioa_socket(s->e, s->family, s->st, TCP_RELAY_DATA_SOCKET); ioa_socket_handle ret = create_unbound_relay_ioa_socket(s->e, s->family, s->st, TCP_RELAY_DATA_SOCKET);
if(!ret) { if(!ret) {
return NULL; return NULL;
@ -1590,7 +1590,7 @@ ioa_socket_handle detach_ioa_socket(ioa_socket_handle s)
evutil_socket_t udp_fd = -1; evutil_socket_t udp_fd = -1;
if(s->parent_s) { if(s->parent_s) {
udp_fd = socket(s->local_addr.ss.sa_family, SOCK_DGRAM, 0); udp_fd = socket(s->local_addr.ss.sa_family, CLIENT_DGRAM_SOCKET_TYPE, CLIENT_DGRAM_SOCKET_PROTOCOL);
if (udp_fd < 0) { if (udp_fd < 0) {
perror("socket"); perror("socket");
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"%s: Cannot allocate new socket\n",__FUNCTION__); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"%s: Cannot allocate new socket\n",__FUNCTION__);

View File

@ -130,7 +130,7 @@ static int create_server_listener(tls_listener_relay_server_type* server) {
evutil_socket_t tls_listen_fd = -1; evutil_socket_t tls_listen_fd = -1;
tls_listen_fd = socket(server->addr.ss.sa_family, SOCK_STREAM, 0); tls_listen_fd = socket(server->addr.ss.sa_family, CLIENT_STREAM_SOCKET_TYPE, CLIENT_STREAM_SOCKET_PROTOCOL);
if (tls_listen_fd < 0) { if (tls_listen_fd < 0) {
perror("socket"); perror("socket");
return -1; return -1;

View File

@ -1263,7 +1263,7 @@ void setup_admin_thread(void)
addr_set_port(&cli_addr,cli_port); addr_set_port(&cli_addr,cli_port);
adminserver.listen_fd = socket(cli_addr.ss.sa_family, SOCK_STREAM, 0); adminserver.listen_fd = socket(cli_addr.ss.sa_family, ADMIN_STREAM_SOCKET_TYPE, ADMIN_STREAM_SOCKET_PROTOCOL);
if (adminserver.listen_fd < 0) { if (adminserver.listen_fd < 0) {
perror("socket"); perror("socket");
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot open CLI socket\n"); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot open CLI socket\n");

View File

@ -258,7 +258,7 @@ static int run_stunclient(const char* rip, int rport, int *port, int *rfc5780, i
err(-1, NULL); err(-1, NULL);
if (udp_fd < 0) { if (udp_fd < 0) {
udp_fd = socket(remote_addr.ss.sa_family, SOCK_DGRAM, 0); udp_fd = socket(remote_addr.ss.sa_family, CLIENT_DGRAM_SOCKET_TYPE, CLIENT_DGRAM_SOCKET_PROTOCOL);
if (udp_fd < 0) if (udp_fd < 0)
err(-1, NULL); err(-1, NULL);
@ -270,7 +270,7 @@ static int run_stunclient(const char* rip, int rport, int *port, int *rfc5780, i
if (response_port >= 0) { if (response_port >= 0) {
new_udp_fd = socket(remote_addr.ss.sa_family, SOCK_DGRAM, 0); new_udp_fd = socket(remote_addr.ss.sa_family, CLIENT_DGRAM_SOCKET_TYPE, CLIENT_DGRAM_SOCKET_PROTOCOL);
if (new_udp_fd < 0) if (new_udp_fd < 0)
err(-1, NULL); err(-1, NULL);

View File

@ -229,7 +229,9 @@ static int clnet_connect(uint16_t clnet_remote_port, const char *remote_address,
ns_bzero(&local_addr, sizeof(ioa_addr)); ns_bzero(&local_addr, sizeof(ioa_addr));
clnet_fd = socket(remote_addr.ss.sa_family, use_tcp ? SOCK_STREAM : SOCK_DGRAM, 0); clnet_fd = socket(remote_addr.ss.sa_family,
use_tcp ? CLIENT_STREAM_SOCKET_TYPE : CLIENT_DGRAM_SOCKET_TYPE,
use_tcp ? CLIENT_STREAM_SOCKET_PROTOCOL : CLIENT_DGRAM_SOCKET_PROTOCOL);
if (clnet_fd < 0) { if (clnet_fd < 0) {
perror("socket"); perror("socket");
exit(-1); exit(-1);
@ -1570,7 +1572,7 @@ void tcp_data_connect(app_ur_session *elem, u32bits cid)
again: again:
clnet_fd = socket(elem->pinfo.remote_addr.ss.sa_family, SOCK_STREAM, 0); clnet_fd = socket(elem->pinfo.remote_addr.ss.sa_family, CLIENT_STREAM_SOCKET_TYPE, CLIENT_STREAM_SOCKET_PROTOCOL);
if (clnet_fd < 0) { if (clnet_fd < 0) {
perror("socket"); perror("socket");
exit(-1); exit(-1);
@ -1606,7 +1608,7 @@ void tcp_data_connect(app_ur_session *elem, u32bits cid)
if (addr_connect(clnet_fd, &(elem->pinfo.remote_addr),&err) < 0) { if (addr_connect(clnet_fd, &(elem->pinfo.remote_addr),&err) < 0) {
if(err == EADDRINUSE) { if(err == EADDRINUSE) {
socket_closesocket(clnet_fd); socket_closesocket(clnet_fd);
clnet_fd = socket(elem->pinfo.remote_addr.ss.sa_family, SOCK_STREAM, 0); clnet_fd = socket(elem->pinfo.remote_addr.ss.sa_family, CLIENT_STREAM_SOCKET_TYPE, CLIENT_STREAM_SOCKET_PROTOCOL);
if (clnet_fd < 0) { if (clnet_fd < 0) {
perror("socket"); perror("socket");
exit(-1); exit(-1);

View File

@ -31,7 +31,7 @@
#ifndef __IOADEFS__ #ifndef __IOADEFS__
#define __IOADEFS__ #define __IOADEFS__
#define TURN_SERVER_VERSION "4.4.2.3" #define TURN_SERVER_VERSION "4.4.3.1"
#define TURN_SERVER_VERSION_NAME "Ardee West" #define TURN_SERVER_VERSION_NAME "Ardee West"
#define TURN_SOFTWARE "Coturn-" TURN_SERVER_VERSION " '" TURN_SERVER_VERSION_NAME "'" #define TURN_SOFTWARE "Coturn-" TURN_SERVER_VERSION " '" TURN_SERVER_VERSION_NAME "'"
@ -218,6 +218,30 @@ typedef u32bits turn_time_t;
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
//#define DGRAM_SOCKET_TYPE SOCK_SEQPACKET
//#define DGRAM_SOCKET_PROTOCOL IPPROTO_SCTP
#define CLIENT_DGRAM_SOCKET_TYPE SOCK_DGRAM
#define CLIENT_DGRAM_SOCKET_PROTOCOL IPPROTO_IP
#define CLIENT_STREAM_SOCKET_TYPE SOCK_STREAM
#if defined(TURN_SCTP)
#define CLIENT_STREAM_SOCKET_PROTOCOL IPPROTO_SCTP
#else
#define CLIENT_STREAM_SOCKET_PROTOCOL IPPROTO_IP
#endif
#define RELAY_DGRAM_SOCKET_TYPE SOCK_DGRAM
#define RELAY_DGRAM_SOCKET_PROTOCOL IPPROTO_IP
#define RELAY_STREAM_SOCKET_TYPE SOCK_STREAM
#define RELAY_STREAM_SOCKET_PROTOCOL IPPROTO_IP
#define ADMIN_STREAM_SOCKET_TYPE SOCK_STREAM
#define ADMIN_STREAM_SOCKET_PROTOCOL IPPROTO_IP
////////////////////////////////////////////////////////
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -206,7 +206,7 @@ void stop_ioa_timer(ioa_timer_handle th);
void delete_ioa_timer(ioa_timer_handle th); void delete_ioa_timer(ioa_timer_handle th);
#define IOA_EVENT_DEL(E) do { if(E) { delete_ioa_timer(E); E = NULL; } } while(0) #define IOA_EVENT_DEL(E) do { if(E) { delete_ioa_timer(E); E = NULL; } } while(0)
ioa_socket_handle create_unbound_ioa_socket(ioa_engine_handle e, int family, SOCKET_TYPE st, SOCKET_APP_TYPE sat); ioa_socket_handle create_unbound_relay_ioa_socket(ioa_engine_handle e, int family, SOCKET_TYPE st, SOCKET_APP_TYPE sat);
void inc_ioa_socket_ref_counter(ioa_socket_handle s); void inc_ioa_socket_ref_counter(ioa_socket_handle s);