summaryrefslogtreecommitdiffstats
path: root/src/core/uuid.c
diff options
context:
space:
mode:
authorSimon Rettberg2024-04-12 14:00:15 +0200
committerSimon Rettberg2024-04-12 14:00:15 +0200
commit98dc341428e247141f120d05fac48c4e144a4c0f (patch)
tree3ebacb37927e338383ac64c2e20eb0b2f820cb85 /src/core/uuid.c
parentMerge branch 'master' into openslx (diff)
parentMerge branch 'ipxe:master' into aqc1xx (diff)
downloadipxe-98dc341428e247141f120d05fac48c4e144a4c0f.tar.gz
ipxe-98dc341428e247141f120d05fac48c4e144a4c0f.tar.xz
ipxe-98dc341428e247141f120d05fac48c4e144a4c0f.zip
Merge branch 'aqc1xx' into openslx
Diffstat (limited to 'src/core/uuid.c')
-rw-r--r--src/core/uuid.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/core/uuid.c b/src/core/uuid.c
index c43d4216..b6600af7 100644
--- a/src/core/uuid.c
+++ b/src/core/uuid.c
@@ -25,7 +25,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <stdint.h>
#include <stdio.h>
+#include <errno.h>
#include <byteswap.h>
+#include <ipxe/base16.h>
#include <ipxe/uuid.h>
/** @file
@@ -53,3 +55,29 @@ const char * uuid_ntoa ( const union uuid *uuid ) {
uuid->canonical.e[4], uuid->canonical.e[5] );
return buf;
}
+
+/**
+ * Parse UUID
+ *
+ * @v string UUID string
+ * @v uuid UUID to fill in
+ * @ret rc Return status code
+ */
+int uuid_aton ( const char *string, union uuid *uuid ) {
+ int len;
+ int rc;
+
+ /* Decode as hex string with optional '-' separator */
+ len = hex_decode ( ( '-' | HEX_DECODE_OPTIONAL ), string, uuid->raw,
+ sizeof ( *uuid ) );
+ if ( len < 0 ) {
+ rc = len;
+ return rc;
+ }
+
+ /* Check length */
+ if ( len != sizeof ( *uuid ) )
+ return -EINVAL;
+
+ return 0;
+}