libUPnP  1.6.17
Data Structures | Defines | Functions | Variables
uuid.c File Reference
#include "config.h"
#include "uuid.h"
#include "UpnpInet.h"
#include "UpnpStdInt.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
Include dependency graph for uuid.c:

Data Structures

struct  uuid_state

Defines

#define CHECK(f1, f2)   if (f1 != f2) return f1 < f2 ? -1 : 1;

Functions

static int read_state (uint16_t *clockseq, uuid_time_t *timestamp, uuid_node_t *node)
 Read UUID generator state from non-volatile store.
static void write_state (uint16_t clockseq, uuid_time_t timestamp, uuid_node_t node)
 Save UUID generator state back to non-volatile storage.
static 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.
static void format_uuid_v3 (uuid_upnp *uid, unsigned char hash[16])
 Make a UUID from a (pseudo)random 128 bit number.
static void get_current_time (uuid_time_t *timestamp)
 Get time as 60 bit 100ns ticks since whenever.
static uint16_t true_random (void)
 generate a crypto-quality random number. This sample doesn't do that.
int uuid_create (uuid_upnp *uid)
 Generator of a UUID.
void uuid_unpack (uuid_upnp *u, char *out)
 Out will be xxxx-xx-xx-xx-xxxxxx format.
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".
int uuid_compare (uuid_upnp *u1, uuid_upnp *u2)
 Compare two UUID's "lexically" and return.

Variables

static uuid_state st
static int stateInited = 0

Detailed Description


Function Documentation

void format_uuid_v1 ( uuid_upnp uid,
uint16_t  clockseq,
uuid_time_t  timestamp,
uuid_node_t  node 
) [static]
void format_uuid_v3 ( uuid_upnp uid,
unsigned char  hash[16] 
) [static]

Make a UUID from a (pseudo)random 128 bit number.

References _uuid_upnp::clock_seq_hi_and_reserved, _uuid_upnp::time_hi_and_version, _uuid_upnp::time_low, and _uuid_upnp::time_mid.

Referenced by uuid_create_from_name().

void get_current_time ( uuid_time_t *  timestamp) [static]

Get time as 60 bit 100ns ticks since whenever.

Compensate for the fact that real clock resolution is less than 100ns.

References get_system_time(), and UUIDS_PER_TICK.

Referenced by uuid_create().

int read_state ( uint16_t *  clockseq,
uuid_time_t *  timestamp,
uuid_node_t node 
) [static]

Read UUID generator state from non-volatile store.

References uuid_state::cs, uuid_state::node, and uuid_state::ts.

Referenced by uuid_create().

static uint16_t true_random ( void  ) [static]

generate a crypto-quality random number. This sample doesn't do that.

References get_system_time(), and UUIDS_PER_TICK.

Referenced by uuid_create().

int uuid_compare ( uuid_upnp u1,
uuid_upnp u2 
)

Compare two UUID's "lexically" and return.

Compare two UUID's "lexically".

  • -1: u1 is lexically before u2
  • 0: u1 is equal to u2
  • 1: u1 is lexically after u2

Note: Lexical ordering is not temporal ordering!

Parameters:
u1.
u2.

References _uuid_upnp::clock_seq_hi_and_reserved, _uuid_upnp::clock_seq_low, _uuid_upnp::node, _uuid_upnp::time_hi_and_version, _uuid_upnp::time_low, and _uuid_upnp::time_mid.

int uuid_create ( uuid_upnp uid)
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".

Parameters:
uidresulting UUID.
nsidUUID to serve as context, so identical names from different name spaces generate different UUIDs.
nameThe name from which to generate a UUID.
namelenThe length of the name.

References format_uuid_v3(), _uuid_upnp::time_hi_and_version, _uuid_upnp::time_low, and _uuid_upnp::time_mid.

void uuid_unpack ( uuid_upnp u,
char *  out 
)
void write_state ( uint16_t  clockseq,
uuid_time_t  timestamp,
uuid_node_t  node 
) [static]

Save UUID generator state back to non-volatile storage.

References uuid_state::cs, uuid_state::node, and uuid_state::ts.

Referenced by uuid_create().