RFC 4122 compliant UUID’s

Provides RFC 4122 compliant UUID’s.

This module provides RFC 4122 compliant UUID generation. The UUID stored in uuid_t struct is stored in network byte order.

UUID_V1

Type 1 UUID - timestamp based.

1
(0x01)
UUID_V2

Type 2 UUID - DCE Security version.

1
(0x02)
UUID_V3

Type 3 UUID - Name based with MD5.

1
(0x03)
UUID_V4

Type 4 UUID - Random generated.

1
(0x04)
UUID_V5

Type 5 UUID - Name based with SHA1.

1
(0x05)
UUID_VERSION_MASK
1
(0xF000)
const uuid_t uuid_namespace_dns

DNS namespace UUID.

const uuid_t uuid_namespace_url

URL namespace UUID.

const uuid_t uuid_namespace_iso

ISO OID namespace UUID.

const uuid_t uuid_namespace_x500

X.500 DN namespace UUID.

void uuid_v3(uuid_t * uuid, const uuid_t * ns, const uint8_t * name, msp430_types.h::size_t len)

Generate a version 3(md5 based) UUID from a namespace and a byte array.

Parameters

uuid:UUID struct to fill
ns:Namespace UUID
name:Ptr to byte array to use as name part
len:Length of the byte array

void uuid_v4(uuid_t * uuid)

Generate a version 4(Full random) UUID.

Parameters

uuid:UUID struct to fill

void uuid_v5(uuid_t * uuid, const uuid_t * ns, const uint8_t * name, msp430_types.h::size_t len)

Generate a version 5(sha1 based) UUID from a namespace and a byte array.

Parameters

uuid:UUID struct to fill
ns:Namespace UUID
name:Ptr to byte array to use as name part
len:Length of the byte array

unsigned uuid_version(const uuid_t * uuid)

Retrieve the type number of a UUID.

Parameters

uuid:UUID to retrieve version number from

Return values

  • Version number
bool uuid_equal(const uuid_t * uuid1, const uuid_t * uuid2)

Compare two UUID’s.

Parameters

uuid1:First uuid to compare
uuid2:Second uuid to compare

Return values

  • True when equal
void uuid_to_string(const uuid_t * uuid, char * str)

Generate an UUID string from an UUID structure.

Parameters

uuid:UUID
str:null-terminated UUID string, must be at least UUID_STR_LEN + 1 bytes

int uuid_from_string(uuid_t * uuid, const char * str)

Populate an UUID structure from an UUID string.

Parameters

uuid:out UUID
str:null-terminated input UUID string, must be UUID_STR_LEN bytes

Return values

  • 0 on succes, < 0 if str is not valid
UUID_NODE_LEN

Size of the node identifier in bytes.

1
(6U)
UUID_STR_LEN

Size of a string UUID without null character.

1
(36U)
struct uuid_t

UUID layout.

Directly from rfc4122

byteorder.h::network_uint32_t time_low

The low field of the timestamp.

byteorder.h::network_uint16_t time_mid

The middle field of the timestamp.

byteorder.h::network_uint16_t time_hi

The high field of the timestamp multiplexed with the version number.

uint8_t clk_seq_hi_res

The high field of the clock sequence Multiplexed with the variant.

uint8_t clk_seq_low

The low field of the clock sequence.

uint8_t node()

The spatially unique node identifier.