iPXE
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)
 FILE_SECBOOT (PERMITTED)
const char * uuid_ntoa (const union uuid *uuid)
 Convert UUID to printable string.
int uuid_aton (const char *string, union uuid *uuid)
 Parse UUID.

Detailed Description

Universally unique IDs.

Definition in file uuid.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

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

46 {
47 static char buf[37]; /* "00000000-0000-0000-0000-000000000000" */
48
49 sprintf ( buf, "%08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x",
54 uuid->canonical.e[0], uuid->canonical.e[1],
55 uuid->canonical.e[2], uuid->canonical.e[3],
56 uuid->canonical.e[4], uuid->canonical.e[5] );
57 return buf;
58}
#define be32_to_cpu(value)
Definition byteswap.h:117
#define be16_to_cpu(value)
Definition byteswap.h:116
#define sprintf(buf, fmt,...)
Write a formatted string to a buffer.
Definition stdio.h:37
A universally unique ID.
Definition uuid.h:16
uint16_t d
2 hex digits, big-endian
Definition uuid.h:26
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

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

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

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().