From: John Kohl <jtk@rational.com>
Subject: Re: Getting Ethernet (MAC) address on DU 4.0
Date: 1998/09/08 [thread overview]
Message-ID: <6chfyi908e.fsf@rational.com> (raw)
In-Reply-To: 35F3AE4E.413E4BF3@nospam.sebb.bel.alcatel.be
Niel Markwick <markwicn@nospam.sebb.bel.alcatel.be> writes:
>So, is there another way to get the MAC address (I suspect not).
>Alternatively, is there a way to get the names of the network interfaces
>on a system, so that I can then use these with the SIOCRPHYSADDR ioctl
>to get the addresses.
Yes, you can use SIOCGIFCONF.
Here's a code snippet:
struct ifreq *ifrq, ifreqs[32];
struct ifdevea eaddr;
struct ifconf ifc;
s = socket(AF_INET, SOCK_STREAM, 0);
if (s == -1) /* XXX what? */
;
ifc.ifc_req = ifreqs;
ifc.ifc_len = sizeof(ifreqs);
if (ioctl(s, SIOCGIFCONF, &ifc) == -1)
/* XXX what? */;
for (ifrq = ifreqs;
ifc.ifc_len > 0;
ifrq++, ifc.ifc_len -= sizeof(*ifrq)) {
/* for each known interface, try to get a physaddr. */
strncpy(eaddr.ifr_name, ifrq->ifr_name, IFNAMSIZ);
if (ioctl(s, SIOCRPHYSADDR, &eaddr) == 0) {
....
break;
}
}
next prev parent reply other threads:[~1998-09-08 4:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-09-07 4:00 Getting Ethernet (MAC) address on DU 4.0 Niel Markwick
1998-09-08 4:00 ` John Kohl [this message]
1998-09-08 4:00 ` Joe Spanicek
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox