OSSP CVS Repository

ossp - Difference in ossp-pkg/uuid/uuid.c versions 1.15 and 1.16
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/uuid/uuid.c 1.15 -> 1.16

--- uuid.c       2004/01/10 15:19:21     1.15
+++ uuid.c       2004/01/10 17:01:22     1.16
@@ -33,15 +33,17 @@
 #include <string.h>
 #include <unistd.h>
 #include <ctype.h>
-#include <time.h>
-#include <sys/time.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <time.h>
+#include <sys/time.h>
+#include <sys/types.h>
 
 #include "config.h"
 #include "uuid.h"
 #include "uuid_md5.h"
 #include "uuid_prng.h"
+#include "uuid_mac.h"
 #include "uuid_ui64.h"
 
 /* determine types of 8-bit size */
@@ -119,9 +121,10 @@
 
 /* abstract data type (ADT) of API */
 struct uuid_st {
-    uuid_obj_t  obj;  /* inlined UUID object */
-    prng_t     *prng; /* RPNG sub-object */
-    md5_t      *md5;  /* MD5 sub-object */
+    uuid_obj_t   obj;    /* inlined UUID object */
+    prng_t      *prng;   /* RPNG sub-object */
+    md5_t       *md5;    /* MD5 sub-object */
+    uuid_uint8_t mac[6]; /* pre-determined MAC address */
 };
 
 /* create UUID object */
@@ -144,6 +147,12 @@
     if (md5_create(&(*uuid)->md5) != MD5_RC_OK)
         return UUID_RC_INT;
 
+    /* resolve MAC address for insertion into node field of UUIDs */
+    if (!mac_address((unsigned char *)((*uuid)->mac), sizeof((*uuid)->mac))) {
+        memset((*uuid)->mac, '\0', sizeof((*uuid)->mac));
+        (*uuid)->mac[0] = 0x80;
+    }
+
     return UUID_RC_OK;
 }
 
@@ -507,7 +516,15 @@
 /* INTERNAL: generate UUID version 1, node part */
 static uuid_rc_t uuid_generate_v1_node(uuid_t *uuid, unsigned int mode, va_list ap)
 {
-    /* FIXME */
+    if ((mode & UUID_MCASTRND) || (uuid->mac[0] & 0x80)) {
+        /* use random multi-cast MAC address */
+        prng_data(uuid->prng, (void *)&(uuid->obj.node), sizeof(uuid->obj.node));
+        uuid->obj.node[0] |= 0x80;
+    }
+    else {
+        /* use real regular MAC address */
+        memcpy(uuid->obj.node, uuid->mac, sizeof(uuid->mac));
+    }
     return UUID_RC_OK;
 }
 

CVSTrac 2.0.1