Asterisk - The Open Source Telephony Project
18.5.0
|
Manages the global transport event notification callbacks. More...
#include "asterisk.h"
#include "asterisk/res_pjsip.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, transport->obj_name) | |
Comparison function for struct transport_monitor. More... | |
AO2_STRING_FIELD_HASH_FN (transport_monitor, transport->obj_name) | |
Hashing 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_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... | |
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_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 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) |
Variables | |
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 40 of file pjsip_transport_events.c.
Referenced by ast_sip_initialize_transport_events().
|
static |
Global container of active reliable transports.
AO2_STRING_FIELD_CMP_FN | ( | transport_monitor | , |
transport-> | obj_name | ||
) |
Comparison function for struct transport_monitor.
AO2_STRING_FIELD_HASH_FN | ( | transport_monitor | , |
transport-> | obj_name | ||
) |
Hashing function for struct transport_monitor.
void ast_sip_destroy_transport_events | ( | void | ) |
Definition at line 382 of file pjsip_transport_events.c.
References ao2_global_obj_release, ast_sip_get_pjsip_endpoint(), and tpmgr_state_callback.
Referenced by unload_pjsip().
int ast_sip_initialize_transport_events | ( | void | ) |
Definition at line 394 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, ast_sip_get_pjsip_endpoint(), NULL, 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 306 of file pjsip_transport_events.c.
References ast_sip_transport_monitor_register_replace(), and NULL.
Referenced by registration_transport_monitor_setup(), and 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 312 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, NULL, OBJ_NOLOCK, OBJ_SEARCH_KEY, ptr_matcher(), and transport_monitor_unregister_cb().
Referenced by ast_sip_transport_monitor_register(), and register_aor_core().
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 callbck 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 277 of file pjsip_transport_events.c.
References ao2_find, ao2_global_obj_ref, ao2_lock, ao2_ref, ao2_unlock, ast_assert, transport_monitor_notifier::cb, callback_data::cb, transport_monitor_notifier::data, NULL, OBJ_NOLOCK, OBJ_SEARCH_KEY, ptr_matcher(), and transport_monitor_unregister_cb().
Referenced by handle_registration_response(), registrar_contact_delete(), and subscription_persistence_remove().
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 callbck 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 257 of file pjsip_transport_events.c.
References ao2_callback, ao2_global_obj_ref, ao2_ref, ast_assert, transport_monitor_notifier::cb, callback_data::cb, transport_monitor_notifier::data, NULL, OBJ_MULTIPLE, OBJ_NODATA, ptr_matcher(), and transport_monitor_unregister_cb().
Referenced by registrar_contact_delete(), and unload_module().
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 366 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 359 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 252 of file pjsip_transport_events.c.
References b.
Referenced by ast_sip_transport_monitor_register_replace(), ast_sip_transport_monitor_unregister(), and ast_sip_transport_monitor_unregister_all().
|
static |
Definition at line 103 of file pjsip_transport_events.c.
References ao2_cleanup, AST_VECTOR_FREE, AST_VECTOR_GET_ADDR, AST_VECTOR_SIZE, and transport_monitor_notifier::data.
Referenced by transport_state_callback().
|
static |
Definition at line 231 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, callback_data::matches, and transport_monitor::transport.
Referenced by ast_sip_transport_monitor_register_replace(), ast_sip_transport_monitor_unregister(), and ast_sip_transport_monitor_unregister_all().
|
static |
Definition at line 74 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 148 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_debug, AST_LIST_EMPTY, AST_LIST_TRAVERSE, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, AST_VECTOR_INIT, ast_sip_tpmgr_state_callback::cb, tpmgr_state_callback, transport_monitor::transport, transport_monitor_dtor(), transport_state2str(), transport_state_do_reg_callbacks(), and transport_state_list.
Referenced by ast_sip_initialize_transport_events().
|
static |
Definition at line 127 of file pjsip_transport_events.c.
References ao2_find, ao2_ref, ast_debug, AST_VECTOR_GET_ADDR, AST_VECTOR_SIZE, transport_monitor_notifier::cb, transport_monitor_notifier::data, OBJ_SEARCH_KEY, and OBJ_UNLINK.
Referenced by transport_state_callback().
struct ast_sip_tpmgr_state_callback* first |
Definition at line 65 of file pjsip_transport_events.c.
struct ast_sip_tpmgr_state_callback* last |
Definition at line 65 of file pjsip_transport_events.c.
ast_rwlock_t lock |
Definition at line 65 of file pjsip_transport_events.c.
|
static |
Existing transport events callback that we need to invoke.
Definition at line 62 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().