diff options
author | Thierry Vignaud <tvignaud@mandriva.org> | 2004-05-26 09:42:51 +0000 |
---|---|---|
committer | Thierry Vignaud <tvignaud@mandriva.org> | 2004-05-26 09:42:51 +0000 |
commit | fcf597bc93e1aa48d0a3997d3501f32939acbb6e (patch) | |
tree | a25141b0b13a023a8dafc22bca0546ae0ab2fcec | |
parent | 1cae126f6f166b3fa77206444af60274e2597981 (diff) | |
download | drakx-backup-do-not-use-fcf597bc93e1aa48d0a3997d3501f32939acbb6e.tar drakx-backup-do-not-use-fcf597bc93e1aa48d0a3997d3501f32939acbb6e.tar.gz drakx-backup-do-not-use-fcf597bc93e1aa48d0a3997d3501f32939acbb6e.tar.bz2 drakx-backup-do-not-use-fcf597bc93e1aa48d0a3997d3501f32939acbb6e.tar.xz drakx-backup-do-not-use-fcf597bc93e1aa48d0a3997d3501f32939acbb6e.zip |
(netdevices) introduce it in order to list network interfaces
-rw-r--r-- | perl-install/c/stuff.xs.pl | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/perl-install/c/stuff.xs.pl b/perl-install/c/stuff.xs.pl index dfa8732eb..2097f0efc 100644 --- a/perl-install/c/stuff.xs.pl +++ b/perl-install/c/stuff.xs.pl @@ -441,6 +441,43 @@ isNetDeviceWirelessAware(device) 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) |