summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2003-11-03 13:25:20 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2003-11-03 13:25:20 +0000
commit4dc3ecdfa9e591fbd9482a9c0b24f3217a3ec7e3 (patch)
tree9ad260c6bb1344692f63568002dfb31ca23e096c
parente01c59488b87ae069d07532b1a356c56cc8a2ef6 (diff)
downloaddrakx-4dc3ecdfa9e591fbd9482a9c0b24f3217a3ec7e3.tar
drakx-4dc3ecdfa9e591fbd9482a9c0b24f3217a3ec7e3.tar.gz
drakx-4dc3ecdfa9e591fbd9482a9c0b24f3217a3ec7e3.tar.bz2
drakx-4dc3ecdfa9e591fbd9482a9c0b24f3217a3ec7e3.tar.xz
drakx-4dc3ecdfa9e591fbd9482a9c0b24f3217a3ec7e3.zip
ask the kernel the list of network devices instead of manually probing
everything (this enable to handle more than 4 ethernet cards)
-rw-r--r--perl-install/c/stuff.xs.pl45
-rw-r--r--perl-install/detect_devices.pm3
2 files changed, 34 insertions, 14 deletions
diff --git a/perl-install/c/stuff.xs.pl b/perl-install/c/stuff.xs.pl
index ca73bfb65..422c96069 100644
--- a/perl-install/c/stuff.xs.pl
+++ b/perl-install/c/stuff.xs.pl
@@ -395,20 +395,41 @@ usb_probe()
unsigned int
getpagesize()
-int
-hasNetDevice(device)
- char * device
- CODE:
- struct ifreq req;
- int s = socket(AF_INET, SOCK_DGRAM, 0);
- if (s == -1) { RETVAL = 0; return; }
+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;
+ }
- strcpy(req.ifr_name, device);
+ // 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;
+ }
+
+ EXTEND(SP, n);
+ for (; n; --n, ++ifr)
+ PUSHs(sv_2mortal(newSVpv(ifr->ifr_name, 0)));
+ Safefree (ifc.ifc_req);
- RETVAL = ioctl(s, SIOCGIFFLAGS, &req) == 0;
- close(s);
- OUTPUT:
- RETVAL
int
addDefaultRoute(gateway)
diff --git a/perl-install/detect_devices.pm b/perl-install/detect_devices.pm
index edd586655..455269ba4 100644
--- a/perl-install/detect_devices.pm
+++ b/perl-install/detect_devices.pm
@@ -16,7 +16,6 @@ use c;
#-#####################################################################################
#- Globals
#-#####################################################################################
-my @netdevices = map { my $l = $_; map { "$l$_" } (0..3) } qw(eth tr fddi plip);
my %serialprobe;
#-######################################################################################
@@ -418,7 +417,7 @@ sub getSagem() {
}
sub getNet() {
- grep { !(($::isStandalone || $::live) && /plip/) && c::hasNetDevice($_) } @netdevices;
+ grep { /^(eth|fddi|plip|tr|wifi|wlan)/ } c::getNetInterfaces();
}
#sub getISDN() {