One (little?) question.

With nice `ip' utility, how one can obtain machine's
interface information programmatically?  On old good
days, I used

 SIOCGIFCONF ioctl to get an array of `struct ifreq'
   elements with iface name and addresse, and
 SIOCGIFNETMASK to obtain other *interface* info
   (e.g. netmask) *by name*.

Now, we have two beasts: *interface* is a real one
(no virtual), and it can have more than one address
and thus more than one netmask/broadcast/flags.  Is
there any way to get a complete configuration (read:
list of ip addresses with netmasks) of an interface
configured as:

  ip dev set lo up
  ip addr add 127.0.0.1/16 dev lo
  ip addr add 127.1.0.1/24 dev lo

(just an example, but shows that I'm lasy to assign
different labels for each address).

SIOCGIFCONF gives me list
 lo 127.0.0.1
 lo 127.1.0.1
and SIOCGIFNETMASK("lo") returns 255.255.0.0.
But how I can obtain netmask (255.255.255.0 in this
case) and others for second address (127.1.0.1)???

There is a NETLINK socket interface available, and
there are example of using it (`ip' utility source),
but is there any other (more "traditional") way?

And e.g. on my home machine `ip' utility gives
me "Connection refused" error on attempt to use
it (probably I forgot to include some kernel option
when compiled my kernel - not a question but again
an example), so NETLINK method is NOT "universal"
way of obtaining that info (I'm not about older
kernels that just have no support for NETLINK,
but about current 2.2 kernel - SIOCGIFNETMASK will
work if IP support is compiled in, but NETLINK
may not work).

Thank you!

Regards,
 Michael.



_______________________________________________
Redhat-devel-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-devel-list

Reply via email to