summaryrefslogtreecommitdiff
path: root/sys/compat/linux
diff options
context:
space:
mode:
Diffstat (limited to 'sys/compat/linux')
-rw-r--r--sys/compat/linux/linux_socket.c31
-rw-r--r--sys/compat/linux/linux_socket.h41
-rw-r--r--sys/compat/linux/linux_sockio.h3
3 files changed, 72 insertions, 3 deletions
diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c
index 88d35dc52e9..30d67719497 100644
--- a/sys/compat/linux/linux_socket.c
+++ b/sys/compat/linux/linux_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: linux_socket.c,v 1.6 1997/11/27 00:57:28 deraadt Exp $ */
+/* $OpenBSD: linux_socket.c,v 1.7 1997/12/10 01:51:23 deraadt Exp $ */
/* $NetBSD: linux_socket.c,v 1.14 1996/04/05 00:01:50 christos Exp $ */
/*
@@ -45,6 +45,8 @@
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <net/if.h>
+#include <net/if_types.h>
+#include <net/if_dl.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/mount.h>
@@ -803,6 +805,33 @@ linux_ioctl_socket(p, uap, retval)
case LINUX_SIOCDELMULTI:
SCARG(&ia, com) = SIOCDELMULTI;
break;
+ case LINUX_SIOCGIFHWADDR: {
+ struct linux_ifreq *ifr = (struct linux_ifreq *)SCARG(&ia, data);
+ struct sockaddr_dl *sdl;
+ struct ifnet *ifp;
+ struct ifaddr *ifa;
+
+ /*
+ * Note that we don't actually respect the name in the ifreq
+ * structure, as Linux interface names are all different.
+ */
+ for (ifp = ifnet.tqh_first; ifp != 0;
+ ifp = ifp->if_list.tqe_next) {
+ if (ifp->if_type != IFT_ETHER)
+ continue;
+ for (ifa = ifp->if_addrlist.tqh_first; ifa;
+ ifa = ifa->ifa_list.tqe_next) {
+ if ((sdl = (struct sockaddr_dl *)ifa->ifa_addr) &&
+ (sdl->sdl_family == AF_LINK) &&
+ (sdl->sdl_type == IFT_ETHER)) {
+ return copyout(LLADDR(sdl),
+ (caddr_t)&ifr->ifr_hwaddr.sa_data,
+ LINUX_IFHWADDRLEN);
+ }
+ }
+ }
+ return ENOENT;
+ }
default:
return EINVAL;
}
diff --git a/sys/compat/linux/linux_socket.h b/sys/compat/linux/linux_socket.h
index 1cd4d53d341..9c89c95cb6b 100644
--- a/sys/compat/linux/linux_socket.h
+++ b/sys/compat/linux/linux_socket.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: linux_socket.h,v 1.2 1996/04/17 05:24:02 mickey Exp $ */
+/* $OpenBSD: linux_socket.h,v 1.3 1997/12/10 01:51:24 deraadt Exp $ */
/* $NetBSD: linux_socket.h,v 1.3 1995/05/28 10:16:34 mycroft Exp $ */
/*
@@ -105,4 +105,43 @@
#define LINUX_TCP_NODELAY 1
#define LINUX_TCP_MAXSEG 2
+struct linux_sockaddr {
+ unsigned short sa_family;
+ char sa_data[14];
+};
+
+struct linux_ifmap {
+ unsigned long mem_start;
+ unsigned long mem_end;
+ unsigned short base_addr;
+ unsigned char irq;
+ unsigned char dma;
+ unsigned char port;
+};
+
+struct linux_ifreq {
+#define LINUX_IFHWADDRLEN 6
+#define LINUX_IFNAMSIZ 16
+ union {
+ char ifrn_name[LINUX_IFNAMSIZ]; /* if name, e.g. "en0" */
+ } ifr_ifrn;
+
+ union {
+ struct linux_sockaddr ifru_addr;
+ struct linux_sockaddr ifru_dstaddr;
+ struct linux_sockaddr ifru_broadaddr;
+ struct linux_sockaddr ifru_netmask;
+ struct linux_sockaddr ifru_hwaddr;
+ short ifru_flags;
+ int ifru_metric;
+ int ifru_mtu;
+ struct linux_ifmap ifru_map;
+ char ifru_slave[LINUX_IFNAMSIZ];
+ caddr_t ifru_data;
+ } ifr_ifru;
+};
+
+#define ifr_name ifr_ifrn.ifrn_name /* interface name */
+#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */
+
#endif /* _LINUX_SOCKET_H */
diff --git a/sys/compat/linux/linux_sockio.h b/sys/compat/linux/linux_sockio.h
index 1a7042cb958..0f7b2cba154 100644
--- a/sys/compat/linux/linux_sockio.h
+++ b/sys/compat/linux/linux_sockio.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: linux_sockio.h,v 1.4 1996/04/17 05:24:04 mickey Exp $ */
+/* $OpenBSD: linux_sockio.h,v 1.5 1997/12/10 01:51:24 deraadt Exp $ */
/* $NetBSD: linux_sockio.h,v 1.5 1996/03/08 04:56:07 mycroft Exp $ */
/*
@@ -41,6 +41,7 @@
#define LINUX_SIOCGIFDSTADDR _LINUX_IO(0x89, 23)
#define LINUX_SIOCGIFBRDADDR _LINUX_IO(0x89, 25)
#define LINUX_SIOCGIFNETMASK _LINUX_IO(0x89, 27)
+#define LINUX_SIOCGIFHWADDR _LINUX_IO(0x89, 39)
#define LINUX_SIOCADDMULTI _LINUX_IO(0x89, 49)
#define LINUX_SIOCDELMULTI _LINUX_IO(0x89, 50)