lua-users home
lua-l archive

Calling network ioctl using alien

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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

AltStyle によって変換されたページ (->オリジナル) /