Eng Se-Hsieng wrote: > Could someone please tell me why when I use > > ioctl(fd, SIOCGIFCONF, (char *)cf); > > All the addresses returned have a link bandwidth > (ifrequest->ifr_bandwidth) of 2? > > What does this 2 mean and why is the same for all the interfaces (eth, > ppp, lo)? ifr_bandwidth isn't valid for ioctl(SIOCGIFCONF). If you look at the definition of "struct ifreq" and its corresponding macros in <net/if.h>, you will notice that most of the structure is comprised of a union, where only one of the members will be meaningful in any given context. For ioctl(SIOCGIFCONF), only ifr_addr is meaningful. Using any other macro will produce a meaningless result. In your specific case (ifr_bandwidth), you are reading the first four bytes of the ifr_ifru union. However, ioctl(SIOCGIFCONF) will have filled in ifr_ifru.ifru_addr with the interface's address, so you are reading the family (AF_INET, which is 2) and the port (which isn't meaningful here, and is set to zero) of that address, hence you get the value 2 (on a little-endian architecture such as x86; on a big-endian system, it would be 0x00020000). Different fields of the ifr_ifru union are meaningful for different ioctl() calls. However, I don't know whether there actually is an ioctl() which returns the link bandwidth (I can't see anything obvious); the ifr_bandwidth macro could just be for compatibility. -- Glynn Clements <glynn.clements@virgin.net> - : send the line "unsubscribe linux-net" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html