iPXE
Functions
uuid.c File Reference

Universally unique IDs. More...

#include <stdint.h>
#include <stdio.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/base16.h>
#include <ipxe/uuid.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
const char * uuid_ntoa (const union uuid *uuid)
 Convert UUID to printable string. More...
 
int uuid_aton (const char *string, union uuid *uuid)
 Parse UUID. More...
 

Detailed Description

Universally unique IDs.

Definition in file uuid.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ 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 45 of file uuid.c.

45  {
46  static char buf[37]; /* "00000000-0000-0000-0000-000000000000" */
47 
48  sprintf ( buf, "%08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x",
53  uuid->canonical.e[0], uuid->canonical.e[1],
54  uuid->canonical.e[2], uuid->canonical.e[3],
55  uuid->canonical.e[4], uuid->canonical.e[5] );
56  return buf;
57 }
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::@594 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_block_match(), efi_guid_ntoa(), format_uuid_setting(), iscsi_fetch_settings(), peerdisc_create(), uuid_aton_okx(), uuid_ntoa_okx(), vmbus_probe_channels(), and vmbus_reset_channels().

◆ uuid_aton()

int uuid_aton ( const char *  string,
union uuid uuid 
)

Parse UUID.

Parameters
stringUUID string
uuidUUID to fill in
Return values
rcReturn status code

Definition at line 66 of file uuid.c.

66  {
67  int len;
68  int rc;
69 
70  /* Decode as hex string with optional '-' separator */
71  len = hex_decode ( ( '-' | HEX_DECODE_OPTIONAL ), string, uuid->raw,
72  sizeof ( *uuid ) );
73  if ( len < 0 ) {
74  rc = len;
75  return rc;
76  }
77 
78  /* Check length */
79  if ( len != sizeof ( *uuid ) )
80  return -EINVAL;
81 
82  return 0;
83 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A universally unique ID.
Definition: uuid.h:15
#define HEX_DECODE_OPTIONAL
Treat separator as optional while decoding.
Definition: base16.h:16
int hex_decode(char separator, const char *encoded, void *data, size_t len)
Decode hexadecimal string (with optional byte separator character)
Definition: base16.c:76
uint8_t raw[16]
Definition: uuid.h:29
uint32_t len
Length.
Definition: ena.h:14

References EINVAL, hex_decode(), HEX_DECODE_OPTIONAL, len, uuid::raw, and rc.

Referenced by parse_uuid(), parse_uuid_setting(), uuid_aton_fail_okx(), and uuid_aton_okx().