Blame SOURCES/uuid-1.6.2-hwaddr.patch

a7754c
diff -urN uuid-1.6.2/configure uuid-1.6.2/configure
a7754c
--- uuid-1.6.2/configure	2008-07-04 15:43:09.000000000 -0600
a7754c
+++ uuid-1.6.2/configure	2012-06-06 19:19:41.659880386 -0600
a7754c
@@ -14208,7 +14208,7 @@
a7754c
 
a7754c
 
a7754c
 
a7754c
-for ac_header in netdb.h ifaddrs.h net/if.h net/if_dl.h net/if_arp.h netinet/in.h arpa/inet.h
a7754c
+for ac_header in netdb.h ifaddrs.h net/if.h net/if_dl.h net/if_arp.h netinet/in.h arpa/inet.h netpacket/packet.h
a7754c
 do
a7754c
 as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
a7754c
 { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
a7754c
diff -urN uuid-1.6.2/uuid.c uuid-1.6.2/uuid.c
a7754c
--- uuid-1.6.2/uuid.c	2008-03-07 03:49:59.000000000 -0700
a7754c
+++ uuid-1.6.2/uuid.c	2012-06-06 15:50:30.060881473 -0600
a7754c
@@ -72,6 +72,8 @@
a7754c
 /* IEEE 802 MAC address octet length */
a7754c
 #define IEEE_MAC_OCTETS 6
a7754c
 
a7754c
+static unsigned char mac_unset[IEEE_MAC_OCTETS] = {BM_OCTET(1,0,0,0,0,0,0,0), 0x00, 0x00, 0x00, 0x00, 0x00};
a7754c
+
a7754c
 /* UUID binary representation according to UUID standards */
a7754c
 typedef struct {
a7754c
     uuid_uint32_t  time_low;                  /* bits  0-31 of time field */
a7754c
@@ -967,7 +969,7 @@
a7754c
      *  GENERATE NODE
a7754c
      */
a7754c
 
a7754c
-    if ((mode & UUID_MAKE_MC) || (uuid->mac[0] & BM_OCTET(1,0,0,0,0,0,0,0))) {
a7754c
+    if ((mode & UUID_MAKE_MC) || !memcmp(uuid->mac, mac_unset, IEEE_MAC_OCTETS)) {
a7754c
         /* generate random IEEE 802 local multicast MAC address */
a7754c
         if (prng_data(uuid->prng, (void *)&(uuid->obj.node), sizeof(uuid->obj.node)) != PRNG_RC_OK)
a7754c
             return UUID_RC_INT;
a7754c
diff -urN uuid-1.6.2/uuid_mac.c uuid-1.6.2/uuid_mac.c
a7754c
--- uuid-1.6.2/uuid_mac.c	2008-03-07 03:49:59.000000000 -0700
a7754c
+++ uuid-1.6.2/uuid_mac.c	2012-06-06 19:30:49.050879930 -0600
a7754c
@@ -76,6 +76,9 @@
a7754c
 #ifdef HAVE_IFADDRS_H
a7754c
 #include <ifaddrs.h>
a7754c
 #endif
a7754c
+#ifdef HAVE_NETPACKET_PACKET_H
a7754c
+#include <netpacket/packet.h>
a7754c
+#endif
a7754c
 
a7754c
 /* own headers (part (1/2) */
a7754c
 #include "uuid_mac.h"
a7754c
@@ -87,6 +90,10 @@
a7754c
 #define TRUE (/*lint -save -e506*/ !FALSE /*lint -restore*/)
a7754c
 #endif
a7754c
 
a7754c
+#if !defined(min)
a7754c
+#define min(a,b) ((a) < (b) ? (a) : (b))
a7754c
+#endif
a7754c
+
a7754c
 /* return the Media Access Control (MAC) address of
a7754c
    the FIRST network interface card (NIC) */
a7754c
 int mac_address(unsigned char *data_ptr, size_t data_len)
a7754c
@@ -95,28 +102,41 @@
a7754c
     if (data_ptr == NULL || data_len < MAC_LEN)
a7754c
         return FALSE;
a7754c
 
a7754c
-#if defined(HAVE_IFADDRS_H) && defined(HAVE_NET_IF_DL_H) && defined(HAVE_GETIFADDRS)
a7754c
+#if defined(HAVE_IFADDRS_H) && (defined(HAVE_NET_IF_DL_H) || defined(HAVE_NETPACKET_PACKET_H)) && defined(HAVE_GETIFADDRS)
a7754c
     /* use getifaddrs(3) on BSD class platforms (xxxBSD, MacOS X, etc) */
a7754c
     {
a7754c
         struct ifaddrs *ifap;
a7754c
         struct ifaddrs *ifap_head;
a7754c
+#if defined(HAVE_NET_IF_DL_H)
a7754c
         const struct sockaddr_dl *sdl;
a7754c
         unsigned char *ucp;
a7754c
-        int i;
a7754c
+#else
a7754c
+	const struct sockaddr_ll *sll;
a7754c
+#endif
a7754c
 
a7754c
         if (getifaddrs(&ifap_head) < 0)
a7754c
             return FALSE;
a7754c
         for (ifap = ifap_head; ifap != NULL; ifap = ifap->ifa_next) {
a7754c
+#if defined(HAVE_NET_IF_DL_H)
a7754c
             if (ifap->ifa_addr != NULL && ifap->ifa_addr->sa_family == AF_LINK) {
a7754c
                 sdl = (const struct sockaddr_dl *)(void *)ifap->ifa_addr;
a7754c
                 ucp = (unsigned char *)(sdl->sdl_data + sdl->sdl_nlen);
a7754c
                 if (sdl->sdl_alen > 0) {
a7754c
-                    for (i = 0; i < MAC_LEN && i < sdl->sdl_alen; i++, ucp++)
a7754c
-                        data_ptr[i] = (unsigned char)(*ucp & 0xff);
a7754c
+                    memcpy(data_ptr, ucp, min(sdl->sdl_alen, MAC_LEN));
a7754c
                     freeifaddrs(ifap_head);
a7754c
                     return TRUE;
a7754c
                 }
a7754c
             }
a7754c
+#else
a7754c
+            if (ifap->ifa_addr != NULL && ifap->ifa_addr->sa_family == AF_PACKET) {
a7754c
+                sll = (const struct sockaddr_ll *)(void *)ifap->ifa_addr;
a7754c
+                if (sll->sll_hatype == ARPHRD_ETHER) {
a7754c
+                    memcpy(data_ptr, sll->sll_addr, min(sll->sll_halen, MAC_LEN));
a7754c
+                    freeifaddrs(ifap_head);
a7754c
+                    return TRUE;
a7754c
+                }
a7754c
+            }
a7754c
+#endif
a7754c
         }
a7754c
         freeifaddrs(ifap_head);
a7754c
     }
a7754c
diff -urN uuid-1.6.2/config.h.in uuid-1.6.2/config.h.in
a7754c
--- uuid-1.6.2/config.h.in	2008-07-04 15:43:10.000000000 -0600
a7754c
+++ uuid-1.6.2/config.h.in	2012-06-06 21:59:03.370227352 -0600
a7754c
@@ -75,6 +75,9 @@
a7754c
 /* Define to 1 if you have the <netinet/in.h> header file. */
a7754c
 #undef HAVE_NETINET_IN_H
a7754c
 
a7754c
+/* Define to 1 if you have the <netpacket/packet.h> header file. */
a7754c
+#undef HAVE_NETPACKET_PACKET_H
a7754c
+
a7754c
 /* Define to 1 if you have the <net/if_arp.h> header file. */
a7754c
 #undef HAVE_NET_IF_ARP_H
a7754c