diff options
author | Thierry Vignaud <tvignaud@mandriva.org> | 2003-11-06 14:17:00 +0000 |
---|---|---|
committer | Thierry Vignaud <tvignaud@mandriva.org> | 2003-11-06 14:17:00 +0000 |
commit | 58776de07de819cb962aa35e76c8379d96f03e6b (patch) | |
tree | 26b4882841a37eedea542a95bfa6eb05bd4a4230 /perl-install/c | |
parent | 10833cd0e189b74bbe12b5dc7dab363edce5e020 (diff) | |
download | drakx-58776de07de819cb962aa35e76c8379d96f03e6b.tar drakx-58776de07de819cb962aa35e76c8379d96f03e6b.tar.gz drakx-58776de07de819cb962aa35e76c8379d96f03e6b.tar.bz2 drakx-58776de07de819cb962aa35e76c8379d96f03e6b.tar.xz drakx-58776de07de819cb962aa35e76c8379d96f03e6b.zip |
(getNetDriver) ask the kernel the network interface <-> driver mapping
Diffstat (limited to 'perl-install/c')
-rw-r--r-- | perl-install/c/stuff.xs.pl | 29 |
1 files changed, 29 insertions, 0 deletions
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 <net/if.h> #include <net/route.h> #include <netinet/in.h> +#include <linux/sockios.h> + +// for ethtool structs: +typedef unsigned long long u64; +typedef __uint32_t u32; +typedef __uint16_t u16; +typedef __uint8_t u8; + +#include <linux/ethtool.h> /* for is_ext3 */ #include <ext2fs/ext2_fs.h> @@ -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 |