From c1450c592f1966cc4f36619373925e49d67a027c Mon Sep 17 00:00:00 2001 From: deraadt Date: Wed, 10 Dec 1997 01:51:23 +0000 Subject: emulate linux SIOCGIFHWADDR; stolen from freebsd; not tested yet --- sys/compat/linux/linux_socket.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'sys/compat/linux/linux_socket.c') 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 #include #include +#include +#include #include #include #include @@ -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; } -- cgit v1.2.3-59-g8ed1b