xref: /illumos-gate/usr/src/boot/sys/sys/uuid.h (revision 199767f8)
1*199767f8SToomas Soome /*-
2*199767f8SToomas Soome  * Copyright (c) 2002 Marcel Moolenaar
3*199767f8SToomas Soome  * All rights reserved.
4*199767f8SToomas Soome  *
5*199767f8SToomas Soome  * Redistribution and use in source and binary forms, with or without
6*199767f8SToomas Soome  * modification, are permitted provided that the following conditions
7*199767f8SToomas Soome  * are met:
8*199767f8SToomas Soome  *
9*199767f8SToomas Soome  * 1. Redistributions of source code must retain the above copyright
10*199767f8SToomas Soome  *    notice, this list of conditions and the following disclaimer.
11*199767f8SToomas Soome  * 2. Redistributions in binary form must reproduce the above copyright
12*199767f8SToomas Soome  *    notice, this list of conditions and the following disclaimer in the
13*199767f8SToomas Soome  *    documentation and/or other materials provided with the distribution.
14*199767f8SToomas Soome  *
15*199767f8SToomas Soome  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16*199767f8SToomas Soome  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17*199767f8SToomas Soome  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18*199767f8SToomas Soome  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19*199767f8SToomas Soome  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20*199767f8SToomas Soome  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21*199767f8SToomas Soome  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22*199767f8SToomas Soome  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23*199767f8SToomas Soome  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24*199767f8SToomas Soome  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*199767f8SToomas Soome  *
26*199767f8SToomas Soome  * $FreeBSD$
27*199767f8SToomas Soome  */
28*199767f8SToomas Soome 
29*199767f8SToomas Soome #ifndef _SYS_UUID_H_
30*199767f8SToomas Soome #define	_SYS_UUID_H_
31*199767f8SToomas Soome 
32*199767f8SToomas Soome #include <sys/cdefs.h>
33*199767f8SToomas Soome 
34*199767f8SToomas Soome /* Length of a node address (an IEEE 802 address). */
35*199767f8SToomas Soome #define	_UUID_NODE_LEN		6
36*199767f8SToomas Soome 
37*199767f8SToomas Soome /*
38*199767f8SToomas Soome  * See also:
39*199767f8SToomas Soome  *      http://www.opengroup.org/dce/info/draft-leach-uuids-guids-01.txt
40*199767f8SToomas Soome  *      http://www.opengroup.org/onlinepubs/009629399/apdxa.htm
41*199767f8SToomas Soome  *
42*199767f8SToomas Soome  * A DCE 1.1 compatible source representation of UUIDs.
43*199767f8SToomas Soome  */
44*199767f8SToomas Soome struct uuid {
45*199767f8SToomas Soome 	uint32_t	time_low;
46*199767f8SToomas Soome 	uint16_t	time_mid;
47*199767f8SToomas Soome 	uint16_t	time_hi_and_version;
48*199767f8SToomas Soome 	uint8_t		clock_seq_hi_and_reserved;
49*199767f8SToomas Soome 	uint8_t		clock_seq_low;
50*199767f8SToomas Soome 	uint8_t		node[_UUID_NODE_LEN];
51*199767f8SToomas Soome };
52*199767f8SToomas Soome 
53*199767f8SToomas Soome #ifdef _KERNEL
54*199767f8SToomas Soome 
55*199767f8SToomas Soome #define	UUID_NODE_LEN	_UUID_NODE_LEN
56*199767f8SToomas Soome 
57*199767f8SToomas Soome struct sbuf;
58*199767f8SToomas Soome 
59*199767f8SToomas Soome struct uuid *kern_uuidgen(struct uuid *, size_t);
60*199767f8SToomas Soome 
61*199767f8SToomas Soome int uuid_ether_add(const uint8_t *);
62*199767f8SToomas Soome int uuid_ether_del(const uint8_t *);
63*199767f8SToomas Soome 
64*199767f8SToomas Soome int snprintf_uuid(char *, size_t, struct uuid *);
65*199767f8SToomas Soome int printf_uuid(struct uuid *);
66*199767f8SToomas Soome int sbuf_printf_uuid(struct sbuf *, struct uuid *);
67*199767f8SToomas Soome int parse_uuid(const char *, struct uuid *);
68*199767f8SToomas Soome 
69*199767f8SToomas Soome void be_uuid_dec(void const *buf, struct uuid *uuid);
70*199767f8SToomas Soome void be_uuid_enc(void *buf, struct uuid const *uuid);
71*199767f8SToomas Soome void le_uuid_dec(void const *buf, struct uuid *uuid);
72*199767f8SToomas Soome void le_uuid_enc(void *buf, struct uuid const *uuid);
73*199767f8SToomas Soome 
74*199767f8SToomas Soome #else	/* _KERNEL */
75*199767f8SToomas Soome 
76*199767f8SToomas Soome /* XXX namespace pollution? */
77*199767f8SToomas Soome typedef struct uuid uuid_t;
78*199767f8SToomas Soome 
79*199767f8SToomas Soome __BEGIN_DECLS
80*199767f8SToomas Soome int	uuidgen(struct uuid *, int);
81*199767f8SToomas Soome __END_DECLS
82*199767f8SToomas Soome 
83*199767f8SToomas Soome #endif	/* _KERNEL */
84*199767f8SToomas Soome 
85*199767f8SToomas Soome #endif /* _SYS_UUID_H_ */
86