summaryrefslogtreecommitdiffstats
path: root/perl-install/c/stuff.xs.pl
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/c/stuff.xs.pl')
-rw-r--r--perl-install/c/stuff.xs.pl31
1 files changed, 31 insertions, 0 deletions
diff --git a/perl-install/c/stuff.xs.pl b/perl-install/c/stuff.xs.pl
index fb9f86074..ab5bf35c7 100644
--- a/perl-install/c/stuff.xs.pl
+++ b/perl-install/c/stuff.xs.pl
@@ -10,6 +10,7 @@ print '
#include <ctype.h>
#include <stdlib.h>
+#include <stdio.h>
#include <unistd.h>
#include <syslog.h>
#include <fcntl.h>
@@ -32,6 +33,16 @@ print '
#include <linux/blkpg.h>
#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>
@@ -404,6 +415,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