10 #include <linux/ethtool.h>
11 #include <linux/sockios.h>
17 * Combines ethernet IP addresses and speed (if requested) for displaying
20 const char *get_eth_info() {
21 static char part[512];
22 const char *ip_address = get_ip_addr(eth_interface);
27 /* This code path requires root privileges */
29 struct ethtool_cmd ecmd;
31 ecmd.cmd = ETHTOOL_GSET;
32 (void)memset(&ifr, 0, sizeof(ifr));
33 ifr.ifr_data = (caddr_t)&ecmd;
34 (void)strcpy(ifr.ifr_name, eth_interface);
35 if (ioctl(general_socket, SIOCETHTOOL, &ifr) == 0)
36 ethspeed = (ecmd.speed == USHRT_MAX ? 0 : ecmd.speed);
37 else get_ethspeed = false;
41 if (ip_address == NULL)
42 (void)snprintf(part, sizeof(part), "E: down");
45 (void)snprintf(part, sizeof(part), "E: %s (%d Mbit/s)", ip_address, ethspeed);
46 else (void)snprintf(part, sizeof(part), "E: %s", ip_address);