From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,a684a3049b399a41,start X-Google-Attributes: gidfee84,public From: Niel Markwick Subject: Getting Ethernet (MAC) address on DU 4.0 Date: 1998/09/07 Message-ID: <35F3AE4E.413E4BF3@nospam.sebb.bel.alcatel.be>#1/1 X-Deja-AN: 388650606 Content-Transfer-Encoding: 7bit Organization: Alcatel Bell, Kontich Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: comp.unix.osf.osf1 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