Asterisk - The Open Source Telephony Project GIT-master-b023714
|
#include "asterisk.h"
#include <signal.h>
#include <pjsip.h>
#include <pjsip_ua.h>
#include "asterisk/res_pjsip.h"
#include "asterisk/module.h"
#include "asterisk/paths.h"
#include "asterisk/test.h"
#include "asterisk/taskprocessor.h"
#include "asterisk/manager.h"
#include "asterisk/named_locks.h"
#include "asterisk/res_pjproject.h"
#include "res_pjsip/include/res_pjsip_private.h"
Go to the source code of this file.
Data Structures | |
struct | aor_core_response |
struct | contact_transport_monitor |
struct | excess_contact_vector |
struct | registrar_contact_details |
Structure used for finding contact. More... | |
Macros | |
#define | AMI_SHOW_REGISTRATION_CONTACT_STATUSES "PJSIPShowRegistrationInboundContactStatuses" |
#define | AMI_SHOW_REGISTRATIONS "PJSIPShowRegistrationsInbound" |
Enumerations | |
enum | contact_delete_type { CONTACT_DELETE_ERROR , CONTACT_DELETE_EXISTING , CONTACT_DELETE_UNAVAILABLE , CONTACT_DELETE_EXPIRE , CONTACT_DELETE_REQUEST , CONTACT_DELETE_SHUTDOWN } |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static int | ami_registrations_aor (void *obj, void *arg, int flags) |
static int | ami_registrations_endpoint (void *obj, void *arg, int flags) |
static int | ami_registrations_endpoints (void *arg) |
static int | ami_show_registration_contact_statuses (struct mansession *s, const struct message *m) |
static int | ami_show_registrations (struct mansession *s, const struct message *m) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
static int | build_path_data (pjsip_rx_data *rdata, struct ast_str **path_str) |
static void * | check_expiration_thread (void *data) |
static int | contact_transport_monitor_matcher (void *a, void *b) |
static void | expiration_global_loaded (const char *object_type) |
static int | expire_contact (void *obj, void *arg, int flags) |
Callback function which deletes a contact. | |
static char * | find_aor_name (const pj_str_t *pj_username, const pj_str_t *pj_domain, const char *aors) |
static struct ast_sip_aor * | find_registrar_aor (struct pjsip_rx_data *rdata, struct ast_sip_endpoint *endpoint) |
static int | load_module (void) |
static int | match_aor (const char *aor_name, const char *id) |
static int | register_aor (pjsip_rx_data *rdata, struct ast_sip_endpoint *endpoint, struct ast_sip_aor *aor, const char *aor_name) |
static void | register_aor_core (pjsip_rx_data *rdata, struct ast_sip_endpoint *endpoint, struct ast_sip_aor *aor, const char *aor_name, struct ao2_container *contacts, struct aor_core_response *response) |
static int | register_contact_transport_remove_cb (void *data) |
static void | register_contact_transport_shutdown_cb (void *data) |
static int | registrar_add_contact (void *obj, void *arg, int flags) |
Internal function which adds a contact to a response. | |
static int | registrar_add_non_permanent (void *obj, void *arg, int flags) |
Callback function which adds non-permanent contacts to a container. | |
static int | registrar_add_unreachable (void *obj, void *arg, int flags) |
Internal callback function which adds any contact which is unreachable. | |
static int | registrar_contact_delete (enum contact_delete_type type, pjsip_transport *transport, struct ast_sip_contact *contact, const char *aor_name) |
static int | registrar_delete_contact (void *obj, void *arg, int flags) |
Internal function used to delete a contact from an AOR. | |
static int | registrar_find_contact (void *obj, void *arg, int flags) |
Callback function for finding a contact. | |
static unsigned int | registrar_get_expiration (const struct ast_sip_aor *aor, const pjsip_contact_hdr *contact, const pjsip_rx_data *rdata) |
Internal function which returns the expiration time for a contact. | |
static pj_bool_t | registrar_on_rx_request (struct pjsip_rx_data *rdata) |
static int | registrar_validate_contacts (const pjsip_rx_data *rdata, pj_pool_t *pool, struct ao2_container *contacts, struct ast_sip_aor *aor, int permanent, int *added, int *updated, int *deleted) |
Internal function which validates provided Contact headers to confirm that they are acceptable, and returns number of contacts. | |
static int | registrar_validate_path (pjsip_rx_data *rdata, struct ast_sip_aor *aor, struct ast_str **path_str) |
static void | remove_excess_contacts (struct ao2_container *contacts, struct ao2_container *response_contacts, unsigned int to_remove, unsigned int remove_existing) |
static int | sip_contact_to_str (void *acp, void *arg, int flags) |
static int | unload_module (void) |
static int | vec_contact_add (void *obj, void *arg, int flags) |
static int | vec_contact_cmp (struct ast_sip_contact *left, struct ast_sip_contact *right) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "PJSIP Registrar Support" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND - 3, .requires = "res_pjproject,res_pjsip", } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static unsigned int | check_interval |
The global interval at which to check for contact expiration. | |
static pthread_t | check_thread = AST_PTHREADT_NULL |
Thread keeping things alive. | |
static struct ast_sorcery_observer | expiration_global_observer |
Observer which is used to update our interval when the global setting changes. | |
static const pj_str_t | path_hdr_name = { "Path", 4 } |
static int | pj_max_hostname = PJ_MAX_HOSTNAME |
static int | pjsip_max_url_size = PJSIP_MAX_URL_SIZE |
static pjsip_module | registrar_module |
#define AMI_SHOW_REGISTRATION_CONTACT_STATUSES "PJSIPShowRegistrationInboundContactStatuses" |
Definition at line 1396 of file res_pjsip_registrar.c.
#define AMI_SHOW_REGISTRATIONS "PJSIPShowRegistrationsInbound" |
Definition at line 1397 of file res_pjsip_registrar.c.
enum contact_delete_type |
Enumerator | |
---|---|
CONTACT_DELETE_ERROR | |
CONTACT_DELETE_EXISTING | |
CONTACT_DELETE_UNAVAILABLE | |
CONTACT_DELETE_EXPIRE | |
CONTACT_DELETE_REQUEST | |
CONTACT_DELETE_SHUTDOWN |
Definition at line 276 of file res_pjsip_registrar.c.
|
static |
Definition at line 1547 of file res_pjsip_registrar.c.
|
static |
Definition at line 1547 of file res_pjsip_registrar.c.
|
static |
Definition at line 1304 of file res_pjsip_registrar.c.
References ast_sip_ami::arg, ast_free, ast_sip_create_ami_event(), ast_sip_for_each_contact(), ast_sip_sorcery_object_to_ami(), ast_str_append(), ast_str_buffer(), astman_append(), buf, ast_sip_ami::count, RAII_VAR, ast_sip_ami::s, and sip_contact_to_str().
Referenced by ami_registrations_endpoint().
|
static |
Definition at line 1326 of file res_pjsip_registrar.c.
References ami_registrations_aor(), ast_sip_endpoint::aors, and ast_sip_for_each_aor().
Referenced by ami_registrations_endpoints().
|
static |
Definition at line 1333 of file res_pjsip_registrar.c.
References ami_registrations_endpoint(), ao2_callback, ao2_cleanup, ast_sip_get_endpoints(), endpoints, OBJ_NODATA, and RAII_VAR.
Referenced by ami_show_registrations().
|
static |
Definition at line 1361 of file res_pjsip_registrar.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_sip_contact::aor, ast_sip_contact_wrapper::aor_id, AST_RETRIEVE_FLAG_ALL, AST_RETRIEVE_FLAG_MULTIPLE, ast_sip_format_contact_ami(), ast_sip_get_sorcery(), ast_sorcery_object_get_id(), ast_sorcery_retrieve_by_fields(), astman_get_header(), astman_send_list_complete_end(), astman_send_list_complete_start(), astman_send_listack(), ast_sip_contact_wrapper::contact, ast_sip_contact_wrapper::contact_id, ast_sip_ami::count, ast_sip_ami::m, NULL, and ast_sip_ami::s.
Referenced by load_module().
|
static |
Definition at line 1346 of file res_pjsip_registrar.c.
References ami_registrations_endpoints(), astman_get_header(), astman_send_list_complete_end(), astman_send_list_complete_start(), astman_send_listack(), ast_sip_ami::count, ast_sip_ami::m, and ast_sip_ami::s.
Referenced by load_module().
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 1547 of file res_pjsip_registrar.c.
|
static |
Definition at line 325 of file res_pjsip_registrar.c.
References ast_str_append(), ast_str_create, ast_str_set(), NULL, and path_hdr_name.
Referenced by registrar_validate_path().
|
static |
Definition at line 1437 of file res_pjsip_registrar.c.
References ao2_callback, ao2_container_count(), ao2_ref, ast_debug, AST_RETRIEVE_FLAG_MULTIPLE, ast_sip_get_sorcery(), ast_sorcery_retrieve_by_fields(), AST_TIME_T_LEN, ast_time_t_to_string(), ast_tvnow(), ast_variable_new, ast_variables_destroy(), check_interval, expire_contact(), NULL, OBJ_NODATA, and var.
Referenced by expiration_global_loaded().
|
static |
Definition at line 394 of file res_pjsip_registrar.c.
References a, contact_transport_monitor::aor_name, b, and contact_transport_monitor::contact_name.
Referenced by register_aor_core(), and registrar_contact_delete().
|
static |
Definition at line 1466 of file res_pjsip_registrar.c.
References ast_debug, ast_log, ast_pthread_create_background, AST_PTHREADT_NULL, ast_sip_get_contact_expiration_check_interval(), check_expiration_thread(), check_interval, check_thread, LOG_ERROR, and NULL.
|
static |
Callback function which deletes a contact.
Definition at line 1413 of file res_pjsip_registrar.c.
References ao2_lock, ao2_unlock, ast_sip_contact::aor, ast_named_lock_get, ast_named_lock_put, AST_NAMED_LOCK_TYPE_MUTEX, ast_tvdiff_ms(), ast_tvnow(), CONTACT_DELETE_EXPIRE, ast_sip_contact::expiration_time, lock, NULL, and registrar_contact_delete().
Referenced by check_expiration_thread().
|
static |
Definition at line 1118 of file res_pjsip_registrar.c.
References ao2_cleanup, ast_alloca, ast_copy_pj_str(), ast_sip_get_sorcery(), ast_sorcery_retrieve_by_id(), ast_strdup, ast_strdupa, ast_strip(), ast_strlen_zero(), ast_sip_domain_alias::domain, match_aor(), NULL, and strsep().
Referenced by find_registrar_aor().
|
static |
Definition at line 1178 of file res_pjsip_registrar.c.
References ast_sip_endpoint::aors, ast_debug, ast_free, ast_log, AST_SIP_ENDPOINT_IDENTIFY_BY_AUTH_USERNAME, AST_SIP_ENDPOINT_IDENTIFY_BY_USERNAME, ast_sip_get_ignore_uri_user_options(), ast_sip_get_pjsip_endpoint(), ast_sip_location_retrieve_aor(), ast_sip_report_req_no_support(), ast_sorcery_object_get_id(), ast_strlen_zero(), AST_VECTOR_GET, AST_VECTOR_SIZE, find_aor_name(), ast_sip_endpoint::ident_method_order, LOG_WARNING, header::next, and NULL.
Referenced by registrar_on_rx_request().
|
static |
Definition at line 1494 of file res_pjsip_registrar.c.
References ami_show_registration_contact_statuses(), AMI_SHOW_REGISTRATION_CONTACT_STATUSES, ami_show_registrations(), AMI_SHOW_REGISTRATIONS, ast_manager_register_xml, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_pjproject_get_buildopt(), ast_sip_get_pjsip_endpoint(), ast_sip_get_sorcery(), ast_sip_register_service(), ast_sip_unregister_service(), ast_sorcery_observer_add(), ast_sorcery_reload_object(), EVENT_FLAG_SYSTEM, expiration_global_observer, NULL, pj_max_hostname, pjsip_max_url_size, and registrar_module.
|
static |
Definition at line 1104 of file res_pjsip_registrar.c.
References ast_debug, and ast_strlen_zero().
Referenced by find_aor_name().
|
static |
Definition at line 1071 of file res_pjsip_registrar.c.
References ao2_cleanup, ao2_lock, ao2_unlock, ast_sip_get_pjsip_endpoint(), ast_sip_location_retrieve_aor_contacts_nolock(), ast_sip_send_stateful_response(), aor_core_response::code, NULL, register_aor_core(), and aor_core_response::tdata.
Referenced by registrar_on_rx_request().
|
static |
Definition at line 725 of file res_pjsip_registrar.c.
References ao2_alloc, AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_callback, ao2_cleanup, ao2_container_alloc_list, ao2_container_count(), ao2_link, ao2_ref, ao2_unlink, ast_sip_contact::aor, contact_transport_monitor::aor_name, ast_alloca, ast_config_AST_SYSTEM_NAME, ast_copy_pj_str(), ast_copy_string(), ast_debug, ast_free, ast_log, ast_samp2tv(), ast_sip_add_date_header(), ast_sip_create_response(), ast_sip_get_pjsip_endpoint(), ast_sip_get_sorcery(), ast_sip_location_create_contact(), ast_sip_location_update_contact(), ast_sip_report_failed_acl(), ast_sip_transport_monitor_register_replace(), ast_sip_will_uri_survive_restart(), ast_sorcery_copy(), ast_sorcery_object_get_id(), ast_sorcery_object_id_compare(), ast_str_buffer(), ast_string_field_set, ast_strlen_zero(), ast_test_suite_event_notify, ast_tvadd(), ast_tvnow(), ast_verb, ast_sip_contact::authenticate_qualify, ast_sip_contact::call_id, aor_core_response::code, CONTACT_DELETE_ERROR, CONTACT_DELETE_REQUEST, contact_transport_monitor::contact_name, contact_transport_monitor_matcher(), ast_sip_contact::endpoint, ast_sip_contact::expiration_time, LOG_ERROR, LOG_WARNING, MAX, NULL, OBJ_MULTIPLE, OBJ_NODATA, OBJ_UNLINK, ast_sip_contact::path, pjsip_max_url_size, registrar_contact_details::pool, ast_sip_contact::prune_on_boot, ast_sip_contact::qualify_2xx_only, ast_sip_contact::qualify_frequency, RAII_VAR, ast_sip_contact::reg_server, register_contact_transport_shutdown_cb(), registrar_add_contact(), registrar_add_non_permanent(), registrar_add_unreachable(), registrar_contact_delete(), registrar_delete_contact(), registrar_find_contact(), registrar_get_expiration(), registrar_validate_contacts(), registrar_validate_path(), remove_excess_contacts(), aor_core_response::tdata, registrar_contact_details::uri, ast_sip_contact::user_agent, ast_sip_contact::via_addr, and ast_sip_contact::via_port.
Referenced by register_aor().
|
static |
Definition at line 403 of file res_pjsip_registrar.c.
References ao2_lock, ao2_ref, ao2_unlock, contact_transport_monitor::aor_name, ast_sip_location_retrieve_aor(), ast_sip_location_retrieve_contact(), CONTACT_DELETE_SHUTDOWN, contact_transport_monitor::contact_name, NULL, registrar_contact_delete(), and contact_transport_monitor::removing.
Referenced by register_contact_transport_shutdown_cb().
|
static |
Definition at line 440 of file res_pjsip_registrar.c.
References ao2_lock, ao2_ref, ao2_unlock, ast_sip_push_task(), NULL, register_contact_transport_remove_cb(), and contact_transport_monitor::removing.
Referenced by register_aor_core(), registrar_contact_delete(), and unload_module().
|
static |
Internal function which adds a contact to a response.
Definition at line 296 of file res_pjsip_registrar.c.
References ast_sip_contact::aor, ast_log, ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), ast_sip_contact::expiration_time, LOG_WARNING, PJSIP_EXPIRES_NOT_SPECIFIED, and ast_sip_contact::uri.
Referenced by register_aor_core().
|
static |
Callback function which adds non-permanent contacts to a container.
Definition at line 681 of file res_pjsip_registrar.c.
References ao2_link, ast_tvzero(), container, and ast_sip_contact::expiration_time.
Referenced by register_aor_core().
|
static |
Internal callback function which adds any contact which is unreachable.
Definition at line 696 of file res_pjsip_registrar.c.
References ao2_link, ao2_ref, ast_sip_get_contact_status(), container, status, and UNAVAILABLE.
Referenced by register_aor_core().
|
static |
Definition at line 474 of file res_pjsip_registrar.c.
References contact_transport_monitor::aor_name, ast_alloca, ast_copy_string(), ast_sip_location_delete_contact(), ast_sip_transport_monitor_unregister(), ast_sip_transport_monitor_unregister_all(), ast_sorcery_object_get_id(), ast_test_suite_event_notify, ast_tvzero(), ast_verb, CONTACT_DELETE_ERROR, CONTACT_DELETE_EXISTING, CONTACT_DELETE_EXPIRE, CONTACT_DELETE_REQUEST, CONTACT_DELETE_SHUTDOWN, CONTACT_DELETE_UNAVAILABLE, contact_transport_monitor::contact_name, contact_transport_monitor_matcher(), ast_sip_contact::expiration_time, ast_sip_contact::prune_on_boot, register_contact_transport_shutdown_cb(), type, ast_sip_contact::uri, ast_sip_contact::user_agent, and VERBOSITY_ATLEAST.
Referenced by expire_contact(), register_aor_core(), register_contact_transport_remove_cb(), registrar_delete_contact(), and remove_excess_contacts().
|
static |
Internal function used to delete a contact from an AOR.
Definition at line 289 of file res_pjsip_registrar.c.
References CMP_MATCH, CONTACT_DELETE_REQUEST, NULL, and registrar_contact_delete().
Referenced by register_aor_core().
|
static |
Callback function for finding a contact.
Definition at line 193 of file res_pjsip_registrar.c.
References ast_log, ast_tvzero(), CMP_MATCH, ast_sip_contact::expiration_time, LOG_WARNING, registrar_contact_details::pool, ast_sip_contact::uri, and registrar_contact_details::uri.
Referenced by register_aor_core(), and registrar_validate_contacts().
|
static |
Internal function which returns the expiration time for a contact.
Definition at line 156 of file res_pjsip_registrar.c.
References ast_sip_aor::default_expiration, ast_sip_aor::maximum_expiration, ast_sip_aor::minimum_expiration, NULL, and PJSIP_EXPIRES_NOT_SPECIFIED.
Referenced by register_aor_core(), and registrar_validate_contacts().
|
static |
Definition at line 1247 of file res_pjsip_registrar.c.
References ao2_cleanup, ao2_ref, ast_log, ast_pjsip_rdata_get_endpoint(), ast_sip_get_pjsip_endpoint(), ast_sip_report_failed_acl(), ast_sip_report_req_no_support(), ast_sorcery_object_get_id(), ast_strlen_zero(), find_registrar_aor(), LOG_WARNING, ast_sip_aor::max_contacts, NULL, RAII_VAR, and register_aor().
|
static |
Internal function which validates provided Contact headers to confirm that they are acceptable, and returns number of contacts.
Definition at line 213 of file res_pjsip_registrar.c.
References ao2_callback, ao2_cleanup, ao2_container_count(), NULL, pj_max_hostname, pjsip_max_url_size, registrar_contact_details::pool, registrar_find_contact(), registrar_get_expiration(), and registrar_contact_details::uri.
Referenced by register_aor_core().
|
static |
Definition at line 347 of file res_pjsip_registrar.c.
References ast_sip_contact::aor, build_path_data(), and NULL.
Referenced by register_aor_core().
|
static |
Definition at line 637 of file res_pjsip_registrar.c.
References ao2_callback, ao2_unlink, ast_sip_contact::aor, ast_assert, AST_VECTOR_FREE, AST_VECTOR_GET, AST_VECTOR_INIT, AST_VECTOR_SIZE, CONTACT_DELETE_EXISTING, CONTACT_DELETE_UNAVAILABLE, NULL, OBJ_MULTIPLE, OBJ_NODATA, registrar_contact_delete(), and vec_contact_add().
Referenced by register_aor_core().
|
static |
Definition at line 1299 of file res_pjsip_registrar.c.
References ast_sip_contact_to_str().
Referenced by ami_registrations_aor().
|
static |
Definition at line 1522 of file res_pjsip_registrar.c.
References AMI_SHOW_REGISTRATION_CONTACT_STATUSES, AMI_SHOW_REGISTRATIONS, ast_manager_unregister(), AST_PTHREADT_NULL, ast_sip_get_sorcery(), ast_sip_transport_monitor_unregister_all(), ast_sip_unregister_service(), ast_sorcery_observer_remove(), check_interval, check_thread, expiration_global_observer, NULL, register_contact_transport_shutdown_cb(), and registrar_module.
|
static |
Definition at line 604 of file res_pjsip_registrar.c.
References AST_VECTOR_ADD_SORTED, AST_VECTOR_MAX_SIZE, AST_VECTOR_SIZE, and vec_contact_cmp().
Referenced by remove_excess_contacts().
|
static |
Definition at line 554 of file res_pjsip_registrar.c.
References ao2_ref, ast_sip_contact::aor, ast_sip_contact_status::aor, ast_sip_get_contact_status(), ast_sip_location_retrieve_aor(), ast_tvcmp(), ast_sip_contact::expiration_time, ast_sip_contact_status::status, and UNAVAILABLE.
Referenced by vec_contact_add().
|
static |
Definition at line 1547 of file res_pjsip_registrar.c.
|
static |
Definition at line 1547 of file res_pjsip_registrar.c.
|
static |
The global interval at which to check for contact expiration.
Definition at line 1410 of file res_pjsip_registrar.c.
Referenced by check_expiration_thread(), expiration_global_loaded(), and unload_module().
|
static |
Thread keeping things alive.
Definition at line 1407 of file res_pjsip_registrar.c.
Referenced by expiration_global_loaded(), and unload_module().
|
static |
Observer which is used to update our interval when the global setting changes.
Definition at line 1490 of file res_pjsip_registrar.c.
Referenced by load_module(), and unload_module().
|
static |
Definition at line 323 of file res_pjsip_registrar.c.
Referenced by build_path_data().
|
static |
Definition at line 152 of file res_pjsip_registrar.c.
Referenced by load_module(), and registrar_validate_contacts().
|
static |
Definition at line 153 of file res_pjsip_registrar.c.
Referenced by load_module(), register_aor_core(), and registrar_validate_contacts().
|
static |
Definition at line 1399 of file res_pjsip_registrar.c.
Referenced by load_module(), and unload_module().