From 58776de07de819cb962aa35e76c8379d96f03e6b Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Thu, 6 Nov 2003 14:17:00 +0000 Subject: (getNetDriver) ask the kernel the network interface <-> driver mapping --- perl-install/c/stuff.xs.pl | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'perl-install') diff --git a/perl-install/c/stuff.xs.pl b/perl-install/c/stuff.xs.pl index ca73bfb65..5ea0f8734 100644 --- a/perl-install/c/stuff.xs.pl +++ b/perl-install/c/stuff.xs.pl @@ -34,6 +34,15 @@ print ' #include #include #include +#include + +// for ethtool structs: +typedef unsigned long long u64; +typedef __uint32_t u32; +typedef __uint16_t u16; +typedef __uint8_t u8; + +#include /* for is_ext3 */ #include @@ -410,6 +419,26 @@ hasNetDevice(device) OUTPUT: RETVAL +char* +getNetDriver(char* device) + CODE: + struct ifreq ifr; + struct ethtool_drvinfo drvinfo; + int s = socket(AF_INET, SOCK_DGRAM, 0); + + memset(&ifr, 0, sizeof(ifr)); + strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)-1); + + drvinfo.cmd = ETHTOOL_GDRVINFO; + ifr.ifr_data = (caddr_t) &drvinfo; + + if (ioctl(s, SIOCETHTOOL, &ifr) != -1) + RETVAL = strdup(drvinfo.driver); + else { perror("SIOCETHTOOL"); RETVAL = strdup(""); } + OUTPUT: + RETVAL + + int addDefaultRoute(gateway) char *gateway -- cgit v1.2.1