home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!eiffel!eiffel.com
- From: ram@eiffel.com (Raphael Manfredi)
- Newsgroups: comp.unix.wizards
- Subject: Getting the Ethernet address from a network interface
- Keywords: network, ethernet, IP, arp
- Message-ID: <126@eiffel.eiffel.com>
- Date: 6 Sep 92 20:22:42 GMT
- Sender: ram@eiffel.com
- Organization: Interactive Software Engineering, Santa Barbara CA
- Lines: 41
-
- Hi!
-
- I am facing what appears to be a simple problem, but cannot seem to
- be able to solve it. What I want is to retrieve the ethernet address
- of the machine. Unfortunately, this has to be done from a program with
- no super-user privileges.
-
- I know the ARP protocol, but the informations are kept in the kernel
- data space, and the mapping between IP and Ethernet addresses is done
- only for the other machines, not the local host. And I did not manage
- to find a system call which would probe the ethernet device and give
- me its ethernet address.
-
- There is obviously a shell solution which works sometimes:
-
- remsh another_host /etc/arp my_host | sed -e 's/^.*at //'
-
- but this is not really acceptable. And the other host might not have
- the maping in its kernel. An arbitrary program cannot depend on this
- to get the local Ethernet address...
-
- What I managed to do so far is getting a datagram socket and calling
- an iotcl SIOCGIFCONF on the socket descriptor, which gives a list of
- the network interfaces available. In particular the struct ifreq
- contains the sockaddr information, providing me with the IP address
- (ifr_addr field from struct ifreq, which is a struct sockaddr).
-
- But how do you get to the struct ether_addr? Is there a way at the
- user level (i.e. with no root privilege) to force an arp resolution
- and then retrieve that information from the kernel via a system call?
- On my machine, /usr/etc/arp is setgid to sys, indicating the program
- is reading /dev/kmem directly, i.e. the information retrieval is not
- easily portable from kernel to kernel.
-
-
- Thank you for any information on this topic.
- --
- Raphael Manfredi <ram@eiffel.com>
- Interactive Software Engineering Inc.
- 270 Storke Road, Suite #7 / Tel +1 (805) 685-1006 \
- Goleta, California 93117, USA \ Fax +1 (805) 685-6869 /
-