[prev in list] [next in list] [prev in thread] [next in thread]
List: netbsd-tech-net
Subject: Re: tap interface address
From: Iain Hibbert <plunky () rya-online ! net>
Date: 2008-08-11 21:16:53
Message-ID: 1218489413.817237.6229.nullmailer () galant ! ukfsn ! org
[Download RAW message or body]
On Mon, 11 Aug 2008, der Mouse wrote:
> > So, how do I get to the ethernet address? (technically, it does not
> > have any address family protocol code :)
>
> I thought that's what AF_LINK was for...?
Ok, I admit it.
s = socket(PF_LINK, SOCK_DGRAM, 0);
memset(&iflr, 0, sizeof(iflr));
memcpy(iflr.iflr_name, ifr.ifr_name, IFNAMSIZ);
sdl = (struct sockaddr_dl *)&iflr.addr;
sdl->sdl_family = AF_LINK;
sdl->sdl_len = sizeof(struct sockaddr_dl);
sdl->sdl_alen = ETHER_ADDR_LEN;
if (ioctl(s, SIOCGLIFADDR, &iflr) == -1) {
syslog(LOG_ERR, "Could not get interface address: %m");
exit(EXIT_FAILURE);
}
gives me the address with CLLADDR(sdl), thanks!
iain
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic