Hi Ravi, That information you provided was very useful, thanks! Regards, Pallav
On Tuesday, February 9, 2016 2:51 PM, Pallav Bose <pallav_b...@yahoo.com> wrote: Hi, I'm writing a C program to list all available interfaces and their link speed. I can use getifaddrs(3) to obtain a list of network interfaces in a struct ifaddrs, but none of the fields in this struct gives me information about the negotiated link speed. From the man page of getifaddrs(3): The ifaddrs structure contains at least the following entries: struct ifaddrs *ifa_next; /* Pointer to next struct */ char *ifa_name; /* Interface name */ u_int ifa_flags; /* Interface flags */ struct sockaddr *ifa_addr; /* Interface address */ struct sockaddr *ifa_netmask; /* Interface netmask */ struct sockaddr *ifa_broadaddr; /* Interface broadcast address */ struct sockaddr *ifa_dstaddr; /* P2P interface destination */ void *ifa_data; /* Address specific data */ Running truss on ifconfig(8) tells me that the ioctl SIOCGIFMEDIA can be used, but it is not clear to me how. Is there an API in C which does this already? # truss ifconfig em0....<snipped>.... ioctl(3,SIOCGIFMAC,0xffffe210) ERR#22 'Invalid argument' ioctl(3,SIOCGIFMEDIA,0xffffe1f0) = 0 (0x0) ioctl(3,SIOCGIFMEDIA,0xffffe1f0) = 0 (0x0) media: Ethernet autoselect (1000baseT <full-duplex>) write(1,"\tmedia: Ethernet autoselect (10"...,54) = 54 (0x36) status: active write(1,"\tstatus: active\n",16) = 16 (0x10) Thanks,Pallav _______________________________________________ freebsd-net@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-net To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"