26 #include <uuid/uuid.h>
35 AST_MUTEX_DEFINE_STATIC(uuid_lock);
37 static int has_dev_urandom;
50 static void generate_uuid(
struct ast_uuid *uuid)
114 if (!has_dev_urandom) {
115 ast_mutex_lock(&uuid_lock);
117 uuid_generate_random(uuid->uu);
118 if (!has_dev_urandom) {
119 ast_mutex_unlock(&uuid_lock);
136 ast_assert(size >= AST_UUID_STR_LEN);
137 uuid_unparse(uuid->uu, buf);
145 generate_uuid(&uuid);
157 res = uuid_parse(str, uuid->uu);
159 ast_log(LOG_WARNING,
"Unable to convert string %s into a UUID\n", str);
173 uuid_copy(dst->uu, src->uu);
179 return uuid_compare(left->uu, right->uu);
184 uuid_clear(uuid->uu);
189 return uuid_is_null(uuid->uu);
214 dev_urandom_fd = open(
"/dev/urandom", O_RDONLY);
215 if (dev_urandom_fd < 0) {
216 ast_log(LOG_WARNING,
"It appears your system does not have /dev/urandom on it. This\n"
217 "means that UUID generation will use a pseudorandom number generator. Since\n"
218 "the thread-safety of your system's random number generator cannot\n"
219 "be guaranteed, we have to synchronize UUID generation. This may result\n"
220 "in decreased performance. It is highly recommended that you set up your\n"
221 "system to have /dev/urandom\n");
224 close(dev_urandom_fd);
226 uuid_generate_random(uu);
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
String manipulation functions.
char * ast_uuid_generate_str(char *buf, size_t size)
Generate a UUID string.
Universally unique identifier support.
int ast_uuid_is_nil(struct ast_uuid *uuid)
Check if a UUID is a nil UUID (all 0s)
int ast_uuid_compare(struct ast_uuid *left, struct ast_uuid *right)
Compare two UUIDs.
struct ast_uuid * ast_uuid_copy(struct ast_uuid *src)
Make a copy of a UUID.
struct ast_uuid * ast_str_to_uuid(char *str)
Convert a string to a UUID.
struct ast_uuid * ast_uuid_generate(void)
Generate a UUID.
void ast_uuid_clear(struct ast_uuid *uuid)
Clear a UUID by setting it to be a nil UUID (all 0s)
#define ast_malloc(len)
A wrapper for malloc()
#define ast_debug(level,...)
Log a DEBUG message.
static force_inline char * ast_str_to_lower(char *str)
Convert a string to all lower-case.
Support for logging to various files, console and syslog Configuration in file logger.conf.
char * ast_uuid_to_str(struct ast_uuid *uuid, char *buf, size_t size)
Convert a UUID to a string.
void ast_uuid_init(void)
Initialize the UUID system.