Niel Markwick wrote: > > I know this is a question that has been asked before, but I am looking > for some different answers! > > I am looking for a generic way of getting the MAC address from the > ethernet card from within a C program... > > On the VMS and Solaris platforms, I am sucessfully using the SIOCGARP > ioctl to get ther ARP entry for the host, but on DEC Unix, this fails... > It seems that VMS and SOLARIS store an entry in the ARP tables for the > local host, but Dec Unix doesn't. > > The answer found in Deja News > (http://www.dejanews.com/getdoc.xp?AN=333909507) > was to use the SIOCRPHYSADDR ioctl, but this requires knowledge of the > name of the network interface that you are interrogating (ie tu#, ln#, > le#) > > 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. > > I currently have a workaround which is to popen the command: > /usr/sbin/netstat -i \ > | awk ' {print $4} ' \ > | grep '[0-9a-f:]\{17\}' > and read the output back into my program, but this feels sooooo messy, > and is subject to the whims of Digital changing the output format of > netstat! > > All help gratefully recieved. > > Niel. > > -- > Niel Markwick > Consultant Software Engineer > Alcatel Bell Telecom, Kontich, Belgium. > Work Email: markwicn@sebb.bel.alcatel.be Hi, I found this bit of C code on the Digital Web Site. Hope it helps. Joe PS: The code is an attachment