Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Aug 2006 07:59:48 +0000
From:      Mario Lobo <mario.lobo@ipad.com.br>
To:        freebsd-hackers@freebsd.org
Subject:   getting interface MAC addr from C
Message-ID:  <200608040759.49390.mario.lobo@ipad.com.br>

next in thread | raw e-mail | index | archive | help
Hi;

Would anyone have a tip on how to get the MAC from a C program?

I tried:

    struct ifreq ifreq;
    unsigned char *hw;

    strcpy(ifreq.ifr_name, "rl0");
    ioctl(fd, SIOCGIFMAC, &ifreq);
    hw = ifreq.ifr_ifru.ifru_data; ????

but i don't know if this is right or, if it is, where to get the MAC from the 
structure. I doesn't issue any error compiling or running though.

In linux i used:

    struct ifreq ifreq;
    unsigned char *hw;

    strcpy(ifreq.ifr_name, "rl0");
    ioctl(fd, SIOCGIFHWADDR, &ifreq);
    hw = ifreq.ifr_hwaddr.sa_data;

Thanks,

Mario



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200608040759.49390.mario.lobo>