lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Tue, Jul 22, 2014 at 12:01:00PM -0400, Sean Conner wrote:
> It was thus said that the Great William Ahern once stated:
> > On Tue, Jul 22, 2014 at 01:52:13AM -0400, Sean Conner wrote:
> > > 
> > > [1]	The first instance is to enumerate all the network interfaces under
> > > 	Linux:
> > > 
> > >
> > 
> > Kinda off-topic, but I noticed your source code comment says that getifaddrs
> > is "Linux-only". getifaddrs was original to BSDi. Linux adopted it. It's
> > supported by not only all the modern BSDs, but also Solaris 11 and even QNX.
> > It should be trivial to emulate on other systems, like AIX.
>   It's marked "Linux only" because of the three systems I have easy access
> to, Linux, Solaris (5.10, so is that Solaris 10?) and Mac OS-X, it's only
> Linux that I found the actual function.

FWIW, I've added getifaddrs bindings to my Lua Unix module.

There's an ifconfig lookalike program in examples/getifaddrs.lua.

I did extensive research, including downloading the original KAME IPv6
network project to understand the relevant ioctls.

The unix module now supports getifaddrs on all supported platforms,
including Linux, Solaris, OS X, OpenBSD, NetBSD, FreeBSD, and AIX.

Most platforms include a native version already. But I've included embedded
implementations for Solaris 10 and AIX, which lack a native getifaddrs. And
I tested my emulated versions (I wrote four different implementations: two
KAME-based which work on most BSDs, one for Solaris, one for AIX) on all
platforms to check for bugs.

I don't have a copy of Solaris 10, so I had to test the emulated version on
Solaris 11. Bug reports appreciated.

Output of the example script:

$ uname -a
AIX aix7 1 7 000ACFDE4C00
$ lua ./getifaddrs.lua
        inet broadcast
        inet6 2001:470:dce3::80 prefixlen 64
        inet6 fe80::209:6bff:fe2e:b12a prefixlen 64
sit0: flags=135266369<UP,RUNNING>
        inet6 :: prefixlen 96
        inet broadcast
        inet6 ::1 prefixlen 128