Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/netbsd32 Add netbsd32_oifreq and fix issue in cop...
details: https://anonhg.NetBSD.org/src/rev/0dcb9b732cf3
branches: trunk
changeset: 749805:0dcb9b732cf3
user: christos <christos%NetBSD.org@localhost>
date: Wed Dec 09 04:50:47 2009 +0000
description:
Add netbsd32_oifreq and fix issue in copying the interface name. With this
patch OSIOC{G,S}IFFLAGS is supposed to work, but unfortunately getifaddrs
seems to be the next problem getting the 4.99.x i386 ifconfig working on an
amd64 current machine.
diffstat:
sys/compat/netbsd32/netbsd32_ioctl.c | 48 +++++++++++++++++++++-
sys/compat/netbsd32/netbsd32_ioctl.h | 76 ++++++++++++++++++++++++++++++++---
2 files changed, 114 insertions(+), 10 deletions(-)
diffs (224 lines):
diff -r cdda1cea799d -r 0dcb9b732cf3 sys/compat/netbsd32/netbsd32_ioctl.c
--- a/sys/compat/netbsd32/netbsd32_ioctl.c Wed Dec 09 00:45:25 2009 +0000
+++ b/sys/compat/netbsd32/netbsd32_ioctl.c Wed Dec 09 04:50:47 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_ioctl.c,v 1.42 2009/05/24 21:41:25 ad Exp $ */
+/* $NetBSD: netbsd32_ioctl.c,v 1.43 2009/12/09 04:50:47 christos 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.42 2009/05/24 21:41:25 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.43 2009/12/09 04:50:47 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -79,6 +79,8 @@
static inline void netbsd32_to_format_op(struct netbsd32_format_op *,
struct format_op *, u_long);
#endif
+static inline void netbsd32_to_oifreq(struct netbsd32_oifreq *, struct oifreq *,
+ u_long cmd);
static inline void netbsd32_to_ifreq(struct netbsd32_ifreq *, struct ifreq *,
u_long cmd);
static inline void netbsd32_to_ifconf(struct netbsd32_ifconf *,
@@ -100,6 +102,8 @@
#endif
static inline void netbsd32_from_ifreq(struct ifreq *,
struct netbsd32_ifreq *, u_long);
+static inline void netbsd32_from_oifreq(struct oifreq *,
+ struct netbsd32_oifreq *, u_long);
static inline void netbsd32_from_ifconf(struct ifconf *,
struct netbsd32_ifconf *, u_long);
static inline void netbsd32_from_ifmediareq(struct ifmediareq *,
@@ -152,6 +156,21 @@
}
static inline void
+netbsd32_to_oifreq(struct netbsd32_oifreq *s32p, struct oifreq *p, u_long cmd)
+{
+
+ memcpy(p, s32p, sizeof *s32p);
+ /*
+ * XXX
+ * struct ifreq says the same, but sometimes the ifr_data
+ * union member needs to be converted to 64 bits... this
+ * is very driver specific and so we ignore it for now..
+ */
+ if (cmd == SIOCGIFDATA || cmd == SIOCZIFDATA)
+ p->ifr_data = (void *)NETBSD32PTR64(s32p->ifr_data);
+}
+
+static inline void
netbsd32_to_ifconf(struct netbsd32_ifconf *s32p, struct ifconf *p, u_long cmd)
{
@@ -235,7 +254,24 @@
* union member needs to be converted to 64 bits... this
* is very driver specific and so we ignore it for now..
*/
- *s32p->ifr_name = *p->ifr_name;
+ (void)memcpy(s32p->ifr_name, p->ifr_name,
+ MIN(sizeof(s32p->ifr_name), sizeof(p->ifr_name)));
+ if (cmd == SIOCGIFDATA || cmd == SIOCZIFDATA)
+ NETBSD32PTR32(s32p->ifr_data, p->ifr_data);
+}
+
+static inline void
+netbsd32_from_oifreq(struct oifreq *p, struct netbsd32_oifreq *s32p, u_long cmd)
+{
+
+ /*
+ * XXX
+ * struct ifreq says the same, but sometimes the ifr_data
+ * union member needs to be converted to 64 bits... this
+ * is very driver specific and so we ignore it for now..
+ */
+ (void)memcpy(s32p->ifr_name, p->ifr_name,
+ MIN(sizeof(s32p->ifr_name), sizeof(p->ifr_name)));
if (cmd == SIOCGIFDATA || cmd == SIOCZIFDATA)
NETBSD32PTR32(s32p->ifr_data, p->ifr_data);
}
@@ -502,6 +538,12 @@
case SIOCSIFFLAGS32:
IOCTL_STRUCT_CONV_TO(SIOCSIFFLAGS, ifreq);
+ case OSIOCGIFFLAGS32:
+ printf("OSIO %lx %zu\n", (long)OSIOCGIFFLAGS, sizeof(struct netbsd32_oifreq));
+ IOCTL_STRUCT_CONV_TO(OSIOCGIFFLAGS, oifreq);
+ case OSIOCSIFFLAGS32:
+ IOCTL_STRUCT_CONV_TO(OSIOCSIFFLAGS, oifreq);
+
case SIOCGIFMEDIA32:
IOCTL_STRUCT_CONV_TO(SIOCGIFMEDIA, ifmediareq);
diff -r cdda1cea799d -r 0dcb9b732cf3 sys/compat/netbsd32/netbsd32_ioctl.h
--- a/sys/compat/netbsd32/netbsd32_ioctl.h Wed Dec 09 00:45:25 2009 +0000
+++ b/sys/compat/netbsd32/netbsd32_ioctl.h Wed Dec 09 04:50:47 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_ioctl.h,v 1.24 2008/06/23 23:14:42 njoly Exp $ */
+/* $NetBSD: netbsd32_ioctl.h,v 1.25 2009/12/09 04:50:47 christos Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@@ -151,7 +151,7 @@
/*
* note that ifr_data is the only one that needs to be changed
*/
-struct netbsd32_ifreq {
+struct netbsd32_oifreq {
char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */
union {
struct sockaddr ifru_addr;
@@ -160,7 +160,13 @@
short ifru_flags;
int ifru_metric;
int ifru_mtu;
+ int ifru_dlt;
+ u_int ifru_value;
netbsd32_caddr_t ifru_data;
+ struct {
+ uint32_t b_buflen;
+ netbsd32_caddr_t b_buf;
+ } ifru_b;
} ifr_ifru;
#define ifr_addr ifr_ifru.ifru_addr /* address */
#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
@@ -171,33 +177,89 @@
#define ifr_media ifr_ifru.ifru_metric /* media options (overload) */
#define ifr_data ifr_ifru.ifru_data /* for use by interface */
};
+struct netbsd32_ifreq {
+ char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */
+ union {
+ struct sockaddr ifru_addr;
+ struct sockaddr ifru_dstaddr;
+ struct sockaddr ifru_broadaddr;
+ struct sockaddr_storage ifru_space;
+ short ifru_flags;
+ int ifru_metric;
+ int ifru_mtu;
+ int ifru_dlt;
+ u_int ifru_value;
+ netbsd32_caddr_t ifru_data;
+ struct {
+ uint32_t b_buflen;
+ netbsd32_caddr_t b_buf;
+ } ifru_b;
+ } ifr_ifru;
+};
#if 1
/* 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 */
/* from <sys/sockio.h> */
#define SIOCSIFADDR32 _IOW('i', 12, struct netbsd32_ifreq) /* set ifnet address */
-#define OSIOCGIFADDR32 _IOWR('i', 13, struct netbsd32_ifreq) /* get ifnet address */
+#define OSIOCSIFADDR32 _IOW('i', 12, struct netbsd32_oifreq) /* set ifnet address */
+#define OOSIOCGIFADDR32 _IOWR('i', 13, struct netbsd32_oifreq) /* get ifnet address */
+
#define SIOCGIFADDR32 _IOWR('i', 33, struct netbsd32_ifreq) /* get ifnet address */
+#define OSIOCGIFADDR32 _IOWR('i', 33, struct netbsd32_oifreq) /* get ifnet address */
+
#define SIOCSIFDSTADDR32 _IOW('i', 14, struct netbsd32_ifreq) /* set p-p address */
-#define OSIOCGIFDSTADDR32 _IOWR('i', 15, struct netbsd32_ifreq) /* get p-p address */
+#define OSIOCSIFDSTADDR32 _IOW('i', 14, struct netbsd32_oifreq) /* set p-p address */
+#define OOSIOCGIFDSTADDR32 _IOWR('i', 15, struct netbsd32_oifreq) /* get p-p address */
+
#define SIOCGIFDSTADDR32 _IOWR('i', 34, struct netbsd32_ifreq) /* get p-p address */
+#define OSIOCGIFDSTADDR32 _IOWR('i', 34, struct netbsd32_oifreq) /* get p-p address */
+
#define SIOCSIFFLAGS32 _IOW('i', 16, struct netbsd32_ifreq) /* set ifnet flags */
+#define OSIOCSIFFLAGS32 _IOW('i', 16, struct netbsd32_oifreq) /* set ifnet flags */
+
#define SIOCGIFFLAGS32 _IOWR('i', 17, struct netbsd32_ifreq) /* get ifnet flags */
-#define OSIOCGIFBRDADDR32 _IOWR('i', 18, struct netbsd32_ifreq) /* get broadcast addr */
-#define SIOCGIFBRDADDR32 _IOWR('i', 35, struct netbsd32_ifreq) /* get broadcast addr */
+#define OSIOCGIFFLAGS32 _IOWR('i', 17, struct netbsd32_oifreq) /* get ifnet flags */
+
+
#define SIOCSIFBRDADDR32 _IOW('i', 19, struct netbsd32_ifreq) /* set broadcast addr */
-#define OSIOCGIFNETMASK32 _IOWR('i', 21, struct netbsd32_ifreq) /* get net addr mask */
+#define OSIOCSIFBRDADDR32 _IOW('i', 19, struct netbsd32_oifreq) /* set broadcast addr */
+#define OOSIOCGIFBRDADDR32 _IOWR('i', 18, struct netbsd32_oifreq) /* get broadcast addr */
+
+#define SIOCGIFBRDADDR32 _IOWR('i', 35, struct netbsd32_ifreq) /* get broadcast addr */
+#define OSIOCGIFBRDADDR32 _IOWR('i', 35, struct netbsd32_oifreq) /* get broadcast addr */
+
+#define OOSIOCGIFNETMASK32 _IOWR('i', 21, struct netbsd32_oifreq) /* get net addr mask */
+
#define SIOCGIFNETMASK32 _IOWR('i', 37, struct netbsd32_ifreq) /* get net addr mask */
+#define OSIOCGIFNETMASK32 _IOWR('i', 37, struct netbsd32_oifreq) /* get net addr mask */
+
#define SIOCSIFNETMASK32 _IOW('i', 22, struct netbsd32_ifreq) /* set net addr mask */
+#define OSIOCSIFNETMASK32 _IOW('i', 22, struct netbsd32_oifreq) /* set net addr mask */
+
#define SIOCGIFMETRIC32 _IOWR('i', 23, struct netbsd32_ifreq) /* get IF metric */
+#define OSIOCGIFMETRIC32 _IOWR('i', 23, struct netbsd32_oifreq) /* get IF metric */
+
#define SIOCSIFMETRIC32 _IOW('i', 24, struct netbsd32_ifreq) /* set IF metric */
+#define OSIOCSIFMETRIC32 _IOW('i', 24, struct netbsd32_oifreq) /* set IF metric */
+
#define SIOCDIFADDR32 _IOW('i', 25, struct netbsd32_ifreq) /* delete IF addr */
+#define OSIOCDIFADDR32 _IOW('i', 25, struct netbsd32_oifreq) /* delete IF addr */
+
#define SIOCADDMULTI32 _IOW('i', 49, struct netbsd32_ifreq) /* add m'cast addr */
+#define OSIOCADDMULTI32 _IOW('i', 49, struct netbsd32_oifreq) /* add m'cast addr */
+
#define SIOCDELMULTI32 _IOW('i', 50, struct netbsd32_ifreq) /* del m'cast addr */
+#define OSIOCDELMULTI32 _IOW('i', 50, struct netbsd32_oifreq) /* del m'cast addr */
+
#define SIOCSIFMEDIA32 _IOWR('i', 53, struct netbsd32_ifreq) /* set net media */
+#define OSIOCSIFMEDIA32 _IOWR('i', 53, struct netbsd32_oifreq) /* set net media */
+
#define SIOCSIFMTU32 _IOW('i', 127, struct netbsd32_ifreq) /* set ifnet mtu */
+#define OSIOCSIFMTU32 _IOW('i', 127, struct netbsd32_oifreq) /* set ifnet mtu */
+
#define SIOCGIFMTU32 _IOWR('i', 126, struct netbsd32_ifreq) /* get ifnet mtu */
+#define OSIOCGIFMTU32 _IOWR('i', 126, struct netbsd32_oifreq) /* get ifnet mtu */
/* was 125 SIOCSIFASYNCMAP32 */
/* was 124 SIOCGIFASYNCMAP32 */
/* from <net/bpf.h> */
Home |
Main Index |
Thread Index |
Old Index