diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2008-08-01 13:46:08 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2008-08-01 13:46:08 +0000 |
commit | b4d335cb9fc40572efd2414347e586c8590feb4e (patch) | |
tree | e11784d760c918612ca597ab217ffecf7f112aec | |
parent | 7ae8be59fa3a47a3fae0b306bafdb4b13881d7c0 (diff) |
PR#4536: Add socket option IPV6_V6ONLY
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@8968 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | otherlibs/unix/sockopt.c | 9 | ||||
-rw-r--r-- | otherlibs/unix/unix.ml | 1 | ||||
-rw-r--r-- | otherlibs/unix/unix.mli | 1 | ||||
-rw-r--r-- | otherlibs/unix/unixLabels.mli | 1 | ||||
-rw-r--r-- | otherlibs/win32unix/sockopt.c | 10 | ||||
-rw-r--r-- | otherlibs/win32unix/unix.ml | 1 |
6 files changed, 21 insertions, 2 deletions
diff --git a/otherlibs/unix/sockopt.c b/otherlibs/unix/sockopt.c index 217ed3730..3e2645040 100644 --- a/otherlibs/unix/sockopt.c +++ b/otherlibs/unix/sockopt.c @@ -83,6 +83,12 @@ #ifndef SO_ERROR #define SO_ERROR (-1) #endif +#ifndef IPPROTO_IPV6 +#define IPPROTO_IPV6 (-1) +#endif +#ifndef IPV6_V6ONLY +#define IPV6_V6ONLY (-1) +#endif enum option_type { TYPE_BOOL = 0, @@ -107,7 +113,8 @@ static struct socket_option sockopt_bool[] = { { SOL_SOCKET, SO_DONTROUTE }, { SOL_SOCKET, SO_OOBINLINE }, { SOL_SOCKET, SO_ACCEPTCONN }, - { IPPROTO_TCP, TCP_NODELAY } + { IPPROTO_TCP, TCP_NODELAY }, + { IPPROTO_IPV6, IPV6_V6ONLY} }; static struct socket_option sockopt_int[] = { diff --git a/otherlibs/unix/unix.ml b/otherlibs/unix/unix.ml index d4a75a4d0..193071c4a 100644 --- a/otherlibs/unix/unix.ml +++ b/otherlibs/unix/unix.ml @@ -485,6 +485,7 @@ type socket_bool_option = | SO_OOBINLINE | SO_ACCEPTCONN | TCP_NODELAY + | IPV6_ONLY type socket_int_option = SO_SNDBUF diff --git a/otherlibs/unix/unix.mli b/otherlibs/unix/unix.mli index 976cd868b..cf0509ce5 100644 --- a/otherlibs/unix/unix.mli +++ b/otherlibs/unix/unix.mli @@ -997,6 +997,7 @@ type socket_bool_option = | SO_OOBINLINE (** Leave out-of-band data in line *) | SO_ACCEPTCONN (** Report whether socket listening is enabled *) | TCP_NODELAY (** Control the Nagle algorithm for TCP sockets *) + | IPV6_ONLY (** Forbid binding an IPv6 socket to an IPv4 address *) (** The socket options that can be consulted with {!Unix.getsockopt} and modified with {!Unix.setsockopt}. These options have a boolean ([true]/[false]) value. *) diff --git a/otherlibs/unix/unixLabels.mli b/otherlibs/unix/unixLabels.mli index bccc3f5ff..c2295e353 100644 --- a/otherlibs/unix/unixLabels.mli +++ b/otherlibs/unix/unixLabels.mli @@ -1010,6 +1010,7 @@ type socket_bool_option = | SO_OOBINLINE (** Leave out-of-band data in line *) | SO_ACCEPTCONN (** Report whether socket listening is enabled *) | TCP_NODELAY (** Control the Nagle algorithm for TCP sockets *) + | IPV6_ONLY (** Forbid binding an IPv6 socket to an IPv4 address *) (** The socket options that can be consulted with {!UnixLabels.getsockopt} and modified with {!UnixLabels.setsockopt}. These options have a boolean ([true]/[false]) value. *) diff --git a/otherlibs/win32unix/sockopt.c b/otherlibs/win32unix/sockopt.c index 5fab2f6ff..f82d810e6 100644 --- a/otherlibs/win32unix/sockopt.c +++ b/otherlibs/win32unix/sockopt.c @@ -21,6 +21,13 @@ #include "unixsupport.h" #include "socketaddr.h" +#ifndef IPPROTO_IPV6 +#define IPPROTO_IPV6 (-1) +#endif +#ifndef IPV6_V6ONLY +#define IPV6_V6ONLY (-1) +#endif + enum option_type { TYPE_BOOL = 0, TYPE_INT = 1, @@ -44,7 +51,8 @@ static struct socket_option sockopt_bool[] = { { SOL_SOCKET, SO_DONTROUTE }, { SOL_SOCKET, SO_OOBINLINE }, { SOL_SOCKET, SO_ACCEPTCONN }, - { IPPROTO_TCP, TCP_NODELAY } + { IPPROTO_TCP, TCP_NODELAY }, + { IPPROTO_IPV6, IPV6_V6ONLY} }; static struct socket_option sockopt_int[] = { diff --git a/otherlibs/win32unix/unix.ml b/otherlibs/win32unix/unix.ml index 08f48ca98..2b4411659 100644 --- a/otherlibs/win32unix/unix.ml +++ b/otherlibs/win32unix/unix.ml @@ -556,6 +556,7 @@ type socket_bool_option = | SO_OOBINLINE | SO_ACCEPTCONN | TCP_NODELAY + | IPV6_ONLY type socket_int_option = SO_SNDBUF |