Commit | Line | Data |
---|---|---|
6162e6b7 | 1 | /* |
0235b0db | 2 | * SPDX-License-Identifier: MIT |
6162e6b7 | 3 | * |
0235b0db | 4 | * Copyright (C) 2019 Michael Jeanson <mjeanson@efficios.com> |
6162e6b7 MJ |
5 | */ |
6 | ||
0235b0db MJ |
7 | #ifndef _BABELTRACE_COMMON_UUID_H |
8 | #define _BABELTRACE_COMMON_UUID_H | |
9 | ||
6162e6b7 MJ |
10 | #include <stdint.h> |
11 | #include "common/macros.h" | |
12 | ||
dbc37715 PP |
13 | #ifdef __cplusplus |
14 | extern "C" { | |
15 | #endif | |
16 | ||
6162e6b7 MJ |
17 | #define BT_UUID_STR_LEN 36 /* Excludes final \0 */ |
18 | #define BT_UUID_LEN 16 | |
19 | #define BT_UUID_VER 4 | |
20 | ||
21 | #define BT_UUID_FMT \ | |
22 | "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "-%02" SCNx8 \ | |
23 | "%02" SCNx8 "-%02" SCNx8 "%02" SCNx8 "-%02" SCNx8 "%02" SCNx8 \ | |
24 | "-%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 \ | |
25 | "%02" SCNx8 | |
26 | ||
27 | #define BT_UUID_FMT_VALUES(uuid) \ | |
28 | (uuid)[0], (uuid)[1], (uuid)[2], (uuid)[3], (uuid)[4], (uuid)[5], \ | |
29 | (uuid)[6], (uuid)[7], (uuid)[8], (uuid)[9], (uuid)[10], (uuid)[11], \ | |
30 | (uuid)[12], (uuid)[13], (uuid)[14], (uuid)[15] | |
31 | ||
32 | #define BT_UUID_SCAN_VALUES(uuid) \ | |
33 | &(uuid)[0], &(uuid)[1], &(uuid)[2], &(uuid)[3], &(uuid)[4], &(uuid)[5], \ | |
34 | &(uuid)[6], &(uuid)[7], &(uuid)[8], &(uuid)[9], &(uuid)[10], &(uuid)[11], \ | |
35 | &(uuid)[12], &(uuid)[13], &(uuid)[14], &(uuid)[15] | |
36 | ||
37 | typedef uint8_t bt_uuid_t[BT_UUID_LEN]; | |
38 | ||
1353b066 SM |
39 | void bt_uuid_generate(bt_uuid_t uuid_out); |
40 | void bt_uuid_to_str(const bt_uuid_t uuid_in, char *str_out); | |
41 | int bt_uuid_from_str(const char *str_in, bt_uuid_t uuid_out); | |
42 | int bt_uuid_compare(const bt_uuid_t uuid_a, const bt_uuid_t uuid_b); | |
43 | void bt_uuid_copy(bt_uuid_t uuid_dest, const bt_uuid_t uuid_src); | |
6162e6b7 | 44 | |
dbc37715 PP |
45 | #ifdef __cplusplus |
46 | } | |
47 | #endif | |
48 | ||
6162e6b7 | 49 | #endif /* _BABELTRACE_COMMON_UUID_H */ |