Here is the code I am using:
(non-important stuff truncated)
int skfd = -1;
struct ifreq ifr;
struct sockaddr_in addr;
if ((skfd = socket(AF_INET, SOCK_DGRAM,0)) < 0) {
syslog(LLEV, "fwtksyserr: socket failed: %s", sys_errlist[errno]);
return(0);
}
memset(&ifr, 0, sizeof(struct ifreq));
strcpy(ifr.ifr_name, ifname);
if (ioctl(skfd, SIOCGIFADDR, &ifr) < 0)
return(0);
memcpy(&addr, &(ifr.ifr_addr), sizeof(struct sockaddr_in));
close(skfd);
now, addr.sin_addr.s_addr should be the encoded ethernet address,
but it is not the same value when called outside of this program.
The kernel code for the glue layer in the net stuff looks fine, so if
there is a bug here, it is probably somewhere in the ip code.
Zachary Amsden
PLEASE E-MAIL THIS ADDRESS
amsdenz@aavid.com