1

I'm trying to implement a application that uses the getifaddrs() function from <ifaddrs.h> across multiple platforms. My goal is to retrieve network interface related info (IP, IPv6, Netmask, Broadcast, Scope, and HWAddress).

I have successfully implemented it on Linux, but it seems that the ifaddrs.h header isn't present on the above platforms (HP-UX, AIX, Solaris).

What is the recommended approach for these platforms?

alk
  • 69,737
  • 10
  • 105
  • 255
Andrei Matei
  • 1,049
  • 2
  • 10
  • 23
  • 1
    See http://stackoverflow.com/a/4139811/1187415, which should work on Solaris and AIX as well, and can be extended for IPv6 (I think). – Martin R Dec 09 '13 at 12:18
  • @MartinR: After having commented out the netmask query. it compiles and runs on `HP-UX B.11.23 U ia64` listing the interface's IP addresses (no IPv6 here so not tested). – alk Dec 09 '13 at 12:50
  • For AIX, I would go find an open BSD implementation of netstat or ifconfig. The concepts of the code should be the same as what AIX has. The old Steve's books would help you out too. I would not be surprised if getifaddrs does not do something similar if it is implemented as a library routine. – pedz Dec 09 '13 at 15:10

1 Answers1

0

Solaris 11 and later have getifaddrs() already in libsocket. For older Solaris releases, see the answer to Solaris: Programmatic interface to ifconfig? here on StackOverflow.

Community
  • 1
  • 1
alanc
  • 4,102
  • 21
  • 24