DPDK  19.08.2
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 
48 typedef unsigned char rte_uuid_t[16];
49 
53 #define RTE_UUID_INIT(a, b, c, d, e) { \
54  ((a) >> 24) & 0xff, ((a) >> 16) & 0xff, \
55  ((a) >> 8) & 0xff, (a) & 0xff, \
56  ((b) >> 8) & 0xff, (b) & 0xff, \
57  ((c) >> 8) & 0xff, (c) & 0xff, \
58  ((d) >> 8) & 0xff, (d) & 0xff, \
59  ((e) >> 40) & 0xff, ((e) >> 32) & 0xff, \
60  ((e) >> 24) & 0xff, ((e) >> 16) & 0xff, \
61  ((e) >> 8) & 0xff, (e) & 0xff \
62 }
63 
72 bool rte_uuid_is_null(const rte_uuid_t uu);
73 
82 static inline void rte_uuid_copy(rte_uuid_t dst, const rte_uuid_t src)
83 {
84  memcpy(dst, src, sizeof(rte_uuid_t));
85 }
86 
98 int rte_uuid_compare(const rte_uuid_t a, const rte_uuid_t b);
99 
110 int rte_uuid_parse(const char *in, rte_uuid_t uu);
111 
122 #define RTE_UUID_STRLEN (36 + 1)
123 void rte_uuid_unparse(const rte_uuid_t uu, char *out, size_t len);
124 
125 #ifdef __cplusplus
126 }
127 #endif
128 
129 #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:48
static void rte_uuid_copy(rte_uuid_t dst, const rte_uuid_t src)
Definition: rte_uuid.h:82