How do I find the MAC address of a network card on IRIX? I'd rather not shell out to something that displays it and parse the output.
I'm coding C.
Methods that require root access are acceptable.
How do I find the MAC address of a network card on IRIX? I'd rather not shell out to something that displays it and parse the output.
I'm coding C.
Methods that require root access are acceptable.
I don't know about programmatically, but you could try /etc/nvram eaddr
, I suppose you could exec()
that.
On some platforms (Linux, for example) ioctl()
allows to obtain MAC address. You need to check on IRIX as ioctl()
is platform-dependent.
#include <net/raw.h>
#include <net/if.h>
#include <net/soioctl.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
...
struct ifreq ifdat;
int s;
s = socket (PF_RAW, SOCK_RAW, RAWPROTO_SNOOP);
strcpy (ifdat.ifr_name, "en0");
ioctl (s, SIOCGIFADDR, &ifdat);
...
Clean it up a little, and ifdat should contain your MAC address.