|
Asterisk - The Open Source Telephony Project GIT-master-80b953f
|
PJSIP Configuration Wizard. More...
#include "asterisk.h"#include <regex.h>#include <pjsip.h>#include "asterisk/astobj2.h"#include "asterisk/cli.h"#include "asterisk/res_pjsip.h"#include "asterisk/module.h"#include "asterisk/pbx.h"#include "asterisk/sorcery.h"#include "asterisk/vector.h"#include "asterisk/stasis.h"#include "asterisk/acl.h"#include "asterisk/security_events.h"
Go to the source code of this file.
Data Structures | |
| struct | object_type_wizard |
| Keeps track of the sorcery wizard and last config for each object type. More... | |
| struct | string_vector |
| A generic char * vector definition. More... | |
Macros | |
| #define | BASE_REGISTRAR "res_pjsip_config_wizard" |
| #define | MAX_ID_SUFFIX 20 |
| Defines the maximum number of characters that can be added to a wizard id. | |
| #define | NOT_EQUALS(a, b) (a != b) |
| #define | OTW_DELETE_CB(otw) |
| #define | variable_list_append_return(existing, name, value) |
| Appends a variable to the end of an existing list. On failure, cause the calling function to return -1. | |
Functions | |
| static void | __reg_module (void) |
| static void | __unreg_module (void) |
| static void | acl_change_stasis_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message) |
| Callback for Named ACL changed. | |
| static int | add_extension (struct ast_context *context, const char *exten, int priority, const char *application) |
| static int | add_hints (const char *context, const char *exten, const char *application, const char *id) |
| struct ast_module * | AST_MODULE_SELF_SYM (void) |
| static | AST_VECTOR_RW (object_type_wizards, struct object_type_wizard *) |
| static void * | create_object (const struct ast_sorcery *sorcery, const char *id, const char *type, struct ast_variable *vars) |
| Creates a sorcery object and applies a variable list. | |
| static int | delete_existing_cb (void *obj, void *arg, int flags) |
| static int | delete_extens (const char *context, const char *exten) |
| static struct object_type_wizard * | find_wizard (const char *object_type) |
| Finds the otw for the object type. | |
| static struct ast_variable * | get_object_variables (struct ast_variable *vars, char *prefix) |
| We need to strip off the prefix from the name of each variable so they're suitable for objectset_apply. I.E. will transform outbound_auth/username to username. | |
| static int | handle_aor (const struct ast_sorcery *sorcery, struct object_type_wizard *otw, struct ast_category *wiz, struct string_vector *remote_hosts_vector) |
| static int | handle_auth (const struct ast_sorcery *sorcery, struct object_type_wizard *otw, struct ast_category *wiz, char *direction) |
| static int | handle_auths (const struct ast_sorcery *sorcery, struct object_type_wizard *otw, struct ast_category *wiz) |
| static int | handle_endpoint (const struct ast_sorcery *sorcery, struct object_type_wizard *otw, struct ast_category *wiz) |
| static char * | handle_export_primitives (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static int | handle_identify (const struct ast_sorcery *sorcery, struct object_type_wizard *otw, struct ast_category *wiz, struct string_vector *remote_hosts_vector) |
| static int | handle_phoneprov (const struct ast_sorcery *sorcery, struct object_type_wizard *otw, struct ast_category *wiz) |
| static int | handle_registrations (const struct ast_sorcery *sorcery, struct object_type_wizard *otw, struct ast_category *wiz, struct string_vector *remote_hosts_vector) |
| static void | instance_created_observer (const char *name, struct ast_sorcery *sorcery) |
| When the res_pjsip instance is created, add an observer to it and initialize the wizard vector. Also, bump the module's ref count so it can't be unloaded before the sorcery instance is destroyed. | |
| static void | instance_destroying_observer (const char *name, struct ast_sorcery *sorcery) |
| When the res_pjsip instance is destroyed, remove the observer and unref the module. This should then allow this module to unload cleanly. | |
| static int | is_one_of (const char *needle, const char *haystack[]) |
| static int | is_variable_true (struct ast_variable *vars, const char *name) |
| Finds the last variable in a list and tests it. | |
| static int | load_module (void) |
| static void | object_type_loaded_observer (const char *name, const struct ast_sorcery *sorcery, const char *object_type, int reloaded) |
| Called after an object type is loaded/reloaded. | |
| static void | object_type_registered_observer (const char *name, struct ast_sorcery *sorcery, const char *object_type) |
| When each object type is registered, map a memory wizard to it. | |
| static int | reload_module (void) |
| static int | unload_module (void) |
| static int | variable_list_append (struct ast_variable **existing, const char *name, const char *value) |
| Appends a variable to the end of an existing list. | |
| static int | wizard_apply_handler (const struct ast_sorcery *sorcery, struct object_type_wizard *otw, struct ast_category *wiz) |
Variables | |
| static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "PJSIP Config Wizard" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .reload = reload_module, .unload = unload_module, .load_pri = AST_MODPRI_REALTIME_DRIVER, } |
| static int | acl_change_detected = 0 |
| static struct stasis_subscription * | acl_change_sub |
| static const struct ast_module_info * | ast_module_info = &__mod_info |
| static struct ast_cli_entry | config_wizard_cli [] |
| static const struct ast_sorcery_global_observer | global_observer |
| struct ast_sorcery_instance_observer | observer |
PJSIP Configuration Wizard.
Definition in file res_pjsip_config_wizard.c.
| #define BASE_REGISTRAR "res_pjsip_config_wizard" |
Definition at line 279 of file res_pjsip_config_wizard.c.
| #define MAX_ID_SUFFIX 20 |
Defines the maximum number of characters that can be added to a wizard id.
Definition at line 277 of file res_pjsip_config_wizard.c.
| #define OTW_DELETE_CB | ( | otw | ) |
Appends a variable to the end of an existing list. On failure, cause the calling function to return -1.
Definition at line 392 of file res_pjsip_config_wizard.c.
|
static |
Definition at line 1399 of file res_pjsip_config_wizard.c.
|
static |
Definition at line 1399 of file res_pjsip_config_wizard.c.
|
static |
Callback for Named ACL changed.
Definition at line 307 of file res_pjsip_config_wizard.c.
References acl_change_detected, ast_debug, ast_named_acl_change_type(), ast_sip_get_sorcery(), and ast_sorcery_reload().
Referenced by load_module().
|
static |
Definition at line 439 of file res_pjsip_config_wizard.c.
References app, ast_add_extension2_nolock(), ast_context_remove_extension2(), ast_free, ast_free_ptr(), ast_get_context_name(), ast_get_extension_app(), ast_get_extension_app_data(), ast_strdup, ast_strdupa, ast_strlen_zero(), BASE_REGISTRAR, context_name, ast_exten::data, E_MATCH, ast_exten::exten, NULL, paren, pbx_find_extension(), priority, and pbx_find_info::stacklen.
Referenced by add_hints().
|
static |
Definition at line 501 of file res_pjsip_config_wizard.c.
References add_extension(), ast_alloca, ast_assert, ast_context_find_or_create(), ast_context_remove_extension2(), ast_log, ast_strlen_zero(), ast_unlock_context(), ast_unlock_contexts(), ast_wrlock_context(), ast_wrlock_contexts(), BASE_REGISTRAR, LOG_ERROR, NULL, and PRIORITY_HINT.
Referenced by handle_endpoint().
| struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 1399 of file res_pjsip_config_wizard.c.
|
static |
Definition at line 292 of file res_pjsip_config_wizard.c.
References NULL.
|
static |
Creates a sorcery object and applies a variable list.
Definition at line 350 of file res_pjsip_config_wizard.c.
References ao2_ref, ast_log, ast_sorcery_alloc(), ast_sorcery_objectset_apply(), LOG_ERROR, NULL, sorcery, and type.
Referenced by handle_aor(), handle_auth(), handle_endpoint(), handle_identify(), handle_phoneprov(), and handle_registrations().
|
static |
Definition at line 844 of file res_pjsip_config_wizard.c.
References ast_sorcery_object_get_extended(), ast_strlen_zero(), CMP_MATCH, ast_sorcery_wizard::delete, delete_extens(), object_type_wizard::object_type, object_type_wizard::sorcery, object_type_wizard::wizard, and object_type_wizard::wizard_data.
Referenced by handle_registrations(), and object_type_loaded_observer().
|
static |
Definition at line 424 of file res_pjsip_config_wizard.c.
References ast_context_remove_extension(), BASE_REGISTRAR, E_MATCH, NULL, pbx_find_extension(), PRIORITY_HINT, and pbx_find_info::stacklen.
Referenced by delete_existing_cb(), and handle_endpoint().
|
static |
Finds the otw for the object type.
Definition at line 332 of file res_pjsip_config_wizard.c.
References AST_VECTOR_GET, AST_VECTOR_RW_RDLOCK, AST_VECTOR_RW_UNLOCK, AST_VECTOR_SIZE, NULL, and object_type_wizard::object_type.
Referenced by object_type_loaded_observer().
|
static |
We need to strip off the prefix from the name of each variable so they're suitable for objectset_apply. I.E. will transform outbound_auth/username to username.
Definition at line 405 of file res_pjsip_config_wizard.c.
References ast_begins_with(), ast_variables_destroy(), ast_variable::name, ast_variable::next, NULL, prefix, ast_variable::value, and variable_list_append().
Referenced by handle_aor(), handle_auth(), handle_endpoint(), handle_identify(), handle_phoneprov(), and handle_registrations().
|
static |
Definition at line 620 of file res_pjsip_config_wizard.c.
References ao2_ref, ast_category_first(), ast_category_get_name(), ast_free, ast_str_buffer(), ast_str_create, ast_str_substitute_variables_varshead(), ast_strlen_zero(), ast_var_assign, ast_var_list_create(), ast_var_list_destroy(), AST_VAR_LIST_INSERT_TAIL(), ast_variable_find_last_in_list(), ast_variables_destroy(), AST_VECTOR_GET, AST_VECTOR_SIZE, ast_sorcery_wizard::create, create_object(), get_object_variables(), NULL, RAII_VAR, sorcery, ast_sorcery_wizard::update, var, variable_list_append(), variable_list_append_return, object_type_wizard::wizard, and object_type_wizard::wizard_data.
Referenced by wizard_apply_handler().
|
static |
Definition at line 550 of file res_pjsip_config_wizard.c.
References ao2_ref, ast_category_first(), ast_category_get_name(), ast_log, ast_variable_find_last_in_list(), ast_variables_destroy(), ast_sorcery_wizard::create, create_object(), ast_sorcery_wizard::delete, get_object_variables(), is_variable_true(), LOG_ERROR, MAX_ID_SUFFIX, NULL, prefix, RAII_VAR, ast_sorcery_wizard::retrieve_id, sorcery, ast_sorcery_wizard::update, variable_list_append_return, object_type_wizard::wizard, and object_type_wizard::wizard_data.
Referenced by handle_auths().
|
static |
Definition at line 608 of file res_pjsip_config_wizard.c.
References handle_auth(), and sorcery.
Referenced by wizard_apply_handler().
|
static |
Definition at line 678 of file res_pjsip_config_wizard.c.
References add_hints(), ao2_ref, ast_category_first(), ast_category_get_name(), ast_strlen_zero(), ast_variable_find_last_in_list(), ast_variables_destroy(), ast_sorcery_wizard::create, create_object(), delete_extens(), get_object_variables(), is_variable_true(), MAX_ID_SUFFIX, NULL, RAII_VAR, sorcery, ast_sorcery_wizard::update, variable_list_append_return, object_type_wizard::wizard, and object_type_wizard::wizard_data.
Referenced by wizard_apply_handler().
|
static |
Definition at line 1237 of file res_pjsip_config_wizard.c.
References a, ao2_cleanup, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_cli(), ast_copy_string(), ast_log, AST_RETRIEVE_FLAG_MULTIPLE, ast_sip_get_sorcery(), ast_sorcery_object_get_id(), ast_sorcery_objectset_create, ast_sorcery_retrieve_by_fields(), ast_strlen_zero(), ast_variable_find_in_list(), ast_variables_destroy(), AST_VECTOR_GET, AST_VECTOR_RW_RDLOCK, AST_VECTOR_RW_UNLOCK, AST_VECTOR_SIZE, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, container, errno, LOG_ERROR, ast_variable::name, ast_variable::next, NULL, object_type_wizard::object_type, sorcery, ast_cli_entry::usage, and ast_variable::value.
|
static |
Definition at line 748 of file res_pjsip_config_wizard.c.
References ao2_ref, ast_category_first(), ast_category_get_name(), ast_log, ast_variable_find_last_in_list(), ast_variables_destroy(), AST_VECTOR_GET, AST_VECTOR_SIZE, ast_sorcery_wizard::create, create_object(), ast_sorcery_wizard::delete, get_object_variables(), is_variable_true(), LOG_ERROR, MAX_ID_SUFFIX, NULL, RAII_VAR, ast_sorcery_wizard::retrieve_id, sorcery, ast_sorcery_wizard::update, variable_list_append_return, object_type_wizard::wizard, and object_type_wizard::wizard_data.
Referenced by wizard_apply_handler().
|
static |
Definition at line 802 of file res_pjsip_config_wizard.c.
References ao2_ref, ast_category_first(), ast_category_get_name(), ast_log, ast_variable_find_last_in_list(), ast_variables_destroy(), ast_sorcery_wizard::create, create_object(), ast_sorcery_wizard::delete, get_object_variables(), is_variable_true(), LOG_ERROR, MAX_ID_SUFFIX, NULL, RAII_VAR, ast_sorcery_wizard::retrieve_id, sorcery, ast_sorcery_wizard::update, variable_list_append_return, object_type_wizard::wizard, and object_type_wizard::wizard_data.
Referenced by wizard_apply_handler().
|
static |
Definition at line 861 of file res_pjsip_config_wizard.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_callback, ao2_cleanup, ao2_container_alloc_list, ao2_container_count(), ao2_ref, ast_category_first(), ast_category_get_name(), ast_free, ast_log, ast_sorcery_object_id_compare(), ast_str_buffer(), ast_str_create, ast_str_reset(), ast_str_substitute_variables_varshead(), ast_strlen_zero(), ast_var_assign, ast_var_list_create(), ast_var_list_destroy(), AST_VAR_LIST_INSERT_TAIL(), ast_variable_find_last_in_list(), ast_variable_new, ast_variables_destroy(), ast_variables_dup(), AST_VECTOR_GET, AST_VECTOR_SIZE, ast_sorcery_wizard::create, create_object(), delete_existing_cb(), get_object_variables(), id, is_variable_true(), LOG_ERROR, MAX_ID_SUFFIX, NULL, OBJ_MULTIPLE, OBJ_NODATA, OBJ_SEARCH_KEY, OBJ_UNLINK, RAII_VAR, ast_sorcery_wizard::retrieve_multiple, rh, sorcery, ast_sorcery_wizard::update, variable_list_append_return, object_type_wizard::wizard, and object_type_wizard::wizard_data.
Referenced by wizard_apply_handler().
|
static |
When the res_pjsip instance is created, add an observer to it and initialize the wizard vector. Also, bump the module's ref count so it can't be unloaded before the sorcery instance is destroyed.
Definition at line 1215 of file res_pjsip_config_wizard.c.
References ast_module_ref, ast_sorcery_instance_observer_add(), name, observer, ast_module_info::self, and sorcery.
|
static |
When the res_pjsip instance is destroyed, remove the observer and unref the module. This should then allow this module to unload cleanly.
Definition at line 1227 of file res_pjsip_config_wizard.c.
References ast_module_unref, ast_sorcery_instance_observer_remove(), name, observer, ast_module_info::self, and sorcery.
|
static |
Definition at line 319 of file res_pjsip_config_wizard.c.
Referenced by object_type_registered_observer().
|
static |
Finds the last variable in a list and tests it.
Definition at line 370 of file res_pjsip_config_wizard.c.
References ast_true(), ast_variable_find_last_in_list(), and name.
Referenced by handle_auth(), handle_endpoint(), handle_identify(), handle_phoneprov(), and handle_registrations().
|
static |
Definition at line 1340 of file res_pjsip_config_wizard.c.
References acl_change_stasis_cb(), acl_change_sub, ARRAY_LEN, ast_cli_register_multiple, AST_MODULE_LOAD_SUCCESS, ast_module_ref, ast_security_topic(), ast_sip_get_sorcery(), ast_sorcery_get_object_type(), ast_sorcery_global_observer_add(), ast_sorcery_instance_observer_add(), ast_sorcery_reload(), AST_VECTOR_RW_INIT, config_wizard_cli, global_observer, NULL, object_type_registered_observer(), observer, ast_module_info::self, and stasis_subscribe.
|
static |
Called after an object type is loaded/reloaded.
Definition at line 1066 of file res_pjsip_config_wizard.c.
References acl_change_detected, AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_callback, ao2_cleanup, ao2_container_alloc_list, ao2_container_count(), ast_category_browse_filtered(), ast_category_delete(), ast_category_first(), ast_category_get(), ast_category_get_name(), ast_config_destroy(), ast_config_load2(), ast_debug, ast_log, ast_variable_lists_match(), ast_variable_new, ast_variables_destroy(), CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEUNCHANGED, delete_existing_cb(), find_wizard(), ast_flags::flags, id, object_type_wizard::last_config, LOG_ERROR, NULL, OBJ_MULTIPLE, OBJ_NODATA, OBJ_UNLINK, RAII_VAR, ast_sorcery_wizard::retrieve_multiple, sorcery, object_type_wizard::wizard, wizard_apply_handler(), and object_type_wizard::wizard_data.
|
static |
When each object type is registered, map a memory wizard to it.
Definition at line 1175 of file res_pjsip_config_wizard.c.
References ast_debug, ast_free, ast_log, ast_malloc, AST_SORCERY_APPLY_SUCCESS, ast_sorcery_object_type_apply_wizard, AST_SORCERY_WIZARD_APPLY_ALLOW_DUPLICATE, AST_SORCERY_WIZARD_APPLY_READONLY, AST_VECTOR_APPEND, AST_VECTOR_RW_UNLOCK, AST_VECTOR_RW_WRLOCK, is_one_of(), object_type_wizard::last_config, LOG_ERROR, NULL, object_type_wizard::object_type, sorcery, object_type_wizard::sorcery, object_type_wizard::wizard, and object_type_wizard::wizard_data.
Referenced by load_module().
|
static |
Definition at line 1334 of file res_pjsip_config_wizard.c.
References ast_sip_get_sorcery(), and ast_sorcery_reload().
|
static |
Definition at line 1379 of file res_pjsip_config_wizard.c.
References acl_change_sub, ARRAY_LEN, ast_cli_unregister_multiple(), ast_sorcery_global_observer_remove(), AST_VECTOR_REMOVE_ALL_CMP_UNORDERED, AST_VECTOR_RW_FREE, config_wizard_cli, global_observer, NOT_EQUALS, NULL, OTW_DELETE_CB, and stasis_unsubscribe_and_join().
|
static |
Appends a variable to the end of an existing list.
Definition at line 376 of file res_pjsip_config_wizard.c.
References ast_log, ast_variable_list_append, ast_variable_new, LOG_ERROR, name, and value.
Referenced by get_object_variables(), and handle_aor().
|
static |
Definition at line 998 of file res_pjsip_config_wizard.c.
References ast_category_first(), ast_debug, ast_free, ast_strdup, ast_strdupa, ast_strlen_zero(), ast_strsep(), AST_STRSEP_TRIM, ast_variable_find_last_in_list(), AST_VECTOR_APPEND, AST_VECTOR_FREE, AST_VECTOR_INIT, AST_VECTOR_REMOVE_ALL_CMP_UNORDERED, handle_aor(), handle_auths(), handle_endpoint(), handle_identify(), handle_phoneprov(), handle_registrations(), NOT_EQUALS, NULL, object_type_wizard::object_type, and sorcery.
Referenced by object_type_loaded_observer().
|
static |
Definition at line 1399 of file res_pjsip_config_wizard.c.
|
static |
Definition at line 303 of file res_pjsip_config_wizard.c.
Referenced by acl_change_stasis_cb(), and object_type_loaded_observer().
|
static |
Definition at line 304 of file res_pjsip_config_wizard.c.
Referenced by load_module(), and unload_module().
|
static |
Definition at line 1399 of file res_pjsip_config_wizard.c.
|
static |
Definition at line 1330 of file res_pjsip_config_wizard.c.
Referenced by load_module(), and unload_module().
|
static |
Definition at line 1055 of file res_pjsip_config_wizard.c.
Referenced by load_module(), and unload_module().
| struct ast_sorcery_instance_observer observer |
Definition at line 1060 of file res_pjsip_config_wizard.c.
Referenced by ast_mwi_add_observer(), ast_mwi_remove_observer(), ast_sorcery_observer_add(), instance_created_observer(), instance_destroying_observer(), load_module(), sorcery_generic_observer_remove(), sorcery_observer_notify_create(), sorcery_observer_notify_delete(), sorcery_observer_notify_loaded(), sorcery_observer_notify_update(), sorcery_observer_remove(), stasis_state_add_observer(), and stasis_state_remove_observer().