Asterisk - The Open Source Telephony Project
18.5.0
|
#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 | 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_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) |
AST_VECTOR (excess_contact_vector, struct ast_sip_contact *) | |
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. More... | |
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. More... | |
static int | registrar_add_non_permanent (void *obj, void *arg, int flags) |
Callback function which adds non-permanent contacts to a container. More... | |
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. More... | |
static int | registrar_find_contact (void *obj, void *arg, int flags) |
Callback function for finding a contact. More... | |
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. More... | |
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. More... | |
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) |
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 = "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 = "30ef0c93b36035ec78c9cfd712d36d9b" , .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. More... | |
static pthread_t | check_thread = AST_PTHREADT_NULL |
Thread keeping things alive. More... | |
static struct ast_sorcery_observer | expiration_global_observer |
Observer which is used to update our interval when the global setting changes. More... | |
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 1225 of file res_pjsip_registrar.c.
Referenced by load_module(), and unload_module().
#define AMI_SHOW_REGISTRATIONS "PJSIPShowRegistrationsInbound" |
Definition at line 1226 of file res_pjsip_registrar.c.
Referenced by load_module(), and unload_module().
enum contact_delete_type |
Enumerator | |
---|---|
CONTACT_DELETE_ERROR | |
CONTACT_DELETE_EXISTING | |
CONTACT_DELETE_EXPIRE | |
CONTACT_DELETE_REQUEST | |
CONTACT_DELETE_SHUTDOWN |
Definition at line 204 of file res_pjsip_registrar.c.
|
static |
Definition at line 1375 of file res_pjsip_registrar.c.
|
static |
Definition at line 1375 of file res_pjsip_registrar.c.
|
static |
Definition at line 1133 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 1155 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 1162 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 1190 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 1175 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 1375 of file res_pjsip_registrar.c.
AST_VECTOR | ( | excess_contact_vector | , |
struct ast_sip_contact * | |||
) |
Referenced by registrar_contact_delete().
|
static |
Definition at line 252 of file res_pjsip_registrar.c.
References ast_str_append(), ast_str_create, ast_str_set(), and NULL.
Referenced by registrar_validate_path().
|
static |
Definition at line 1266 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_tvnow(), ast_variable_new, ast_variables_destroy(), expire_contact(), NULL, OBJ_NODATA, and var.
Referenced by expiration_global_loaded().
|
static |
Definition at line 321 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 1294 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(), LOG_ERROR, and NULL.
|
static |
Callback function which deletes a contact.
Definition at line 1242 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 947 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 1007 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, NULL, and registrar_contact_details::uri.
Referenced by registrar_on_rx_request().
|
static |
Definition at line 1322 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, NULL, pj_max_hostname, and pjsip_max_url_size.
Referenced by unload_module().
|
static |
Definition at line 933 of file res_pjsip_registrar.c.
References ast_debug, and ast_strlen_zero.
Referenced by find_aor_name().
|
static |
Definition at line 900 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 584 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, 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, monitor, NULL, OBJ_MULTIPLE, OBJ_NODATA, OBJ_UNLINK, ast_sip_contact::path, pjsip_max_url_size, ast_sip_contact::prune_on_boot, 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_contact_delete(), registrar_delete_contact(), registrar_find_contact(), registrar_get_expiration(), registrar_validate_contacts(), registrar_validate_path(), remove_excess_contacts(), ast_sip_contact::user_agent, ast_sip_contact::via_addr, and ast_sip_contact::via_port.
Referenced by register_aor().
|
static |
Definition at line 330 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, monitor, NULL, registrar_contact_delete(), and contact_transport_monitor::removing.
Referenced by register_contact_transport_shutdown_cb().
|
static |
Definition at line 369 of file res_pjsip_registrar.c.
References ao2_lock, ao2_ref, ao2_unlock, ast_sip_push_task(), monitor, 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 223 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, registrar_contact_details::uri, and ast_sip_contact::uri.
Referenced by register_aor_core().
|
static |
Callback function which adds non-permanent contacts to a container.
Definition at line 563 of file res_pjsip_registrar.c.
References ao2_link, ast_tvzero(), container, and ast_sip_contact::expiration_time.
Referenced by register_aor_core().
|
static |
Definition at line 403 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_VECTOR(), ast_verb, CONTACT_DELETE_ERROR, CONTACT_DELETE_EXISTING, CONTACT_DELETE_EXPIRE, CONTACT_DELETE_REQUEST, CONTACT_DELETE_SHUTDOWN, contact_transport_monitor::contact_name, contact_transport_monitor_matcher(), ast_sip_contact::expiration_time, monitor, ast_sip_contact::prune_on_boot, register_contact_transport_shutdown_cb(), 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 216 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 121 of file res_pjsip_registrar.c.
References ast_log, ast_tvzero(), CMP_MATCH, ast_sip_contact::expiration_time, LOG_WARNING, registrar_contact_details::pool, registrar_contact_details::uri, and ast_sip_contact::uri.
Referenced by register_aor_core().
|
static |
Internal function which returns the expiration time for a contact.
Definition at line 84 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().
|
static |
Definition at line 1076 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 141 of file res_pjsip_registrar.c.
References NULL, and registrar_contact_details::pool.
Referenced by register_aor_core().
|
static |
Definition at line 274 of file res_pjsip_registrar.c.
References build_path_data(), NULL, and ast_sip_aor::support_path.
Referenced by register_aor_core().
|
static |
Definition at line 523 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, NULL, OBJ_MULTIPLE, OBJ_NODATA, registrar_contact_delete(), and vec_contact_add().
Referenced by register_aor_core().
|
static |
Definition at line 1128 of file res_pjsip_registrar.c.
References ast_sip_contact_to_str().
Referenced by ami_registrations_aor().
|
static |
Definition at line 1350 of file res_pjsip_registrar.c.
References AMI_SHOW_REGISTRATION_CONTACT_STATUSES, AMI_SHOW_REGISTRATIONS, ast_manager_unregister(), AST_MODFLAG_LOAD_ORDER, AST_MODPRI_CHANNEL_DEPEND, AST_MODULE_INFO(), AST_MODULE_SUPPORT_CORE, AST_PTHREADT_NULL, ast_sip_get_sorcery(), ast_sip_transport_monitor_unregister_all(), ast_sip_unregister_service(), ast_sorcery_observer_remove(), ASTERISK_GPL_KEY, load_module(), NULL, and register_contact_transport_shutdown_cb().
|
static |
Definition at line 489 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 480 of file res_pjsip_registrar.c.
References ast_tvcmp(), and ast_sip_contact::expiration_time.
Referenced by vec_contact_add().
|
static |
Definition at line 1375 of file res_pjsip_registrar.c.
|
static |
Definition at line 1375 of file res_pjsip_registrar.c.
|
static |
The global interval at which to check for contact expiration.
Definition at line 1239 of file res_pjsip_registrar.c.
|
static |
Thread keeping things alive.
Definition at line 1236 of file res_pjsip_registrar.c.
|
static |
Observer which is used to update our interval when the global setting changes.
Definition at line 1318 of file res_pjsip_registrar.c.
|
static |
Definition at line 250 of file res_pjsip_registrar.c.
|
static |
Definition at line 80 of file res_pjsip_registrar.c.
Referenced by load_module().
|
static |
Definition at line 81 of file res_pjsip_registrar.c.
Referenced by load_module(), and register_aor_core().
|
static |
Definition at line 1228 of file res_pjsip_registrar.c.