Asterisk - The Open Source Telephony Project
18.5.0
|
Populate and remember extensions from static config file. More...
#include "asterisk.h"
#include <ctype.h>
#include "asterisk/paths.h"
#include "asterisk/pbx.h"
#include "asterisk/config.h"
#include "asterisk/module.h"
#include "asterisk/logger.h"
#include "asterisk/cli.h"
#include "asterisk/channel.h"
#include "asterisk/callerid.h"
Go to the source code of this file.
Macros | |
#define | AMI_EXTENSION_ADD "DialplanExtensionAdd" |
#define | AMI_EXTENSION_REMOVE "DialplanExtensionRemove" |
#define | PUT_CTX_HDR |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static void | append_interface (char *iface, int maxlen, char *add) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
static char * | complete_dialplan_add_extension (struct ast_cli_args *) |
static char * | complete_dialplan_add_ignorepat (struct ast_cli_args *) |
static char * | complete_dialplan_add_include (struct ast_cli_args *) |
static char * | complete_dialplan_remove_context (struct ast_cli_args *) |
static char * | complete_dialplan_remove_extension (struct ast_cli_args *) |
static char * | complete_dialplan_remove_ignorepat (struct ast_cli_args *) |
static char * | complete_dialplan_remove_include (struct ast_cli_args *) |
static char * | handle_cli_dialplan_add_extension (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
ADD EXTENSION command stuff. More... | |
static char * | handle_cli_dialplan_add_ignorepat (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_cli_dialplan_add_include (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_cli_dialplan_reload (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_cli_dialplan_remove_context (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_cli_dialplan_remove_extension (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_cli_dialplan_remove_ignorepat (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_cli_dialplan_remove_include (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_cli_dialplan_save (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
'save dialplan' CLI command implementation functions ... More... | |
static int | load_module (void) |
static int | lookup_c_ip (struct ast_context *c, const char *name) |
return true if 'name' is in the ignorepats for context c More... | |
static int | lookup_ci (struct ast_context *c, const char *name) |
return true if 'name' is included by context c More... | |
static int | manager_dialplan_extension_add (struct mansession *s, const struct message *m) |
static int | manager_dialplan_extension_remove (struct mansession *s, const struct message *m) |
static int | partial_match (const char *s, const char *word, int len) |
match the first 'len' chars of word. len==0 always succeeds More... | |
static int | pbx_load_config (const char *config_file) |
static int | pbx_load_module (void) |
static void | pbx_load_users (void) |
static char * | pbx_strsep (char **destructible, const char *delim) |
static int | reload (void) |
static const char * | skip_words (const char *p, int n) |
moves to the n-th word in the string, or empty string if none More... | |
static int | split_ec (const char *src, char **ext, char **const ctx, char **const cid) |
split extension@context in two parts, return -1 on error. The return string is malloc'ed and pointed by *ext More... | |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Text Extension Configuration" , .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" , .buildopt_sum = "30ef0c93b36035ec78c9cfd712d36d9b" , .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .reload = reload, } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static int | autofallthrough_config = 1 |
static int | clearglobalvars_config = 0 |
static struct ast_cli_entry | cli_dialplan_save |
static struct ast_cli_entry | cli_pbx_config [] |
static const char | config [] = "extensions.conf" |
static int | extenpatternmatchnew_config = 0 |
static struct ast_context * | local_contexts = NULL |
static struct ast_hashtab * | local_table = NULL |
static char * | overrideswitch_config = NULL |
static const char | registrar [] = "pbx_config" |
static ast_mutex_t | reload_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } |
static ast_mutex_t | save_dialplan_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } |
static int | static_config = 0 |
static char | userscontext [AST_MAX_EXTENSION] = "default" |
static int | write_protect_config = 1 |
Populate and remember extensions from static config file.
Definition in file pbx_config.c.
#define AMI_EXTENSION_ADD "DialplanExtensionAdd" |
Definition at line 1619 of file pbx_config.c.
Referenced by load_module(), and unload_module().
#define AMI_EXTENSION_REMOVE "DialplanExtensionRemove" |
Definition at line 1620 of file pbx_config.c.
Referenced by load_module(), and unload_module().
#define PUT_CTX_HDR |
Referenced by handle_cli_dialplan_save().
|
static |
Definition at line 2164 of file pbx_config.c.
|
static |
Definition at line 2164 of file pbx_config.c.
|
static |
Definition at line 1965 of file pbx_config.c.
References len().
Referenced by pbx_load_users().
struct ast_module* AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 2164 of file pbx_config.c.
|
static |
dialplan add extension 6123,1,Dial,IAX/212.71.138.13/6123 into local
Definition at line 1306 of file pbx_config.c.
References ast_get_context_name(), ast_log, ast_rdlock_contexts(), ast_strdup, ast_unlock_contexts(), ast_walk_contexts(), c, len(), LOG_WARNING, ast_cli_args::n, NULL, partial_match(), ast_cli_args::pos, and ast_cli_args::word.
Referenced by handle_cli_dialplan_add_extension().
|
static |
Definition at line 1392 of file pbx_config.c.
References ast_free, ast_get_context_name(), ast_log, ast_rdlock_contexts(), ast_strdup, ast_unlock_contexts(), ast_walk_contexts(), c, len(), ast_cli_args::line, LOG_ERROR, lookup_c_ip(), ast_cli_args::n, NULL, partial_match(), ast_cli_args::pos, skip_words(), strsep(), and ast_cli_args::word.
Referenced by handle_cli_dialplan_add_ignorepat().
|
static |
Definition at line 744 of file pbx_config.c.
References ast_free, ast_get_context_name(), ast_log, ast_rdlock_contexts(), ast_strdup, ast_unlock_contexts(), ast_walk_contexts(), c, context, len(), ast_cli_args::line, LOG_ERROR, lookup_ci(), ast_cli_args::n, NULL, partial_match(), ast_cli_args::pos, skip_words(), strsep(), and ast_cli_args::word.
Referenced by handle_cli_dialplan_add_include().
|
static |
Definition at line 1277 of file pbx_config.c.
References ast_get_context_name(), ast_log, ast_rdlock_contexts(), ast_strdup, ast_unlock_contexts(), ast_walk_contexts(), c, len(), LOG_WARNING, ast_cli_args::n, NULL, partial_match(), ast_cli_args::pos, and ast_cli_args::word.
Referenced by handle_cli_dialplan_remove_context().
|
static |
Definition at line 550 of file pbx_config.c.
References ast_asprintf, ast_free, ast_get_context_name(), ast_get_extension_cidmatch(), ast_get_extension_matchcid(), ast_get_extension_name(), ast_get_extension_priority(), ast_log, ast_rdlock_contexts(), ast_strdup, ast_unlock_contexts(), ast_walk_context_extensions(), ast_walk_contexts(), ast_walk_extension_priorities(), c, context, exten, len(), ast_cli_args::line, LOG_ERROR, ast_cli_args::n, NULL, partial_match(), ast_cli_args::pos, priority, skip_words(), split_ec(), and ast_cli_args::word.
Referenced by handle_cli_dialplan_remove_extension().
|
static |
Definition at line 1488 of file pbx_config.c.
References ast_context_ignorepats_count(), ast_context_ignorepats_get(), ast_free, ast_get_context_name(), ast_get_ignorepat_name(), ast_log, ast_rdlock_context(), ast_rdlock_contexts(), ast_strdup, ast_unlock_context(), ast_unlock_contexts(), ast_walk_contexts(), c, len(), ast_cli_args::line, LOG_WARNING, lookup_c_ip(), ast_cli_args::n, NULL, partial_match(), pbx_load_module(), ast_cli_args::pos, strsep(), and ast_cli_args::word.
Referenced by handle_cli_dialplan_remove_ignorepat().
|
static |
Definition at line 289 of file pbx_config.c.
References ast_context_includes_count(), ast_context_includes_get(), ast_free, ast_get_context_name(), ast_get_include_name(), ast_log, ast_rdlock_context(), ast_rdlock_contexts(), ast_strdup, ast_unlock_context(), ast_unlock_contexts(), ast_walk_contexts(), ast_wrlock_contexts(), c, context, len(), ast_cli_args::line, LOG_ERROR, LOG_WARNING, lookup_ci(), ast_cli_args::n, NULL, partial_match(), ast_cli_args::pos, skip_words(), strsep(), and ast_cli_args::word.
Referenced by handle_cli_dialplan_remove_include().
|
static |
ADD EXTENSION command stuff.
Definition at line 1063 of file pbx_config.c.
References app, ast_cli_args::argc, ast_cli_args::argv, ast_add_extension(), ast_cli(), ast_context_find(), ast_context_find_or_create(), ast_free_ptr(), ast_strdup, ast_strdupa, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_dialplan_add_extension(), end, errno, exten, ast_cli_args::fd, NULL, PRIORITY_HINT, registrar, strsep(), and ast_cli_entry::usage.
|
static |
IGNOREPAT CLI stuff
Definition at line 1338 of file pbx_config.c.
References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_context_add_ignorepat(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_dialplan_add_ignorepat(), errno, ast_cli_args::fd, NULL, registrar, and ast_cli_entry::usage.
|
static |
Include context ...
Definition at line 674 of file pbx_config.c.
References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_context_add_include(), ast_context_find(), ast_context_find_or_create(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_dialplan_add_include(), errno, ast_cli_args::fd, NULL, registrar, and ast_cli_entry::usage.
|
static |
Definition at line 1576 of file pbx_config.c.
References ast_cli_args::argc, ast_cli(), clearglobalvars_config, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, NULL, pbx_builtin_clear_globals(), pbx_load_module(), and ast_cli_entry::usage.
|
static |
Definition at line 132 of file pbx_config.c.
References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_context_destroy_by_name(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_dialplan_remove_context(), ast_cli_args::fd, NULL, and ast_cli_entry::usage.
|
static |
REMOVE EXTENSION command stuff
Definition at line 415 of file pbx_config.c.
References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_context_remove_extension_callerid(), ast_free, c, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_dialplan_remove_extension(), context, exten, ast_cli_args::fd, NULL, PRIORITY_HINT, registrar, split_ec(), and ast_cli_entry::usage.
|
static |
Definition at line 1439 of file pbx_config.c.
References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_context_remove_ignorepat(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_dialplan_remove_ignorepat(), errno, ast_cli_args::fd, NULL, registrar, and ast_cli_entry::usage.
|
static |
REMOVE INCLUDE command stuff
Definition at line 160 of file pbx_config.c.
References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_context_remove_include(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_dialplan_remove_include(), ast_cli_args::fd, NULL, registrar, and ast_cli_entry::usage.
|
static |
'save dialplan' CLI command implementation functions ...
Definition at line 809 of file pbx_config.c.
References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_config_AST_CONFIG_DIR, ast_config_destroy(), ast_config_load, ast_context_ignorepats_count(), ast_context_ignorepats_get(), ast_context_includes_count(), ast_context_includes_get(), ast_context_switches_count(), ast_context_switches_get(), ast_escape_semicolons(), ast_get_context_name(), ast_get_context_registrar(), ast_get_extension_app(), ast_get_extension_app_data(), ast_get_extension_cidmatch(), ast_get_extension_label(), ast_get_extension_matchcid(), ast_get_extension_name(), ast_get_extension_priority(), ast_get_extension_registrar(), ast_get_ignorepat_name(), ast_get_ignorepat_registrar(), ast_get_include_name(), ast_get_include_registrar(), ast_get_switch_data(), ast_get_switch_name(), ast_get_switch_registrar(), ast_mutex_lock, ast_mutex_unlock, ast_rdlock_context(), ast_rdlock_contexts(), ast_strlen_zero, ast_unlock_context(), ast_unlock_contexts(), ast_variable_browse(), ast_walk_context_extensions(), ast_walk_contexts(), ast_walk_extension_priorities(), autofallthrough_config, c, clearglobalvars_config, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, config, el, ext, extenpatternmatchnew_config, ast_cli_args::fd, ast_exten::label, ast_variable::name, ast_variable::next, NULL, overrideswitch, overrideswitch_config, PRIORITY_HINT, PUT_CTX_HDR, registrar, save_dialplan_lock, static_config, ast_cli_entry::usage, ast_variable::value, and write_protect_config.
|
static |
Definition at line 2126 of file pbx_config.c.
References AMI_EXTENSION_ADD, AMI_EXTENSION_REMOVE, ARRAY_LEN, ast_cli_register, ast_cli_register_multiple, ast_manager_register_xml, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, EVENT_FLAG_SYSTEM, manager_dialplan_extension_add(), manager_dialplan_extension_remove(), pbx_load_module(), static_config, unload_module(), and write_protect_config.
Referenced by reload().
|
static |
return true if 'name' is in the ignorepats for context c
Definition at line 212 of file pbx_config.c.
References ast_context_ignorepats_count(), ast_context_ignorepats_get(), ast_get_ignorepat_name(), ast_rdlock_context(), and ast_unlock_context().
Referenced by complete_dialplan_add_ignorepat(), and complete_dialplan_remove_ignorepat().
|
static |
return true if 'name' is included by context c
Definition at line 188 of file pbx_config.c.
References ast_context_includes_count(), ast_context_includes_get(), ast_get_include_name(), ast_rdlock_context(), and ast_unlock_context().
Referenced by complete_dialplan_add_include(), and complete_dialplan_remove_include().
|
static |
Definition at line 1195 of file pbx_config.c.
References ast_add_extension2(), ast_context_find_or_create(), ast_free_ptr(), ast_strdup, ast_strdupa, ast_strlen_zero, ast_true(), ast_unlock_contexts(), ast_wrlock_contexts(), astman_get_header(), astman_send_ack(), astman_send_error(), context, errno, exten, NULL, priority, PRIORITY_HINT, registrar, replace(), and strsep().
Referenced by load_module().
|
static |
Definition at line 502 of file pbx_config.c.
References ast_context_remove_extension_callerid(), ast_strdupa, ast_strlen_zero, astman_get_header(), astman_send_ack(), astman_send_error(), context, exten, NULL, priority, PRIORITY_HINT, registrar, and strsep().
Referenced by load_module().
|
static |
match the first 'len' chars of word. len==0 always succeeds
Definition at line 251 of file pbx_config.c.
Referenced by complete_dialplan_add_extension(), complete_dialplan_add_ignorepat(), complete_dialplan_add_include(), complete_dialplan_remove_context(), complete_dialplan_remove_extension(), complete_dialplan_remove_ignorepat(), and complete_dialplan_remove_include().
|
static |
Definition at line 1674 of file pbx_config.c.
References ast_add_extension2(), ast_category_browse(), ast_config_destroy(), ast_config_load, ast_context_add_ignorepat2(), ast_context_add_include2(), ast_context_add_switch2(), ast_context_find_or_create(), ast_context_set_autohints(), ast_copy_string(), ast_findlabel_extension2(), ast_free, ast_free_ptr(), ast_log, ast_opt_dont_warn, ast_shrink_phone_number(), ast_skip_blanks(), ast_strdup, ast_strip(), ast_strlen_zero, ast_true(), ast_variable_browse(), ast_variable_retrieve(), autofallthrough_config, clearglobalvars_config, config_file, CONFIG_STATUS_FILEINVALID, end, errno, ext, extenpatternmatchnew_config, ast_variable::file, ast_variable::lineno, LOG_ERROR, LOG_WARNING, ast_variable::name, ast_variable::next, NULL, overrideswitch_config, pbx_builtin_setvar_helper(), pbx_strsep(), pbx_substitute_variables_helper(), PRIORITY_HINT, registrar, S_OR, static_config, strsep(), userscontext, ast_variable::value, and write_protect_config.
Referenced by pbx_load_module().
|
static |
Definition at line 2087 of file pbx_config.c.
References ast_context_verify_includes(), ast_hashtab_compare_contexts(), ast_hashtab_create, ast_hashtab_destroy(), ast_hashtab_hash_contexts(), ast_hashtab_newsize_java(), ast_hashtab_resize_java(), ast_merge_contexts_and_delete(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_mutex_lock, ast_mutex_unlock, ast_walk_contexts(), autofallthrough_config, config, extenpatternmatchnew_config, NULL, overrideswitch_config, pbx_load_config(), pbx_load_users(), pbx_set_autofallthrough(), pbx_set_extenpatternmatchnew(), pbx_set_overrideswitch(), registrar, and reload_lock.
Referenced by complete_dialplan_remove_ignorepat(), handle_cli_dialplan_reload(), load_module(), and reload().
|
static |
Definition at line 1977 of file pbx_config.c.
References append_interface(), ast_add_extension2(), ast_category_browse(), ast_config_destroy(), ast_config_load, ast_config_option(), ast_context_find_or_create(), ast_copy_string(), ast_free_ptr(), ast_log, ast_opt_stdexten_macro, ast_strdup, ast_strlen_zero, ast_true(), ast_variable_retrieve(), c, ext, LOG_ERROR, NULL, registrar, strsep(), tmp(), and userscontext.
Referenced by pbx_load_module().
|
static |
Definition at line 1644 of file pbx_config.c.
References NULL.
Referenced by pbx_load_config().
|
static |
Definition at line 2152 of file pbx_config.c.
References AST_MODFLAG_DEFAULT, AST_MODULE_INFO(), AST_MODULE_SUPPORT_CORE, ASTERISK_GPL_KEY, clearglobalvars_config, load_module(), pbx_builtin_clear_globals(), pbx_load_module(), and unload_module().
|
static |
moves to the n-th word in the string, or empty string if none
Definition at line 236 of file pbx_config.c.
Referenced by complete_dialplan_add_ignorepat(), complete_dialplan_add_include(), complete_dialplan_remove_extension(), and complete_dialplan_remove_include().
|
static |
split extension@context in two parts, return -1 on error. The return string is malloc'ed and pointed by *ext
Definition at line 259 of file pbx_config.c.
References ast_free, ast_strdup, c, and NULL.
Referenced by complete_dialplan_remove_extension(), and handle_cli_dialplan_remove_extension().
|
static |
Standard module functions ...
Definition at line 1625 of file pbx_config.c.
References AMI_EXTENSION_ADD, AMI_EXTENSION_REMOVE, ARRAY_LEN, ast_cli_unregister(), ast_cli_unregister_multiple(), ast_context_destroy(), ast_free, ast_manager_unregister(), NULL, overrideswitch_config, and registrar.
Referenced by load_module(), and reload().
|
static |
Definition at line 2164 of file pbx_config.c.
|
static |
Definition at line 2164 of file pbx_config.c.
|
static |
Definition at line 102 of file pbx_config.c.
Referenced by handle_cli_dialplan_save(), pbx_load_config(), and pbx_load_module().
|
static |
Definition at line 103 of file pbx_config.c.
Referenced by handle_cli_dialplan_reload(), handle_cli_dialplan_save(), pbx_load_config(), and reload().
|
static |
Definition at line 1616 of file pbx_config.c.
|
static |
CLI entries for commands provided by this module
Definition at line 1605 of file pbx_config.c.
|
static |
Definition at line 96 of file pbx_config.c.
Referenced by handle_cli_dialplan_save(), and pbx_load_module().
|
static |
Definition at line 104 of file pbx_config.c.
Referenced by handle_cli_dialplan_save(), pbx_load_config(), and pbx_load_module().
|
static |
Definition at line 111 of file pbx_config.c.
|
static |
Definition at line 112 of file pbx_config.c.
Referenced by pbx_load_module().
|
static |
Definition at line 105 of file pbx_config.c.
Referenced by handle_cli_dialplan_save(), pbx_load_config(), pbx_load_module(), and unload_module().
|
static |
Definition at line 97 of file pbx_config.c.
Referenced by handle_cli_dialplan_add_extension(), handle_cli_dialplan_add_ignorepat(), handle_cli_dialplan_add_include(), handle_cli_dialplan_remove_extension(), handle_cli_dialplan_remove_ignorepat(), handle_cli_dialplan_remove_include(), handle_cli_dialplan_save(), manager_dialplan_extension_add(), manager_dialplan_extension_remove(), pbx_load_config(), pbx_load_module(), pbx_load_users(), and unload_module().
|
static |
Definition at line 109 of file pbx_config.c.
Referenced by pbx_load_module().
|
static |
Definition at line 107 of file pbx_config.c.
Referenced by handle_cli_dialplan_save().
|
static |
Definition at line 100 of file pbx_config.c.
Referenced by handle_cli_dialplan_save(), load_module(), and pbx_load_config().
|
static |
Definition at line 98 of file pbx_config.c.
Referenced by pbx_load_config(), and pbx_load_users().
|
static |
Definition at line 101 of file pbx_config.c.
Referenced by handle_cli_dialplan_save(), load_module(), and pbx_load_config().