From owner-freebsd-emulation Mon Nov 6 9:31:52 2000 Delivered-To: freebsd-emulation@freebsd.org Received: from palrel3.hp.com (palrel3.hp.com [156.153.255.226]) by hub.freebsd.org (Postfix) with ESMTP id BC54B37B4E5 for ; Mon, 6 Nov 2000 09:31:49 -0800 (PST) Received: from adlmail.cup.hp.com (adlmail.cup.hp.com [15.0.100.30]) by palrel3.hp.com (Postfix) with ESMTP id 6B941562; Mon, 6 Nov 2000 09:31:49 -0800 (PST) Received: from cup.hp.com (gauss.cup.hp.com [15.28.97.152]) by adlmail.cup.hp.com (8.9.3 (PHNE_18546)/8.9.3 SMKit7.02) with ESMTP id JAA16736; Mon, 6 Nov 2000 09:31:49 -0800 (PST) Message-ID: <3A06EB05.F908822@cup.hp.com> Date: Mon, 06 Nov 2000 12:31:49 -0500 From: Marcel Moolenaar Organization: Hewlett-Packard X-Mailer: Mozilla 4.73 [en] (X11; U; Linux 2.2.12 i386) X-Accept-Language: en MIME-Version: 1.0 To: Gerald Pfeifer Cc: emulation@FreeBSD.ORG Subject: Re: Wine port: How to obtain MAC address? References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-emulation@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Gerald Pfeifer wrote: > > For the Wine port I'd need to obtain the MAC address of an ethernet > interface, alas it seems that this is not easily possible the way it > is done in Linux/Solaris? > > For Linux, the code in Wine looks as follows: > > strcpy(ifInfo.ifr_name, ifName); > if (ioctl(sock, SIOCGIFHWADDR, &ifInfo) < 0) > { > ERR ("Error obtaining MAC Address!\n"); > close(sock); > return (-1); > } > else > { > /* FIXME: Is it correct to assume size of 6? */ > memcpy(IntInfo->if_physaddr, ifInfo.ifr_hwaddr.sa_data, 6); > IntInfo->if_physaddrlen=6; > } See /sys/compat/linux/linux_ioctl.c:1370 case LINUX_SIOCGIFHWADDR: { int ifn; struct ifnet *ifp; struct ifaddr *ifa; struct sockaddr_dl *sdl; struct linux_ifreq *ifr = (struct linux_ifreq *)args->arg; /* Note that we don't actually respect the name in the ifreq * structure, as Linux interface names are all different. */ for (ifn = 0; ifn < if_index; ifn++) { ifp = ifnet_addrs[ifn]->ifa_ifp; if (ifp->if_type == IFT_ETHER) { ifa = TAILQ_FIRST(&ifp->if_addrhead); while (ifa) { sdl=(struct sockaddr_dl*)ifa->ifa_addr; if (sdl != NULL && (sdl->sdl_family == AF_LINK) && (sdl->sdl_type == IFT_ETHER)) { return (copyout(LLADDR(sdl), &ifr->ifr_hwaddr.sa_data, LINUX_IFHWADDRLEN)); } ifa = TAILQ_NEXT(ifa, ifa_link); } } } return (ENOENT); } This gives you a kernel-space datapoint. With that, you should be able to mimic what ifconfig (as Will suggested) does. HTH, -- Marcel Moolenaar mail: marcel@cup.hp.com / marcel@FreeBSD.org tel: (408) 447-4222 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-emulation" in the body of the message