[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Calling network ioctl using alien
- From: "jonsmirl@..." <jonsmirl@...>
- Date: Sun, 13 Feb 2011 14:40:55 -0500
To get the hardware address I need to call ioctl on the socket handle.
ioctl is varargs, I can't figure how to get alien to call it.
struct ifreq ifinfo;
strcpy(ifinfo.ifr_name, "eth0");
int sd = socket(AF_INET, SOCK_DGRAM, 0);
local s = socket.udp()
looking at the source for socket, the first int in the s structure is
the socket handle.
int result = ioctl(sd, SIOCGIFHWADDR, &ifinfo);
How do I make this call using alien? int ioctl(int d, int request, ...);
close(sd);
if ((result == 0) && (ifinfo.ifr_hwaddr.sa_family == 1)) {
memcpy(mac_addr, ifinfo.ifr_hwaddr.sa_data, IFHWADDRLEN);
return true;
}
return false;
--
Jon Smirl
jonsmirl@gmail.com