1139825Simp/*- 297372Smarcel * Copyright (c) 2002 Marcel Moolenaar 397372Smarcel * All rights reserved. 497372Smarcel * 597372Smarcel * Redistribution and use in source and binary forms, with or without 697372Smarcel * modification, are permitted provided that the following conditions 797372Smarcel * are met: 897372Smarcel * 997372Smarcel * 1. Redistributions of source code must retain the above copyright 1097372Smarcel * notice, this list of conditions and the following disclaimer. 1197372Smarcel * 2. Redistributions in binary form must reproduce the above copyright 1297372Smarcel * notice, this list of conditions and the following disclaimer in the 1397372Smarcel * documentation and/or other materials provided with the distribution. 1497372Smarcel * 1597372Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1697372Smarcel * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1797372Smarcel * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1897372Smarcel * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1997372Smarcel * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2097372Smarcel * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2197372Smarcel * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2297372Smarcel * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2397372Smarcel * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2497372Smarcel * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2597372Smarcel * 2697372Smarcel * $FreeBSD$ 2797372Smarcel */ 2897372Smarcel 2997372Smarcel#ifndef _SYS_UUID_H_ 3097372Smarcel#define _SYS_UUID_H_ 3197372Smarcel 32106454Sjmallett#include <sys/cdefs.h> 33106454Sjmallett 3497372Smarcel/* Length of a node address (an IEEE 802 address). */ 3597372Smarcel#define _UUID_NODE_LEN 6 3697372Smarcel 3797372Smarcel/* 3897372Smarcel * See also: 3997372Smarcel * http://www.opengroup.org/dce/info/draft-leach-uuids-guids-01.txt 4097372Smarcel * http://www.opengroup.org/onlinepubs/009629399/apdxa.htm 4197372Smarcel * 4297372Smarcel * A DCE 1.1 compatible source representation of UUIDs. 4397372Smarcel */ 4497372Smarcelstruct uuid { 4597372Smarcel uint32_t time_low; 4697372Smarcel uint16_t time_mid; 4797372Smarcel uint16_t time_hi_and_version; 4897372Smarcel uint8_t clock_seq_hi_and_reserved; 4997372Smarcel uint8_t clock_seq_low; 5097372Smarcel uint8_t node[_UUID_NODE_LEN]; 5197372Smarcel}; 5297372Smarcel 5397372Smarcel#ifdef _KERNEL 5497372Smarcel 5597372Smarcel#define UUID_NODE_LEN _UUID_NODE_LEN 5697372Smarcel 5797372Smarcelstruct sbuf; 5897372Smarcel 59150303Smarcelstruct uuid *kern_uuidgen(struct uuid *, size_t); 60150303Smarcel 61253590Smarcelint uuid_ether_add(const uint8_t *); 62253590Smarcelint uuid_ether_del(const uint8_t *); 63253590Smarcel 6497372Smarcelint snprintf_uuid(char *, size_t, struct uuid *); 6597372Smarcelint printf_uuid(struct uuid *); 6697372Smarcelint sbuf_printf_uuid(struct sbuf *, struct uuid *); 67151059Smarcelint parse_uuid(const char *, struct uuid *); 68151059Smarcel 69115459Sphkvoid be_uuid_dec(void const *buf, struct uuid *uuid); 70115459Sphkvoid be_uuid_enc(void *buf, struct uuid const *uuid); 71115459Sphkvoid le_uuid_dec(void const *buf, struct uuid *uuid); 72115459Sphkvoid le_uuid_enc(void *buf, struct uuid const *uuid); 7397372Smarcel 7497372Smarcel#else /* _KERNEL */ 7597372Smarcel 7697372Smarcel/* XXX namespace pollution? */ 7797372Smarceltypedef struct uuid uuid_t; 7897372Smarcel 79106454Sjmallett__BEGIN_DECLS 8097372Smarcelint uuidgen(struct uuid *, int); 81106454Sjmallett__END_DECLS 8297372Smarcel 8397372Smarcel#endif /* _KERNEL */ 8497372Smarcel 8597372Smarcel#endif /* _SYS_UUID_H_ */ 86