/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2024, Maksim Nesterov * * See http://www.asterisk.org for more information about * the Asterisk project. Please do not directly contact * any of the maintainers of this project for assistance; * the project provides a web site, mailing lists and IRC * channels for your use. * * This program is free software, distributed under the terms of * the GNU General Public License Version 2. See the LICENSE file * at the top of the source tree. */ /*! \file * * \brief UUID dialplan function * * \author Maksim Nesterov * * \ingroup functions */ /*** MODULEINFO extended ***/ #include "asterisk.h" #include "asterisk/module.h" #include "asterisk/pbx.h" #include "asterisk/uuid.h" /*** DOCUMENTATION Generates an UUID. Returns a version 4 (random) Universally Unique Identifier (UUID) as a string. same => n,Set(uuid=${UUID()}) ***/ static int uuid(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { ast_uuid_generate_str(buf, AST_UUID_STR_LEN); return 0; } static struct ast_custom_function uuid_function = { .name = "UUID", .read = uuid, .read_max = AST_UUID_STR_LEN, }; static int unload_module(void) { return ast_custom_function_unregister(&uuid_function); } static int load_module(void) { return ast_custom_function_register(&uuid_function); } AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "UUID generation dialplan function");