xref: /titanic_44/usr/src/uts/common/sys/uuid.h (revision fb3fb4f3d76d55b64440afd0af72775dfad3bd1d)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_UUID_H
28 #define	_SYS_UUID_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * The copyright in this file is taken from the original Leach
38  * & Salz UUID specification, from which this implementation
39  * is derived.
40  */
41 
42 /*
43  * Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc.
44  * Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. &
45  * Digital Equipment Corporation, Maynard, Mass.  Copyright (c) 1998
46  * Microsoft.  To anyone who acknowledges that this file is provided
47  * "AS IS" without any express or implied warranty: permission to use,
48  * copy, modify, and distribute this file for any purpose is hereby
49  * granted without fee, provided that the above copyright notices and
50  * this notice appears in all source code copies, and that none of the
51  * names of Open Software Foundation, Inc., Hewlett-Packard Company,
52  * or Digital Equipment Corporation be used in advertising or
53  * publicity pertaining to distribution of the software without
54  * specific, written prior permission.  Neither Open Software
55  * Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital
56  * Equipment Corporation makes any representations about the
57  * suitability of this software for any purpose.
58  */
59 
60 #include <sys/types.h>
61 #include <sys/byteorder.h>
62 
63 typedef struct {
64 	uint8_t		nodeID[6];
65 } uuid_node_t;
66 
67 /*
68  * The uuid type used throughout when referencing uuids themselves
69  */
70 struct uuid {
71 	uint32_t	time_low;
72 	uint16_t	time_mid;
73 	uint16_t	time_hi_and_version;
74 	uint8_t		clock_seq_hi_and_reserved;
75 	uint8_t		clock_seq_low;
76 	uint8_t		node_addr[6];
77 };
78 
79 #define	UUID_LEN	16
80 
81 #define	UUID_PRINTABLE_STRING_LENGTH 37
82 
83 typedef uchar_t		uuid_t[UUID_LEN];
84 
85 /*
86  * Convert a uuid to/from little-endian format
87  */
88 #define	UUID_LE_CONVERT(dest, src)					\
89 {									\
90 	(dest) = (src);							\
91 	(dest).time_low = LE_32((dest).time_low);			\
92 	(dest).time_mid = LE_16((dest).time_mid);			\
93 	(dest).time_hi_and_version = LE_16((dest).time_hi_and_version);	\
94 }
95 
96 #ifdef __cplusplus
97 }
98 #endif
99 
100 #endif /* _SYS_UUID_H */
101