My UUID is structured like this:
struct UUID_FIELDS
{
uint32_t time_low;
uint16_t time_mid;
uint16_t time_hi_and_version;
uint8_t clock_seq_hi_and_reserved;
uint8_t clock_seq_low;
uint8_t node[6];
};
I have functions that swap
along 32 bit boundaries and a swap function
that swaps along 16 bit boundaries. I have tried calling swap32()
on time_low
and swap16()
on time_mid
and time_hi_and_version
. I do not believe I need to swap bytes for the rest of the fields because two of them are 8 bit fields and I have read that the node part of a uuid does not change. Here is a link for that reference.
The problem is when I complete the swaps the uuid that is printed does not match the one that was in little endian before being converted.
What is the correct way to convert a uuid following RFC-4122 standard from little endian
to big endian
. And when converted should the uuids match?
time_low
,time_mid
, andtime_high_and_version
in order to use them properly. – Vickeryhtonl
andhtons
instead of unconditional byte swapping, so you don't perform the swap on machines where it is already big endian. – Mariannmariannaoffsetof(struct UUID_FIELDS, member)
for each struct member, on both systems? – Lissotrichous