]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[core] Enable MSRP over IPv6
authorCiprian <ciprian.dosoftei@gmail.com>
Tue, 15 Sep 2020 09:42:22 +0000 (05:42 -0400)
committerGitHub <noreply@github.com>
Tue, 15 Sep 2020 09:42:22 +0000 (13:42 +0400)
* [core] Enable MSRP over IPv6
* [core] SWITCH_SO_IPV6_V6ONLY socket option

src/include/switch_apr.h
src/mod/event_handlers/mod_event_socket/mod_event_socket.c
src/mod/event_handlers/mod_rayo/xmpp_streams.c
src/switch_msrp.c

index 2157007046625bbb5122d855c5ff495e1d74783b..62d207261e79c1874ea1b2a68f64f00760c852d5 100644 (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
index 93514c8c1d1a43e66d91767d2e4ad5874166daff..d60db15112fa107e15ecb2bc991d800710cbd8b9 100644 (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
index fcc3c76213cf06bdcee1882118552b9dd3ef3837..e8e9f6487dd94adbe09393c7ec7af60a41dd3202 100644 (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
index 5eba9e34ecb25e15494fa90c686b6dd3e67f6cda..6a7594587465cd1f2a09dfe17a8d21ebbf8bdd1b 100644 (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;