networking - UUIDs and byte-swapping over network -


Is there a standard acceptable way of byte-swap UUID for transmission on network (or file storage)? (I want to send / send 16 raw bytes instead of converting UIID to string presentation.)

I first thought that I should divide the UUID into 4 32-bit integers and on each Huntlal should call them, but that was not the right odor. The internal structure (RFC 4122) is in a UUID:

  Type -Fff structure {unsigned32 time_low; Unsigned 16 timings_media; Unsigned 16 time_en_and_version; Unsigned 8 clock_ac_c_a_and_reserved; Unsigned 8 clock_sc_la; Byte node [6]; } Uuid_t;  

Is it OK to do this:

  ... uuid.time_low = htonl (uuid.time_low); Uuid.time_mid = htons (uuid.time_mid); Uuid.time_en_and_version = htons (uuid.time_high_and_version); / * Other fields are displayed as bytes and should not be swap / ....  

before writing it, and then it is okay ... second end Call after reading?

Thank you.

Yes, that's the right thing.

Each number ( time_low , time_mid , time_hi_and_version ) is subject to the byte sequence node The field is not clock_seq_en_and_reserved and clock_seq_low are also subject to byte order, but they are each byte, so it does not matter.

Of course, this is to make sure that you choose the correct sequence at both ends or understand what is the order at the other end if you do not control it, Microsoft will definitely for its UUIDs Little Endian uses you can see the definition of Microsoft's UUID.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -