diff options
author | Theodore Ts'o <tytso@mit.edu> | 2004-03-19 19:29:17 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2004-03-19 19:29:17 -0500 |
commit | 84ea6e70b77090c8a35702b265039d58c2efd6ad (patch) | |
tree | 6f7bc46bf1150664dd4fc7c04ecb636d8460c402 /lib/uuid | |
parent | 39595ce86c1567461ef699995f659c4c7721e2a3 (diff) | |
download | e2fsprogs-84ea6e70b77090c8a35702b265039d58c2efd6ad.tar.gz |
Fix Darwin/Mac OS X support to fetch the ethernet address in the uuid library.
Diffstat (limited to 'lib/uuid')
-rw-r--r-- | lib/uuid/gen_uuid.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/uuid/gen_uuid.c b/lib/uuid/gen_uuid.c index c7e62a60..931d7c1b 100644 --- a/lib/uuid/gen_uuid.c +++ b/lib/uuid/gen_uuid.c @@ -43,6 +43,9 @@ #ifdef HAVE_NETINET_IN_H #include <netinet/in.h> #endif +#ifdef HAVE_NET_IF_DL_H +#include <net/if_dl.h> +#endif #include "uuidP.h" @@ -117,7 +120,10 @@ static int get_node_id(unsigned char *node_id) char buf[1024]; int n, i; unsigned char *a; - +#if defined(HAVE_NET_IF_DL_H) && defined(AF_LINK) + struct sockaddr_dl *sdlp; +#endif + /* * BSD 4.4 defines the size of an ifreq to be * max(sizeof(ifreq), sizeof(ifreq.ifr_name)+ifreq.ifr_addr.sa_len @@ -146,7 +152,7 @@ static int get_node_id(unsigned char *node_id) return -1; } n = ifc.ifc_len; - for (i = 0; i < n; i+= ifreq_size(*ifr) ) { + for (i = 0; i < n; i+= ifreq_size(*ifrp) ) { ifrp = (struct ifreq *)((char *) ifc.ifc_buf+i); strncpy(ifr.ifr_name, ifrp->ifr_name, IFNAMSIZ); #ifdef SIOCGIFHWADDR @@ -159,12 +165,19 @@ static int get_node_id(unsigned char *node_id) continue; a = (unsigned char *) ifr.ifr_enaddr; #else +#if defined(HAVE_NET_IF_DL_H) && defined(AF_LINK) + sdlp = (struct sockaddr_dl *) &ifrp->ifr_addr; + if ((sdlp->sdl_family != AF_LINK) || (sdlp->sdl_alen < 6)) + continue; + a = (unsigned char *) &sdlp->sdl_data[sdlp->sdl_nlen]; +#else /* * XXX we don't have a way of getting the hardware * address */ close(sd); return 0; +#endif /* HAVE_NET_IF_DL_H && AF_LINK */ #endif /* SIOCGENADDR */ #endif /* SIOCGIFHWADDR */ if (!a[0] && !a[1] && !a[2] && !a[3] && !a[4] && !a[5]) |