3

I'm looking for a programmatic interface to the Solaris ifconfig(1M) command.

Apparently Linux has the getifaddrs(3) command, but as far as I can tell this has not been ported to Solaris.

Short of attempting to use the code at the link above, is there any way to determine ifconfig(1M)-type data (network interface presence, state, etc.) without forking the system command and parsing the output?

Community
  • 1
  • 1
David Citron
  • 43,219
  • 21
  • 62
  • 72

3 Answers3

2

getifaddrs() was recently integrated into the source code for future OpenSolaris & Solaris releases, but that doesn't help your code run on current releases:

Until then you'll need to use the SIOCGLIFCONF ioctls, which you should find lots of examples of in open source code, including the link you posted.

alanc
  • 4,102
  • 21
  • 24
  • `getifaddrs()` is now available in Solaris 11 and later (which was in the future when I wrote the above in 2010, but was released in 2011). – alanc Sep 02 '14 at 07:08
2

I have an implementation here, IPv4-only based on SIOCGIFCONF ioctl()'s and IP family agnostic version using SIOCGLIFCONF:

http://code.google.com/p/openpgm/source/browse/trunk/openpgm/pgm/getifaddrs.c

Tested on SPARC/Solaris 10 and x86/OpenSolaris 2008.11 & 2009.06, LGPL 2.1 license.

Steve-o
  • 12,678
  • 2
  • 41
  • 60
0

Real men use ioctl ;)

Take a look at if(7P).

alanc
  • 4,102
  • 21
  • 24
Volker Stolz
  • 7,274
  • 1
  • 32
  • 50