38 #include "asterisk/_private.h"
80 { 0x87, 0x76, 0x79, 0x35, 0x23, 0xea, 0x3a, 0xd3,
81 0x25, 0x2a, 0xbb, 0x35, 0x87, 0xe4, 0x22, 0x24 };
95 unsigned int running:1;
96 unsigned int declined:1;
106 if (!mod || !mod->info) {
110 return mod->info->name;
122 int (*updater)(void);
152 if (!(mod =
ast_calloc(1,
sizeof(*mod) + strlen(info->name) + 1)))
182 *((
struct ast_module **) &(info->self)) = mod;
195 if (mod->
info == info) {
278 int (*reload_fn)(void);
301 for (pos = 0, x = 0; x < 16; x++)
302 pos += sprintf(buf + pos,
" %02x", (
unsigned)*d++);
304 ast_debug(1,
"Unexpected signature:%s\n", buf);
309 static int key_matches(
const unsigned char *key1,
const unsigned char *key2)
313 for (x = 0; x < 16; x++) {
314 if (key1[x] != key2[x])
324 unsigned char digest[16];
340 char *name1 = (
char *) name1_in;
341 char *name2 = (
char *) name2_in;
344 if (!strcasecmp(name1 + strlen(name1) - 3,
".so")) {
346 name1[strlen(name1) - 3] =
'\0';
348 if (!strcasecmp(name2 + strlen(name2) - 3,
".so")) {
350 name2[strlen(name2) - 3] =
'\0';
353 return strcasecmp(name1, name2);
374 #ifdef LOADABLE_MODULES
389 S_OR(name,
"unknown"),
S_OR(error,
"Unknown error"));
407 char fn[PATH_MAX] =
"";
410 unsigned int wants_global;
414 space =
sizeof(*resource_being_loaded) + strlen(resource_in) + 1;
415 if (strcasecmp(resource_in + strlen(resource_in) - 3,
".so")) {
433 if (!(lib = dlopen(fn, RTLD_LAZY |
RTLD_LOCAL))) {
447 ast_log(
LOG_WARNING,
"Module '%s' did not register itself during load\n", resource_in);
459 if (global_symbols_only && !wants_global) {
469 #if !defined(HAVE_ATTRIBUTE_weak_import) && !defined(HAVE_ATTRIBUTE_weakref)
473 while ((each =
strsep(&required_resource,
","))) {
496 if (!(lib = dlopen(fn, wants_global ? RTLD_LAZY | RTLD_GLOBAL :
RTLD_NOW |
RTLD_LOCAL))) {
516 int somethingchanged = 1,
final = 0;
524 if (!somethingchanged) {
531 somethingchanged = 0;
543 somethingchanged = 1;
546 }
while (somethingchanged && !
final);
570 if (!error && (mod->
usecount > 0)) {
591 ast_log(
LOG_WARNING,
"** Dangerous **: Unloading resource anyway, at user request\n");
613 #ifdef LOADABLE_MODULES
629 int i, which=0, l = strlen(word);
637 if (!strncasecmp(word, cur->
resource, l) &&
658 struct reload_queue_item *item;
685 struct reload_queue_item *item;
704 if (!strcasecmp(item->
module, module)) {
709 item =
ast_calloc(1,
sizeof(*item) + strlen(module) + 1);
715 strcpy(item->
module, module);
735 ast_verbose(
"The previous reload command didn't finish yet\n");
785 "Before reloading the module, you must run \"module load %s\" "
786 "and fix whatever is preventing the module from being initialized.\n",
835 ast_log(
LOG_WARNING,
"Module '%s' was not compiled with the same compile-time options as this version of Asterisk.\n", mod->
resource);
906 #ifdef LOADABLE_MODULES
909 if (!global_symbols_only) {
924 #ifdef LOADABLE_MODULES
931 ast_log(
LOG_WARNING,
"Module '%s' was unable to backup its global data.\n", resource_name);
968 static struct load_order_entry *
add_to_load_order(const
char *resource, struct load_order *load_order,
int required)
970 struct load_order_entry *order;
999 if (a_pri == b_pri) {
1001 }
else if (a_pri < b_pri) {
1033 fprintf(stderr,
"*** Failed to load module %s - %s\n", order->
resource, order->
required ?
"Required" :
"Not required");
1065 *mod_count += count;
1078 unsigned int load_count;
1082 int modulecount = 0;
1084 #ifdef LOADABLE_MODULES
1085 struct dirent *dirent;
1092 ast_verb(1,
"Asterisk Dynamic Loader Starting:\n");
1112 if (!strcasecmp(v->
name, preload_only ?
"preload" :
"load")) {
1115 if (!strcasecmp(v->
name, preload_only ?
"preload-require" :
"require")) {
1137 #ifdef LOADABLE_MODULES
1141 while ((dirent = readdir(dir))) {
1142 int ld = strlen(dirent->d_name);
1149 if (strcasecmp(dirent->d_name + ld - 3,
".so"))
1172 if (strcasecmp(v->
name,
"noload"))
1217 manager_event(
EVENT_FLAG_SYSTEM,
"ModuleLoadReport",
"ModuleLoadStatus: Done\r\nModuleSelection: %s\r\nModuleCount: %d\r\n", preload_only ?
"Preload" :
"All", modulecount);
1226 struct loadupdate *m;
1239 int total_mod_loaded = 0;
1251 return total_mod_loaded;
1264 return (cur != NULL);
1270 struct loadupdate *tmp;
1285 struct loadupdate *cur;
1297 return cur ? 0 : -1;
static enum ast_module_load_result start_resource(struct ast_module *mod)
Main Channel structure associated with a channel.
struct module_user_list users
#define AST_LIST_LOCK(head)
Locks a list.
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
const char * ast_variable_retrieve(const struct ast_config *config, const char *category, const char *variable)
Gets a variable.
#define AST_LIST_HEAD(name, type)
Defines a structure to be used to hold a list of specified type.
void ast_module_unref(struct ast_module *)
char * strsep(char **str, const char *delims)
enum ast_module_load_result ast_load_resource(const char *resource_name)
Load a module.
static int key_matches(const unsigned char *key1, const unsigned char *key2)
void __ast_module_user_hangup_all(struct ast_module *)
static const unsigned char expected_key[]
struct ast_module * first
int ast_cel_engine_reload(void)
#define ast_test_flag(p, flag)
const char * ast_config_AST_MODULE_DIR
int ast_indications_reload(void)
Reload indications module.
Convenient Signal Processing routines.
int reload_manager(void)
Called by Asterisk module functions and the CLI command.
static struct ast_module * resource_being_loaded
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Goes through variables.
void __ast_module_user_remove(struct ast_module *, struct ast_module_user *)
void ast_verbose(const char *fmt,...)
int ast_unlock_path(const char *path)
Unlock a path.
struct ast_module_user::@276 entry
Structure for variables, used for configurations and for channel variables.
static void close_lib(const char *name, void *lib)
void MD5Final(unsigned char digest[16], struct MD5Context *context)
int ast_heap_push(struct ast_heap *h, void *elm)
Push an element on to a heap.
enum ast_module_load_result(* load)(void)
Configuration File Parser.
struct ast_heap * ast_heap_destroy(struct ast_heap *h)
Destroy a max heap.
int ast_udptl_reload(void)
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
void ast_module_shutdown(void)
Run the unload() callback for all loaded modules.
void * ast_heap_pop(struct ast_heap *h)
Pop the max element off of the heap.
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
void ast_update_use_count(void)
Notify when usecount has been changed.
list of users found in the config file
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
static struct ast_module * find_resource(const char *resource, int do_lock)
#define ast_verb(level,...)
void ast_config_destroy(struct ast_config *config)
Destroys a config.
void MD5Init(struct MD5Context *context)
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return * the previous value of *p. This can be used to handle reference co...
int ast_features_reload(void)
Reload call features from features.conf.
static int verify_key(const unsigned char *key)
int ast_module_check(const char *name)
Check if module with the name given is loaded.
static int resource_name_match(const char *name1_in, const char *name2_in)
#define AST_LIST_HEAD_DESTROY(head)
Destroys a list head structure.
static enum ast_module_load_result load_resource(const char *resource_name, unsigned int global_symbols_only, struct ast_heap *resource_heap, int required)
#define CONFIG_STATUS_FILEMISSING
Support for Private Asterisk HTTP Servers.
void ast_module_unregister(const struct ast_module_info *)
#define EVENT_FLAG_SYSTEM
#define ast_debug(level,...)
Log a DEBUG message.
enum AST_LOCK_RESULT ast_lock_path(const char *path)
Lock a filesystem path.
int ast_http_reload(void)
General Asterisk PBX channel definitions.
Asterisk file paths, configured in asterisk.conf.
#define ast_mutex_trylock(a)
char * ast_module_helper(const char *line, const char *word, int pos, int state, int rpos, int needsreload)
Match modules names for the Asterisk cli.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
int ast_softhangup(struct ast_channel *chan, int reason)
Softly hangup up a channel.
int logger_reload(void)
Reload logger without rotating log files.
struct timeval ast_lastreloadtime
int ast_plc_reload(void)
Reload genericplc configuration value from codecs.conf.
A set of macros to manage forward-linked lists.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
int ast_enum_reload(void)
#define AST_LIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a list of specified type, statically initialized.
struct ast_module_user * __ast_module_user_add(struct ast_module *, struct ast_channel *)
struct ast_channel * chan
#define ast_test_suite_event_notify(s, f,...)
char * term_color(char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout)
int ast_cdr_engine_reload(void)
Reload the configuration file cdr.conf and start/stop CDR scheduling thread.
static void unload_dynamic_module(struct ast_module *mod)
struct ast_module::@277 flags
void MD5Update(struct MD5Context *context, unsigned char const *buf, unsigned len)
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
#define ast_strdupa(s)
duplicate a string in memory from the stack
static struct ast_module * load_dynamic_module(const char *resource_in, unsigned int global_symbols_only, struct ast_heap *resource_heap)
static int load_resource_list(struct load_order *load_order, unsigned int global_symbols, int *mod_count)
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
const char * ast_config_AST_CONFIG_DIR
int ast_loader_unregister(int(*updater)(void))
Remove a procedure to be run when modules are updated.
static char buildopt_sum[33]
int ast_unload_resource(const char *resource_name, enum ast_module_unload_mode)
Unload a module.
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
#define AST_LIST_LAST(head)
Returns the last entry contained in a list.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
#define AST_LIST_HEAD_INIT(head)
Initializes a list head structure.
int ast_module_reload(const char *name)
Reload asterisk modules.
static int do_full_reload
int ast_loader_register(int(*updater)(void))
Add a procedure to be run when modules have been updated.
Structure used to handle boolean flags.
static void queue_reload_request(const char *module)
static ast_mutex_t reloadlock
static struct module_list embedded_module_list
#define AST_MODULE_CONFIG
Module configuration file.
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
const char * ast_module_name(const struct ast_module *mod)
Get the name of a module.
int load_modules(unsigned int)
int ast_dsp_reload(void)
Reloads dsp settings from dsp.conf.
int(* backup_globals)(void)
static struct load_order_entry * add_to_load_order(const char *resource, struct load_order *load_order, int required)
int ast_update_module_list(int(*modentry)(const char *module, const char *description, int usecnt, const char *like), const char *like)
Ask for a list of modules, descriptions, and use counts.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
struct ast_heap * ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_fn, ssize_t index_offset)
Create a max heap.
void(* restore_globals)(void)
#define AST_LIST_TRYLOCK(head)
Locks a list, without blocking if the list is locked.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
void ast_module_register(const struct ast_module_info *)
Handy terminal functions for vt* terms.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
struct ast_variable * next
static int mod_load_cmp(void *a, void *b)
#define CONFIG_STATUS_FILEINVALID
Call Parking and Pickup API Includes code and algorithms from the Zapata library. ...
static unsigned int embedding
#define manager_event(category, event, contents,...)
External routines may send asterisk manager events this way.
Asterisk module definitions.
struct ast_module_info * info
static unsigned int inspect_module(const struct ast_module *mod)
static int printdigest(const unsigned char *d)
const char buildopt_sum[33]
#define ast_opt_lock_confdir
void ast_process_pending_reloads(void)
Process reload requests received during startup.
#define AST_MUTEX_DEFINE_STATIC(mutex)
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
#define ast_mutex_unlock(a)
struct ast_module * ast_module_ref(struct ast_module *)
int read_config_maps(void)
Exposed re-initialization method for core process.