Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
Manages the global transport event notification callbacks. More...
#include "asterisk.h"
#include "asterisk/res_pjsip.h"
#include "asterisk/res_pjsip_cli.h"
#include "include/res_pjsip_private.h"
#include "asterisk/linkedlists.h"
#include "asterisk/vector.h"
Go to the source code of this file.
Data Structures | |
struct | callback_data |
struct | transport_monitor |
Structure for transport to be monitored. More... | |
struct | transport_monitor_notifier |
Macros | |
#define | ACTIVE_TRANSPORTS_BUCKETS 127 |
Number of buckets for monitored active transports. More... | |
Functions | |
static | AO2_GLOBAL_OBJ_STATIC (active_transports) |
Global container of active reliable transports. More... | |
AO2_STRING_FIELD_CMP_FN (transport_monitor, key) | |
Comparison function for struct transport_monitor. More... | |
AO2_STRING_FIELD_HASH_FN (transport_monitor, key) | |
Hashing function for struct transport_monitor. More... | |
AO2_STRING_FIELD_SORT_FN (transport_monitor, key) | |
Sort function for struct transport_monitor. More... | |
void | ast_sip_destroy_transport_events (void) |
int | ast_sip_initialize_transport_events (void) |
enum ast_transport_monitor_reg | ast_sip_transport_monitor_register (pjsip_transport *transport, ast_transport_monitor_shutdown_cb cb, void *ao2_data) |
Register a reliable transport shutdown monitor callback. More... | |
enum ast_transport_monitor_reg | ast_sip_transport_monitor_register_key (const char *transport_key, ast_transport_monitor_shutdown_cb cb, void *ao2_data) |
Register a reliable transport shutdown monitor callback. More... | |
enum ast_transport_monitor_reg | ast_sip_transport_monitor_register_replace (pjsip_transport *transport, ast_transport_monitor_shutdown_cb cb, void *ao2_data, ast_transport_monitor_data_matcher matches) |
Register a reliable transport shutdown monitor callback replacing any duplicate. More... | |
enum ast_transport_monitor_reg | ast_sip_transport_monitor_register_replace_key (const char *transport_key, ast_transport_monitor_shutdown_cb cb, void *ao2_data, ast_transport_monitor_data_matcher matches) |
Register a reliable transport shutdown monitor callback replacing any duplicate. More... | |
void | ast_sip_transport_monitor_unregister (pjsip_transport *transport, ast_transport_monitor_shutdown_cb cb, void *data, ast_transport_monitor_data_matcher matches) |
Unregister a reliable transport shutdown monitor. More... | |
void | ast_sip_transport_monitor_unregister_all (ast_transport_monitor_shutdown_cb cb, void *data, ast_transport_monitor_data_matcher matches) |
Unregister a transport shutdown monitor from all reliable transports. More... | |
void | ast_sip_transport_monitor_unregister_key (const char *transport_key, ast_transport_monitor_shutdown_cb cb, void *data, ast_transport_monitor_data_matcher matches) |
Unregister a reliable transport shutdown monitor. More... | |
void | ast_sip_transport_state_register (struct ast_sip_tpmgr_state_callback *element) |
Register a transport state notification callback element. More... | |
void | ast_sip_transport_state_unregister (struct ast_sip_tpmgr_state_callback *element) |
Unregister a transport state notification callback element. More... | |
static char * | cli_show_monitors (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static int | ptr_matcher (void *a, void *b) |
static void | transport_monitor_dtor (void *vdoomed) |
static int | transport_monitor_unregister_cb (void *obj, void *arg, int flags) |
static const char * | transport_state2str (pjsip_transport_state state) |
static void | transport_state_callback (pjsip_transport *transport, pjsip_transport_state state, const pjsip_transport_state_info *info) |
Callback invoked when transport state changes occur. More... | |
static void | transport_state_do_reg_callbacks (struct ao2_container *transports, pjsip_transport *transport) |
static int | transport_tls_verify (const pjsip_transport *transport, const pjsip_tls_state_info *state_info) |
static int | verify_cert_name (const pj_str_t *local, const pj_str_t *remote) |
static int | verify_cert_names (const pj_str_t *host, const pj_ssl_cert_info *remote) |
static void | verify_log_result (int log_level, const pjsip_transport *transport, pj_uint32_t verify_status) |
Variables | |
static struct ast_cli_entry | cli_commands [] |
static pjsip_tp_state_callback | tpmgr_state_callback |
Existing transport events callback that we need to invoke. More... | |
struct { | |
struct ast_sip_tpmgr_state_callback * first | |
struct ast_sip_tpmgr_state_callback * last | |
ast_rwlock_t lock | |
} | transport_state_list |
Manages the global transport event notification callbacks.
Definition in file pjsip_transport_events.c.
#define ACTIVE_TRANSPORTS_BUCKETS 127 |
Number of buckets for monitored active transports.
Definition at line 41 of file pjsip_transport_events.c.
|
static |
Global container of active reliable transports.
AO2_STRING_FIELD_CMP_FN | ( | transport_monitor | , |
key | |||
) |
Comparison function for struct transport_monitor.
AO2_STRING_FIELD_HASH_FN | ( | transport_monitor | , |
key | |||
) |
Hashing function for struct transport_monitor.
AO2_STRING_FIELD_SORT_FN | ( | transport_monitor | , |
key | |||
) |
Sort function for struct transport_monitor.
void ast_sip_destroy_transport_events | ( | void | ) |
Definition at line 683 of file pjsip_transport_events.c.
References ao2_global_obj_release, ARRAY_LEN, ast_cli_unregister_multiple(), ast_sip_get_pjsip_endpoint(), cli_commands, and tpmgr_state_callback.
Referenced by unload_pjsip().
int ast_sip_initialize_transport_events | ( | void | ) |
Definition at line 697 of file pjsip_transport_events.c.
References ACTIVE_TRANSPORTS_BUCKETS, AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ao2_global_obj_replace_unref, ao2_ref, ARRAY_LEN, ast_cli_register_multiple, ast_sip_get_pjsip_endpoint(), cli_commands, tpmgr_state_callback, and transport_state_callback().
Referenced by load_module().
enum ast_transport_monitor_reg ast_sip_transport_monitor_register | ( | pjsip_transport * | transport, |
ast_transport_monitor_shutdown_cb | cb, | ||
void * | ao2_data | ||
) |
Register a reliable transport shutdown monitor callback.
transport | Transport to monitor for shutdown. |
cb | Who to call when transport is shutdown. |
ao2_data | Data to pass with the callback. |
There is no checking for duplicate registrations.
Definition at line 478 of file pjsip_transport_events.c.
References AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR, ast_sip_transport_monitor_register_replace_key(), callback_data::cb, IP6ADDR_COLON_PORT_BUFLEN, and NULL.
enum ast_transport_monitor_reg ast_sip_transport_monitor_register_key | ( | const char * | transport_key, |
ast_transport_monitor_shutdown_cb | cb, | ||
void * | ao2_data | ||
) |
Register a reliable transport shutdown monitor callback.
transport_key | Key for the transport to monitor for shutdown. Create the key with AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR. |
cb | Who to call when transport is shutdown. |
ao2_data | Data to pass with the callback. |
There is no checking for duplicate registrations.
Definition at line 487 of file pjsip_transport_events.c.
References ast_sip_transport_monitor_register_replace_key(), callback_data::cb, and NULL.
Referenced by subscription_persistence_update().
enum ast_transport_monitor_reg ast_sip_transport_monitor_register_replace | ( | pjsip_transport * | transport, |
ast_transport_monitor_shutdown_cb | cb, | ||
void * | ao2_data, | ||
ast_transport_monitor_data_matcher | matches | ||
) |
Register a reliable transport shutdown monitor callback replacing any duplicate.
transport | Transport to monitor for shutdown. |
cb | Who to call when transport is shutdown. |
ao2_data | Data to pass with the callback. |
matches | Matcher function that returns true if data matches a previously registered data object |
This function checks for duplicates, and overwrites/replaces the old monitor with the given one.
Definition at line 493 of file pjsip_transport_events.c.
References AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR, ast_sip_transport_monitor_register_replace_key(), callback_data::cb, IP6ADDR_COLON_PORT_BUFLEN, and NULL.
enum ast_transport_monitor_reg ast_sip_transport_monitor_register_replace_key | ( | const char * | transport_key, |
ast_transport_monitor_shutdown_cb | cb, | ||
void * | ao2_data, | ||
ast_transport_monitor_data_matcher | matches | ||
) |
Register a reliable transport shutdown monitor callback replacing any duplicate.
transport_key | Key for the transport to monitor for shutdown. Create the key with AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR. |
cb | Who to call when transport is shutdown. |
ao2_data | Data to pass with the callback. |
matches | Matcher function that returns true if data matches a previously registered data object |
This function checks for duplicates, and overwrites/replaces the old monitor with the given one.
Definition at line 502 of file pjsip_transport_events.c.
References ao2_bump, ao2_cleanup, ao2_find, ao2_global_obj_ref, ao2_lock, ao2_ref, ao2_unlock, ast_assert, ast_debug, AST_TRANSPORT_MONITOR_REG_FAILED, AST_TRANSPORT_MONITOR_REG_NOT_FOUND, AST_TRANSPORT_MONITOR_REG_SUCCESS, AST_VECTOR_APPEND, transport_monitor_notifier::cb, callback_data::cb, transport_monitor_notifier::data, transport_monitor::key, callback_data::matches, transport_monitor::monitors, NULL, OBJ_NOLOCK, OBJ_SEARCH_KEY, ptr_matcher(), transport_monitor::transport, transport_monitor_unregister_cb(), and transport_monitor::transport_obj_name.
Referenced by ast_sip_transport_monitor_register(), ast_sip_transport_monitor_register_key(), ast_sip_transport_monitor_register_replace(), and registration_transport_monitor_setup().
void ast_sip_transport_monitor_unregister | ( | pjsip_transport * | transport, |
ast_transport_monitor_shutdown_cb | cb, | ||
void * | data, | ||
ast_transport_monitor_data_matcher | matches | ||
) |
Unregister a reliable transport shutdown monitor.
transport | Transport to monitor for shutdown. |
cb | The callback that was used for the original register. |
data | Data to pass to the matcher. May be NULL and does NOT need to be an ao2 object. If NULL, all monitors with the provided callback are unregistered. |
matches | Matcher function that returns true if data matches the previously registered data object. If NULL, a simple pointer comparison is done. |
Definition at line 441 of file pjsip_transport_events.c.
References AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR, ast_sip_transport_monitor_unregister_key(), callback_data::cb, callback_data::data, IP6ADDR_COLON_PORT_BUFLEN, and callback_data::matches.
Referenced by registrar_contact_delete().
void ast_sip_transport_monitor_unregister_all | ( | ast_transport_monitor_shutdown_cb | cb, |
void * | data, | ||
ast_transport_monitor_data_matcher | matches | ||
) |
Unregister a transport shutdown monitor from all reliable transports.
cb | The callback that was used for the original register. |
data | Data to pass to the matcher. May be NULL and does NOT need to be an ao2 object. If NULL, all monitors with the provided callback are unregistered. |
matches | Matcher function that returns true if ao2_data matches the previously registered data object. If NULL, a simple pointer comparison is done. |
Definition at line 421 of file pjsip_transport_events.c.
References ao2_callback, ao2_global_obj_ref, ao2_ref, ast_assert, callback_data::cb, callback_data::data, callback_data::matches, NULL, OBJ_MULTIPLE, OBJ_NODATA, ptr_matcher(), and transport_monitor_unregister_cb().
Referenced by registrar_contact_delete(), and unload_module().
void ast_sip_transport_monitor_unregister_key | ( | const char * | transport_key, |
ast_transport_monitor_shutdown_cb | cb, | ||
void * | data, | ||
ast_transport_monitor_data_matcher | matches | ||
) |
Unregister a reliable transport shutdown monitor.
transport_key | Key for the transport to monitor for shutdown. Create the key with AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR. |
cb | The callback that was used for the original register. |
data | Data to pass to the matcher. May be NULL and does NOT need to be an ao2 object. If NULL, all monitors with the provided callback are unregistered. |
matches | Matcher function that returns true if data matches the previously registered data object. If NULL, a simple pointer comparison is done. |
Definition at line 449 of file pjsip_transport_events.c.
References ao2_find, ao2_global_obj_ref, ao2_lock, ao2_ref, ao2_unlock, ast_assert, callback_data::cb, callback_data::data, callback_data::matches, NULL, OBJ_NOLOCK, OBJ_SEARCH_KEY, ptr_matcher(), and transport_monitor_unregister_cb().
Referenced by ast_sip_transport_monitor_unregister(), handle_registration_response(), and subscription_persistence_remove().
void ast_sip_transport_state_register | ( | struct ast_sip_tpmgr_state_callback * | element | ) |
Register a transport state notification callback element.
element | What we are registering. |
Definition at line 559 of file pjsip_transport_events.c.
References AST_LIST_INSERT_HEAD, AST_LIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and transport_state_list.
Referenced by ast_sip_initialize_transport_management().
void ast_sip_transport_state_unregister | ( | struct ast_sip_tpmgr_state_callback * | element | ) |
Unregister a transport state notification callback element.
element | What we are unregistering. |
Definition at line 552 of file pjsip_transport_events.c.
References AST_LIST_REMOVE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and transport_state_list.
Referenced by ast_sip_destroy_transport_management().
|
static |
Definition at line 575 of file pjsip_transport_events.c.
References a, AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_cleanup, ao2_container_alloc_rbtree, ao2_container_count(), ao2_container_dup(), ao2_global_obj_ref, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, AO2_ITERATOR_UNLINK, ao2_lock, ao2_ref, ao2_unlock, ast_cli(), AST_VECTOR_SIZE, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, error(), transport_monitor::key, transport_monitor::monitors, NULL, regex(), state, transport_monitor::transport, and ast_cli_entry::usage.
|
static |
Definition at line 416 of file pjsip_transport_events.c.
Referenced by ast_sip_transport_monitor_register_replace_key(), ast_sip_transport_monitor_unregister_all(), and ast_sip_transport_monitor_unregister_key().
|
static |
Definition at line 112 of file pjsip_transport_events.c.
References ao2_cleanup, ast_debug, ast_free, AST_VECTOR_FREE, AST_VECTOR_GET_ADDR, AST_VECTOR_SIZE, transport_monitor_notifier::data, transport_monitor::key, transport_monitor::monitors, transport_monitor::transport, and transport_monitor::transport_obj_name.
Referenced by transport_state_callback().
|
static |
Definition at line 393 of file pjsip_transport_events.c.
References ao2_cleanup, ast_debug, AST_VECTOR_GET_ADDR, AST_VECTOR_REMOVE_UNORDERED, AST_VECTOR_SIZE, transport_monitor_notifier::cb, callback_data::cb, transport_monitor_notifier::data, callback_data::data, transport_monitor::key, callback_data::matches, transport_monitor::monitors, transport_monitor::transport, and transport_monitor::transport_obj_name.
Referenced by ast_sip_transport_monitor_register_replace_key(), ast_sip_transport_monitor_unregister_all(), and ast_sip_transport_monitor_unregister_key().
|
static |
Definition at line 83 of file pjsip_transport_events.c.
References ast_assert, and name.
Referenced by transport_state_callback().
|
static |
Callback invoked when transport state changes occur.
Definition at line 293 of file pjsip_transport_events.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_global_obj_ref, ao2_link, ao2_ref, ast_assert, ast_copy_string(), ast_debug, AST_LIST_EMPTY, AST_LIST_TRAVERSE, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR, ast_strdup, AST_VECTOR_INIT, ast_sip_tpmgr_state_callback::cb, sip_to_pjsip::info(), IP6ADDR_COLON_PORT_BUFLEN, transport_monitor::key, transport_monitor::monitors, tpmgr_state_callback, transport_monitor::transport, transport_monitor_dtor(), transport_monitor::transport_obj_name, transport_state2str(), transport_state_do_reg_callbacks(), transport_state_list, and transport_tls_verify().
Referenced by ast_sip_initialize_transport_events().
|
static |
Definition at line 139 of file pjsip_transport_events.c.
References ao2_find, ao2_iterator_destroy(), ao2_iterator_next, ao2_ref, ao2_unlink, ast_debug, AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR, AST_VECTOR_GET_ADDR, AST_VECTOR_SIZE, transport_monitor_notifier::cb, transport_monitor_notifier::data, IP6ADDR_COLON_PORT_BUFLEN, transport_monitor::key, transport_monitor::monitors, OBJ_MULTIPLE, OBJ_SEARCH_KEY, and transport_monitor::transport.
Referenced by transport_state_callback().
|
static |
Definition at line 243 of file pjsip_transport_events.c.
References __LOG_ERROR, __LOG_NOTICE, ast_assert, ast_log, ast_sip_get_transport_state(), ast_strlen_zero(), LOG_ERROR, state, ast_sip_transport_state::transport, verify_cert_names(), and verify_log_result().
Referenced by transport_state_callback().
|
static |
Definition at line 197 of file pjsip_transport_events.c.
References ast_debug.
Referenced by verify_cert_names().
|
static |
Definition at line 225 of file pjsip_transport_events.c.
References verify_cert_name().
Referenced by transport_tls_verify().
|
static |
Definition at line 173 of file pjsip_transport_events.c.
References _A_, ARRAY_LEN, ast_log, AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR, IP6ADDR_COLON_PORT_BUFLEN, LOG_ERROR, log_level, and status.
Referenced by transport_tls_verify().
|
static |
Definition at line 679 of file pjsip_transport_events.c.
Referenced by ast_sip_destroy_transport_events(), and ast_sip_initialize_transport_events().
struct ast_sip_tpmgr_state_callback* first |
Definition at line 72 of file pjsip_transport_events.c.
struct ast_sip_tpmgr_state_callback* last |
Definition at line 72 of file pjsip_transport_events.c.
ast_rwlock_t lock |
Definition at line 72 of file pjsip_transport_events.c.
|
static |
Existing transport events callback that we need to invoke.
Definition at line 69 of file pjsip_transport_events.c.
Referenced by ast_sip_destroy_transport_events(), ast_sip_initialize_transport_events(), and transport_state_callback().
struct { ... } transport_state_list |
List of registered transport state callbacks.
Referenced by ast_sip_transport_state_register(), ast_sip_transport_state_unregister(), and transport_state_callback().