diff options
author | Michael Brown <mcb30@ipxe.org> | 2013-03-20 15:06:40 +0000 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2013-03-20 15:06:40 +0000 |
commit | d938e50136b0bd7dbc56b250cd4363646e59c9fc (patch) | |
tree | 2b5cdf555219f0a238820dc55445f384441e72f3 /src/include/ipxe/uuid.h | |
parent | a9b63ecda55ea24df7d51d59cc7fd7b3234bc135 (diff) | |
download | ipxe-d938e50136b0bd7dbc56b250cd4363646e59c9fc.zip ipxe-d938e50136b0bd7dbc56b250cd4363646e59c9fc.tar.gz ipxe-d938e50136b0bd7dbc56b250cd4363646e59c9fc.tar.bz2 |
[uuid] Abstract UUID mangling code out to a separate uuid_mangle() function
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe/uuid.h')
-rw-r--r-- | src/include/ipxe/uuid.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/include/ipxe/uuid.h b/src/include/ipxe/uuid.h index 5de56b9..ad515d0 100644 --- a/src/include/ipxe/uuid.h +++ b/src/include/ipxe/uuid.h @@ -9,6 +9,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include <stdint.h> +#include <byteswap.h> /** A universally unique ID */ union uuid { @@ -28,6 +29,24 @@ union uuid { uint8_t raw[16]; }; +/** + * Change UUID endianness + * + * @v uuid UUID + * + * 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. + */ +static inline void uuid_mangle ( union uuid *uuid ) { + + __bswap_32s ( &uuid->canonical.a ); + __bswap_16s ( &uuid->canonical.b ); + __bswap_16s ( &uuid->canonical.c ); +} + extern char * uuid_ntoa ( const union uuid *uuid ); #endif /* _IPXE_UUID_H */ |