0

I want to get hardware address of network interface on AIX using ioctl. Like in Linux we get it through:

ioctl(sockFd, SIOCGIFADDR, ifr_p);

I didn't find SIOCGIFADDR flag in /usr/include/sys/ioctl.h on AIX to get hardware address information.

Is there any way to get it from ioctl? or any file in system from where I can get this information like in linux this information is stored in '/sys/class/net/'

diago
  • 33
  • 1
  • 1
  • 7

2 Answers2

0

You can easily detect a needed include file using something like grep -w SIOCGIFADDR /usr/include. This could give not the recommended header file but a deeper one, but at least this will be a clue.

In general, BSD style says the proper header is <net/if.h>. I doubt AIX is changed to make it not work. Also, a convenient wrapper getifaddrs() should be available.

Netch
  • 4,171
  • 1
  • 19
  • 31
0

There are plenty of example codes available, see here or here. Basically, you'll have to call getkerninfo with the KINFO_NDD argument and then read the address from the ndd_addr field of the kinfo_ndd struct filled by that call.

Phillip
  • 13,448
  • 29
  • 41
  • Thank you so much that worked :) just one more clarification getKerninfo works on solaris and HP-UX also? – diago Sep 03 '14 at 11:21
  • No, for HP you'll need the `NETSTAT` ioctl. See [here](http://cplus.kompf.de/artikel/macaddr.html). – Phillip Sep 03 '14 at 11:27
  • @Philip regarding ndd_type, NDD_ETHER or NDD_ISO88023 are for ethernet. Are there any ndd_type for Wlan? I looked in ndd.h but didn't find there any or I might overlooked it – diago Sep 04 '14 at 09:06
  • Actually I want to get all available network interfaces if I don;t filter them using ndd_type getkerninfo will give me network interfaces and also network adapters also. I want to get only network interfaces not network adapters. – diago Sep 04 '14 at 09:13