Messages in this thread | | | Date | Sun, 23 May 2004 08:29:15 -0700 | Subject | Re: consistent ioctl for getting all net interfaces? | From | (Joshua Kwan) |
| |
On Sun, May 23, 2004 at 04:20:57PM +0100, Tigran Aivazian wrote: > Note that a more simple solution is also possible but is less portable > (because will depend on glibc version).
That uses if_nameindex, right? It's also affected by kernel version.
> if(ioctl(fd, SIOCGIFCONF, &ifc) < 0) { > DPRINTF("ioctl(SIOCGIFCONF), errno=%d (%s)\n", > errno, strerror(errno)); > if (ifc.ifc_buf) > free(ifc.ifc_buf); > ret = TERR_IOCTL; > goto outclose; > }
As I said, when I tried SIOCGIFCONF, results varied.. I think it's slightly more reliable to just keep using /proc/net/dev for now. (My parser is more robust than viro's ;))
I took a look at the net-tools ifconfig source and saw that it also parsed /proc/net/dev to pick up what SIOCGIFCONF didn't. Shudder.
-- Joshua Kwan [unhandled content-type:application/pgp-signature] | |