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 
9 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
10 
11 #include <stdint.h>
12 #include <byteswap.h>
13 
14 /** A universally unique ID */
15 union uuid {
16  /** Canonical form (00000000-0000-0000-0000-000000000000) */
17  struct {
18  /** 8 hex digits, big-endian */
20  /** 2 hex digits, big-endian */
22  /** 2 hex digits, big-endian */
24  /** 2 hex digits, big-endian */
26  /** 12 hex digits, big-endian */
27  uint8_t e[6];
28  } canonical;
29  uint8_t raw[16];
30 };
31 
32 /**
33  * Change UUID endianness
34  *
35  * @v uuid UUID
36  *
37  * RFC4122 defines UUIDs as being encoded in network byte order, but
38  * leaves some wriggle room for "explicit application or presentation
39  * protocol specification to the contrary". PXE, EFI and SMBIOS
40  * (versions 2.6 and above) treat the first three fields as being
41  * little-endian.
42  */
43 static inline void uuid_mangle ( union uuid *uuid ) {
44 
45  __bswap_32s ( &uuid->canonical.a );
46  __bswap_16s ( &uuid->canonical.b );
47  __bswap_16s ( &uuid->canonical.c );
48 }
49 
50 extern const char * uuid_ntoa ( const union uuid *uuid );
51 extern int uuid_aton ( const char *string, union uuid *uuid );
52 
53 #endif /* _IPXE_UUID_H */
uint32_t a
8 hex digits, big-endian
Definition: uuid.h:19
unsigned short uint16_t
Definition: stdint.h:11
uint16_t c
2 hex digits, big-endian
Definition: uuid.h:23
A universally unique ID.
Definition: uuid.h:15
int uuid_aton(const char *string, union uuid *uuid)
Parse UUID.
Definition: uuid.c:66
uint16_t d
2 hex digits, big-endian
Definition: uuid.h:25
static void uuid_mangle(union uuid *uuid)
Change UUID endianness.
Definition: uuid.h:43
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
uint16_t b
2 hex digits, big-endian
Definition: uuid.h:21
struct uuid::@648 canonical
Canonical form (00000000-0000-0000-0000-000000000000)
uint8_t e[6]
12 hex digits, big-endian
Definition: uuid.h:27
unsigned char uint8_t
Definition: stdint.h:10
uint8_t raw[16]
Definition: uuid.h:29
unsigned int uint32_t
Definition: stdint.h:12
const char * uuid_ntoa(const union uuid *uuid)
Convert UUID to printable string.
Definition: uuid.c:45