diff options
author | Thierry Vignaud <tvignaud@mandriva.org> | 2003-10-30 19:51:30 +0000 |
---|---|---|
committer | Thierry Vignaud <tvignaud@mandriva.org> | 2003-10-30 19:51:30 +0000 |
commit | ebed3a49240ba0dfba86d2b530c92aeff2b40500 (patch) | |
tree | 43d8afb50582179e0dbec82b451744343fc01148 /perl-install/c/stuff.xs.pl | |
parent | 367f0bed2bef215e2587f839664c1e123aad7443 (diff) | |
download | drakx-backup-do-not-use-ebed3a49240ba0dfba86d2b530c92aeff2b40500.tar drakx-backup-do-not-use-ebed3a49240ba0dfba86d2b530c92aeff2b40500.tar.gz drakx-backup-do-not-use-ebed3a49240ba0dfba86d2b530c92aeff2b40500.tar.bz2 drakx-backup-do-not-use-ebed3a49240ba0dfba86d2b530c92aeff2b40500.tar.xz drakx-backup-do-not-use-ebed3a49240ba0dfba86d2b530c92aeff2b40500.zip |
(get_hw_address) introduce it to eventually track down ethernet cards
swap/move on bootstrapping
Diffstat (limited to 'perl-install/c/stuff.xs.pl')
-rw-r--r-- | perl-install/c/stuff.xs.pl | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/perl-install/c/stuff.xs.pl b/perl-install/c/stuff.xs.pl index d3851bfe4..ca73bfb65 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,7 @@ print ' #include <linux/blkpg.h> #include <net/if.h> #include <net/route.h> +#include <netinet/in.h> /* for is_ext3 */ #include <ext2fs/ext2_fs.h> @@ -435,6 +437,34 @@ addDefaultRoute(gateway) OUTPUT: RETVAL + +char* +get_hw_address(const char* ifname) + CODE: + int s; + struct ifreq ifr; + unsigned char *a; + char *res; + s = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP); + if (s < 0) { + perror("socket"); + RETVAL = NULL; + return; + } + strncpy((char*) &ifr.ifr_name, ifname, IFNAMSIZ); + if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { + perror("ioctl(SIOCGIFHWADDR)"); + RETVAL = NULL; + return; + } + a = ifr.ifr_hwaddr.sa_data; + asprintf(&res, "%02x:%02x:%02x:%02x:%02x:%02x", a[0],a[1],a[2],a[3],a[4],a[5]); + RETVAL= res; + OUTPUT: + RETVAL + + + char * kernel_version() CODE: |