1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (C) 1996, 1997, 1998 Theodore Ts'o.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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
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
33 * UUID related functions originally from libuuid
46 * Struct describing a Universal Unique Identifier
48 typedef unsigned char rte_uuid_t[16];
51 * Helper for defining UUID values for id tables.
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 \
65 * Test if UUID is all zeros.
70 * true if uuid is NULL value, false otherwise
72 bool rte_uuid_is_null(const rte_uuid_t uu);
82 static inline void rte_uuid_copy(rte_uuid_t dst, const rte_uuid_t src)
84 memcpy(dst, src, sizeof(rte_uuid_t));
95 * returns an integer less than, equal to, or greater than zero if UUID a is
96 * is less than, equal, or greater than UUID b.
98 int rte_uuid_compare(const rte_uuid_t a, const rte_uuid_t b);
101 * Extract UUID from string
104 * Pointer to string of characters to convert
108 * Returns 0 on success, and -1 if string is not a valid UUID.
110 int rte_uuid_parse(const char *in, rte_uuid_t uu);
113 * Convert UUID to string
118 * Resulting string buffer
120 * Sizeof the available string buffer
122 #define RTE_UUID_STRLEN (36 + 1)
123 void rte_uuid_unparse(const rte_uuid_t uu, char *out, size_t len);
129 #endif /* RTE_UUID_H */