lkml.org 
[lkml]   [2004]   [May]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: consistent ioctl for getting all net interfaces?
From
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]
\
 
 \ /
  Last update: 2005-03-22 14:03    [W:0.063 / U:1.500 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site