Asterisk - The Open Source Telephony Project GIT-master-3dae2cf
|
#include "asterisk.h"
#include <signal.h>
#include <pjsip.h>
#include <pjsip_ua.h>
#include "asterisk/res_pjsip.h"
#include "asterisk/module.h"
#include "asterisk/astobj2.h"
#include "include/res_pjsip_private.h"
Go to the source code of this file.
Data Structures | |
struct | monitored_transport |
Structure for transport to be monitored. More... | |
Macros | |
#define | IDLE_TIMEOUT (pjsip_cfg()->tsx.td) |
#define | TRANSPORTS_BUCKETS 127 |
Number of buckets for monitored transports. More... | |
Functions | |
static void | __init_desc_storage (void) |
static | AO2_GLOBAL_OBJ_STATIC (monitored_transports) |
Global container of active transports. More... | |
void | ast_sip_destroy_transport_management (void) |
int | ast_sip_initialize_transport_management (void) |
static struct monitored_transport * | get_monitored_transport_by_name (const char *obj_name) |
static pj_bool_t | idle_monitor_on_rx_request (pjsip_rx_data *rdata) |
On incoming TCP connections, when we receive a SIP request, we mark that we have received a valid SIP request. This way, we will not shut the transport down for idleness. More... | |
static int | idle_sched_cb (const void *data) |
static int | idle_sched_cleanup (const void *data) |
static int | idle_sched_init_pj_thread (void) |
static void | keepalive_global_loaded (const char *object_type) |
static void | keepalive_transport_send_keepalive (struct monitored_transport *monitored) |
static void * | keepalive_transport_thread (void *data) |
Thread which sends keepalives to all active connection-oriented transports. More... | |
static int | monitored_transport_cmp_fn (void *obj, void *arg, int flags) |
Comparison function for monitored transport. More... | |
static void | monitored_transport_destroy (void *obj) |
Destructor for keepalive transport. More... | |
static int | monitored_transport_hash_fn (const void *obj, int flags) |
Hashing function for monitored transport. More... | |
static void | monitored_transport_state_callback (pjsip_transport *transport, pjsip_transport_state state, const pjsip_transport_state_info *info) |
Callback invoked when transport changes occur. More... | |
Variables | |
static struct ast_threadstorage | desc_storage = { .once = PTHREAD_ONCE_INIT , .key_init = __init_desc_storage , .custom_init = NULL , } |
static pjsip_module | idle_monitor_module |
static struct ast_sorcery_observer | keepalive_global_observer |
Observer which is used to update our interval when the global setting changes. More... | |
static unsigned int | keepalive_interval |
The global interval at which to send keepalives. More... | |
static const pj_str_t | keepalive_packet = { "\r\n\r\n", 4 } |
The keep alive packet to send. More... | |
static pthread_t | keepalive_thread = AST_PTHREADT_NULL |
Thread keeping things alive. More... | |
struct ast_sip_tpmgr_state_callback | monitored_transport_reg |
static struct ast_sched_context * | sched |
Scheduler context for timing out connections with no data received. More... | |
#define IDLE_TIMEOUT (pjsip_cfg()->tsx.td) |
Definition at line 34 of file pjsip_transport_management.c.
#define TRANSPORTS_BUCKETS 127 |
Number of buckets for monitored transports.
Definition at line 32 of file pjsip_transport_management.c.
|
static |
Definition at line 120 of file pjsip_transport_management.c.
|
static |
Global container of active transports.
void ast_sip_destroy_transport_management | ( | void | ) |
Definition at line 410 of file pjsip_transport_management.c.
References ao2_global_obj_release, AST_PTHREADT_NULL, ast_sched_clean_by_callback(), ast_sched_context_destroy(), ast_sip_get_sorcery(), ast_sip_transport_state_unregister(), ast_sip_unregister_service(), ast_sorcery_observer_remove(), idle_monitor_module, idle_sched_cb(), idle_sched_cleanup(), keepalive_global_observer, keepalive_interval, keepalive_thread, monitored_transport_reg, and NULL.
Referenced by unload_pjsip().
int ast_sip_initialize_transport_management | ( | void | ) |
Definition at line 372 of file pjsip_transport_management.c.
References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ao2_global_obj_release, ao2_global_obj_replace_unref, ao2_ref, ast_log, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_sched_context_create(), ast_sched_context_destroy(), ast_sched_start_thread(), ast_sip_get_sorcery(), ast_sip_register_service(), ast_sip_transport_state_register(), ast_sorcery_observer_add(), ast_sorcery_reload_object(), idle_monitor_module, keepalive_global_observer, LOG_ERROR, monitored_transport_cmp_fn(), monitored_transport_hash_fn(), monitored_transport_reg, NULL, and TRANSPORTS_BUCKETS.
Referenced by load_module().
|
static |
Definition at line 142 of file pjsip_transport_management.c.
References ao2_cleanup, ao2_find, ao2_global_obj_ref, NULL, and OBJ_SEARCH_KEY.
Referenced by idle_monitor_on_rx_request(), idle_sched_cb(), and idle_sched_cleanup().
|
static |
On incoming TCP connections, when we receive a SIP request, we mark that we have received a valid SIP request. This way, we will not shut the transport down for idleness.
Definition at line 353 of file pjsip_transport_management.c.
References ao2_ref, get_monitored_transport_by_name(), and monitored_transport::sip_received.
|
static |
Definition at line 157 of file pjsip_transport_management.c.
References ao2_ref, ast_free, ast_log, get_monitored_transport_by_name(), idle_sched_init_pj_thread(), IDLE_TIMEOUT, LOG_NOTICE, monitored_transport::sip_received, and monitored_transport::transport.
Referenced by ast_sip_destroy_transport_management(), and monitored_transport_state_callback().
|
static |
Definition at line 181 of file pjsip_transport_management.c.
References ao2_ref, ast_free, get_monitored_transport_by_name(), idle_sched_init_pj_thread(), and monitored_transport::transport.
Referenced by ast_sip_destroy_transport_management().
|
static |
Definition at line 122 of file pjsip_transport_management.c.
References ast_log, ast_threadstorage_get(), desc, desc_storage, LOG_ERROR, and thread.
Referenced by idle_sched_cb(), and idle_sched_cleanup().
|
static |
Definition at line 317 of file pjsip_transport_management.c.
References ast_log, ast_pthread_create, AST_PTHREADT_NULL, ast_sip_get_keep_alive_interval(), keepalive_interval, keepalive_thread, keepalive_transport_thread(), LOG_ERROR, LOG_NOTICE, and NULL.
|
static |
Definition at line 59 of file pjsip_transport_management.c.
References ast_sip_get_pjsip_endpoint(), keepalive_packet, NULL, and monitored_transport::transport.
Referenced by keepalive_transport_thread().
|
static |
Thread which sends keepalives to all active connection-oriented transports.
Definition at line 78 of file pjsip_transport_management.c.
References ao2_global_obj_ref, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_log, desc, keepalive_interval, keepalive_transport_send_keepalive(), LOG_ERROR, NULL, and thread.
Referenced by keepalive_global_loaded().
|
static |
Comparison function for monitored transport.
Definition at line 284 of file pjsip_transport_management.c.
References CMP_MATCH, OBJ_SEARCH_KEY, OBJ_SEARCH_MASK, OBJ_SEARCH_OBJECT, OBJ_SEARCH_PARTIAL_KEY, and monitored_transport::transport.
Referenced by ast_sip_initialize_transport_management().
|
static |
Destructor for keepalive transport.
Definition at line 202 of file pjsip_transport_management.c.
References monitored_transport::transport.
Referenced by monitored_transport_state_callback().
|
static |
Hashing function for monitored transport.
Definition at line 262 of file pjsip_transport_management.c.
References ast_assert, ast_str_hash(), OBJ_SEARCH_KEY, OBJ_SEARCH_MASK, and OBJ_SEARCH_OBJECT.
Referenced by ast_sip_initialize_transport_management().
|
static |
Callback invoked when transport changes occur.
Definition at line 210 of file pjsip_transport_management.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_find, ao2_global_obj_ref, ao2_link, ao2_ref, ast_free, ast_sched_add_variable(), ast_strdup, idle_sched_cb(), IDLE_TIMEOUT, keepalive_interval, monitored_transport_destroy(), OBJ_NODATA, OBJ_SEARCH_KEY, OBJ_UNLINK, and monitored_transport::transport.
|
static |
Definition at line 120 of file pjsip_transport_management.c.
Referenced by idle_sched_init_pj_thread().
|
static |
Definition at line 366 of file pjsip_transport_management.c.
Referenced by ast_sip_destroy_transport_management(), and ast_sip_initialize_transport_management().
|
static |
Observer which is used to update our interval when the global setting changes.
Definition at line 343 of file pjsip_transport_management.c.
Referenced by ast_sip_destroy_transport_management(), and ast_sip_initialize_transport_management().
|
static |
The global interval at which to send keepalives.
Definition at line 49 of file pjsip_transport_management.c.
Referenced by ast_sip_destroy_transport_management(), keepalive_global_loaded(), keepalive_transport_thread(), and monitored_transport_state_callback().
|
static |
The keep alive packet to send.
Definition at line 37 of file pjsip_transport_management.c.
Referenced by keepalive_transport_send_keepalive().
|
static |
Thread keeping things alive.
Definition at line 46 of file pjsip_transport_management.c.
Referenced by ast_sip_destroy_transport_management(), and keepalive_global_loaded().
struct ast_sip_tpmgr_state_callback monitored_transport_reg |
Definition at line 257 of file pjsip_transport_management.c.
Referenced by ast_sip_destroy_transport_management(), and ast_sip_initialize_transport_management().
|
static |
Scheduler context for timing out connections with no data received.
Definition at line 43 of file pjsip_transport_management.c.