Asterisk module definitions. More...
#include "asterisk/utils.h"
Go to the source code of this file.
Data Structures | |
struct | ast_module_info |
Macros | |
#define | __MODULE_INFO_GLOBALS |
#define | __MODULE_INFO_SECTION |
#define | AST_MODULE_CONFIG "modules.conf" |
Module configuration file. More... | |
#define | AST_MODULE_INFO(keystr, flags_to_set, desc, fields...) |
#define | AST_MODULE_INFO_STANDARD(keystr, desc) |
#define | ast_module_user_add(chan) __ast_module_user_add(ast_module_info->self, chan) |
#define | ast_module_user_hangup_all() __ast_module_user_hangup_all(ast_module_info->self) |
#define | ast_module_user_remove(user) __ast_module_user_remove(ast_module_info->self, user) |
#define | ast_register_application(app, execute, synopsis, description) ast_register_application2(app, execute, synopsis, description, ast_module_info->self) |
Register an application. More... | |
#define | ast_register_application_xml(app, execute) ast_register_application(app, execute, NULL, NULL) |
Register an application using XML documentation. More... | |
#define | ASTERISK_GPL_KEY "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" |
The text the key() function should return. More... | |
Enumerations | |
enum | ast_module_flags { AST_MODFLAG_DEFAULT = 0, AST_MODFLAG_GLOBAL_SYMBOLS = (1 << 0), AST_MODFLAG_LOAD_ORDER = (1 << 1) } |
enum | ast_module_load_priority { AST_MODPRI_REALTIME_DEPEND = 10, AST_MODPRI_REALTIME_DEPEND2 = 20, AST_MODPRI_REALTIME_DRIVER = 30, AST_MODPRI_TIMING = 40, AST_MODPRI_CHANNEL_DEPEND = 50, AST_MODPRI_CHANNEL_DRIVER = 60, AST_MODPRI_APP_DEPEND = 70, AST_MODPRI_DEVSTATE_PROVIDER = 80, AST_MODPRI_DEVSTATE_PLUGIN = 90, AST_MODPRI_CDR_DRIVER = 100, AST_MODPRI_DEFAULT = 128, AST_MODPRI_DEVSTATE_CONSUMER = 150 } |
enum | ast_module_load_result { AST_MODULE_LOAD_SUCCESS = 0, AST_MODULE_LOAD_DECLINE = 1, AST_MODULE_LOAD_SKIP = 2, AST_MODULE_LOAD_PRIORITY = 3, AST_MODULE_LOAD_FAILURE = -1 } |
enum | ast_module_unload_mode { AST_FORCE_SOFT = 0, AST_FORCE_FIRM = 1, AST_FORCE_HARD = 2 } |
Functions | |
struct ast_module_user * | __ast_module_user_add (struct ast_module *, struct ast_channel *) |
void | __ast_module_user_hangup_all (struct ast_module *) |
void | __ast_module_user_remove (struct ast_module *, struct ast_module_user *) |
enum ast_module_load_result | ast_load_resource (const char *resource_name) |
Load a module. More... | |
int | ast_loader_register (int(*updater)(void)) |
Add a procedure to be run when modules have been updated. More... | |
int | ast_loader_unregister (int(*updater)(void)) |
Remove a procedure to be run when modules are updated. More... | |
int | ast_module_check (const char *name) |
Check if module with the name given is loaded. More... | |
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. More... | |
const char * | ast_module_name (const struct ast_module *mod) |
Get the name of a module. More... | |
struct ast_module * | ast_module_ref (struct ast_module *) |
void | ast_module_register (const struct ast_module_info *) |
void | ast_module_shutdown (void) |
Run the unload() callback for all loaded modules. More... | |
void | ast_module_unref (struct ast_module *) |
void | ast_module_unregister (const struct ast_module_info *) |
int | ast_register_application2 (const char *app, int(*execute)(struct ast_channel *, const char *), const char *synopsis, const char *description, void *mod) |
Register an application. More... | |
int | ast_unload_resource (const char *resource_name, enum ast_module_unload_mode) |
Unload a module. More... | |
int | ast_unregister_application (const char *app) |
Unregister an application. More... | |
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. More... | |
void | ast_update_use_count (void) |
Notify when usecount has been changed. More... | |
Variables | |
static struct ast_module_info * | ast_module_info |
Asterisk module definitions.
This file contains the definitons for functions Asterisk modules should provide and some other module related functions.
Definition in file module.h.
#define AST_MODULE_CONFIG "modules.conf" |
#define AST_MODULE_INFO | ( | keystr, | |
flags_to_set, | |||
desc, | |||
fields... | |||
) |
#define AST_MODULE_INFO_STANDARD | ( | keystr, | |
desc | |||
) |
#define ast_module_user_add | ( | chan | ) | __ast_module_user_add(ast_module_info->self, chan) |
Definition at line 268 of file module.h.
Referenced by ast_calendar_register(), canmatch(), exec(), exists(), matchmore(), nbs_new(), queue_function_queuememberpaused(), queue_function_queuememberstatus(), smdi_msg_read(), and smdi_msg_retrieve_read().
#define ast_module_user_hangup_all | ( | ) | __ast_module_user_hangup_all(ast_module_info->self) |
#define ast_module_user_remove | ( | user | ) | __ast_module_user_remove(ast_module_info->self, user) |
Definition at line 269 of file module.h.
Referenced by ast_calendar_unregister(), canmatch(), exec(), exists(), matchmore(), nbs_destroy(), queue_function_queuememberpaused(), queue_function_queuememberstatus(), smdi_msg_read(), and smdi_msg_retrieve_read().
#define ast_register_application | ( | app, | |
execute, | |||
synopsis, | |||
description | |||
) | ast_register_application2(app, execute, synopsis, description, ast_module_info->self) |
Register an application.
app | Short name of the application |
execute | a function callback to execute the application. It should return non-zero if the channel needs to be hung up. |
synopsis | a short description (one line synopsis) of the application |
description | long description with all of the details about the use of the application |
This registers an application with Asterisk's internal application list.
0 | success |
-1 | failure. |
Definition at line 421 of file module.h.
Referenced by load_module().
#define ast_register_application_xml | ( | app, | |
execute | |||
) | ast_register_application(app, execute, NULL, NULL) |
Register an application using XML documentation.
app | Short name of the application |
execute | a function callback to execute the application. It should return non-zero if the channel needs to be hung up. |
This registers an application with Asterisk's internal application list.
0 | success |
-1 | failure. |
Definition at line 437 of file module.h.
Referenced by load_module().
#define ASTERISK_GPL_KEY "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" |
enum ast_module_flags |
Enumerator | |
---|---|
AST_MODFLAG_DEFAULT | |
AST_MODFLAG_GLOBAL_SYMBOLS | |
AST_MODFLAG_LOAD_ORDER |
Definition at line 204 of file module.h.
Definition at line 60 of file module.h.
struct ast_module_user* __ast_module_user_add | ( | struct ast_module * | , |
struct ast_channel * | |||
) |
Definition at line 209 of file loader.c.
References ast_atomic_fetchadd_int(), ast_calloc, AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_update_use_count(), ast_module_user::chan, ast_module::usecount, and ast_module::users.
Referenced by ast_func_read(), ast_func_read2(), ast_func_write(), and pbx_exec().
void __ast_module_user_hangup_all | ( | struct ast_module * | ) |
Definition at line 254 of file loader.c.
References ast_atomic_fetchadd_int(), ast_free, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, ast_softhangup(), AST_SOFTHANGUP_APPUNLOAD, ast_update_use_count(), ast_module_user::chan, ast_module::usecount, and ast_module::users.
Referenced by ast_unload_resource().
void __ast_module_user_remove | ( | struct ast_module * | , |
struct ast_module_user * | |||
) |
Definition at line 231 of file loader.c.
References ast_atomic_fetchadd_int(), ast_free, AST_LIST_LOCK, AST_LIST_REMOVE, AST_LIST_UNLOCK, ast_update_use_count(), ast_module::usecount, and ast_module::users.
Referenced by ast_func_read(), ast_func_read2(), ast_func_write(), and pbx_exec().
enum ast_module_load_result ast_load_resource | ( | const char * | resource_name | ) |
Load a module.
resource_name | The name of the module to load. |
This function is run by the PBX to load the modules. It performs all loading and initialization tasks. Basically, to load a module, just give it the name of the module and it will do the rest.
Definition at line 947 of file loader.c.
References AST_LIST_LOCK, AST_LIST_UNLOCK, ast_test_suite_event_notify, and load_resource().
Referenced by handle_load(), load_module(), and manager_moduleload().
int ast_loader_register | ( | int(*)(void) | updater | ) |
Add a procedure to be run when modules have been updated.
updater | The function to run when modules have been updated. |
This function adds the given function to a linked list of functions to be run when the modules are updated.
0 | on success |
-1 | on failure. |
Definition at line 1268 of file loader.c.
References AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_malloc, and loadupdate::updater.
int ast_loader_unregister | ( | int(*)(void) | updater | ) |
Remove a procedure to be run when modules are updated.
updater | The updater function to unregister. |
This removes the given function from the updater list.
0 | on success |
-1 | on failure. |
Definition at line 1283 of file loader.c.
References AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, and loadupdate::updater.
int ast_module_check | ( | const char * | name | ) |
Check if module with the name given is loaded.
name | Module name, like "chan_sip.so" |
1 | if true |
0 | if false |
Check if module with the name given is loaded.
Definition at line 1255 of file loader.c.
References ast_strlen_zero(), and find_resource().
Referenced by ifmodule_read(), load_module(), manager_modulecheck(), and unload_module().
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.
line | Unused by this function, but this should be the line we are matching. |
word | The partial name to match. |
pos | The position the word we are completing is in. |
state | The possible match to return. |
rpos | The position we should be matching. This should be the same as pos. |
needsreload | This should be 1 if we need to reload this module and 0 otherwise. This function will only return modules that are reloadble if this is 1. |
A | possible completion of the partial match. |
NULL | if no matches were found. |
Definition at line 626 of file loader.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_strdup, ast_module::info, name, reload_classes::name, ast_module_info::reload, and ast_module::resource.
Referenced by conf_run(), handle_modlist(), handle_reload(), handle_unload(), and load_module().
const char* ast_module_name | ( | const struct ast_module * | mod | ) |
Get the name of a module.
mod | A pointer to the module. |
NULL | if mod or mod->info is NULL |
Definition at line 104 of file loader.c.
Referenced by acf_retrieve_docs(), ast_register_application2(), and unload_dynamic_module().
struct ast_module* ast_module_ref | ( | struct ast_module * | ) |
Definition at line 1300 of file loader.c.
References ast_atomic_fetchadd_int(), ast_update_use_count(), and ast_module::usecount.
Referenced by __oh323_new(), agi_handle_command(), alsa_new(), ast_agi_register(), ast_app_exec_sub(), ast_app_expand_sub_args(), ast_fax_tech_register(), ast_iax2_new(), ast_rtp_instance_new(), ast_srtp_create(), ast_timer_open(), dahdi_new(), dahdi_pri_cc_agent_init(), data_result_generate_node(), fax_session_new(), fax_session_reserve(), find_best_technology(), fn_wrapper(), gtalk_new(), handle_cli_file_convert(), handle_orig(), load_module(), local_alloc(), mgcp_new(), mixmonitor_exec(), moh_alloc(), moh_files_alloc(), mute_add_audiohook(), my_module_ref(), newpvt(), oss_new(), phone_check_exception(), phone_new(), sip_handle_cc(), sip_new(), skinny_new(), and smdi_load().
void ast_module_register | ( | const struct ast_module_info * | ) |
Definition at line 147 of file loader.c.
References ast_calloc, AST_LIST_HEAD_INIT, AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_UNLOCK, embedded_module_list, embedding, ast_module::info, ast_module::resource, resource_being_loaded, and ast_module::users.
void ast_module_shutdown | ( | void | ) |
Run the unload() callback for all loaded modules.
This function should be called when Asterisk is shutting down gracefully.
Definition at line 513 of file loader.c.
References AST_LIST_HEAD_DESTROY, AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_module::declined, ast_module::flags, free, ast_module::info, ast_module::running, ast_module_info::unload, ast_module::usecount, and ast_module::users.
Referenced by really_quit().
void ast_module_unref | ( | struct ast_module * | ) |
Definition at line 1312 of file loader.c.
References ast_atomic_fetchadd_int(), ast_update_use_count(), and ast_module::usecount.
Referenced by agi_handle_command(), alsa_hangup(), ast_agi_unregister(), ast_app_exec_sub(), ast_app_expand_sub_args(), ast_bridge_check(), ast_fax_tech_unregister(), ast_rtp_instance_new(), ast_smdi_interface_destroy(), ast_srtp_destroy(), ast_timer_close(), dahdi_destroy_channel_bynum(), dahdi_hangup(), dahdi_pri_cc_agent_destructor(), dahdi_pri_cc_agent_init(), data_result_generate_node(), destroy(), destroy_bridge(), destroy_callback(), destroy_session(), fax_session_new(), filestream_destructor(), gtalk_hangup(), handle_cli_file_convert(), handle_orig(), iax2_predestroy(), instance_destructor(), local_ast_moh_cleanup(), local_pvt_destructor(), mgcp_hangup(), mixmonitor_exec(), mixmonitor_thread(), my_module_unref(), oh323_hangup(), oss_hangup(), phone_check_exception(), phone_hangup(), sip_cc_monitor_destructor(), sip_hangup(), skinny_hangup(), and smart_bridge_operation().
void ast_module_unregister | ( | const struct ast_module_info * | ) |
Definition at line 185 of file loader.c.
References ast_free, AST_LIST_HEAD_DESTROY, AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_module::info, and ast_module::users.
int ast_register_application2 | ( | const char * | app, |
int(*)(struct ast_channel *, const char *) | execute, | ||
const char * | synopsis, | ||
const char * | description, | ||
void * | mod | ||
) |
Register an application.
app | Short name of the application |
execute | a function callback to execute the application. It should return non-zero if the channel needs to be hung up. |
synopsis | a short description (one line synopsis) of the application |
description | long description with all of the details about the use of the application |
mod | module this application belongs to |
This registers an application with Asterisk's internal application list.
0 | success |
-1 | failure. |
Register an application.
Definition at line 6344 of file pbx.c.
References ast_app::arguments, ast_calloc, ast_free, ast_log(), ast_module_name(), AST_RWLIST_INSERT_BEFORE_CURRENT, AST_RWLIST_INSERT_TAIL, AST_RWLIST_TRAVERSE, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, AST_STATIC_DOC, ast_string_field_init, ast_string_field_set, ast_strlen_zero(), ast_verb, AST_XML_DOC, ast_xmldoc_build_arguments(), ast_xmldoc_build_description(), ast_xmldoc_build_seealso(), ast_xmldoc_build_synopsis(), ast_xmldoc_build_syntax(), COLOR_BRCYAN, ast_app::docsrc, ast_app::execute, LOG_WARNING, ast_app::seealso, ast_app::syntax, and term_color().
Referenced by ast_cc_init(), ast_features_init(), and load_pbx().
int ast_unload_resource | ( | const char * | resource_name, |
enum | ast_module_unload_mode | ||
) |
Unload a module.
resource_name | The name of the module to unload. |
ast_module_unload_mode | The force flag. This should be set using one of the AST_FORCE flags. |
This function unloads a module. It will only unload modules that are not in use (usecount not zero), unless AST_FORCE_FIRM or AST_FORCE_HARD is specified. Setting AST_FORCE_FIRM or AST_FORCE_HARD will unload the module regardless of consequences (NOT RECOMMENDED).
0 | on success. |
-1 | on error. |
Definition at line 551 of file loader.c.
References __ast_module_user_hangup_all(), AST_FORCE_FIRM, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_log(), ast_test_suite_event_notify, ast_update_use_count(), ast_module::declined, find_resource(), ast_module::flags, ast_module::info, ast_module::lib, LOG_WARNING, ast_module_info::restore_globals, ast_module::running, ast_module_info::unload, unload_dynamic_module(), and ast_module::usecount.
Referenced by handle_unload(), manager_moduleload(), and unload_module().
int ast_unregister_application | ( | const char * | app | ) |
Unregister an application.
app | name of the application (does not have to be the same string as the one that was registered) |
This unregisters an application from Asterisk's internal application list.
0 | success |
-1 | failure |
Definition at line 7705 of file pbx.c.
References ast_free, AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_string_field_free_memory, ast_verb, and unreference_cached_app().
Referenced by __unload_module(), cc_shutdown(), features_shutdown(), load_module(), unload_module(), and unload_pbx().
int ast_update_module_list | ( | int(*)(const char *module, const char *description, int usecnt, const char *like) | modentry, |
const char * | like | ||
) |
Ask for a list of modules, descriptions, and use counts.
modentry | A callback to an updater function. |
like | For each of the modules loaded, modentry will be executed with the resource, description, and usecount values of each particular module. |
Definition at line 1234 of file loader.c.
References AST_LIST_TRAVERSE, AST_LIST_TRYLOCK, AST_LIST_UNLOCK, ast_module_info::description, ast_module::info, ast_module::resource, and ast_module::usecount.
Referenced by ast_var_Modules(), and handle_modlist().
void ast_update_use_count | ( | void | ) |
Notify when usecount has been changed.
This function calulates use counts and notifies anyone trying to keep track of them. It should be called whenever your module's usecount changes.
Definition at line 1222 of file loader.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, and loadupdate::updater.
Referenced by __ast_module_user_add(), __ast_module_user_hangup_all(), __ast_module_user_remove(), ast_module_ref(), ast_module_unref(), ast_unload_resource(), handle_request_do(), oh323_request(), sip_request_call(), start_resource(), and unistim_new().
|
static |