Asterisk - The Open Source Telephony Project GIT-master-8ef3e4f
|
Config framework stuffz for ARI. More...
#include <limits.h>
#include "asterisk.h"
#include "asterisk/sorcery.h"
#include "asterisk/config_options.h"
#include "asterisk/http_websocket.h"
#include "asterisk/websocket_client.h"
#include "asterisk/app.h"
#include "asterisk/channel.h"
#include "asterisk/vector.h"
#include "internal.h"
Go to the source code of this file.
Data Structures | |
struct | outbound_websocket_state |
Macros | |
#define | MAX_VARS 128 |
#define | OWC_STATES_BUCKETS 13 |
Functions | |
void | ari_conf_destroy (void) |
Destroy the ARI configuration. More... | |
struct ari_conf_general * | ari_conf_get_general (void) |
struct ari_conf_outbound_websocket * | ari_conf_get_owc (const char *id) |
struct ari_conf_outbound_websocket * | ari_conf_get_owc_for_app (const char *app_name, unsigned int ws_type) |
Get the outbound websocket configuration for a Stasis app. More... | |
struct ao2_container * | ari_conf_get_owcs (void) |
struct ari_conf_user * | ari_conf_get_user (const char *username) |
struct ao2_container * | ari_conf_get_users (void) |
static int | ari_conf_init (void) |
int | ari_conf_load (enum ari_conf_load_flags flags) |
(Re)load the ARI configuration More... | |
enum ari_conf_owc_fields | ari_conf_owc_detect_changes (struct ari_conf_outbound_websocket *old_owc, struct ari_conf_outbound_websocket *new_owc) |
Detect changes between two outbound websocket configurations. More... | |
enum ari_conf_owc_fields | ari_conf_owc_get_invalid_fields (const char *id) |
struct ari_conf_user * | ari_conf_validate_user (const char *username, const char *password) |
Validated a user's credentials. More... | |
int | ari_sorcery_observer_add (const char *object_type, const struct ast_sorcery_observer *callbacks) |
int | ari_sorcery_observer_remove (const char *object_type, const struct ast_sorcery_observer *callbacks) |
const char * | ari_websocket_type_to_str (enum ast_websocket_type type) |
static void * | general_alloc (const char *name) |
static int | general_apply (const struct ast_sorcery *sorcery, void *obj) |
static void | general_dtor (void *obj) |
ast_ari_conf destructor. More... | |
static int | general_pretty_from_str (const struct aco_option *opt, struct ast_variable *var, void *obj) |
Encoding format handler converts from boolean to enum. More... | |
static int | general_pretty_to_str (const void *obj, const intptr_t *args, char **buf) |
static void * | outbound_websocket_alloc (const char *id) |
static int | outbound_websocket_apply (const struct ast_sorcery *sorcery, void *obj) |
Callback to initialize an outbound websocket object. More... | |
static void | outbound_websocket_dtor (void *obj) |
static int | outbound_websocket_state_cleanup (void *obj, void *arg, int flags) |
static int | outbound_websocket_validate_cb (void *obj, void *args, int flags) |
static int | outbound_websocket_websocket_client_id_from_str (const struct aco_option *opt, struct ast_variable *var, void *obj) |
static int | outbound_websocket_websocket_client_id_to_str (const void *obj, const intptr_t *args, char **buf) |
static void | outbound_websockets_validate (const char *name) |
static void * | user_alloc (const char *cat) |
Allocate an ast_ari_conf_user for config parsing. More... | |
static int | user_apply (const struct ast_sorcery *sorcery, void *obj) |
static void | user_dtor (void *obj) |
Destructor for ast_ari_conf_user. More... | |
static int | user_password_format_from_str (const struct aco_option *opt, struct ast_variable *var, void *obj) |
Parses the ast_ari_password_format enum from a config file. More... | |
static int | user_password_format_to_str (const void *obj, const intptr_t *args, char **buf) |
static void | ws_client_load (const char *name) |
Variables | |
static struct ast_sorcery_observer | observer_callbacks |
struct ao2_container * | owc_states = NULL |
static struct ast_sorcery * | sorcery |
static struct ast_sorcery_observer | ws_client_observer_callbacks |
Config framework stuffz for ARI.
Definition in file res/ari/config.c.
#define MAX_VARS 128 |
Definition at line 447 of file res/ari/config.c.
#define OWC_STATES_BUCKETS 13 |
Definition at line 45 of file res/ari/config.c.
void ari_conf_destroy | ( | void | ) |
Destroy the ARI configuration.
Definition at line 789 of file res/ari/config.c.
References ao2_cleanup, ast_sorcery_unref, ast_websocket_client_observer_remove(), NULL, owc_states, sorcery, and ws_client_observer_callbacks.
Referenced by unload_module().
struct ari_conf_general * ari_conf_get_general | ( | void | ) |
Definition at line 477 of file res/ari/config.c.
References ast_sorcery_retrieve_by_id(), NULL, and sorcery.
Referenced by ari_show(), ast_ari_invoke(), ast_ari_json_format(), is_enabled(), origin_allowed(), and session_update().
struct ari_conf_outbound_websocket * ari_conf_get_owc | ( | const char * | id | ) |
Definition at line 308 of file res/ari/config.c.
References ast_sorcery_retrieve_by_id(), NULL, and sorcery.
Referenced by ari_show_owc(), ari_start_owc(), outbound_sessions_load(), and outbound_websocket_state_cleanup().
struct ari_conf_outbound_websocket * ari_conf_get_owc_for_app | ( | const char * | app_name, |
unsigned int | ws_type | ||
) |
Get the outbound websocket configuration for a Stasis app.
app_name | The application name to search for. |
ws_type | An OR'd list of ari_websocket_types or ARI_WS_TYPE_ANY. |
ARI | outbound websocket configuration object. |
NULL | if not found. |
Definition at line 317 of file res/ari/config.c.
References ao2_cleanup, ao2_container_count(), ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, app_name(), ari_conf_outbound_websocket::apps, ari_conf_get_owcs(), ast_debug, ast_in_delimited_string(), ast_sorcery_object_get_id(), ast_strlen_zero(), ast_websocket_client::connection_type, NULL, and ari_conf_outbound_websocket::websocket_client.
Referenced by ast_ari_create_per_call_websocket().
struct ao2_container * ari_conf_get_owcs | ( | void | ) |
Definition at line 298 of file res/ari/config.c.
References AST_RETRIEVE_FLAG_ALL, AST_RETRIEVE_FLAG_MULTIPLE, ast_sorcery_retrieve_by_fields(), NULL, and sorcery.
Referenced by ari_conf_get_owc_for_app(), ari_show_owc(), ari_show_owcs(), ari_start_owc(), outbound_sessions_load(), outbound_websocket_validate_cb(), and outbound_websockets_validate().
struct ari_conf_user * ari_conf_get_user | ( | const char * | username | ) |
Definition at line 578 of file res/ari/config.c.
References ast_sorcery_retrieve_by_id(), NULL, and sorcery.
Referenced by ari_show_user().
struct ao2_container * ari_conf_get_users | ( | void | ) |
Definition at line 568 of file res/ari/config.c.
References AST_RETRIEVE_FLAG_ALL, AST_RETRIEVE_FLAG_MULTIPLE, ast_sorcery_retrieve_by_fields(), NULL, and sorcery.
Referenced by ari_show_user(), and ari_show_users().
|
static |
Definition at line 658 of file res/ari/config.c.
References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE, ast_debug, AST_DEFAULT_WEBSOCKET_WRITE_TIMEOUT, ast_log, ast_sorcery_apply_default, ast_sorcery_object_field_register, ast_sorcery_object_field_register_nodoc, ast_sorcery_object_register, ast_sorcery_observer_add(), ast_sorcery_open, ast_sorcery_register_bool, ast_sorcery_register_cust, ast_sorcery_register_int, ast_sorcery_register_sf, ast_sorcery_unref, ast_websocket_client_observer_add(), enabled, general_alloc(), general_apply(), LOG_ERROR, LOG_WARNING, NULL, observer_callbacks, OPT_NOOP_T, outbound_websocket_alloc(), outbound_websocket_apply(), owc_states, OWC_STATES_BUCKETS, sorcery, subscribe_all(), user_alloc(), user_apply(), and ws_client_observer_callbacks.
Referenced by ari_conf_load().
int ari_conf_load | ( | enum ari_conf_load_flags | flags | ) |
(Re)load the ARI configuration
Definition at line 745 of file res/ari/config.c.
References ari_conf_init(), ARI_CONF_INIT, ARI_CONF_LOAD_GENERAL, ARI_CONF_LOAD_OWC, ARI_CONF_LOAD_USER, ARI_CONF_RELOAD, ast_debug, ast_log, ast_sorcery_load_object(), ast_sorcery_reload_object(), ast_websocket_client_reload(), LOG_ERROR, sorcery, and type.
Referenced by load_module(), and reload_module().
enum ari_conf_owc_fields ari_conf_owc_detect_changes | ( | struct ari_conf_outbound_websocket * | old_owc, |
struct ari_conf_outbound_websocket * | new_owc | ||
) |
Detect changes between two outbound websocket configurations.
old_owc | The old outbound websocket configuration. |
new_owc | The new outbound websocket configuration. |
Definition at line 377 of file res/ari/config.c.
References ARI_OWC_FIELD_APPS, ARI_OWC_FIELD_LOCAL_ARI_PASSWORD, ARI_OWC_FIELD_LOCAL_ARI_USER, ARI_OWC_FIELD_NONE, ARI_OWC_FIELD_SUBSCRIBE_ALL, ast_debug, ast_log, ast_sorcery_diff(), ast_sorcery_object_get_id(), ast_strings_equal(), ast_variables_destroy(), ast_websocket_client_get_field_diff(), LOG_WARNING, ast_variable::name, ast_variable::next, NULL, RAII_VAR, sorcery, ast_variable::value, and ari_conf_outbound_websocket::websocket_client.
Referenced by outbound_session_apply_config().
enum ari_conf_owc_fields ari_conf_owc_get_invalid_fields | ( | const char * | id | ) |
Definition at line 158 of file res/ari/config.c.
References ao2_cleanup, ao2_find, ARI_OWC_FIELD_NONE, NULL, OBJ_SEARCH_KEY, owc_states, and RAII_VAR.
Referenced by ari_show_owc(), ast_ari_create_per_call_websocket(), outbound_session_create(), and show_owc_cb().
struct ari_conf_user * ari_conf_validate_user | ( | const char * | username, |
const char * | password | ||
) |
Validated a user's credentials.
username | Name of the user. |
password | User's password. |
NULL | if username or password is invalid. |
Definition at line 591 of file res/ari/config.c.
References ao2_cleanup, ARI_PASSWORD_FORMAT_CRYPT, ARI_PASSWORD_FORMAT_PLAIN, ast_crypt_validate(), ast_sorcery_retrieve_by_id(), ast_strlen_zero(), NULL, ari_conf_user::password, sorcery, and user.
Referenced by authenticate_api_key(), and authenticate_user().
int ari_sorcery_observer_add | ( | const char * | object_type, |
const struct ast_sorcery_observer * | callbacks | ||
) |
Definition at line 623 of file res/ari/config.c.
References ast_sorcery_observer_add(), callbacks, and sorcery.
Referenced by ari_websocket_load_module().
int ari_sorcery_observer_remove | ( | const char * | object_type, |
const struct ast_sorcery_observer * | callbacks | ||
) |
Definition at line 632 of file res/ari/config.c.
References ast_sorcery_observer_remove(), callbacks, and sorcery.
Referenced by ari_websocket_unload_module().
const char * ari_websocket_type_to_str | ( | enum ast_websocket_type | type | ) |
Definition at line 359 of file res/ari/config.c.
References AST_WS_TYPE_ANY, AST_WS_TYPE_CLIENT_PER_CALL, AST_WS_TYPE_CLIENT_PER_CALL_CONFIG, AST_WS_TYPE_CLIENT_PERSISTENT, AST_WS_TYPE_INBOUND, and type.
Referenced by ari_show_owc(), session_shutdown_cb(), show_owc_cb(), and show_sessions_cb().
|
static |
Definition at line 431 of file res/ari/config.c.
References ast_sorcery_generic_alloc(), ast_string_field_init, general_dtor(), and NULL.
Referenced by ari_conf_init().
|
static |
Definition at line 449 of file res/ari/config.c.
References args, AST_APP_ARG, ast_channel_set_ari_vars(), ast_debug, AST_DECLARE_APP_ARGS, AST_STANDARD_APP_ARGS, ast_strdupa, ari_conf_general::channelvars, MAX_VARS, and NULL.
Referenced by ari_conf_init().
|
static |
ast_ari_conf destructor.
Definition at line 424 of file res/ari/config.c.
References ast_string_field_free_memory.
Referenced by general_alloc().
|
static |
Encoding format handler converts from boolean to enum.
Definition at line 467 of file res/ari/config.c.
References AST_JSON_COMPACT, AST_JSON_PRETTY, ast_true(), ari_conf_general::format, and var.
|
static |
Definition at line 486 of file res/ari/config.c.
References AST_JSON_PRETTY, ast_strdup, buf, and ari_conf_general::format.
|
static |
Definition at line 59 of file res/ari/config.c.
References ao2_cleanup, ast_debug, ast_sorcery_generic_alloc(), ast_string_field_init, NULL, and outbound_websocket_dtor().
Referenced by ari_conf_init().
|
static |
Callback to initialize an outbound websocket object.
0 | on success |
CMP_MATCH | on error which will cause the object to be removed |
Definition at line 114 of file res/ari/config.c.
References app, ari_conf_outbound_websocket::apps, ARI_MAX_APP_NAME_LEN, ast_debug, ast_log, ast_sorcery_object_get_id(), ast_strdupa, ast_strlen_zero(), ast_strsep(), AST_STRSEP_STRIP, ari_conf_outbound_websocket::local_ari_user, and LOG_WARNING.
Referenced by ari_conf_init().
|
static |
Definition at line 48 of file res/ari/config.c.
References ao2_cleanup, ast_debug, ast_sorcery_object_get_id(), ast_string_field_free_memory, NULL, and ari_conf_outbound_websocket::websocket_client.
Referenced by outbound_websocket_alloc().
|
static |
Definition at line 273 of file res/ari/config.c.
References ao2_cleanup, ari_conf_get_owc(), ast_debug, and CMP_MATCH.
Referenced by outbound_websockets_validate().
|
static |
Definition at line 166 of file res/ari/config.c.
References ao2_alloc, ao2_cleanup, ao2_container_count(), ao2_find, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_link, app, ari_conf_outbound_websocket::apps, ari_conf_get_owcs(), ARI_OWC_FIELD_APPS, ARI_OWC_FIELD_LOCAL_ARI_USER, ARI_OWC_FIELD_NONE, ARI_PASSWORD_FORMAT_PLAIN, ast_debug, ast_free_ptr(), ast_in_delimited_string(), ast_log, ast_sorcery_object_get_id(), ast_sorcery_retrieve_by_id(), ast_string_field_set, ast_strings_equal(), AST_VECTOR_FREE, AST_VECTOR_GET, AST_VECTOR_INIT, AST_VECTOR_RESET, AST_VECTOR_SIZE, ast_vector_string_split(), ari_conf_outbound_websocket::invalid, ari_conf_outbound_websocket::local_ari_user, LOG_WARNING, NULL, OBJ_SEARCH_KEY, owc_states, RAII_VAR, and sorcery.
Referenced by outbound_websockets_validate().
|
static |
Definition at line 77 of file res/ari/config.c.
References ast_log, ast_sorcery_object_get_id(), ast_string_field_set, ast_strlen_zero(), ast_websocket_client_retrieve_by_id(), LOG_ERROR, var, ari_conf_outbound_websocket::websocket_client, and ari_conf_outbound_websocket::websocket_client_id.
|
static |
Definition at line 99 of file res/ari/config.c.
References ast_strdup, buf, ari_conf_outbound_websocket::websocket_client, and ari_conf_outbound_websocket::websocket_client_id.
|
static |
Definition at line 288 of file res/ari/config.c.
References ao2_callback, ao2_cleanup, ari_conf_get_owcs(), NULL, OBJ_NODATA, OBJ_UNLINK, outbound_websocket_state_cleanup(), outbound_websocket_validate_cb(), owc_states, and RAII_VAR.
|
static |
Allocate an ast_ari_conf_user for config parsing.
Definition at line 507 of file res/ari/config.c.
References ao2_cleanup, ast_sorcery_generic_alloc(), ast_string_field_init, NULL, user, and user_dtor().
Referenced by ari_conf_init().
|
static |
Definition at line 524 of file res/ari/config.c.
References ast_debug, ast_log, ast_sorcery_object_get_id(), ast_strlen_zero(), and LOG_WARNING.
Referenced by ari_conf_init().
|
static |
Destructor for ast_ari_conf_user.
Definition at line 499 of file res/ari/config.c.
References ast_debug, ast_sorcery_object_get_id(), and ast_string_field_free_memory.
Referenced by user_alloc().
|
static |
Parses the ast_ari_password_format enum from a config file.
Definition at line 540 of file res/ari/config.c.
References ARI_PASSWORD_FORMAT_CRYPT, ARI_PASSWORD_FORMAT_PLAIN, and var.
|
static |
Definition at line 556 of file res/ari/config.c.
References ARI_PASSWORD_FORMAT_CRYPT, ast_strdup, and buf.
|
static |
Definition at line 646 of file res/ari/config.c.
References ast_sorcery_force_reload_object(), and sorcery.
|
static |
Definition at line 642 of file res/ari/config.c.
Referenced by ari_conf_init().
struct ao2_container* owc_states = NULL |
Definition at line 46 of file res/ari/config.c.
Referenced by ari_conf_destroy(), ari_conf_init(), ari_conf_owc_get_invalid_fields(), outbound_websocket_validate_cb(), and outbound_websockets_validate().
|
static |
Definition at line 38 of file res/ari/config.c.
Referenced by __ast_sorcery_apply_config(), __ast_sorcery_apply_default(), __ast_sorcery_apply_wizard_mapping(), __ast_sorcery_insert_wizard_mapping(), __ast_sorcery_object_field_register(), __ast_sorcery_object_register(), __ast_sorcery_object_type_insert_wizard(), __ast_sorcery_object_type_remove_wizard(), __ast_sorcery_open(), __ast_sorcery_remove_wizard_mapping(), alloc_and_initialize_sorcery(), apply_list_configuration(), ari_conf_destroy(), ari_conf_get_general(), ari_conf_get_owc(), ari_conf_get_owcs(), ari_conf_get_user(), ari_conf_get_users(), ari_conf_init(), ari_conf_load(), ari_conf_owc_detect_changes(), ari_conf_validate_user(), ari_sorcery_observer_add(), ari_sorcery_observer_remove(), as_config_load(), as_config_reload(), ast_ari_asterisk_delete_object(), ast_ari_asterisk_get_object(), ast_ari_asterisk_update_object(), ast_sip_destroy_sorcery_global(), ast_sip_initialize_sorcery_auth(), ast_sip_initialize_sorcery_domain_alias(), ast_sip_initialize_sorcery_global(), ast_sip_initialize_sorcery_location(), ast_sip_initialize_sorcery_transport(), ast_sorcery_alloc(), ast_sorcery_copy(), ast_sorcery_create(), ast_sorcery_delete(), ast_sorcery_diff(), ast_sorcery_force_reload(), ast_sorcery_force_reload_object(), ast_sorcery_get_module(), ast_sorcery_get_object_type(), ast_sorcery_get_wizard_mapping(), ast_sorcery_get_wizard_mapping_count(), ast_sorcery_instance_observer_add(), ast_sorcery_instance_observer_remove(), ast_sorcery_is_stale(), ast_sorcery_load(), ast_sorcery_load_object(), ast_sorcery_object_fields_register(), ast_sorcery_object_set_congestion_levels(), ast_sorcery_object_set_copy_handler(), ast_sorcery_object_set_diff_handler(), ast_sorcery_object_unregister(), ast_sorcery_objectset_apply(), ast_sorcery_objectset_create2(), ast_sorcery_objectset_json_create(), ast_sorcery_observer_add(), ast_sorcery_observer_remove(), ast_sorcery_ref(), ast_sorcery_reload(), ast_sorcery_reload_object(), ast_sorcery_retrieve_by_fields(), ast_sorcery_retrieve_by_id(), ast_sorcery_retrieve_by_prefix(), ast_sorcery_retrieve_by_regex(), ast_sorcery_update(), AST_TEST_DEFINE(), bucket_file_wizard_create(), bucket_file_wizard_delete(), bucket_file_wizard_is_stale(), bucket_file_wizard_retrieve(), bucket_file_wizard_update(), bucket_http_wizard_retrieve_id(), bucket_wizard_create(), bucket_wizard_delete(), bucket_wizard_is_stale(), bucket_wizard_retrieve(), can_reuse_registration(), create_object(), deinitialize_sorcery(), global_loaded_observer(), handle_aor(), handle_auth(), handle_auths(), handle_endpoint(), handle_export_primitives(), handle_identify(), handle_phoneprov(), handle_registrations(), instance_created_observer(), instance_destroying_observer(), load_module(), memory_cache_full_update(), memory_cache_populate(), memory_cache_stale_check(), memory_cache_stale_check_object(), memory_cache_stale_update_full(), memory_cache_stale_update_object(), mock_retrieve_id(), object_type_loaded_observer(), object_type_registered_observer(), outbound_websocket_validate_cb(), profile_load(), profile_reload(), return_sorcery_object(), sorcery_astdb_create(), sorcery_astdb_filter_objectset(), sorcery_astdb_retrieve_fields(), sorcery_astdb_retrieve_fields_common(), sorcery_astdb_retrieve_id(), sorcery_astdb_retrieve_multiple(), sorcery_astdb_retrieve_prefix(), sorcery_astdb_retrieve_regex(), sorcery_astdb_update(), sorcery_config_internal_load(), sorcery_config_load(), sorcery_config_reload(), sorcery_config_retrieve_fields(), sorcery_config_retrieve_multiple(), sorcery_config_retrieve_prefix(), sorcery_config_retrieve_regex(), sorcery_destructor(), sorcery_function_read(), sorcery_is_configuration_met(), sorcery_is_explicit_name_met(), sorcery_memory_cache_create(), sorcery_memory_cache_load(), sorcery_memory_cache_retrieve_fields(), sorcery_memory_cache_retrieve_id(), sorcery_memory_cache_retrieve_multiple(), sorcery_memory_cache_retrieve_prefix(), sorcery_memory_cache_retrieve_regex(), sorcery_memory_cached_object_alloc(), sorcery_memory_retrieve_fields(), sorcery_memory_retrieve_multiple(), sorcery_memory_retrieve_prefix(), sorcery_memory_retrieve_regex(), sorcery_realtime_create(), sorcery_realtime_filter_objectset(), sorcery_realtime_retrieve_fields(), sorcery_realtime_retrieve_id(), sorcery_realtime_retrieve_multiple(), sorcery_realtime_retrieve_prefix(), sorcery_realtime_retrieve_regex(), sorcery_realtime_update(), sorcery_reloadable(), sorcery_test_retrieve_id(), sorcery_wizard_load(), stale_cache_update_task_data_alloc(), stale_update_task_data_alloc(), tn_config_load(), tn_config_reload(), transport_apply(), vs_config_load(), vs_config_reload(), wizard_apply_handler(), and ws_client_load().
|
static |
Definition at line 651 of file res/ari/config.c.
Referenced by ari_conf_destroy(), and ari_conf_init().