1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#ifndef QEMU_UUID_H
17#define QEMU_UUID_H
18
19
20
21
22typedef struct {
23 union {
24 unsigned char data[16];
25 struct {
26
27 uint32_t time_low;
28 uint16_t time_mid;
29 uint16_t time_high_and_version;
30 uint8_t clock_seq_and_reserved;
31 uint8_t clock_seq_low;
32 uint8_t node[6];
33 } fields;
34 };
35} QemuUUID;
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55#define UUID_LE(time_low, time_mid, time_hi_and_version, \
56 clock_seq_hi_and_reserved, clock_seq_low, node0, node1, node2, \
57 node3, node4, node5) \
58 { (time_low) & 0xff, ((time_low) >> 8) & 0xff, ((time_low) >> 16) & 0xff, \
59 ((time_low) >> 24) & 0xff, (time_mid) & 0xff, ((time_mid) >> 8) & 0xff, \
60 (time_hi_and_version) & 0xff, ((time_hi_and_version) >> 8) & 0xff, \
61 (clock_seq_hi_and_reserved), (clock_seq_low), (node0), (node1), (node2),\
62 (node3), (node4), (node5) }
63
64
65#define UUID(time_low, time_mid, time_hi_and_version, \
66 clock_seq_hi_and_reserved, clock_seq_low, node0, node1, node2, \
67 node3, node4, node5) \
68 { ((time_low) >> 24) & 0xff, ((time_low) >> 16) & 0xff, \
69 ((time_low) >> 8) & 0xff, (time_low) & 0xff, \
70 ((time_mid) >> 8) & 0xff, (time_mid) & 0xff, \
71 ((time_hi_and_version) >> 8) & 0xff, (time_hi_and_version) & 0xff, \
72 (clock_seq_hi_and_reserved), (clock_seq_low), \
73 (node0), (node1), (node2), (node3), (node4), (node5) \
74 }
75
76#define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-" \
77 "%02hhx%02hhx-%02hhx%02hhx-" \
78 "%02hhx%02hhx-" \
79 "%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
80
81#define UUID_FMT_LEN 36
82
83#define UUID_NONE "00000000-0000-0000-0000-000000000000"
84
85void qemu_uuid_generate(QemuUUID *out);
86
87int qemu_uuid_is_null(const QemuUUID *uu);
88
89int qemu_uuid_is_equal(const QemuUUID *lhv, const QemuUUID *rhv);
90
91void qemu_uuid_unparse(const QemuUUID *uuid, char *out);
92
93char *qemu_uuid_unparse_strdup(const QemuUUID *uuid);
94
95int qemu_uuid_parse(const char *str, QemuUUID *uuid);
96
97QemuUUID qemu_uuid_bswap(QemuUUID uuid);
98
99#endif
100