Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
Config framework stuffz for ARI. More...
#include "asterisk.h"
#include "asterisk/config_options.h"
#include "asterisk/http_websocket.h"
#include "asterisk/app.h"
#include "asterisk/channel.h"
#include "internal.h"
Go to the source code of this file.
Macros | |
#define | CONF_FILENAME "ari.conf" |
#define | MAX_VARS 128 |
Functions | |
static | AO2_GLOBAL_OBJ_STATIC (confs) |
Locking container for safe configuration access. More... | |
void | ast_ari_config_destroy (void) |
Destroy the ARI configuration. More... | |
struct ast_ari_conf * | ast_ari_config_get (void) |
Get the current ARI configuration. More... | |
int | ast_ari_config_init (void) |
Initialize the ARI configuration. More... | |
int | ast_ari_config_reload (void) |
Reload the ARI configuration. More... | |
struct ast_ari_conf_user * | ast_ari_config_validate_user (const char *username, const char *password) |
Validated a user's credentials. More... | |
static int | channelvars_handler (const struct aco_option *opt, struct ast_variable *var, void *obj) |
static void * | conf_alloc (void) |
Allocate an ast_ari_conf for config parsing. More... | |
static void | conf_destructor (void *obj) |
ast_ari_conf destructor. More... | |
static void | conf_general_dtor (void *obj) |
CONFIG_INFO_STANDARD (cfg_info, confs, conf_alloc,.files=ACO_FILES(&conf_file)) | |
static int | encoding_format_handler (const struct aco_option *opt, struct ast_variable *var, void *obj) |
Encoding format handler converts from boolean to enum. More... | |
static int | password_format_handler (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 | process_config (int reload) |
Load (or reload) configuration. More... | |
static void * | user_alloc (const char *cat) |
Allocate an ast_ari_conf_user for config parsing. More... | |
static void | user_dtor (void *obj) |
Destructor for ast_ari_conf_user. More... | |
static void * | user_find (struct ao2_container *tmp_container, const char *cat) |
aco_type item_find function More... | |
static int | user_sort_cmp (const void *obj_left, const void *obj_right, int flags) |
Sorting function for use with red/black tree. More... | |
static int | validate_user_cb (void *obj, void *arg, int flags) |
Callback to validate a user object. More... | |
Variables | |
static struct aco_file | conf_file |
The conf file that's processed for the module. More... | |
static struct aco_type | general_option |
Mapping of the ARI conf struct's globals to the general context in the config file. More... | |
static struct aco_type * | general_options [] = ACO_TYPES(&general_option) |
static struct aco_type * | global_user [] = ACO_TYPES(&user_option) |
static struct aco_type | user_option |
Config framework stuffz for ARI.
Definition in file res/ari/config.c.
#define CONF_FILENAME "ari.conf" |
Definition at line 214 of file res/ari/config.c.
#define MAX_VARS 128 |
Definition at line 321 of file res/ari/config.c.
|
static |
Locking container for safe configuration access.
void ast_ari_config_destroy | ( | void | ) |
Destroy the ARI configuration.
Definition at line 383 of file res/ari/config.c.
References aco_info_destroy(), and ao2_global_obj_release.
Referenced by unload_module().
struct ast_ari_conf * ast_ari_config_get | ( | void | ) |
Get the current ARI configuration.
This is an immutable object, so don't modify it. It is AO2 managed, so ao2_cleanup() when you're done with it.
NULL | on error. |
Definition at line 227 of file res/ari/config.c.
References ao2_global_obj_ref, ast_log, CONF_FILENAME, and LOG_ERROR.
Referenced by ari_show(), ari_show_user(), ari_show_users(), ast_ari_callback(), ast_ari_config_validate_user(), ast_ari_json_format(), ast_ari_websocket_session_create(), complete_ari_user(), is_enabled(), origin_allowed(), and process_config().
int ast_ari_config_init | ( | void | ) |
Initialize the ARI configuration.
Definition at line 337 of file res/ari/config.c.
References ACO_EXACT, aco_info_destroy(), aco_info_init(), aco_option_register, aco_option_register_custom, ARI_AUTH_REALM_LEN, ARI_PASSWORD_LEN, AST_DEFAULT_WEBSOCKET_WRITE_TIMEOUT_STR, channelvars_handler(), enabled, encoding_format_handler(), FLDSET, general_options, global_user, NULL, OPT_BOOL_T, OPT_CHAR_ARRAY_T, OPT_INT_T, OPT_NOOP_T, OPT_STRINGFIELD_T, PARSE_IN_RANGE, ast_ari_conf_user::password, password_format_handler(), process_config(), ast_ari_conf_user::read_only, and STRFLDSET.
Referenced by load_module().
int ast_ari_config_reload | ( | void | ) |
Reload the ARI configuration.
Definition at line 378 of file res/ari/config.c.
References process_config().
Referenced by reload_module().
struct ast_ari_conf_user * ast_ari_config_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 237 of file res/ari/config.c.
References ao2_cleanup, ao2_find, ao2_ref, ARI_PASSWORD_FORMAT_CRYPT, ARI_PASSWORD_FORMAT_PLAIN, ast_ari_config_get(), ast_crypt_validate(), ast_log, ast_strlen_zero(), LOG_WARNING, NULL, OBJ_SEARCH_KEY, ast_ari_conf_user::password, RAII_VAR, user, and ast_ari_conf_user::username.
Referenced by authenticate_api_key(), and authenticate_user().
|
static |
Definition at line 323 of file res/ari/config.c.
References args, AST_APP_ARG, ast_channel_set_ari_vars(), AST_DECLARE_APP_ARGS, AST_STANDARD_APP_ARGS, ast_strdupa, MAX_VARS, NULL, and var.
Referenced by ast_ari_config_init().
|
static |
Allocate an ast_ari_conf for config parsing.
Definition at line 187 of file res/ari/config.c.
References aco_set_defaults(), AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE, ao2_container_alloc_rbtree, ao2_ref, ast_string_field_init, conf_destructor(), conf_general_dtor(), ast_ari_conf::general, general_option, NULL, user_sort_cmp(), and ast_ari_conf::users.
|
static |
ast_ari_conf destructor.
Definition at line 178 of file res/ari/config.c.
References ao2_cleanup, ast_ari_conf::general, and ast_ari_conf::users.
Referenced by conf_alloc().
|
static |
Definition at line 170 of file res/ari/config.c.
References ast_string_field_free_memory.
Referenced by conf_alloc().
CONFIG_INFO_STANDARD | ( | cfg_info | , |
confs | , | ||
conf_alloc | , | ||
. | files = ACO_FILES(&conf_file) |
||
) |
|
static |
Encoding format handler converts from boolean to enum.
Definition at line 49 of file res/ari/config.c.
References AST_JSON_COMPACT, AST_JSON_PRETTY, ast_true(), ast_ari_conf_general::format, and var.
Referenced by ast_ari_config_init().
|
static |
Parses the ast_ari_password_format enum from a config file.
Definition at line 65 of file res/ari/config.c.
References ARI_PASSWORD_FORMAT_CRYPT, ARI_PASSWORD_FORMAT_PLAIN, and var.
Referenced by ast_ari_config_init().
|
static |
Load (or reload) configuration.
Definition at line 292 of file res/ari/config.c.
References aco_process_config(), ACO_PROCESS_ERROR, ACO_PROCESS_OK, ACO_PROCESS_UNCHANGED, ao2_callback, ao2_cleanup, ao2_container_count(), ast_ari_config_get(), ast_assert, ast_log, conf::general, LOG_ERROR, NULL, OBJ_NODATA, RAII_VAR, reload(), and validate_user_cb().
Referenced by ast_ari_config_init(), and ast_ari_config_reload().
|
static |
Allocate an ast_ari_conf_user for config parsing.
Definition at line 90 of file res/ari/config.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_cleanup, ao2_ref, ast_debug, ast_strdup, NULL, RAII_VAR, user, and user_dtor().
|
static |
Destructor for ast_ari_conf_user.
Definition at line 82 of file res/ari/config.c.
References ast_debug, and ast_free.
Referenced by user_alloc().
|
static |
aco_type item_find function
Definition at line 147 of file res/ari/config.c.
References ao2_find, NULL, and OBJ_SEARCH_KEY.
|
static |
Sorting function for use with red/black tree.
Definition at line 116 of file res/ari/config.c.
References ast_assert, OBJ_SEARCH_KEY, OBJ_SEARCH_MASK, OBJ_SEARCH_OBJECT, OBJ_SEARCH_PARTIAL_KEY, and ast_ari_conf_user::username.
Referenced by conf_alloc().
|
static |
Callback to validate a user object.
Definition at line 279 of file res/ari/config.c.
References ast_log, ast_strlen_zero(), and LOG_WARNING.
Referenced by process_config().
|
static |
The conf file that's processed for the module.
Definition at line 217 of file res/ari/config.c.
|
static |
Mapping of the ARI conf struct's globals to the general context in the config file.
Definition at line 38 of file res/ari/config.c.
Referenced by conf_alloc().
|
static |
Definition at line 46 of file res/ari/config.c.
Referenced by ast_ari_config_init().
|
static |
Definition at line 168 of file res/ari/config.c.
Referenced by ast_ari_config_init().
|
static |
Definition at line 156 of file res/ari/config.c.