From 55e9e095c96d0a090575bb72d58d8792b3b05eaf Mon Sep 17 00:00:00 2001 From: Gino Carrozzo Date: Wed, 24 Sep 2008 21:02:31 +0200 Subject: [PATCH] Added version type and some comments --- src/libs/net/uuid.cxx | 4 ++-- src/libs/net/uuid.h | 31 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/libs/net/uuid.cxx b/src/libs/net/uuid.cxx index 6f08203..de2febc 100644 --- a/src/libs/net/uuid.cxx +++ b/src/libs/net/uuid.cxx @@ -135,7 +135,7 @@ UUID::UUID(const std::string & u) // Grab the time-high-and-version part e = u.find_first_of('-', s); - if (!grab_4hex(u, s, e, uuid_.time_high_and_version)) { + if (!grab_4hex(u, s, e, uuid_.time_hi_and_version)) { throw std::invalid_argument("Wrong field-3"); } s = e + 1; @@ -183,7 +183,7 @@ UUID::operator std::string(void) s << "-"; s << std::hex << std::setw(4) << uuid_.time_mid; s << "-"; - s << std::hex << std::setw(4) << uuid_.time_high_and_version; + s << std::hex << std::setw(4) << uuid_.time_hi_and_version; s << "-"; s << std::hex << std::setw(4) << uuid_.clock_seq; s << "-"; diff --git a/src/libs/net/uuid.h b/src/libs/net/uuid.h index 5cbd765..a9ba385 100644 --- a/src/libs/net/uuid.h +++ b/src/libs/net/uuid.h @@ -41,13 +41,42 @@ namespace Net { friend std::istream & operator >>(std::istream & stream, UUID & obj); + typedef enum { + UNKNOWN = 0, + IETF_RFC4122_TIMEBASED = 1, + DCE_SECURITY_POSIX_UID = 2, + IETF_RFC4122_NAMEBASED_MD5 = 3, + IETF_RFC4122_RANDOM = 4, + IETF_RFC4122_NAMEBASED_SHA1 = 5 + } version_t; + protected: private: +// From RFC4122 +// +// The fields are encoded as 16 octets, with the sizes and order of the +// fields defined above, and with each field encoded with the Most +// Significant Byte first (known as network byte order). Note that the +// field names, particularly for multiplexed fields, follow historical +// practice. +// +// 0 1 2 3 +// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | time_low | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | time_mid | time_hi_and_version | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// |clk_seq_hi_res | clk_seq_low | node (0-1) | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | node (2-5) | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + struct uuid { uint32_t time_low; uint16_t time_mid; - uint16_t time_high_and_version; + uint16_t time_hi_and_version; uint16_t clock_seq; uint8_t node[6]; } uuid_; -- 2.11.4.GIT