iPXE
Data Structures | Functions
uuid.h File Reference

Universally unique IDs. More...

#include <stdint.h>
#include <byteswap.h>

Go to the source code of this file.

Data Structures

union  uuid
 A universally unique ID. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static void uuid_mangle (union uuid *uuid)
 Change UUID endianness. More...
 
const char * uuid_ntoa (const union uuid *uuid)
 Convert UUID to printable string. More...
 

Detailed Description

Universally unique IDs.

Definition in file uuid.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ uuid_mangle()

static void uuid_mangle ( union uuid uuid)
inlinestatic

Change UUID endianness.

Parameters
uuidUUID

RFC4122 defines UUIDs as being encoded in network byte order, but leaves some wriggle room for "explicit application or presentation protocol specification to the contrary". PXE, EFI and SMBIOS (versions 2.6 and above) treat the first three fields as being little-endian.

Definition at line 43 of file uuid.h.

43  {
44 
45  __bswap_32s ( &uuid->canonical.a );
46  __bswap_16s ( &uuid->canonical.b );
47  __bswap_16s ( &uuid->canonical.c );
48 }
uint32_t a
8 hex digits, big-endian
Definition: uuid.h:19
uint16_t c
2 hex digits, big-endian
Definition: uuid.h:23
A universally unique ID.
Definition: uuid.h:15
uint16_t b
2 hex digits, big-endian
Definition: uuid.h:21
struct uuid::@563 canonical
Canonical form (00000000-0000-0000-0000-000000000000)

References uuid::a, uuid::b, uuid::c, and uuid::canonical.

Referenced by dhcp_create_request(), efi_guid_ntoa(), smbios_fetch(), and vmbus_probe_channels().

◆ uuid_ntoa()

const char* uuid_ntoa ( const union uuid uuid)

Convert UUID to printable string.

Parameters
uuidUUID
Return values
stringUUID in canonical form

Definition at line 43 of file uuid.c.

43  {
44  static char buf[37]; /* "00000000-0000-0000-0000-000000000000" */
45 
46  sprintf ( buf, "%08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x",
51  uuid->canonical.e[0], uuid->canonical.e[1],
52  uuid->canonical.e[2], uuid->canonical.e[3],
53  uuid->canonical.e[4], uuid->canonical.e[5] );
54  return buf;
55 }
uint32_t a
8 hex digits, big-endian
Definition: uuid.h:19
uint16_t c
2 hex digits, big-endian
Definition: uuid.h:23
A universally unique ID.
Definition: uuid.h:15
#define sprintf(buf, fmt,...)
Write a formatted string to a buffer.
Definition: stdio.h:36
uint16_t d
2 hex digits, big-endian
Definition: uuid.h:25
#define be32_to_cpu(value)
Definition: byteswap.h:116
#define be16_to_cpu(value)
Definition: byteswap.h:115
uint16_t b
2 hex digits, big-endian
Definition: uuid.h:21
uint8_t e[6]
12 hex digits, big-endian
Definition: uuid.h:27
struct uuid::@563 canonical
Canonical form (00000000-0000-0000-0000-000000000000)

References uuid::a, uuid::b, be16_to_cpu, be32_to_cpu, uuid::c, uuid::canonical, uuid::d, uuid::e, and sprintf.

Referenced by efi_guid_ntoa(), format_uuid_setting(), iscsi_fetch_settings(), peerdisc_create(), vmbus_probe_channels(), and vmbus_reset_channels().