iPXE
uuid.h
Go to the documentation of this file.
1#ifndef _IPXE_UUID_H
2#define _IPXE_UUID_H
3
4/** @file
5 *
6 * Universally unique IDs
7 */
8
9FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
10FILE_SECBOOT ( PERMITTED );
11
12#include <stdint.h>
13#include <byteswap.h>
14
15/** A universally unique ID */
16union uuid {
17 /** Canonical form (00000000-0000-0000-0000-000000000000) */
18 struct {
19 /** 8 hex digits, big-endian */
21 /** 2 hex digits, big-endian */
23 /** 2 hex digits, big-endian */
25 /** 2 hex digits, big-endian */
27 /** 12 hex digits, big-endian */
31};
32
33/**
34 * Change UUID endianness
35 *
36 * @v uuid UUID
37 *
38 * RFC4122 defines UUIDs as being encoded in network byte order, but
39 * leaves some wriggle room for "explicit application or presentation
40 * protocol specification to the contrary". PXE, EFI and SMBIOS
41 * (versions 2.6 and above) treat the first three fields as being
42 * little-endian.
43 */
44static inline void uuid_mangle ( union uuid *uuid ) {
45
46 __bswap_32s ( &uuid->canonical.a );
47 __bswap_16s ( &uuid->canonical.b );
48 __bswap_16s ( &uuid->canonical.c );
49}
50
51extern const char * uuid_ntoa ( const union uuid *uuid );
52extern int uuid_aton ( const char *string, union uuid *uuid );
53
54#endif /* _IPXE_UUID_H */
unsigned short uint16_t
Definition stdint.h:11
unsigned int uint32_t
Definition stdint.h:12
unsigned char uint8_t
Definition stdint.h:10
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
A universally unique ID.
Definition uuid.h:16
uint16_t d
2 hex digits, big-endian
Definition uuid.h:26
uint8_t raw[16]
Definition uuid.h:30
uint8_t e[6]
12 hex digits, big-endian
Definition uuid.h:28
uint32_t a
8 hex digits, big-endian
Definition uuid.h:20
struct uuid::@036242100033237070006335026303064005125164242336 canonical
Canonical form (00000000-0000-0000-0000-000000000000)
uint16_t b
2 hex digits, big-endian
Definition uuid.h:22
uint16_t c
2 hex digits, big-endian
Definition uuid.h:24
static void uuid_mangle(union uuid *uuid)
Change UUID endianness.
Definition uuid.h:44
const char * uuid_ntoa(const union uuid *uuid)
Convert UUID to printable string.
Definition uuid.c:46
int uuid_aton(const char *string, union uuid *uuid)
Parse UUID.
Definition uuid.c:67