VSF Documented
uuid.h
Go to the documentation of this file.
1#ifndef __VSF_LINUX_UUID_H__
2#define __VSF_LINUX_UUID_H__
3
4#include <linux/types.h>
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
10#define UUID_SIZE 16
11typedef struct {
13} uuid_t;
14#define UUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
15((uuid_t){{ \
16 ((a) >> 24) & 0xff, ((a) >> 16) & 0xff, ((a) >> 8) & 0xff, (a) & 0xff, \
17 ((b) >> 8) & 0xff, (b) & 0xff, \
18 ((c) >> 8) & 0xff, (c) & 0xff, \
19 (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) \
20}})
21
22#define UUID_STRING_LEN 36
23
24typedef struct {
25 __u8 b[16];
26} guid_t;
27
28#define GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
29((guid_t){{ \
30 (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \
31 (b) & 0xff, ((b) >> 8) & 0xff, \
32 (c) & 0xff, ((c) >> 8) & 0xff, \
33 (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7), \
34}})
35
36extern const guid_t guid_null;
37extern const uuid_t uuid_null;
38
39static inline bool guid_equal(const guid_t *u1, const guid_t *u2)
40{
41 return memcmp(u1, u2, sizeof(guid_t)) == 0;
42}
43
44static inline void guid_copy(guid_t *dst, const guid_t *src)
45{
46 memcpy(dst, src, sizeof(guid_t));
47}
48
49static inline void import_guid(guid_t *dst, const __u8 *src)
50{
51 memcpy(dst, src, sizeof(guid_t));
52}
53
54static inline void export_guid(__u8 *dst, const guid_t *src)
55{
56 memcpy(dst, src, sizeof(guid_t));
57}
58
59static inline bool guid_is_null(const guid_t *guid)
60{
61 return guid_equal(guid, &guid_null);
62}
63
64static inline bool uuid_equal(const uuid_t *u1, const uuid_t *u2)
65{
66 return memcmp(u1, u2, sizeof(uuid_t)) == 0;
67}
68
69static inline void uuid_copy(uuid_t *dst, const uuid_t *src)
70{
71 memcpy(dst, src, sizeof(uuid_t));
72}
73
74static inline void import_uuid(uuid_t *dst, const __u8 *src)
75{
76 memcpy(dst, src, sizeof(uuid_t));
77}
78
79static inline void export_uuid(__u8 *dst, const uuid_t *src)
80{
81 memcpy(dst, src, sizeof(uuid_t));
82}
83
84static inline bool uuid_is_null(const uuid_t *uuid)
85{
86 return uuid_equal(uuid, &uuid_null);
87}
88
89#ifdef __cplusplus
90}
91#endif
92
93#endif
uint8_t __u8
Definition types.h:51
void * memcpy(void *dest, const void *src, size_t n)
int memcmp(const void *str1, const void *str2, size_t n)
Definition uuid.h:24
Definition uuid.h:11
#define UUID_SIZE
Definition uuid.h:10
const guid_t guid_null
Definition vsf_linux_core.c:716
const uuid_t uuid_null
Definition vsf_linux_core.c:717