Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/netbsd32 Define 32bit version of SIOC[GS]IFADDRPR...



details:   https://anonhg.NetBSD.org/src/rev/073d8fdf1ac5
branches:  trunk
changeset: 761553:073d8fdf1ac5
user:      matt <matt%NetBSD.org@localhost>
date:      Tue Feb 01 00:53:22 2011 +0000

description:
Define 32bit version of SIOC[GS]IFADDRPREF32.  We wouldn't need this to
if i386 actually aligned a uint64_t on a 64bit boundary but it doesn't.
So all that work in sockaddr_storage goes for naught.

diffstat:

 sys/compat/netbsd32/netbsd32_ioctl.c |  35 +++++++++++++++++++++++++++++++++--
 sys/compat/netbsd32/netbsd32_ioctl.h |  18 +++++++++++++++++-
 2 files changed, 50 insertions(+), 3 deletions(-)

diffs (123 lines):

diff -r 21d4835113aa -r 073d8fdf1ac5 sys/compat/netbsd32/netbsd32_ioctl.c
--- a/sys/compat/netbsd32/netbsd32_ioctl.c      Mon Jan 31 23:56:14 2011 +0000
+++ b/sys/compat/netbsd32/netbsd32_ioctl.c      Tue Feb 01 00:53:22 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_ioctl.c,v 1.53 2011/01/22 20:51:21 matt Exp $ */
+/*     $NetBSD: netbsd32_ioctl.c,v 1.54 2011/02/01 00:53:22 matt Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.53 2011/01/22 20:51:21 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.54 2011/02/01 00:53:22 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -85,6 +85,8 @@
                                       u_long cmd);
 static inline void netbsd32_to_ifreq(struct netbsd32_ifreq *, struct ifreq *,
                                       u_long cmd);
+static inline void netbsd32_to_if_addrprefreq(
+    const struct netbsd32_if_addrprefreq *, struct if_addrprefreq *, u_long);
 static inline void netbsd32_to_ifconf(struct netbsd32_ifconf *,
                                        struct ifconf *, u_long);
 static inline void netbsd32_to_ifmediareq(struct netbsd32_ifmediareq *,
@@ -102,6 +104,9 @@
                                             struct netbsd32_format_op *,
                                             u_long);
 #endif
+static inline void netbsd32_from_if_addrprefreq(const struct if_addrprefreq *,
+                                       struct netbsd32_if_addrprefreq *,
+                                       u_long);
 static inline void netbsd32_from_ifreq(struct ifreq *,
                                          struct netbsd32_ifreq *, u_long);
 static inline void netbsd32_from_oifreq(struct oifreq *,
@@ -173,6 +178,16 @@
 }
 
 static inline void
+netbsd32_to_if_addrprefreq(const struct netbsd32_if_addrprefreq *ifap32,
+       struct if_addrprefreq *ifap, u_long cmd)
+{
+       strlcpy(ifap->ifap_name, ifap32->ifap_name, sizeof(ifap->ifap_name));
+       ifap->ifap_preference = ifap32->ifap_preference;
+       memcpy(&ifap->ifap_addr, &ifap32->ifap_addr,
+           max(ifap32->ifap_addr.ss_len, _SS_MAXSIZE));
+}
+
+static inline void
 netbsd32_to_ifconf(struct netbsd32_ifconf *s32p, struct ifconf *p, u_long cmd)
 {
 
@@ -322,6 +337,16 @@
 }
 
 static inline void
+netbsd32_from_if_addrprefreq(const struct if_addrprefreq *ifap,
+       struct netbsd32_if_addrprefreq *ifap32, u_long cmd)
+{
+       strlcpy(ifap32->ifap_name, ifap->ifap_name, sizeof(ifap32->ifap_name));
+       ifap32->ifap_preference = ifap->ifap_preference;
+       memcpy(&ifap32->ifap_addr, &ifap->ifap_addr,
+           max(ifap->ifap_addr.ss_len, _SS_MAXSIZE));
+}
+
+static inline void
 netbsd32_from_ifconf(struct ifconf *p, struct netbsd32_ifconf *s32p, u_long cmd)
 {
 
@@ -674,6 +699,12 @@
        case SIOCSIFFLAGS32:
                IOCTL_STRUCT_CONV_TO(SIOCSIFFLAGS, ifreq);
 
+       case SIOCGIFADDRPREF32:
+               IOCTL_STRUCT_CONV_TO(SIOCGIFADDRPREF, if_addrprefreq);
+       case SIOCSIFADDRPREF32:
+               IOCTL_STRUCT_CONV_TO(SIOCSIFADDRPREF, if_addrprefreq);
+
+
        case OSIOCGIFFLAGS32:
                IOCTL_STRUCT_CONV_TO(OSIOCGIFFLAGS, oifreq);
        case OSIOCSIFFLAGS32:
diff -r 21d4835113aa -r 073d8fdf1ac5 sys/compat/netbsd32/netbsd32_ioctl.h
--- a/sys/compat/netbsd32/netbsd32_ioctl.h      Mon Jan 31 23:56:14 2011 +0000
+++ b/sys/compat/netbsd32/netbsd32_ioctl.h      Tue Feb 01 00:53:22 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_ioctl.h,v 1.29 2010/09/24 13:12:53 njoly Exp $        */
+/*     $NetBSD: netbsd32_ioctl.h,v 1.30 2011/02/01 00:53:22 matt Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -208,6 +208,19 @@
                } ifru_b;
        } ifr_ifru;
 };
+
+struct netbsd32_if_addrprefreq {
+       char                    ifap_name[IFNAMSIZ];
+       uint16_t                ifap_preference;
+       struct {
+               __uint8_t       ss_len;         /* address length */
+               sa_family_t     ss_family;      /* address family */
+               char            __ss_pad1[_SS_PAD1SIZE];
+               __int32_t       __ss_align[2];
+               char            __ss_pad2[_SS_PAD2SIZE];
+       } ifap_addr;
+};
+
 /* from <dev/pci/if_devar.h> */
 #define        SIOCGADDRROM32          _IOW('i', 240, struct netbsd32_ifreq)   /* get 128 bytes of ROM */
 #define        SIOCGCHIPID32           _IOWR('i', 241, struct netbsd32_ifreq)  /* get chipid */
@@ -257,6 +270,9 @@
 #define        SIOCDIFADDR32    _IOW('i', 25, struct netbsd32_ifreq)   /* delete IF addr */
 #define        OSIOCDIFADDR32   _IOW('i', 25, struct netbsd32_oifreq)  /* delete IF addr */
 
+#define SIOCSIFADDRPREF32       _IOW('i', 31, struct netbsd32_if_addrprefreq)
+#define SIOCGIFADDRPREF32      _IOWR('i', 32, struct netbsd32_if_addrprefreq)
+
 #define        SIOCADDMULTI32   _IOW('i', 49, struct netbsd32_ifreq)   /* add m'cast addr */
 #define        OSIOCADDMULTI32  _IOW('i', 49, struct netbsd32_oifreq)  /* add m'cast addr */
 



Home | Main Index | Thread Index | Old Index