Asterisk - The Open Source Telephony Project GIT-master-fe341c2
|
#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/astobj2.h"
#include "asterisk/strings.h"
#include "asterisk/vector.h"
#include "asterisk/websocket_client.h"
Go to the source code of this file.
Macros | |
#define | DEFAULT_RECONNECT_ATTEMPTS -2147483648 |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
struct ast_websocket * | ast_websocket_client_connect (struct ast_websocket_client *wc, void *lock_obj, const char *display_name, enum ast_websocket_result *result) |
Connect to a websocket server using the configured authentication, retry and TLS options. More... | |
enum ast_ws_client_fields | ast_websocket_client_get_field_diff (struct ast_websocket_client *old_wc, struct ast_websocket_client *new_wc) |
Detect changes between two websocket client configurations. More... | |
int | ast_websocket_client_observer_add (const struct ast_sorcery_observer *callbacks) |
Add sorcery observers for websocket client events. More... | |
void | ast_websocket_client_observer_remove (const struct ast_sorcery_observer *callbacks) |
Remove sorcery observers for websocket client events. More... | |
int | ast_websocket_client_reload (void) |
Force res_websocket_client to reload its configuration. More... | |
struct ao2_container * | ast_websocket_client_retrieve_all (void) |
Retrieve a container of all websocket client objects. More... | |
struct ast_websocket_client * | ast_websocket_client_retrieve_by_id (const char *id) |
Retrieve a websocket client object by ID. More... | |
static int | load_module (void) |
static int | reload_module (void) |
static int | unload_module (void) |
static void * | wc_alloc (const char *id) |
static int | wc_apply (const struct ast_sorcery *sorcery, void *obj) |
static void | wc_dtor (void *obj) |
static int | websocket_client_connection_type_from_str (const struct aco_option *opt, struct ast_variable *var, void *obj) |
static int | websocket_client_connection_type_to_str (const void *obj, const intptr_t *args, char **buf) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "WebSocket Client Support" , .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_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND, .requires = "res_http_websocket", } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_sorcery * | sorcery = NULL |
#define DEFAULT_RECONNECT_ATTEMPTS -2147483648 |
Definition at line 400 of file res_websocket_client.c.
|
static |
Definition at line 617 of file res_websocket_client.c.
|
static |
Definition at line 617 of file res_websocket_client.c.
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 617 of file res_websocket_client.c.
struct ast_websocket * ast_websocket_client_connect | ( | struct ast_websocket_client * | wc, |
void * | lock_obj, | ||
const char * | display_name, | ||
enum ast_websocket_result * | result | ||
) |
Connect to a websocket server using the configured authentication, retry and TLS options.
wc | A pointer to the ast_websocket_structure |
lock_obj | A pointer to an ao2 object to lock while the connection is being attempted or NULL if no locking is needed. |
display_name | An id string to use for logging messages. If NULL or empty the connection's ID will be used. |
result | A pointer to an enum ast_websocket_result to store the result of the connection attempt. |
Definition at line 240 of file res_websocket_client.c.
References ao2_lock, ao2_unlock, ast_calloc, ast_log, ast_set2_flag, ast_sorcery_object_get_id(), AST_SSL_DONT_VERIFY_SERVER, AST_SSL_IGNORE_COMMON_NAME, ast_strdup, ast_strlen_zero(), ast_websocket_client_create_with_options(), ast_websocket_result_to_str(), AST_WS_TYPE_CLIENT_PERSISTENT, ast_websocket_client::ca_list_file, ast_websocket_client::ca_list_path, ast_websocket_client::cert_file, ast_websocket_client::connect_timeout, ast_websocket_client::connection_type, errno, LOG_WARNING, NULL, options, ast_websocket_client::password, ast_websocket_client::priv_key_file, ast_websocket_client::protocols, ast_websocket_client::reconnect_attempts, ast_websocket_client::reconnect_interval, result, ast_websocket_client::tls_enabled, ast_websocket_client::uri, ast_websocket_client::username, ast_websocket_client::verify_server_cert, ast_websocket_client::verify_server_hostname, and WS_OK.
Referenced by outbound_session_handler_thread().
enum ast_ws_client_fields ast_websocket_client_get_field_diff | ( | struct ast_websocket_client * | old_wc, |
struct ast_websocket_client * | new_wc | ||
) |
Detect changes between two websocket client configurations.
old_ow | The old websocket configuration. |
new_ow | The new websocket configuration. |
Definition at line 451 of file res_websocket_client.c.
References ast_debug, ast_log, ast_sorcery_diff(), ast_sorcery_object_get_id(), ast_strings_equal(), ast_variables_destroy(), AST_WS_CLIENT_FIELD_CA_LIST_FILE, AST_WS_CLIENT_FIELD_CA_LIST_PATH, AST_WS_CLIENT_FIELD_CERT_FILE, AST_WS_CLIENT_FIELD_CONNECTION_TIMEOUT, AST_WS_CLIENT_FIELD_CONNECTION_TYPE, AST_WS_CLIENT_FIELD_NONE, AST_WS_CLIENT_FIELD_PASSWORD, AST_WS_CLIENT_FIELD_PRIV_KEY_FILE, AST_WS_CLIENT_FIELD_PROTOCOLS, AST_WS_CLIENT_FIELD_RECONNECT_ATTEMPTS, AST_WS_CLIENT_FIELD_RECONNECT_INTERVAL, AST_WS_CLIENT_FIELD_TLS_ENABLED, AST_WS_CLIENT_FIELD_URI, AST_WS_CLIENT_FIELD_USERNAME, AST_WS_CLIENT_FIELD_VERIFY_SERVER_CERT, AST_WS_CLIENT_FIELD_VERIFY_SERVER_HOSTNAME, LOG_WARNING, ast_variable::name, ast_variable::next, NULL, RAII_VAR, sorcery, and ast_variable::value.
Referenced by ari_conf_owc_detect_changes().
int ast_websocket_client_observer_add | ( | const struct ast_sorcery_observer * | callbacks | ) |
Add sorcery observers for websocket client events.
callbacks | The observer callbacks to add. |
Definition at line 516 of file res_websocket_client.c.
References ast_log, ast_sorcery_observer_add(), callbacks, LOG_ERROR, and sorcery.
Referenced by ari_conf_init().
void ast_websocket_client_observer_remove | ( | const struct ast_sorcery_observer * | callbacks | ) |
Remove sorcery observers for websocket client events.
callbacks | The observer callbacks to remove. |
Definition at line 530 of file res_websocket_client.c.
References ast_sorcery_observer_remove(), callbacks, and sorcery.
Referenced by ari_conf_destroy().
int ast_websocket_client_reload | ( | void | ) |
Force res_websocket_client to reload its configuration.
Definition at line 590 of file res_websocket_client.c.
References ast_debug, ast_sorcery_reload(), and sorcery.
Referenced by ari_conf_load().
struct ao2_container * ast_websocket_client_retrieve_all | ( | void | ) |
Retrieve a container of all websocket client objects.
Definition at line 432 of file res_websocket_client.c.
References AST_RETRIEVE_FLAG_ALL, AST_RETRIEVE_FLAG_MULTIPLE, ast_sorcery_retrieve_by_fields(), NULL, and sorcery.
struct ast_websocket_client * ast_websocket_client_retrieve_by_id | ( | const char * | id | ) |
Retrieve a websocket client object by ID.
id | The ID of the websocket client object. |
Definition at line 442 of file res_websocket_client.c.
References ast_sorcery_retrieve_by_id(), NULL, and sorcery.
Referenced by outbound_websocket_websocket_client_id_from_str().
|
static |
Definition at line 540 of file res_websocket_client.c.
References ast_debug, ast_log, ast_sorcery_apply_default, ast_sorcery_load(), ast_sorcery_object_field_register, ast_sorcery_object_register, ast_sorcery_open, ast_sorcery_register_bool, ast_sorcery_register_cust, ast_sorcery_register_int, ast_sorcery_register_sf, ast_sorcery_unref, LOG_ERROR, NULL, OPT_NOOP_T, sorcery, wc_alloc(), and wc_apply().
|
static |
Definition at line 582 of file res_websocket_client.c.
References ast_debug, ast_sorcery_reload(), and sorcery.
|
static |
Definition at line 600 of file res_websocket_client.c.
References ast_debug, ast_sorcery_unref, NULL, and sorcery.
|
static |
Definition at line 346 of file res_websocket_client.c.
References ao2_cleanup, ast_debug, ast_sorcery_generic_alloc(), ast_string_field_init, NULL, and wc_dtor().
Referenced by load_module().
|
static |
Definition at line 402 of file res_websocket_client.c.
References ast_debug, ast_log, ast_sorcery_object_get_id(), ast_strlen_zero(), AST_WS_TYPE_CLIENT_PERSISTENT, ast_websocket_client::connection_type, DEFAULT_RECONNECT_ATTEMPTS, LOG_WARNING, ast_websocket_client::reconnect_attempts, and ast_websocket_client::uri.
Referenced by load_module().
|
static |
Definition at line 337 of file res_websocket_client.c.
References ast_debug, ast_sorcery_object_get_id(), and ast_string_field_free_memory.
Referenced by wc_alloc().
|
static |
Definition at line 364 of file res_websocket_client.c.
References AST_WS_TYPE_CLIENT_PER_CALL_CONFIG, AST_WS_TYPE_CLIENT_PERSISTENT, ast_websocket_client::connection_type, and var.
|
static |
Definition at line 380 of file res_websocket_client.c.
References ast_strdup, AST_WS_TYPE_CLIENT_PER_CALL_CONFIG, AST_WS_TYPE_CLIENT_PERSISTENT, buf, and ast_websocket_client::connection_type.
|
static |
Definition at line 617 of file res_websocket_client.c.
|
static |
Definition at line 617 of file res_websocket_client.c.
|
static |
Definition at line 238 of file res_websocket_client.c.
Referenced by ast_websocket_client_get_field_diff(), ast_websocket_client_observer_add(), ast_websocket_client_observer_remove(), ast_websocket_client_reload(), ast_websocket_client_retrieve_all(), ast_websocket_client_retrieve_by_id(), load_module(), reload_module(), and unload_module().