Re: Programmatically get ethernet interface speed?

From: David S. Miller (davem@redhat.com)
Date: Wed Jul 11 2001 - 20:19:13 EST


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
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org



This archive was generated by hypermail 2b29 : Sun Jul 15 2001 - 21:00:25 EST