70 uid->
time_low = (uint32_t)(timestamp & 0xFFFFFFFF);
71 uid->
time_mid = (uint16_t)((timestamp >> 32) & 0xFFFF);
77 memcpy(&uid->
node, &node,
sizeof uid->
node);
106 next_save = timestamp;
113 if (timestamp >= next_save) {
115 next_save = timestamp + (10 * 10 * 1000 * 1000);
127 static uint16_t uuids_this_tick;
128 static int inited = 0;
137 if (time_last != time_now) {
150 *timestamp = time_now + uuids_this_tick;
151 time_last = *timestamp;
159 static int inited = 0;
165 srand((
unsigned int)(((time_now >> 32) ^ time_now) & 0xffffffff));
169 return (uint16_t)(rand());
191#define CHECK(f1, f2) \
193 return f1 < f2 ? -1 : 1;
207 "MSG1149")
"POSIX thread destroy uuid_mutex fails with EBUSY.";
226 f =
read_state(&clockseq, &last_time, &last_node);
229 if (!f || memcmp(&node, &last_node,
sizeof(
uuid_node_t)))
231 else if (timestamp < last_time)
244 "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x",
261 unsigned char hash[16];
272 MD5Update(&c, name, (
unsigned int)namelen);
286 for (i = 0; i < 6; i++) {
void MD5Update(MD5_CTX *, const void *, size_t)
MD5 Update.
void MD5Init(MD5_CTX *)
MD5 Initialisation.
void MD5Final(unsigned char digest[MD5_DIGEST_LENGTH], MD5_CTX *ctx)
MD5 Final.
uuid_state st
UUID generator persistent state.
void get_current_time(uuid_time_t *timestamp)
Get time as 60 bit 100ns ticks since whenever.
int read_state(uint16_t *clockseq, uuid_time_t *timestamp, uuid_node_t *node)
Read UUID generator state from non-volatile store.
uint16_t true_random()
generate a crypto-quality random number. This sample doesn't do that.
void write_state(uint16_t clockseq, uuid_time_t timestamp, uuid_node_t node)
Save UUID generator state back to non-volatile storage.
void format_uuid_v3(uuid_upnp *uid, unsigned char hash[16])
Make a UUID from a (pseudo)random 128 bit number.
void format_uuid_v1(uuid_upnp *uid, uint16_t clock_seq, uuid_time_t timestamp, uuid_node_t node)
Make a UUID from the timestamp, clockseq, and node ID.
int stateInited
Flag if UUID generator persistent state is initiated.
pthread_mutex_t uuid_mutex
Mutex to synchronize the uuid creation process.
Data type for UUID generator persistent state.
Specifications to be portable with sockets between different platforms.
Define macro for synced logging to the console for detailed info and debug.
void get_ieee_node_identifier(uuid_node_t *node)
System dependent call to get IEEE node identifier.
uint64_t uuid_time_t
UUID time.
void get_system_time(uuid_time_t *uuid_time)
System dependent call to get the current system time.
constexpr int UUIDS_PER_TICK
set the following to the number of 100ns ticks of the actual resolution of your system's clock
void uuid_create_from_name(uuid_upnp *uid, uuid_upnp nsid, void *name, int namelen)
Create a UUID using a "name" from a "name space".
void uuidMutexInit()
Initialize mutex for synchronizing the uuid creation process.
int uuid_compare(uuid_upnp *u1, uuid_upnp *u2)
Compare two UUID's "lexically".
#define CHECK(f1, f2)
Macro to compare times.
void upnp_uuid_unpack(uuid_upnp *u, char *out)
Unpack a UUID.
int uuidMutexDestroy()
Destroy mutex for synchronizing the uuid creation process.
int uuid_create(uuid_upnp *uid)
Generate a UUID.
uint8_t clock_seq_hi_and_reserved
Member variable.
uint16_t time_mid
Member variable.
uint32_t time_low
Member variable.
uint8_t node[6]
Member variable.
uint8_t clock_seq_low
Member variable.
uint16_t time_hi_and_version
Member variable.