From ebed3a49240ba0dfba86d2b530c92aeff2b40500 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Thu, 30 Oct 2003 19:51:30 +0000 Subject: (get_hw_address) introduce it to eventually track down ethernet cards swap/move on bootstrapping --- perl-install/c/stuff.xs.pl | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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 #include +#include #include #include #include @@ -32,6 +33,7 @@ print ' #include #include #include +#include /* for is_ext3 */ #include @@ -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: -- cgit v1.2.1