Asterisk - The Open Source Telephony Project GIT-master-2070bb5
|
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 void | startup_event_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message) |
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 = AST_BUILDOPT_SUM, .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 stasis_subscription * | fully_booted_subscription |
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 1621 of file pbx_config.c.
#define AMI_EXTENSION_REMOVE "DialplanExtensionRemove" |
Definition at line 1622 of file pbx_config.c.
#define PUT_CTX_HDR |
|
static |
Definition at line 2183 of file pbx_config.c.
|
static |
Definition at line 2183 of file pbx_config.c.
|
static |
Definition at line 1969 of file pbx_config.c.
References len().
Referenced by pbx_load_users().
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 2183 of file pbx_config.c.
|
static |
dialplan add extension 6123,1,Dial,IAX/212.71.138.13/6123 into local
Definition at line 1308 of file pbx_config.c.
References a, ast_get_context_name(), ast_log, ast_rdlock_contexts(), ast_strdup, ast_unlock_contexts(), ast_walk_contexts(), c, len(), LOG_WARNING, NULL, and partial_match().
Referenced by handle_cli_dialplan_add_extension().
|
static |
Definition at line 1394 of file pbx_config.c.
References a, ast_free, ast_get_context_name(), ast_log, ast_rdlock_contexts(), ast_strdup, ast_unlock_contexts(), ast_walk_contexts(), c, len(), LOG_ERROR, lookup_c_ip(), NULL, partial_match(), skip_words(), and strsep().
Referenced by handle_cli_dialplan_add_ignorepat().
|
static |
Definition at line 746 of file pbx_config.c.
References a, ast_free, ast_get_context_name(), ast_log, ast_rdlock_contexts(), ast_strdup, ast_unlock_contexts(), ast_walk_contexts(), c, voicemailpwcheck::context, len(), LOG_ERROR, lookup_ci(), NULL, partial_match(), skip_words(), and strsep().
Referenced by handle_cli_dialplan_add_include().
|
static |
Definition at line 1279 of file pbx_config.c.
References a, ast_get_context_name(), ast_log, ast_rdlock_contexts(), ast_strdup, ast_unlock_contexts(), ast_walk_contexts(), c, len(), LOG_WARNING, NULL, and partial_match().
Referenced by handle_cli_dialplan_remove_context().
|
static |
Definition at line 552 of file pbx_config.c.
References a, 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, voicemailpwcheck::context, ast_exten::exten, len(), LOG_ERROR, NULL, partial_match(), priority, skip_words(), and split_ec().
Referenced by handle_cli_dialplan_remove_extension().
|
static |
Definition at line 1490 of file pbx_config.c.
References a, 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(), LOG_WARNING, lookup_c_ip(), NULL, partial_match(), and strsep().
Referenced by handle_cli_dialplan_remove_ignorepat().
|
static |
Definition at line 291 of file pbx_config.c.
References a, 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, voicemailpwcheck::context, len(), LOG_ERROR, LOG_WARNING, lookup_ci(), NULL, partial_match(), skip_words(), and strsep().
Referenced by handle_cli_dialplan_remove_include().
|
static |
ADD EXTENSION command stuff.
Definition at line 1065 of file pbx_config.c.
References a, app, 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, NULL, PRIORITY_HINT, registrar, strsep(), and ast_cli_entry::usage.
|
static |
IGNOREPAT CLI stuff
Definition at line 1340 of file pbx_config.c.
References a, 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, NULL, registrar, and ast_cli_entry::usage.
|
static |
Include context ...
Definition at line 676 of file pbx_config.c.
References a, 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, NULL, registrar, and ast_cli_entry::usage.
|
static |
Definition at line 1578 of file pbx_config.c.
References a, ast_cli(), clearglobalvars_config, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, NULL, pbx_builtin_clear_globals(), pbx_load_module(), and ast_cli_entry::usage.
|
static |
Definition at line 134 of file pbx_config.c.
References a, ast_cli(), ast_context_destroy_by_name(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_dialplan_remove_context(), NULL, and ast_cli_entry::usage.
|
static |
REMOVE EXTENSION command stuff
Definition at line 417 of file pbx_config.c.
References a, 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(), voicemailpwcheck::context, NULL, PRIORITY_HINT, registrar, split_ec(), and ast_cli_entry::usage.
|
static |
Definition at line 1441 of file pbx_config.c.
References a, 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, NULL, registrar, and ast_cli_entry::usage.
|
static |
REMOVE INCLUDE command stuff
Definition at line 162 of file pbx_config.c.
References a, ast_cli(), ast_context_remove_include(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_dialplan_remove_include(), NULL, registrar, and ast_cli_entry::usage.
|
static |
'save dialplan' CLI command implementation functions ...
Definition at line 811 of file pbx_config.c.
References a, 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_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 2145 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, cli_dialplan_save, cli_pbx_config, EVENT_FLAG_SYSTEM, manager_dialplan_extension_add(), manager_dialplan_extension_remove(), pbx_load_module(), static_config, unload_module(), and write_protect_config.
|
static |
return true if 'name' is in the ignorepats for context c
Definition at line 214 of file pbx_config.c.
References ast_context_ignorepats_count(), ast_context_ignorepats_get(), ast_get_ignorepat_name(), ast_rdlock_context(), ast_unlock_context(), c, and name.
Referenced by complete_dialplan_add_ignorepat(), and complete_dialplan_remove_ignorepat().
|
static |
return true if 'name' is included by context c
Definition at line 190 of file pbx_config.c.
References ast_context_includes_count(), ast_context_includes_get(), ast_get_include_name(), ast_rdlock_context(), ast_unlock_context(), c, and name.
Referenced by complete_dialplan_add_include(), and complete_dialplan_remove_include().
|
static |
Definition at line 1197 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(), voicemailpwcheck::context, errno, NULL, priority, PRIORITY_HINT, registrar, replace(), and strsep().
Referenced by load_module().
|
static |
Definition at line 504 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(), voicemailpwcheck::context, 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 253 of file pbx_config.c.
References len().
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 1678 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, local_contexts, local_table, 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 2106 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, local_contexts, local_table, NULL, overrideswitch_config, pbx_load_config(), pbx_load_users(), pbx_set_autofallthrough(), pbx_set_extenpatternmatchnew(), pbx_set_overrideswitch(), registrar, and reload_lock.
Referenced by handle_cli_dialplan_reload(), load_module(), and reload().
|
static |
Definition at line 2002 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_manager_get_topic(), ast_strdup, ast_strlen_zero(), ast_true(), ast_variable_retrieve(), c, ext, fully_booted_subscription, local_contexts, local_table, LOG_ERROR, NULL, registrar, startup_event_cb(), stasis_subscribe_pool, strsep(), tmp(), and userscontext.
Referenced by pbx_load_module().
|
static |
Definition at line 1648 of file pbx_config.c.
References NULL.
Referenced by pbx_load_config().
|
static |
Definition at line 2171 of file pbx_config.c.
References clearglobalvars_config, pbx_builtin_clear_globals(), and pbx_load_module().
|
static |
moves to the n-th word in the string, or empty string if none
Definition at line 238 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 261 of file pbx_config.c.
References ast_free, ast_strdup, c, ext, and NULL.
Referenced by complete_dialplan_remove_extension(), and handle_cli_dialplan_remove_extension().
|
static |
Definition at line 1981 of file pbx_config.c.
References ast_json_object_get(), ast_json_string_get(), ast_log, ast_manager_get_generic_type(), fully_booted_subscription, ast_json_payload::json, LOG_WARNING, stasis_message_data(), stasis_message_type(), stasis_unsubscribe(), and type.
Referenced by pbx_load_users().
|
static |
Standard module functions ...
Definition at line 1627 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(), cli_dialplan_save, cli_pbx_config, fully_booted_subscription, NULL, overrideswitch_config, registrar, and stasis_unsubscribe_and_join().
Referenced by load_module().
|
static |
Definition at line 2183 of file pbx_config.c.
|
static |
Definition at line 2183 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 1618 of file pbx_config.c.
Referenced by load_module(), and unload_module().
|
static |
CLI entries for commands provided by this module
Definition at line 1607 of file pbx_config.c.
Referenced by load_module(), and unload_module().
|
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 107 of file pbx_config.c.
Referenced by pbx_load_users(), startup_event_cb(), and unload_module().
|
static |
Definition at line 113 of file pbx_config.c.
Referenced by ast_compile_ael2(), ast_context_find_or_create(), pbx_load_config(), pbx_load_module(), and pbx_load_users().
|
static |
Definition at line 114 of file pbx_config.c.
Referenced by ast_compile_ael2(), pbx_load_config(), pbx_load_module(), and pbx_load_users().
|
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 111 of file pbx_config.c.
Referenced by pbx_load_module().
|
static |
Definition at line 109 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().