Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
Universally unique identifier support. More...
#include "asterisk.h"
#include <uuid/uuid.h>
#include <fcntl.h>
#include "asterisk/uuid.h"
#include "asterisk/utils.h"
#include "asterisk/strings.h"
#include "asterisk/logger.h"
#include "asterisk/lock.h"
Go to the source code of this file.
Data Structures | |
struct | ast_uuid |
Functions | |
struct ast_uuid * | ast_str_to_uuid (char *str) |
Convert a string to a UUID. More... | |
void | ast_uuid_clear (struct ast_uuid *uuid) |
Clear a UUID by setting it to be a nil UUID (all 0s) More... | |
int | ast_uuid_compare (struct ast_uuid *left, struct ast_uuid *right) |
Compare two UUIDs. More... | |
struct ast_uuid * | ast_uuid_copy (struct ast_uuid *src) |
Make a copy of a UUID. More... | |
struct ast_uuid * | ast_uuid_generate (void) |
Generate a UUID. More... | |
char * | ast_uuid_generate_str (char *buf, size_t size) |
Generate a UUID string. More... | |
void | ast_uuid_init (void) |
Initialize the UUID system. More... | |
int | ast_uuid_is_nil (struct ast_uuid *uuid) |
Check if a UUID is a nil UUID (all 0s) More... | |
char * | ast_uuid_to_str (struct ast_uuid *uuid, char *buf, size_t size) |
Convert a UUID to a string. More... | |
static void | generate_uuid (struct ast_uuid *uuid) |
Variables | |
static int | has_dev_urandom |
static ast_mutex_t | uuid_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } |
Universally unique identifier support.
Definition in file uuid.c.
struct ast_uuid * ast_str_to_uuid | ( | char * | str | ) |
Convert a string to a UUID.
This function allocates memory on the heap. The returned pointer must be freed using ast_free()
str | The string to convert to a UUID |
NULL | Failed to convert |
non-NULL | The heap-allocated converted UUID |
Definition at line 149 of file uuid.c.
References ast_free, ast_log, ast_malloc, LOG_WARNING, NULL, str, and uuid().
Referenced by AST_TEST_DEFINE(), and is_valid_uuid().
void ast_uuid_clear | ( | struct ast_uuid * | uuid | ) |
Clear a UUID by setting it to be a nil UUID (all 0s)
uuid | UUID to clear |
Definition at line 182 of file uuid.c.
References uuid().
Referenced by AST_TEST_DEFINE().
Compare two UUIDs.
left | First UUID to compare |
right | Second UUID to compare |
<0 | left is lexicographically less than right |
0 | left and right are the same |
>0 | left is lexicographically greater than right |
Definition at line 177 of file uuid.c.
References ast_uuid::uu.
Referenced by AST_TEST_DEFINE().
Make a copy of a UUID.
This function allocates memory on the heap. The returned pointer must be freed using ast_free()
src | The source UUID to copy |
NULL | Failed to copy |
non-NULL | The heap-allocated duplicate UUID |
Definition at line 166 of file uuid.c.
References ast_malloc, NULL, and ast_uuid::uu.
Referenced by AST_TEST_DEFINE().
struct ast_uuid * ast_uuid_generate | ( | void | ) |
Generate a UUID.
This function allocates memory on the heap. The returned pointer must be freed using ast_free()
NULL | Generation failed |
non-NULL | heap-allocated UUID |
Definition at line 123 of file uuid.c.
References ast_malloc, generate_uuid(), NULL, and uuid().
Referenced by AST_TEST_DEFINE().
char * ast_uuid_generate_str | ( | char * | buf, |
size_t | size | ||
) |
Generate a UUID string.
buf | The buffer where the UUID string will be stored |
size | The size of the buffer. Must be at least AST_UUID_STR_LEN. |
Definition at line 141 of file uuid.c.
References ast_uuid_to_str(), buf, generate_uuid(), and uuid().
Referenced by add_msid_to_stream(), ast_aeap_message_id_generate(), ast_datastores_alloc_datastore(), ast_rtp_new(), ast_sip_publish_client_alloc_datastore(), ast_sip_session_alloc_datastore(), ast_sorcery_alloc(), AST_TEST_DEFINE(), ast_websocket_uri_cb(), asterisk_daemon(), bridge_base_init(), build_entity_id(), generate_exchange_uuid(), pack_payload(), playback_create(), sorcery_config_open(), and uuid().
void ast_uuid_init | ( | void | ) |
Initialize the UUID system.
Definition at line 192 of file uuid.c.
References ast_debug, ast_log, dev_urandom_fd, has_dev_urandom, LOG_WARNING, and ast_uuid::uu.
Referenced by asterisk_daemon().
int ast_uuid_is_nil | ( | struct ast_uuid * | uuid | ) |
Check if a UUID is a nil UUID (all 0s)
uuid | UUID to check |
0 | The UUID is not nil |
non-zero | The UUID is nil |
Definition at line 187 of file uuid.c.
References uuid().
Referenced by AST_TEST_DEFINE().
char * ast_uuid_to_str | ( | struct ast_uuid * | uuid, |
char * | buf, | ||
size_t | size | ||
) |
Convert a UUID to a string.
uuid | The UUID to convert to a string | |
[out] | buf | The buffer where the UUID string will be stored |
size | The size of the buffer. Must be at least AST_UUID_STR_LEN. |
Definition at line 134 of file uuid.c.
References ast_assert, ast_str_to_lower(), AST_UUID_STR_LEN, buf, and uuid().
Referenced by AST_TEST_DEFINE(), and ast_uuid_generate_str().
|
static |
Definition at line 50 of file uuid.c.
References ast_mutex_lock, ast_mutex_unlock, has_dev_urandom, uuid(), and uuid_lock.
Referenced by ast_uuid_generate(), and ast_uuid_generate_str().
|
static |
Definition at line 37 of file uuid.c.
Referenced by ast_uuid_init(), and generate_uuid().
|
static |
Definition at line 35 of file uuid.c.
Referenced by generate_uuid().