summaryrefslogtreecommitdiffstats
path: root/perl-install/c/stuff.xs.pl
diff options
context:
space:
mode:
authorMystery Man <unknown@mandriva.org>2005-10-20 14:05:54 +0000
committerMystery Man <unknown@mandriva.org>2005-10-20 14:05:54 +0000
commit9b6a0d83d135fad376b4eadcb2bd7bd8c8a07aa5 (patch)
treef3ef7ada2ce82dafb6d41cc087b0cc7fdfc40a46 /perl-install/c/stuff.xs.pl
parent3e4ad5e1b687f262a1d7cc39a0b905a595ac7f95 (diff)
downloaddrakx-9b6a0d83d135fad376b4eadcb2bd7bd8c8a07aa5.tar
drakx-9b6a0d83d135fad376b4eadcb2bd7bd8c8a07aa5.tar.gz
drakx-9b6a0d83d135fad376b4eadcb2bd7bd8c8a07aa5.tar.bz2
drakx-9b6a0d83d135fad376b4eadcb2bd7bd8c8a07aa5.tar.xz
drakx-9b6a0d83d135fad376b4eadcb2bd7bd8c8a07aa5.zip
This commit was manufactured by cvs2svn to create tagV10_34_11_100mdk
'V10_34_11_100mdk'.
Diffstat (limited to 'perl-install/c/stuff.xs.pl')
-rw-r--r--perl-install/c/stuff.xs.pl61
1 files changed, 59 insertions, 2 deletions
diff --git a/perl-install/c/stuff.xs.pl b/perl-install/c/stuff.xs.pl
index 26e6ce413..07249d66b 100644
--- a/perl-install/c/stuff.xs.pl
+++ b/perl-install/c/stuff.xs.pl
@@ -23,6 +23,8 @@ print '
#include <sys/stat.h>
#include <sys/utsname.h>
#include <sys/mount.h>
+#undef __USE_MISC
+#include <linux/wireless.h>
#include <linux/keyboard.h>
#include <linux/kd.h>
#include <linux/hdreg.h>
@@ -398,13 +400,68 @@ hasNetDevice(device)
int s = socket(AF_INET, SOCK_DGRAM, 0);
if (s == -1) { RETVAL = 0; return; }
- strcpy(req.ifr_name, device);
+ strncpy(req.ifr_name, device, IFNAMSIZ);
RETVAL = ioctl(s, SIOCGIFFLAGS, &req) == 0;
close(s);
OUTPUT:
RETVAL
+
+int
+isNetDeviceWirelessAware(device)
+ char * device
+ CODE:
+ struct iwreq ifr;
+
+ int s = socket(AF_INET, SOCK_DGRAM, 0);
+
+ memset(&ifr, 0, sizeof(ifr));
+ strncpy(ifr.ifr_name, device, IFNAMSIZ);
+ RETVAL = ioctl(s, SIOCGIWNAME, &ifr) != -1;
+ close(s);
+ OUTPUT:
+ RETVAL
+
+
+void
+get_netdevices()
+ PPCODE:
+ struct ifconf ifc;
+ struct ifreq *ifr;
+ int i;
+ int numreqs = 10;
+
+ int s = socket(AF_INET, SOCK_DGRAM, 0);
+
+ ifc.ifc_buf = NULL;
+ for (;;) {
+ ifc.ifc_len = sizeof(struct ifreq) * numreqs;
+ ifc.ifc_buf = realloc(ifc.ifc_buf, ifc.ifc_len);
+
+ if (ioctl(s, SIOCGIFCONF, &ifc) < 0) {
+ perror("SIOCGIFCONF");
+ return;
+ }
+ if (ifc.ifc_len == sizeof(struct ifreq) * numreqs) {
+ /* assume it overflowed and try again */
+ numreqs += 10;
+ continue;
+ }
+ break;
+ }
+ if (ifc.ifc_len) {
+ ifr = ifc.ifc_req;
+ EXTEND(sp, ifc.ifc_len);
+ for (i=0; i < ifc.ifc_len; i+= sizeof(struct ifreq)) {
+ PUSHs(sv_2mortal(newSVpv(ifr->ifr_name, 0)));
+ ifr++;
+ }
+ }
+
+ close(s);
+
+
char*
getNetDriver(char* device)
ALIAS:
@@ -415,7 +472,7 @@ getNetDriver(char* device)
int s = socket(AF_INET, SOCK_DGRAM, 0);
memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)-1);
+ strncpy(ifr.ifr_name, device, IFNAMSIZ);
drvinfo.cmd = ETHTOOL_GDRVINFO;
ifr.ifr_data = (caddr_t) &drvinfo;