DPDK  18.11.11
rte_uuid.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (C) 1996, 1997, 1998 Theodore Ts'o.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, and the entire permission notice in its entirety,
9  * including the disclaimer of warranties.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote
14  * products derived from this software without specific prior
15  * written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
18  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
20  * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
23  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
27  * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
28  * DAMAGE.
29  */
36 #ifndef _RTE_UUID_H_
37 #define _RTE_UUID_H_
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 #include <stdbool.h>
44 #include <stddef.h>
45 #include <string.h>
46 
50 typedef unsigned char rte_uuid_t[16];
51 
55 #define RTE_UUID_INIT(a, b, c, d, e) { \
56  ((a) >> 24) & 0xff, ((a) >> 16) & 0xff, \
57  ((a) >> 8) & 0xff, (a) & 0xff, \
58  ((b) >> 8) & 0xff, (b) & 0xff, \
59  ((c) >> 8) & 0xff, (c) & 0xff, \
60  ((d) >> 8) & 0xff, (d) & 0xff, \
61  ((e) >> 40) & 0xff, ((e) >> 32) & 0xff, \
62  ((e) >> 24) & 0xff, ((e) >> 16) & 0xff, \
63  ((e) >> 8) & 0xff, (e) & 0xff \
64 }
65 
74 bool rte_uuid_is_null(const rte_uuid_t uu);
75 
84 static inline void rte_uuid_copy(rte_uuid_t dst, const rte_uuid_t src)
85 {
86  memcpy(dst, src, sizeof(rte_uuid_t));
87 }
88 
100 int rte_uuid_compare(const rte_uuid_t a, const rte_uuid_t b);
101 
112 int rte_uuid_parse(const char *in, rte_uuid_t uu);
113 
124 #define RTE_UUID_STRLEN (36 + 1)
125 void rte_uuid_unparse(const rte_uuid_t uu, char *out, size_t len);
126 
127 #ifdef __cplusplus
128 }
129 #endif
130 
131 #endif /* RTE_UUID_H */
int rte_uuid_parse(const char *in, rte_uuid_t uu)
int rte_uuid_compare(const rte_uuid_t a, const rte_uuid_t b)
bool rte_uuid_is_null(const rte_uuid_t uu)
unsigned char rte_uuid_t[16]
Definition: rte_uuid.h:50
static void rte_uuid_copy(rte_uuid_t dst, const rte_uuid_t src)
Definition: rte_uuid.h:84