Provides RFC 4122 compliant UUID's.
More...
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.
|
#define | UUID_NODE_LEN (6U) |
| Size of the node identifier in bytes.
|
|
#define | UUID_STR_LEN (36U) |
| Size of a string UUID without null character.
|
|
|
void | uuid_v3 (uuid_t *uuid, const uuid_t *ns, const uint8_t *name, size_t len) |
| Generate a version 3(md5 based) UUID from a namespace and a byte array.
|
|
void | uuid_v4 (uuid_t *uuid) |
| Generate a version 4(Full random) UUID.
|
|
void | uuid_v5 (uuid_t *uuid, const uuid_t *ns, const uint8_t *name, size_t len) |
| Generate a version 5(sha1 based) UUID from a namespace and a byte array.
|
|
static unsigned | uuid_version (const uuid_t *uuid) |
| Retrieve the type number of a UUID.
|
|
static bool | uuid_equal (const uuid_t *uuid1, const uuid_t *uuid2) |
| Compare two UUID's.
|
|
void | uuid_to_string (const uuid_t *uuid, char *str) |
| Generate an UUID string from an UUID structure.
|
|
int | uuid_from_string (uuid_t *uuid, const char *str) |
| Populate an UUID structure from an UUID string.
|
|
|
Copied from rfc4122 Appendix C
|
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.
|
|
|
#define | UUID_V1 (0x01) |
| Type 1 UUID - timestamp based
|
|
#define | UUID_V2 (0x02) |
| Type 2 UUID - DCE Security version.
|
|
#define | UUID_V3 (0x03) |
| Type 3 UUID - Name based with MD5
|
|
#define | UUID_V4 (0x04) |
| Type 4 UUID - Random generated
|
|
#define | UUID_V5 (0x05) |
| Type 5 UUID - Name based with SHA1.
|
|
◆ UUID_NODE_LEN
#define UUID_NODE_LEN (6U) |
Size of the node identifier in bytes.
Definition at line 39 of file uuid.h.
◆ UUID_STR_LEN
#define UUID_STR_LEN (36U) |
Size of a string UUID without null character.
Definition at line 41 of file uuid.h.
◆ UUID_V1
Type 1 UUID - timestamp based
Definition at line 47 of file uuid.h.
◆ UUID_V2
Type 2 UUID - DCE Security version.
Definition at line 48 of file uuid.h.
◆ UUID_V3
Type 3 UUID - Name based with MD5
Definition at line 49 of file uuid.h.
◆ UUID_V4
Type 4 UUID - Random generated
Definition at line 50 of file uuid.h.
◆ UUID_V5
Type 5 UUID - Name based with SHA1.
Definition at line 51 of file uuid.h.
◆ UUID_VERSION_MASK
#define UUID_VERSION_MASK (0xF000) |
◆ uuid_equal()
static bool uuid_equal |
( |
const uuid_t * |
uuid1, |
|
|
const uuid_t * |
uuid2 |
|
) |
| |
|
inlinestatic |
Compare two UUID's.
- Parameters
-
[in] | uuid1 | First uuid to compare |
[in] | uuid2 | Second uuid to compare |
- Returns
- True when equal
Definition at line 138 of file uuid.h.
◆ uuid_from_string()
int uuid_from_string |
( |
uuid_t * |
uuid, |
|
|
const char * |
str |
|
) |
| |
Populate an UUID structure from an UUID string.
- Parameters
-
[out] | uuid | out UUID |
[in] | str | null-terminated input UUID string, must be UUID_STR_LEN bytes |
- Returns
- 0 on success, < 0 if
str
is not valid
◆ uuid_to_string()
void uuid_to_string |
( |
const uuid_t * |
uuid, |
|
|
char * |
str |
|
) |
| |
Generate an UUID string from an UUID structure.
- Parameters
-
[in] | uuid | UUID |
[out] | str | null-terminated UUID string, must be at least UUID_STR_LEN + 1 bytes |
◆ uuid_v3()
void uuid_v3 |
( |
uuid_t * |
uuid, |
|
|
const uuid_t * |
ns, |
|
|
const uint8_t * |
name, |
|
|
size_t |
len |
|
) |
| |
Generate a version 3(md5 based) UUID from a namespace and a byte array.
- Parameters
-
[out] | uuid | UUID struct to fill |
[in] | ns | Namespace UUID |
[in] | name | Ptr to byte array to use as name part |
[in] | len | Length of the byte array |
◆ uuid_v4()
Generate a version 4(Full random) UUID.
- Parameters
-
[out] | uuid | UUID struct to fill |
◆ uuid_v5()
void uuid_v5 |
( |
uuid_t * |
uuid, |
|
|
const uuid_t * |
ns, |
|
|
const uint8_t * |
name, |
|
|
size_t |
len |
|
) |
| |
Generate a version 5(sha1 based) UUID from a namespace and a byte array.
- Parameters
-
[out] | uuid | UUID struct to fill |
[in] | ns | Namespace UUID |
[in] | name | Ptr to byte array to use as name part |
[in] | len | Length of the byte array |
◆ uuid_version()
static unsigned uuid_version |
( |
const uuid_t * |
uuid | ) |
|
|
inlinestatic |
Retrieve the type number of a UUID.
- Parameters
-
[in] | uuid | UUID to retrieve version number from |
- Returns
- Version number
Definition at line 123 of file uuid.h.