aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPaul Saab <ps@FreeBSD.org>2006-02-02 19:58:37 +0000
committerPaul Saab <ps@FreeBSD.org>2006-02-02 19:58:37 +0000
commit19cf04981affe4b939978f0155ff276b3b205f29 (patch)
tree36b70587703e5ca6ebc8b744205d0a4ca7b61cb0 /sys
parent0e74562fbc17c3e412a5f318ea098a47525cf07e (diff)
Notes
Diffstat (limited to 'sys')
-rw-r--r--sys/net/if.c22
-rw-r--r--sys/net/if.h9
-rw-r--r--sys/sys/sockio.h3
3 files changed, 34 insertions, 0 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 814815b14b80..e1811a3b5cbf 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -191,6 +191,10 @@ netioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td
*/
if (cmd == SIOCGIFCONF)
return (ifconf(cmd, data)); /* XXX remove cmd */
+#ifdef __amd64__
+ if (cmd == SIOCGIFCONF32)
+ return (ifconf(cmd, data)); /* XXX remove cmd */
+#endif
return (EOPNOTSUPP);
}
@@ -1493,6 +1497,9 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct thread *td)
switch (cmd) {
case SIOCGIFCONF:
case OSIOCGIFCONF:
+#ifdef __amd64__
+ case SIOCGIFCONF32:
+#endif
return (ifconf(cmd, data));
}
ifr = (struct ifreq *)data;
@@ -1699,12 +1706,23 @@ static int
ifconf(u_long cmd, caddr_t data)
{
struct ifconf *ifc = (struct ifconf *)data;
+#ifdef __amd64__
+ struct ifconf32 *ifc32 = (struct ifconf32 *)data;
+ struct ifconf ifc_swab;
+#endif
struct ifnet *ifp;
struct ifaddr *ifa;
struct ifreq ifr;
struct sbuf *sb;
int error, full = 0, valid_len, max_len;
+#ifdef __amd64__
+ if (cmd == SIOCGIFCONF32) {
+ ifc_swab.ifc_len = ifc32->ifc_len;
+ ifc_swab.ifc_buf = (caddr_t)(uintptr_t)ifc32->ifc_buf;
+ ifc = &ifc_swab;
+ }
+#endif
/* Limit initial buffer size to MAXPHYS to avoid DoS from userspace. */
max_len = MAXPHYS - 1;
@@ -1793,6 +1811,10 @@ again:
}
ifc->ifc_len = valid_len;
+#ifdef __amd64__
+ if (cmd == SIOCGIFCONF32)
+ ifc32->ifc_len = valid_len;
+#endif
sbuf_finish(sb);
error = copyout(sbuf_data(sb), ifc->ifc_req, ifc->ifc_len);
sbuf_delete(sb);
diff --git a/sys/net/if.h b/sys/net/if.h
index 8e483cc31616..4e976018a44d 100644
--- a/sys/net/if.h
+++ b/sys/net/if.h
@@ -348,6 +348,15 @@ struct ifconf {
#define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
};
+#if defined (__amd64__) || defined (COMPAT_32BIT)
+struct ifconf32 {
+ int ifc_len; /* size of associated buffer */
+ union {
+ u_int ifcu_buf;
+ u_int ifcu_req;
+ } ifc_ifcu;
+};
+#endif
/*
* Structure for SIOC[AGD]LIFADDR
diff --git a/sys/sys/sockio.h b/sys/sys/sockio.h
index 82059a43d988..3331e87678da 100644
--- a/sys/sys/sockio.h
+++ b/sys/sys/sockio.h
@@ -62,6 +62,9 @@
#define SIOCSIFBRDADDR _IOW('i', 19, struct ifreq) /* set broadcast addr */
#define OSIOCGIFCONF _IOWR('i', 20, struct ifconf) /* get ifnet list */
#define SIOCGIFCONF _IOWR('i', 36, struct ifconf) /* get ifnet list */
+#if defined (__amd64__) || defined (COMPAT_32BIT)
+#define SIOCGIFCONF32 _IOWR('i', 36, struct ifconf32) /* get ifnet list */
+#endif
#define OSIOCGIFNETMASK _IOWR('i', 21, struct ifreq) /* get net addr mask */
#define SIOCGIFNETMASK _IOWR('i', 37, struct ifreq) /* get net addr mask */
#define SIOCSIFNETMASK _IOW('i', 22, struct ifreq) /* set net addr mask */