From ef6722750b4518fcb29bf983755b5f02451ef224 Mon Sep 17 00:00:00 2001 From: John Denker Date: Tue, 31 Jul 2012 22:34:58 -0700 Subject: a bunch of files added by the ipv6 patch --- ucspi-tcp-0.88/socket_tcp6.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 ucspi-tcp-0.88/socket_tcp6.c (limited to 'ucspi-tcp-0.88/socket_tcp6.c') diff --git a/ucspi-tcp-0.88/socket_tcp6.c b/ucspi-tcp-0.88/socket_tcp6.c new file mode 100644 index 0000000..74099e2 --- /dev/null +++ b/ucspi-tcp-0.88/socket_tcp6.c @@ -0,0 +1,44 @@ +#include +#include +#include +#include +#include +#include "ndelay.h" +#include "socket.h" +#include "haveip6.h" +#include "error.h" + +#ifdef LIBC_HAS_IP6 +int noipv6=0; +#else +int noipv6=1; +#endif + +int socket_tcp6(void) +{ +#ifdef LIBC_HAS_IP6 + int s; + + if (noipv6) goto compat; + s = socket(PF_INET6,SOCK_STREAM,0); + if (s == -1) { + if (errno == EINVAL || errno == EAFNOSUPPORT) { +compat: + s=socket(AF_INET,SOCK_STREAM,0); + noipv6=1; + if (s==-1) return -1; + } else + return -1; + } + if (ndelay_on(s) == -1) { close(s); return -1; } +#ifdef IPV6_V6ONLY + { + int zero=0; + setsockopt(s,IPPROTO_IPV6,IPV6_V6ONLY,(void*)&zero,sizeof(zero)); + } +#endif + return s; +#else + return socket_tcp(); +#endif +} -- cgit v1.2.3