Re: Programmatically get ethernet interface speed?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Andrew Morton writes:
 > Unfortunately we have no uniform way of doing this.

Really? ;-)

#include <linux/ethtool.h>

struct ethtool_cmd tmp;
int err;
err = ioctl(fd, ETHTOOL_GSET, &tmp);
if (err < 0) {
   perror("ETHTOOL_GSET");
   exit(1);
}
switch (tmp.speed) {
case SPEED_10: printf("10 Mb\n"); break;
case SPEED_100: printf("100 Mb\n"); break;
case SPEED_1000: printf("1000 Mb\n"); break;
};
exit(0);

Later,
David S. Miller
davem@redhat.com
-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux