Asterisk - The Open Source Telephony Project
21.4.1
|
Asterisk module definitions. More...
#include "asterisk/utils.h"
Go to the source code of this file.
Data Structures | |
struct | ast_module_info |
Macros | |
#define | AST_MODULE_CONFIG "modules.conf" |
Module configuration file. | |
#define | AST_MODULE_INFO(keystr, flags_to_set, desc, fields...) |
#define | AST_MODULE_INFO_STANDARD(keystr, desc) |
#define | AST_MODULE_INFO_STANDARD_DEPRECATED(keystr, desc) |
#define | AST_MODULE_INFO_STANDARD_EXTENDED(keystr, desc) |
#define | ast_module_ref(mod) __ast_module_ref(mod, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Hold a reference to the module. More... | |
#define | ast_module_running_ref(mod) __ast_module_running_ref(mod, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Hold a reference to the module if it is running. More... | |
#define | ast_module_shutdown_ref(mod) __ast_module_shutdown_ref(mod, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Prevent unload of the module before shutdown. More... | |
#define | ast_module_unref(mod) __ast_module_unref(mod, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Release a reference to the module. More... | |
#define | ast_module_user_add(chan) __ast_module_user_add(AST_MODULE_SELF, chan) |
#define | ast_module_user_hangup_all() __ast_module_user_hangup_all(AST_MODULE_SELF) |
#define | ast_module_user_remove(user) __ast_module_user_remove(AST_MODULE_SELF, user) |
#define | ast_register_application(app, execute, synopsis, description) ast_register_application2(app, execute, synopsis, description, AST_MODULE_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. | |
#define | SCOPED_MODULE_USE(module) RAII_VAR(struct ast_module *, __self__ ## __LINE__, ast_module_ref(module), ast_module_unref) |
Functions | |
struct ast_module * | __ast_module_ref (struct ast_module *mod, const char *file, int line, const char *func) |
struct ast_module * | __ast_module_running_ref (struct ast_module *mod, const char *file, int line, const char *func) |
void | __ast_module_shutdown_ref (struct ast_module *mod, const char *file, int line, const char *func) |
void | __ast_module_unref (struct ast_module *mod, const char *file, int line, const char *func) |
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, enum ast_module_helper_type type) |
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... | |
void | ast_module_register (const struct ast_module_info *) |
enum ast_module_reload_result | ast_module_reload (const char *name) |
Reload asterisk modules. More... | |
const char * | ast_module_support_level_to_string (enum ast_module_support_level support_level) |
void | ast_module_unregister (const struct ast_module_info *) |
int | ast_refresh_resource (const char *resource_name, enum ast_module_unload_mode force, int recursive) |
Unload and load a module again. More... | |
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 *status, const char *like, enum ast_module_support_level support_level), const char *like) |
Ask for a list of modules, descriptions, use counts and status. More... | |
int | ast_update_module_list_condition (int(*modentry)(const char *module, const char *description, int usecnt, const char *status, const char *like, enum ast_module_support_level support_level, void *data, const char *condition), const char *like, void *data, const char *condition) |
Ask for a list of modules, descriptions, use counts and status. More... | |
int | ast_update_module_list_data (int(*modentry)(const char *module, const char *description, int usecnt, const char *status, const char *like, enum ast_module_support_level support_level, void *data), const char *like, void *data) |
Ask for a list of modules, descriptions, use counts and status. More... | |
void | ast_update_use_count (void) |
Notify when usecount has been changed. More... | |
Variables | |
static const 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_ref | ( | mod | ) | __ast_module_ref(mod, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Hold a reference to the module.
mod | Module to reference |
Definition at line 457 of file module.h.
Referenced by __ast_datastore_alloc(), ast_iax2_new(), instance_created_observer(), and newpvt().
#define ast_module_running_ref | ( | mod | ) | __ast_module_running_ref(mod, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Hold a reference to the module if it is running.
mod | Module to reference |
mod | if running |
NULL | if not running |
The returned pointer should be released with ast_module_unref.
Definition at line 469 of file module.h.
Referenced by __ast_sorcery_object_type_insert_wizard(), ast_app_exec_sub(), ast_app_expand_sub_args(), ast_cli_command_full(), ast_hook_send_action(), ast_rtp_instance_new(), ast_timer_open(), fax_session_new(), fax_session_reserve(), find_best_technology(), and process_message().
#define ast_module_shutdown_ref | ( | mod | ) | __ast_module_shutdown_ref(mod, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Prevent unload of the module before shutdown.
mod | Module to hold |
Definition at line 478 of file module.h.
Referenced by __ast_bucket_scheme_register(), and __ast_format_interface_register().
#define ast_module_unref | ( | mod | ) | __ast_module_unref(mod, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Release a reference to the module.
mod | Module to release |
Definition at line 483 of file module.h.
Referenced by __ast_sorcery_object_type_insert_wizard(), ast_app_exec_sub(), ast_app_expand_sub_args(), ast_cli_command_full(), ast_datastore_free(), ast_hook_send_action(), ast_rtp_instance_new(), ast_timer_close(), ast_timer_open(), destroy_session(), fax_session_new(), find_best_technology(), iax2_predestroy(), instance_destroying_observer(), modules_shutdown(), newpvt(), process_message(), and sorcery_object_wizard_destructor().
#define ast_register_application | ( | app, | |
execute, | |||
synopsis, | |||
description | |||
) | ast_register_application2(app, execute, synopsis, description, AST_MODULE_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. |
#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 640 of file module.h.
Referenced by load_module(), and load_parking_applications().
#define SCOPED_MODULE_USE | ( | module | ) | RAII_VAR(struct ast_module *, __self__ ## __LINE__, ast_module_ref(module), ast_module_unref) |
Macro to safely ref and unref the self module for the current scope
Definition at line 679 of file module.h.
Referenced by ast_parking_blind_transfer_park(), ast_parking_is_exten_park(), ast_parking_park_bridge_channel(), and ast_parking_park_call().
Used to specify which modules should be returned by ast_module_helper.
Definition at line 127 of file module.h.
Definition at line 334 of file module.h.
Enumerator | |
---|---|
AST_MODULE_LOAD_SUCCESS |
Module is loaded and configured. |
AST_MODULE_LOAD_DECLINE |
Module has failed to load, may be in an inconsistent state. This value is used when a module fails to start but does not risk system-wide stability. Declined modules will prevent any other dependent module from starting. |
AST_MODULE_LOAD_FAILURE |
Module could not be loaded properly. This return should only be returned by modules for unrecoverable failures that cause the whole system to become unstable. In almost all cases AST_MODULE_LOAD_DECLINE should be used instead.
|
Definition at line 68 of file module.h.
Possible return types for ast_module_reload.
Definition at line 109 of file module.h.
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 1978 of file loader.c.
References ast_debug, AST_DLLIST_LOCK, AST_DLLIST_UNLOCK, ast_test_suite_event_notify, ast_unload_resource(), ast_module::declined, and load_resource().
Referenced by ast_ari_asterisk_load_module(), ast_refresh_resource(), and auto_unload_resource().
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 2836 of file loader.c.
References AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_UNLOCK, and ast_malloc.
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 2851 of file loader.c.
References AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, and AST_LIST_UNLOCK.
int ast_module_check | ( | const char * | name | ) |
Check if module with the name given is loaded.
name | Module name, like "chan_pjsip.so" |
1 | if true |
0 | if false |
Check if module with the name given is loaded.
Definition at line 2823 of file loader.c.
Referenced by ast_ari_asterisk_get_module(), ast_ari_asterisk_load_module(), ast_ari_asterisk_reload_module(), ast_ari_asterisk_unload_module(), and manager_modulecheck().
char* ast_module_helper | ( | const char * | line, |
const char * | word, | ||
int | pos, | ||
int | state, | ||
int | rpos, | ||
enum ast_module_helper_type | type | ||
) |
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. |
type | The type of action that will be performed by CLI. |
A | possible completion of the partial match. |
NULL | if no matches were found or Asterisk is not yet fully booted. |
Definition at line 1528 of file loader.c.
References AST_DLLIST_LOCK, AST_DLLIST_TRAVERSE, AST_DLLIST_UNLOCK, AST_MODULE_HELPER_LOAD, AST_OPT_FLAG_FULLY_BOOTED, and ast_strdup.
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 615 of file loader.c.
References ast_module_info::name.
Referenced by ast_register_application2(), and graceful_unload_possible().
enum ast_module_reload_result ast_module_reload | ( | const char * | name | ) |
Reload asterisk modules.
name | the name of the module to reload |
This function reloads the specified module, or if no modules are specified, it will reload all loaded modules.
The | ast_module_reload_result status of the module load request |
Definition at line 1721 of file loader.c.
References AST_DLLIST_LOCK, AST_DLLIST_TRAVERSE, AST_DLLIST_UNLOCK, ast_lock_path(), AST_MODULE_LOAD_SUCCESS, AST_MODULE_RELOAD_ERROR, AST_MODULE_RELOAD_IN_PROGRESS, AST_MODULE_RELOAD_NOT_FOUND, AST_MODULE_RELOAD_NOT_IMPLEMENTED, AST_MODULE_RELOAD_QUEUED, AST_MODULE_RELOAD_SUCCESS, AST_MODULE_RELOAD_UNINITIALIZED, ast_sd_notify(), ast_tvnow(), ast_unlock_path(), ast_module::declined, ast_module_info::description, publish_reload_message(), ast_module_info::reload, and ast_module::running.
Referenced by action_reload(), ast_ari_asterisk_reload_module(), and ast_process_pending_reloads().
int ast_refresh_resource | ( | const char * | resource_name, |
enum ast_module_unload_mode | force, | ||
int | recursive | ||
) |
Unload and load a module again.
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. |
recursive | Attempt to recursively unload any dependents of this module if that will allow the module to unload, and load them back again afterwards. |
0 | on success. |
1 | on error unloading modules. |
-1 | on error loading modules back. |
Definition at line 1407 of file loader.c.
References ast_load_resource(), ast_unload_resource(), AST_VECTOR_FREE, AST_VECTOR_GET, AST_VECTOR_INIT, AST_VECTOR_SIZE, and auto_unload_resource().
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 103 of file pbx_app.c.
References ast_app::arguments, ast_calloc, ast_module_name(), AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, AST_STATIC_DOC, ast_string_field_init, ast_string_field_set, AST_XML_DOC, ast_xmldoc_build_arguments(), ast_xmldoc_build_description(), ast_xmldoc_build_seealso(), ast_xmldoc_build_synopsis(), ast_xmldoc_build_syntax(), COLORIZE_FMT, ast_app::docsrc, ast_app::seealso, and ast_app::syntax.
Referenced by ast_msg_init(), load_pbx_builtins(), and load_pbx_variables().
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 1448 of file loader.c.
References auto_unload_resource().
Referenced by ast_ari_asterisk_unload_module(), ast_load_resource(), ast_refresh_resource(), and auto_unload_resource().
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 392 of file pbx_app.c.
References ast_rdlock_contexts(), AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_string_field_free_memory, ast_unlock_contexts(), and unreference_cached_app().
Referenced by load_module(), unload_module(), and unload_parking_applications().
int ast_update_module_list | ( | int(*)(const char *module, const char *description, int usecnt, const char *status, const char *like, enum ast_module_support_level support_level) | modentry, |
const char * | like | ||
) |
Ask for a list of modules, descriptions, use counts and status.
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. |
int ast_update_module_list_condition | ( | int(*)(const char *module, const char *description, int usecnt, const char *status, const char *like, enum ast_module_support_level support_level, void *data, const char *condition) | modentry, |
const char * | like, | ||
void * | data, | ||
const char * | condition | ||
) |
Ask for a list of modules, descriptions, use counts and status.
modentry | A callback to an updater function |
like | |
data | Data passed into the callback for manipulation |
condition | The condition to meet |
For each of the modules loaded, modentry will be executed with the resource, description, and usecount values of each particular module.
Referenced by ast_ari_asterisk_get_module().
int ast_update_module_list_data | ( | int(*)(const char *module, const char *description, int usecnt, const char *status, const char *like, enum ast_module_support_level support_level, void *data) | modentry, |
const char * | like, | ||
void * | data | ||
) |
Ask for a list of modules, descriptions, use counts and status.
modentry | A callback to an updater function |
like | |
data | Data passed into the callback for manipulation |
For each of the modules loaded, modentry will be executed with the resource, description, and usecount values of each particular module.
Definition at line 2764 of file loader.c.
References AST_DLLIST_LOCK, AST_DLLIST_UNLOCK, AST_VECTOR_FREE, AST_VECTOR_GET, AST_VECTOR_SIZE, ast_module_info::description, ast_module::running, ast_module_info::support_level, and ast_module::usecount.
Referenced by ast_ari_asterisk_list_modules().
void ast_update_use_count | ( | void | ) |
Notify when usecount has been changed.
This function calculates use counts and notifies anyone trying to keep track of them. It should be called whenever your module's usecount changes.
Definition at line 2698 of file loader.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, and AST_LIST_UNLOCK.
Referenced by auto_unload_resource(), and unistim_new().