Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
#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. 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_add_unreachable (void *obj, void *arg, int flags) |
Internal callback function which adds any contact which is unreachable. 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, 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 = "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 = 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. 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 1323 of file res_pjsip_registrar.c.
#define AMI_SHOW_REGISTRATIONS "PJSIPShowRegistrationsInbound" |
Definition at line 1324 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 204 of file res_pjsip_registrar.c.
|
static |
Definition at line 1474 of file res_pjsip_registrar.c.
|
static |
Definition at line 1474 of file res_pjsip_registrar.c.
|
static |
Definition at line 1231 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 1253 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 1260 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 1288 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 1273 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 1474 of file res_pjsip_registrar.c.
|
static |
Definition at line 253 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 1364 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 322 of file res_pjsip_registrar.c.
References a, contact_transport_monitor::aor_name, b, and contact_transport_monitor::contact_name.
Referenced by registrar_contact_delete().
|
static |
Definition at line 1393 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 1340 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 1045 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 1105 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 1421 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 1031 of file res_pjsip_registrar.c.
References ast_debug, and ast_strlen_zero().
Referenced by find_aor_name().
|
static |
Definition at line 998 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 653 of file res_pjsip_registrar.c.
References NULL.
Referenced by register_aor().
|
static |
Definition at line 331 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 368 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 registrar_contact_delete(), and unload_module().
|
static |
Internal function which adds a contact to a response.
Definition at line 224 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.
|
static |
Callback function which adds non-permanent contacts to a container.
Definition at line 609 of file res_pjsip_registrar.c.
References ao2_link, ast_tvzero(), container, and ast_sip_contact::expiration_time.
|
static |
Internal callback function which adds any contact which is unreachable.
Definition at line 624 of file res_pjsip_registrar.c.
References ao2_link, ao2_ref, ast_sip_get_contact_status(), container, status, and UNAVAILABLE.
|
static |
Definition at line 402 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_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 217 of file res_pjsip_registrar.c.
References CMP_MATCH, CONTACT_DELETE_REQUEST, NULL, and registrar_contact_delete().
|
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, ast_sip_contact::uri, and registrar_contact_details::uri.
|
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.
|
static |
Definition at line 1174 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.
|
static |
Definition at line 275 of file res_pjsip_registrar.c.
References ast_sip_contact::aor, build_path_data(), and NULL.
|
static |
Definition at line 565 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().
|
static |
Definition at line 1226 of file res_pjsip_registrar.c.
References ast_sip_contact_to_str().
Referenced by ami_registrations_aor().
|
static |
Definition at line 1449 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 532 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 482 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 1474 of file res_pjsip_registrar.c.
|
static |
Definition at line 1474 of file res_pjsip_registrar.c.
|
static |
The global interval at which to check for contact expiration.
Definition at line 1337 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 1334 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 1417 of file res_pjsip_registrar.c.
Referenced by load_module(), and unload_module().
|
static |
Definition at line 251 of file res_pjsip_registrar.c.
Referenced by build_path_data().
|
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().
|
static |
Definition at line 1326 of file res_pjsip_registrar.c.
Referenced by load_module(), and unload_module().