iPXE
uuid.h
Go to the documentation of this file.
00001 #ifndef _IPXE_UUID_H
00002 #define _IPXE_UUID_H
00003 
00004 /** @file
00005  *
00006  * Universally unique IDs
00007  */
00008 
00009 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00010 
00011 #include <stdint.h>
00012 #include <byteswap.h>
00013 
00014 /** A universally unique ID */
00015 union uuid {
00016         /** Canonical form (00000000-0000-0000-0000-000000000000) */
00017         struct {
00018                 /** 8 hex digits, big-endian */
00019                 uint32_t a;
00020                 /** 2 hex digits, big-endian */
00021                 uint16_t b;
00022                 /** 2 hex digits, big-endian */
00023                 uint16_t c;
00024                 /** 2 hex digits, big-endian */
00025                 uint16_t d;
00026                 /** 12 hex digits, big-endian */
00027                 uint8_t e[6];
00028         } canonical;
00029         uint8_t raw[16];
00030 };
00031 
00032 /**
00033  * Change UUID endianness
00034  *
00035  * @v uuid              UUID
00036  *
00037  * RFC4122 defines UUIDs as being encoded in network byte order, but
00038  * leaves some wriggle room for "explicit application or presentation
00039  * protocol specification to the contrary".  PXE, EFI and SMBIOS
00040  * (versions 2.6 and above) treat the first three fields as being
00041  * little-endian.
00042  */
00043 static inline void uuid_mangle ( union uuid *uuid ) {
00044 
00045         __bswap_32s ( &uuid->canonical.a );
00046         __bswap_16s ( &uuid->canonical.b );
00047         __bswap_16s ( &uuid->canonical.c );
00048 }
00049 
00050 extern const char * uuid_ntoa ( const union uuid *uuid );
00051 
00052 #endif /* _IPXE_UUID_H */