[core] Enable MSRP over IPv6

* [core] Enable MSRP over IPv6
* [core] SWITCH_SO_IPV6_V6ONLY socket option
This commit is contained in:
Ciprian 2020-09-15 05:42:22 -04:00 committed by GitHub
parent 301f113037
commit 5ce4855a1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 5 deletions

View File

@ -990,7 +990,7 @@ SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t ** new_thre
#define SWITCH_SO_TCP_NODELAY 512
#define SWITCH_SO_TCP_KEEPIDLE 520
#define SWITCH_SO_TCP_KEEPINTVL 530
#define SWITCH_SO_IPV6_V6ONLY 16384 /* Don't accept IPv4 connections on an IPv6 listening socket. */
/**
* @def SWITCH_INET

View File

@ -2971,7 +2971,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_event_socket_runtime)
#ifdef WIN32
/* Enable dual-stack listening on Windows (if the listening address is IPv6), it's default on Linux */
if (switch_sockaddr_get_family(sa) == AF_INET6) {
rv = switch_socket_opt_set(listen_list.sock, 16384, 0);
rv = switch_socket_opt_set(listen_list.sock, SWITCH_SO_IPV6_V6ONLY, 0);
if (rv) goto sock_fail;
}
#endif

View File

@ -1539,7 +1539,7 @@ static void *SWITCH_THREAD_FUNC xmpp_listener_thread(switch_thread_t *thread, vo
#ifdef WIN32
/* Enable dual-stack listening on Windows (if the listening address is IPv6), it's default on Linux */
if (switch_sockaddr_get_family(sa) == AF_INET6) {
rv = switch_socket_opt_set(listener->socket, 16384, 0);
rv = switch_socket_opt_set(listener->socket, SWITCH_SO_IPV6_V6ONLY, 0);
if (rv) goto sock_fail;
}
#endif

View File

@ -252,8 +252,11 @@ static switch_status_t msock_init(char *ip, switch_port_t port, switch_socket_t
switch_sockaddr_t *sa;
switch_status_t rv;
rv = switch_sockaddr_info_get(&sa, ip, SWITCH_INET, port, 0, pool);
if (rv) goto sock_fail;
rv = switch_sockaddr_info_get(&sa, ip, SWITCH_UNSPEC, port, 0, pool);
if (rv) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot get information about MSRP listen IP address %s\n", ip);
goto sock_fail;
}
rv = switch_socket_create(sock, switch_sockaddr_get_family(sa), SOCK_STREAM, SWITCH_PROTO_TCP, pool);
if (rv) goto sock_fail;
@ -261,6 +264,14 @@ static switch_status_t msock_init(char *ip, switch_port_t port, switch_socket_t
rv = switch_socket_opt_set(*sock, SWITCH_SO_REUSEADDR, 1);
if (rv) goto sock_fail;
#ifdef WIN32
/* Enable dual-stack listening on Windows */
if (switch_sockaddr_get_family(sa) == AF_INET6) {
rv = switch_socket_opt_set(*sock, SWITCH_SO_IPV6_V6ONLY, 0);
if (rv) goto sock_fail;
}
#endif
rv = switch_socket_bind(*sock, sa);
if (rv) goto sock_fail;