summaryrefslogtreecommitdiff
path: root/ucspi-tcp-0.88/socket_udp6.c
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-07-31 22:34:58 -0700
committerJohn Denker <jsd@av8n.com>2012-07-31 22:36:28 -0700
commitef6722750b4518fcb29bf983755b5f02451ef224 (patch)
tree966e94ffd01cd8abb59e16a6992e142db345aa9f /ucspi-tcp-0.88/socket_udp6.c
parentb95f5ec1d83519c603f6e2145865c14932c4a813 (diff)
a bunch of files added by the ipv6 patch
Diffstat (limited to 'ucspi-tcp-0.88/socket_udp6.c')
-rw-r--r--ucspi-tcp-0.88/socket_udp6.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/ucspi-tcp-0.88/socket_udp6.c b/ucspi-tcp-0.88/socket_udp6.c
new file mode 100644
index 0000000..3769b1d
--- /dev/null
+++ b/ucspi-tcp-0.88/socket_udp6.c
@@ -0,0 +1,38 @@
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <errno.h>
+#include "haveip6.h"
+#include "socket.h"
+
+#ifndef EAFNOSUPPORT
+#define EAFNOSUPPORT EINVAL
+#endif
+
+int socket_udp6(void)
+{
+#ifdef LIBC_HAS_IP6
+ int s;
+
+ if (noipv6) goto compat;
+ s = socket(PF_INET6,SOCK_DGRAM,0);
+ if (s == -1) {
+ if (errno == EINVAL || errno == EAFNOSUPPORT) {
+compat:
+ s=socket(AF_INET,SOCK_DGRAM,0);
+ noipv6=1;
+ if (s==-1) return -1;
+ } else
+ return -1;
+ }
+#ifdef IPV6_V6ONLY
+ {
+ int zero=0;
+ setsockopt(s,IPPROTO_IPV6,IPV6_V6ONLY,(void*)&zero,sizeof(zero));
+ }
+#endif
+ return s;
+#else
+ return socket_udp();
+#endif
+}