summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/probing.c
diff options
context:
space:
mode:
Diffstat (limited to 'mdk-stage1/probing.c')
-rw-r--r--mdk-stage1/probing.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/mdk-stage1/probing.c b/mdk-stage1/probing.c
index 956038da2..b9420deb7 100644
--- a/mdk-stage1/probing.c
+++ b/mdk-stage1/probing.c
@@ -40,6 +40,8 @@
#include <fnmatch.h>
#include <sys/socket.h>
#include <net/if.h>
+#include <linux/sockios.h>
+#include <linux/ethtool.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
#include <pci/pci.h>
@@ -125,11 +127,25 @@ void net_discovered_interface(char * intf_name)
char * get_net_intf_description(char * intf_name)
{
- int i;
- for (i = 0; i < net_descr_number ; i++)
- if (!strcmp(net_descriptions[i].intf_name, intf_name))
- return net_descriptions[i].intf_description;
- return strdup("unknown");
+ struct ifreq ifr;
+ struct ethtool_drvinfo drvinfo;
+ int s = socket(AF_INET, SOCK_DGRAM, 0);
+ char *res;
+
+ memset(&ifr, 0, sizeof(ifr));
+ strncpy(ifr.ifr_name, intf_name, IFNAMSIZ);
+
+ drvinfo.cmd = ETHTOOL_GDRVINFO;
+ ifr.ifr_data = (caddr_t) &drvinfo;
+
+ if (ioctl(s, SIOCETHTOOL, &ifr) != -1) {
+ res = drvinfo.driver;
+ } else {
+ perror("SIOCETHTOOL");
+ res = "unknown";
+ }
+ close(s);
+ return strdup(res);
}
#endif