diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 11:19:16 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 12:07:37 +0000 |
commit | b485aab7e71c1625cfc27e0f92c9509f42378458 (patch) | |
tree | ae9abe108601079d1679194de237c9a435ae5b55 /src/libnetdata/uuid/uuid.c | |
parent | Adding upstream version 1.44.3. (diff) | |
download | netdata-b485aab7e71c1625cfc27e0f92c9509f42378458.tar.xz netdata-b485aab7e71c1625cfc27e0f92c9509f42378458.zip |
Adding upstream version 1.45.3+dfsg.upstream/1.45.3+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/libnetdata/uuid/uuid.c (renamed from libnetdata/uuid/uuid.c) | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libnetdata/uuid/uuid.c b/src/libnetdata/uuid/uuid.c index 55b66db9b..f062d0bc5 100644 --- a/libnetdata/uuid/uuid.c +++ b/src/libnetdata/uuid/uuid.c @@ -2,6 +2,26 @@ #include "../libnetdata.h" + +UUID UUID_generate_from_hash(const void *payload, size_t payload_len) { + assert(sizeof(XXH128_hash_t) == sizeof(UUID)); + + UUID uuid; + XXH128_hash_t *xxh3_128 = (XXH128_hash_t *)&uuid; + + // Hash the payload using XXH128 + // Assume xxh128_hash_function is your function to generate XXH128 hash + *xxh3_128 = XXH3_128bits(payload, payload_len); + + // Set the UUID version (here, setting it to 4) + uuid.uuid[6] = (uuid.uuid[6] & 0x0F) | 0x40; // Version 4 + + // Set the UUID variant (standard variant for UUID) + uuid.uuid[8] = (uuid.uuid[8] & 0x3F) | 0x80; // Variant is 10xxxxxx + + return uuid; +} + void uuid_unparse_lower_compact(const uuid_t uuid, char *out) { static const char *hex_chars = "0123456789abcdef"; for (int i = 0; i < 16; i++) { |