summaryrefslogtreecommitdiffstats
path: root/perl-install/c
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2003-11-05 13:32:54 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2003-11-05 13:32:54 +0000
commit4022d5f26b22c02a995540a3a7d5453226082ed4 (patch)
tree060c73e98c87f760e26f997738e0c5c500272716 /perl-install/c
parent23884dd52425fc59bf4fba24ef1a475408ea7e09 (diff)
downloaddrakx-4022d5f26b22c02a995540a3a7d5453226082ed4.tar
drakx-4022d5f26b22c02a995540a3a7d5453226082ed4.tar.gz
drakx-4022d5f26b22c02a995540a3a7d5453226082ed4.tar.bz2
drakx-4022d5f26b22c02a995540a3a7d5453226082ed4.tar.xz
drakx-4022d5f26b22c02a995540a3a7d5453226082ed4.zip
reput back hasNetDevice() instead of getNetInterfaces() since
SIOCGIFCONF only list *active* network interfaces
Diffstat (limited to 'perl-install/c')
-rw-r--r--perl-install/c/stuff.xs.pl45
1 files changed, 12 insertions, 33 deletions
diff --git a/perl-install/c/stuff.xs.pl b/perl-install/c/stuff.xs.pl
index 422c96069..ca73bfb65 100644
--- a/perl-install/c/stuff.xs.pl
+++ b/perl-install/c/stuff.xs.pl
@@ -395,41 +395,20 @@ usb_probe()
unsigned int
getpagesize()
-void
-getNetInterfaces()
- PPCODE:
- struct ifconf ifc;
- struct ifreq *ifr;
- int fd, n;
-
- if ((fd = socket (PF_INET, SOCK_DGRAM, 0)) == -1) {
- perror("getNetInterfaces() >> creating socket");
- XSRETURN_EMPTY;
- }
-
- // SIOCGIFCOUNT is unimplemented, let\'s call SIOCGIFCONF(0) to get number of interfaces
- ifc.ifc_len = 0; ifc.ifc_buf = NULL; ifc.ifc_req = NULL;
- if (ioctl (fd, SIOCGIFCONF, &ifc) == -1) {
- perror("getNetInterfaces() >> SIOCGIFCONF(0)");
- XSRETURN_EMPTY;
- }
-
- // allocate enough space
- n = ifc.ifc_len / sizeof (struct ifreq);
- New (0xbad, ifr, ifc.ifc_len, struct ifreq);
-
- // Get the network interfaces list
- ifc.ifc_req = ifr;
- if (ioctl (fd, SIOCGIFCONF, &ifc) == -1) {
- perror("getNetInterfaces() >> SIOCGIFCONF()");
- XSRETURN_EMPTY;
- }
+int
+hasNetDevice(device)
+ char * device
+ CODE:
+ struct ifreq req;
+ int s = socket(AF_INET, SOCK_DGRAM, 0);
+ if (s == -1) { RETVAL = 0; return; }
- EXTEND(SP, n);
- for (; n; --n, ++ifr)
- PUSHs(sv_2mortal(newSVpv(ifr->ifr_name, 0)));
- Safefree (ifc.ifc_req);
+ strcpy(req.ifr_name, device);
+ RETVAL = ioctl(s, SIOCGIFFLAGS, &req) == 0;
+ close(s);
+ OUTPUT:
+ RETVAL
int
addDefaultRoute(gateway)