MAC address ( ioctl )

MAC address ( ioctl )

Post by Tiaan Wessel » Wed, 06 Nov 1996 04:00:00

I need to get the MAC address from linux
This is how far I got ( ideas from strace ifconfig ) however I'm not
very familiar with ioctl. How do I decode the returned value from ioctl.
I've just made it a string but don't know how to interpret it. Could
anyone help please.

#include <sys/types.h>
#include <sys/socket.h>

int main()
   char str[128];

   int fd = socket( PF_INET, SOCK_DGRAM, 0 );

   ioctl( fd, SIOCGIFHWADDR, str );


Thank you in advance


1. MAC ADDRESS/ioctl(siocgifhwaddr)

Hi (again)!
I want to figure out the mac-address of my network-devices (ippp0,eth0).
I have already found the ioctl()-call i have to use but i have the
problem, that i dont know how to decode the given data.
the ioctl call is as follows: ioctl(filedes,siocgifhwaddr,struct ifreq*)

the ifreq struct has a member ifr_ifru (a union) an this one has a
member ifru_hwaddr of type "struct sockaddr". Now i dont know how to
get the mac-address from the sockaddr.sa_data member. I thought sockaddr
was only used to store ip-addresses...

thanx for any help


2. Problem with labeling a 4GB SCSI HDD in "format" utility in INTEL Solaris

3. socket ioctl and mac address

4. Apache Module deployement problem

5. filtering users by mac address and limiting bandwidth to each mac.

6. My busted e-mail address

7. Binding a single IP Address to two different MAC addresses

8. memory compatability question

9. Is different 'Ethenet address' from 'Mac Address' ?

10. Determining IP address from MAC address

11. MAC Address From IP Address

12. change MAC address can change IP address of a machine?

13. using mac address instead of an IP address of hostname