Solaris: Programmatic interface to ifconfig?

后端 未结 3 390
半阙折子戏
半阙折子戏 2021-01-14 13:37

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

相关标签:
3条回答
  • 2021-01-14 13:45

    Real men use ioctl ;)

    Take a look at if(7P).

    0 讨论(0)
  • 2021-01-14 13:46

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

    • 6731945 need BSD getifaddrs() API
    • OpenSolaris source: usr/src/lib/libsocket/inet/getifaddrs.c

    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.

    0 讨论(0)
  • 2021-01-14 13:52

    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.

    0 讨论(0)
提交回复
热议问题