Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat/linux/common Add basic IPV6 level socket options ...



details:   https://anonhg.NetBSD.org/src/rev/7668bd7ff299
branches:  trunk
changeset: 793116:7668bd7ff299
user:      njoly <njoly%NetBSD.org@localhost>
date:      Mon Jan 27 19:19:15 2014 +0000

description:
Add basic IPV6 level socket options support (IPV6_V6ONLY).

diffstat:

 sys/compat/linux/common/linux_socket.c |  36 ++++++++++++++++++++++++++++++++-
 sys/compat/linux/common/linux_socket.h |  10 +++++++-
 2 files changed, 42 insertions(+), 4 deletions(-)

diffs (117 lines):

diff -r c538c03ab261 -r 7668bd7ff299 sys/compat/linux/common/linux_socket.c
--- a/sys/compat/linux/common/linux_socket.c    Mon Jan 27 18:43:07 2014 +0000
+++ b/sys/compat/linux/common/linux_socket.c    Mon Jan 27 19:19:15 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_socket.c,v 1.116 2014/01/27 13:23:33 njoly Exp $ */
+/*     $NetBSD: linux_socket.c,v 1.117 2014/01/27 19:19:15 njoly Exp $ */
 
 /*-
  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.116 2014/01/27 13:23:33 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.117 2014/01/27 19:19:15 njoly Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -114,6 +114,7 @@
 int linux_to_bsd_sopt_level(int);
 int linux_to_bsd_so_sockopt(int);
 int linux_to_bsd_ip_sockopt(int);
+int linux_to_bsd_ipv6_sockopt(int);
 int linux_to_bsd_tcp_sockopt(int);
 int linux_to_bsd_udp_sockopt(int);
 int linux_getifname(struct lwp *, register_t *, void *);
@@ -833,6 +834,10 @@
                return SOL_SOCKET;
        case LINUX_SOL_IP:
                return IPPROTO_IP;
+#ifdef INET6
+       case LINUX_SOL_IPV6:
+               return IPPROTO_IPV6;
+#endif
        case LINUX_SOL_TCP:
                return IPPROTO_TCP;
        case LINUX_SOL_UDP:
@@ -922,6 +927,23 @@
 }
 
 /*
+ * Convert Linux IPV6 level socket option number to NetBSD values.
+ */
+#ifdef INET6
+int
+linux_to_bsd_ipv6_sockopt(int lopt)
+{
+
+       switch (lopt) {
+       case LINUX_IPV6_V6ONLY:
+               return IPV6_V6ONLY;
+       default:
+               return -1;
+       }
+}
+#endif
+
+/*
  * Convert Linux TCP level socket option number to NetBSD values.
  */
 int
@@ -1000,6 +1022,11 @@
        case IPPROTO_IP:
                name = linux_to_bsd_ip_sockopt(SCARG(uap, optname));
                break;
+#ifdef INET6
+       case IPPROTO_IPV6:
+               name = linux_to_bsd_ipv6_sockopt(SCARG(uap, optname));
+               break;
+#endif
        case IPPROTO_TCP:
                name = linux_to_bsd_tcp_sockopt(SCARG(uap, optname));
                break;
@@ -1045,6 +1072,11 @@
        case IPPROTO_IP:
                name = linux_to_bsd_ip_sockopt(SCARG(uap, optname));
                break;
+#ifdef INET6
+       case IPPROTO_IPV6:
+               name = linux_to_bsd_ipv6_sockopt(SCARG(uap, optname));
+               break;
+#endif
        case IPPROTO_TCP:
                name = linux_to_bsd_tcp_sockopt(SCARG(uap, optname));
                break;
diff -r c538c03ab261 -r 7668bd7ff299 sys/compat/linux/common/linux_socket.h
--- a/sys/compat/linux/common/linux_socket.h    Mon Jan 27 18:43:07 2014 +0000
+++ b/sys/compat/linux/common/linux_socket.h    Mon Jan 27 19:19:15 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_socket.h,v 1.21 2011/06/30 20:09:39 wiz Exp $    */
+/*     $NetBSD: linux_socket.h,v 1.22 2014/01/27 19:19:15 njoly Exp $  */
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -78,8 +78,8 @@
 #define LINUX_SOL_IP           0
 #define LINUX_SOL_TCP          6
 #define LINUX_SOL_UDP          17
+#define LINUX_SOL_IPV6         41
 /* Unused for now: */
-#define LINUX_SOL_IPV6         41
 #define LINUX_SOL_ICMPV6       58
 #define LINUX_SOL_RAW          255
 #define LINUX_SOL_IPX          256
@@ -111,6 +111,12 @@
 #define        LINUX_IP_DROP_MEMBERSHIP 36
 
 /*
+ * Options for [gs]etsockopt(2), IPV6 level.
+ */
+
+#define LINUX_IPV6_V6ONLY              26
+
+/*
  * Options for [gs]etsockopt(2), TCP level.
  */
 



Home | Main Index | Thread Index | Old Index