dmi_uuid_decode
Description
The dmi_uuid_decode function converts a raw 16-byte UUID as stored in an
SMBIOS structure into a dmi_uuid_t value conforming to RFC 4122.
SMBIOS stores the first three UUID fields (time_low, time_mid, and
time_hi_and_version) in little-endian byte order. RFC 4122 requires all
multi-byte fields to be in big-endian (network) byte order. This function
copies the raw SMBIOS value and byte-swaps those three fields so that the
returned dmi_uuid_t conforms to RFC 4122. The clock_seq_hi_and_reserved,
clock_seq_low, and node fields are stored identically in both formats and
are not modified.
Examples
const dmi_byte_t raw[16] = { /* raw SMBIOS UUID bytes */ };
dmi_uuid_t uuid = dmi_uuid_decode(raw);
printf("UUID: %08x-%04x-%04x-%02x%02x-",
uuid.time_low, uuid.time_mid,
uuid.time_hi_and_version,
uuid.clock_seq_hi_and_reserved,
uuid.clock_seq_low);
for (int i = 0; i < 6; i++)
printf("%02x", uuid.node[i]);
printf("\n");