diff options
author | Jim McDonough <jmcd@samba.org> | 2002-10-18 20:11:29 +0000 |
---|---|---|
committer | Jim McDonough <jmcd@samba.org> | 2002-10-18 20:11:29 +0000 |
commit | e042a93cce2fdadfd88c93b813e10f0cc12f570e (patch) | |
tree | a1f6505e4aac40fe92c3d2ec6c868444befc2186 /source3/lib | |
parent | e13dd2f3025a557bbd71765a684005562591843d (diff) | |
download | samba-e042a93cce2fdadfd88c93b813e10f0cc12f570e.tar.gz samba-e042a93cce2fdadfd88c93b813e10f0cc12f570e.tar.xz samba-e042a93cce2fdadfd88c93b813e10f0cc12f570e.zip |
Format objectGUIDs on ads dumps.
(This used to be commit 7eaf7e7115c75e682b1b9368c6f28c60429885e5)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/util_uuid.c | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/source3/lib/util_uuid.c b/source3/lib/util_uuid.c index 63e25049820..1543094d408 100644 --- a/source3/lib/util_uuid.c +++ b/source3/lib/util_uuid.c @@ -31,7 +31,7 @@ struct uuid { uint32 time_low; uint16 time_mid; uint16 time_hi_and_version; - uint16 clock_seq; + uint8 clock_seq[2]; uint8 node[6]; }; @@ -43,7 +43,7 @@ static void uuid_pack(const struct uuid *uu, GUID *ptr) SIVAL(out, 0, uu->time_low); SSVAL(out, 4, uu->time_mid); SSVAL(out, 6, uu->time_hi_and_version); - SSVAL(out, 8, uu->clock_seq); + memcpy(out+8, uu->clock_seq, 2); memcpy(out+10, uu->node, 6); } @@ -54,7 +54,7 @@ static void uuid_unpack(const GUID in, struct uuid *uu) uu->time_low = IVAL(ptr, 0); uu->time_mid = SVAL(ptr, 4); uu->time_hi_and_version = SVAL(ptr, 6); - uu->clock_seq = SVAL(ptr, 8); + memcpy(uu->clock_seq, ptr+8, 2); memcpy(uu->node, ptr+10, 6); } @@ -66,7 +66,38 @@ void uuid_generate_random(GUID *out) generate_random_buffer(tmp.info, sizeof(tmp.info), True); uuid_unpack(tmp, &uu); - uu.clock_seq = (uu.clock_seq & 0x3FFF) | 0x8000; + uu.clock_seq[0] = (uu.clock_seq[0] & 0x3F) | 0x80; uu.time_hi_and_version = (uu.time_hi_and_version & 0x0FFF) | 0x4000; uuid_pack(&uu, out); } + +char *uuid_to_string(const GUID in) +{ + struct uuid uu; + char *out; + + uuid_unpack(in, &uu); + + asprintf(&out, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + uu.time_low, uu.time_mid, uu.time_hi_and_version, + uu.clock_seq[0], uu.clock_seq[1], + uu.node[0], uu.node[1], uu.node[2], + uu.node[3], uu.node[4], uu.node[5]); + + return out; +} + +const char *uuid_string_static(const GUID in) +{ + struct uuid uu; + static char out[37]; + + uuid_unpack(in, &uu); + slprintf(out, sizeof(out) -1, + "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + uu.time_low, uu.time_mid, uu.time_hi_and_version, + uu.clock_seq[0], uu.clock_seq[1], + uu.node[0], uu.node[1], uu.node[2], + uu.node[3], uu.node[4], uu.node[5]); + return out; +} |