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#define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-" \
65 "%02hhx%02hhx-%02hhx%02hhx-" \
66 "%02hhx%02hhx-" \
67 "%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
68
69#define UUID_FMT_LEN 36
70
71#define UUID_NONE "00000000-0000-0000-0000-000000000000"
72
73void qemu_uuid_generate(QemuUUID *out);
74
75int qemu_uuid_is_null(const QemuUUID *uu);
76
77int qemu_uuid_is_equal(const QemuUUID *lhv, const QemuUUID *rhv);
78
79void qemu_uuid_unparse(const QemuUUID *uuid, char *out);
80
81char *qemu_uuid_unparse_strdup(const QemuUUID *uuid);
82
83int qemu_uuid_parse(const char *str, QemuUUID *uuid);
84
85QemuUUID qemu_uuid_bswap(QemuUUID uuid);
86
87#endif
88