Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Add support for UUID versioning and generation of UUIDv7. #2734

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

ar45
Copy link
Contributor

@ar45 ar45 commented Jan 15, 2025

control using macro DEFAULT_UUID_VERSION defaults to 4

This update introduces support for generating UUIDs with specific versions, including the newly implemented UUIDv7. The create_uuid API has been updated to accept optional version parameters. Additionally, a new utility function switch_getentropy was added to ensure secure random number generation.

@ar45 ar45 marked this pull request as draft January 15, 2025 22:09
@ar45 ar45 changed the title Add support for UUID versioning and generation of UUIDv7. [WIP] - Add support for UUID versioning and generation of UUIDv7. Jan 15, 2025
@ar45 ar45 changed the title [WIP] - Add support for UUID versioning and generation of UUIDv7. [core] Add support for UUID versioning and generation of UUIDv7. Jan 15, 2025
@ar45 ar45 marked this pull request as ready for review January 15, 2025 22:42
@seven1240
Copy link
Collaborator

I have a different patch based on https://github.com/LiosK/uuidv7-h, would you like to compare with this?

@ar45
Copy link
Contributor Author

ar45 commented Jan 15, 2025

I have a different patch based on https://github.com/LiosK/uuidv7-h, would you like to compare with this?

Yes, can you share?

@@ -1518,6 +1519,9 @@ SWITCH_DECLARE(const char *) switch_memory_usage_stream(switch_stream_handle_t *
/ Compliant random number generator. Returns the value between 0 and 0x7fff (RAND_MAX).
**/
SWITCH_DECLARE(int) switch_rand(void);
SWITCH_DECLARE(int) switch_getentropy(void *buffer, switch_size_t length);
SWITCH_DECLARE(switch_status_t) switch_uuid_generate_v7(switch_uuid_t *uuid);
SWITCH_DECLARE(switch_status_t) switch_uuid_generate_v7(switch_uuid_t *uuid);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ar45 you declared twice switch_uuid_generate_v7 I guess one should be switch_uuid_generate_v4

ar45 added 7 commits January 16, 2025 08:52
This update introduces support for generating UUIDs with specific versions, including the newly implemented UUIDv7. The `create_uuid` API has been updated to accept optional version parameters. Additionally, a new utility function `switch_getentropy` was added to ensure secure random number generation.
Ensure that invalid UUID generation scenarios are correctly handled by checking the return status of `switch_uuid_generate_version`. This prevents potential incorrect formatting or uninitialized usage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants