Asterisk - The Open Source Telephony Project
18.5.0
|
#include "asterisk.h"
#include <pjsip.h>
#include "asterisk/res_pjsip.h"
#include "asterisk/acl.h"
#include "include/res_pjsip_private.h"
#include "asterisk/taskprocessor.h"
#include "asterisk/threadpool.h"
#include "asterisk/res_pjsip_cli.h"
Go to the source code of this file.
Data Structures | |
struct | distributor_dialog_data |
struct | unidentified_request |
Macros | |
#define | DEFAULT_SUSPECTS_BUCKETS 53 |
#define | DIALOG_ASSOCIATIONS_BUCKETS 251 |
#define | DISTRIBUTOR_POOL_SIZE 31 |
#define | MAX_REALM_LENGTH 40 |
Functions | |
static struct ast_sip_auth * | alloc_artificial_auth (char *default_realm) |
static | AO2_GLOBAL_OBJ_STATIC (artificial_auth) |
static void | apply_acls (pjsip_rx_data *rdata) |
static int | apply_endpoint_acl (pjsip_rx_data *rdata, struct ast_sip_endpoint *endpoint) |
static int | apply_endpoint_contact_acl (pjsip_rx_data *rdata, struct ast_sip_endpoint *endpoint) |
struct ast_sip_endpoint * | ast_pjsip_rdata_get_endpoint (pjsip_rx_data *rdata) |
Get the looked-up endpoint on an out-of dialog request or response. More... | |
void | ast_sip_destroy_distributor (void) |
struct ast_sip_endpoint * | ast_sip_dialog_get_endpoint (pjsip_dialog *dlg) |
Get the endpoint associated with this dialog. More... | |
void | ast_sip_dialog_set_endpoint (pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint) |
Set an endpoint on a SIP dialog so in-dialog requests do not undergo endpoint lookup. More... | |
void | ast_sip_dialog_set_serializer (pjsip_dialog *dlg, struct ast_taskprocessor *serializer) |
Set a serializer on a SIP dialog so requests and responses are automatically serialized. More... | |
struct ast_sip_auth * | ast_sip_get_artificial_auth (void) |
Retrieves a reference to the artificial auth. More... | |
struct ast_sip_endpoint * | ast_sip_get_artificial_endpoint (void) |
Retrieves a reference to the artificial endpoint. More... | |
struct ast_taskprocessor * | ast_sip_get_distributor_serializer (pjsip_rx_data *rdata) |
Determine the distributor serializer for the SIP message. More... | |
int | ast_sip_initialize_distributor (void) |
static pj_bool_t | authenticate (pjsip_rx_data *rdata) |
static int | buf_hash (const char *pos, size_t len) |
static int | buf_hash_add (const char *pos, size_t len, int hash) |
static void | check_endpoint (pjsip_rx_data *rdata, struct unidentified_request *unid, const char *name) |
static int | clean_task (const void *data) |
static struct ao2_container * | cli_unid_get_container (const char *regex) |
static const char * | cli_unid_get_id (const void *obj) |
static int | cli_unid_iterate (void *container, ao2_callback_fn callback, void *args) |
static int | cli_unid_print_body (void *obj, void *arg, int flags) |
static int | cli_unid_print_header (void *obj, void *arg, int flags) |
static void * | cli_unid_retrieve_by_id (const char *id) |
static int | create_artificial_auth (void) |
static int | create_artificial_endpoint (void) |
static int | dialog_associations_cmp (void *obj, void *arg, int flags) |
static int | dialog_associations_hash (const void *obj, int flags) |
static int | distribute (void *data) |
static pj_bool_t | distributor (pjsip_rx_data *rdata) |
static int | distributor_pool_setup (void) |
static void | distributor_pool_shutdown (void) |
static pj_bool_t | endpoint_lookup (pjsip_rx_data *rdata) |
static int | expire_requests (void *object, void *arg, int flags) |
static int | extract_contact_addr (pjsip_contact_hdr *contact, struct ast_sockaddr **addrs) |
static pjsip_dialog * | find_dialog (pjsip_rx_data *rdata) |
static struct ast_taskprocessor * | find_request_serializer (pjsip_rx_data *rdata) |
static void | global_loaded (const char *object_type) |
static void | log_failed_request (pjsip_rx_data *rdata, char *msg, unsigned int count, unsigned int period) |
static int | pjstr_hash (pj_str_t *str) |
static int | pjstr_hash_add (pj_str_t *str, int hash) |
static int | prune_task (const void *data) |
static pj_status_t | record_serializer (pjsip_tx_data *tdata) |
static int | suspects_compare (void *obj, void *arg, int flags) |
static int | suspects_hash (const void *obj, int flags) |
static int | suspects_sort (const void *obj, const void *arg, int flags) |
Variables | |
static struct ast_sip_endpoint * | artificial_endpoint = NULL |
static pjsip_module | auth_mod |
static struct ast_cli_entry | cli_commands [] |
static struct ao2_container * | dialog_associations |
static pjsip_module | distributor_mod |
static struct ast_taskprocessor * | distributor_pool [DISTRIBUTOR_POOL_SIZE] |
static pjsip_module | endpoint_mod |
static struct ast_sorcery_observer | global_observer |
Observer which is used to update our interval and default_realm when the global setting changes. More... | |
static enum ast_sip_taskprocessor_overload_trigger | overload_trigger |
struct ast_sched_context * | prune_context |
struct ast_sip_cli_formatter_entry * | unid_formatter |
static unsigned int | unidentified_count |
static unsigned int | unidentified_period |
static unsigned int | unidentified_prune_interval |
static struct ao2_container * | unidentified_requests |
static int | using_auth_username |
#define DEFAULT_SUSPECTS_BUCKETS 53 |
Definition at line 47 of file pjsip_distributor.c.
Referenced by ast_sip_initialize_distributor().
#define DIALOG_ASSOCIATIONS_BUCKETS 251 |
Definition at line 162 of file pjsip_distributor.c.
Referenced by ast_sip_initialize_distributor().
#define DISTRIBUTOR_POOL_SIZE 31 |
Number of serializers in pool if one not otherwise known. (Best if prime number)
Definition at line 63 of file pjsip_distributor.c.
#define MAX_REALM_LENGTH 40 |
Definition at line 45 of file pjsip_distributor.c.
Referenced by create_artificial_auth(), and global_loaded().
|
static |
Definition at line 594 of file pjsip_distributor.c.
References AO2_GLOBAL_OBJ_STATIC(), AST_SIP_AUTH_TYPE_ARTIFICIAL, ast_sip_get_sorcery(), ast_sorcery_alloc(), ast_string_field_set, ast_sip_auth::auth_pass, ast_sip_auth::auth_user, NULL, ast_sip_auth::realm, and ast_sip_auth::type.
Referenced by create_artificial_auth(), and global_loaded().
|
static |
Referenced by alloc_artificial_auth().
|
static |
Definition at line 701 of file pjsip_distributor.c.
References ao2_replace, apply_endpoint_acl(), apply_endpoint_contact_acl(), ast_debug, ast_sorcery_object_get_id(), and endpoint_mod.
Referenced by endpoint_lookup().
|
static |
Definition at line 807 of file pjsip_distributor.c.
References ast_sip_endpoint::acl, ast_acl_list_is_empty(), ast_apply_acl(), AST_SENSE_ALLOW, ast_sip_report_failed_acl(), ast_sockaddr_parse(), ast_sockaddr_set_port, log_failed_request(), and PARSE_PORT_FORBID.
Referenced by apply_acls(), and check_endpoint().
|
static |
Definition at line 845 of file pjsip_distributor.c.
References ast_acl_list_is_empty(), ast_apply_acl(), ast_free, AST_SENSE_ALLOW, ast_sip_report_failed_acl(), ast_sip_endpoint::contact_acl, extract_contact_addr(), if(), and log_failed_request().
Referenced by apply_acls(), and check_endpoint().
struct ast_sip_endpoint* ast_pjsip_rdata_get_endpoint | ( | pjsip_rx_data * | rdata | ) |
Get the looked-up endpoint on an out-of dialog request or response.
The function may ONLY be called on out-of-dialog requests or responses. For in-dialog requests and responses, it is required that the user of the dialog has the looked-up endpoint stored locally.
This function should never return NULL if the message is out-of-dialog. It will always return NULL if the message is in-dialog.
This function will increase the reference count of the returned endpoint by one. Release your reference using the ao2_ref function when finished.
rdata | Out-of-dialog request or response |
Definition at line 969 of file pjsip_distributor.c.
References ao2_ref, and endpoint_mod.
Referenced by authenticate(), handle_new_invite_request(), nat_on_rx_message(), options_on_rx_request(), pubsub_on_rx_mwi_notify_request(), pubsub_on_rx_publish_request(), pubsub_on_rx_subscribe_request(), registrar_on_rx_request(), rx_data_to_ast_msg(), send_options_response(), send_response(), and supplement_on_rx_request().
void ast_sip_destroy_distributor | ( | void | ) |
Definition at line 1334 of file pjsip_distributor.c.
References ao2_cleanup, ao2_global_obj_release, ARRAY_LEN, ast_cli_unregister_multiple(), ast_sched_context_destroy(), ast_sip_get_sorcery(), ast_sip_unregister_cli_formatter(), ast_sip_unregister_service(), ast_sorcery_observer_remove(), auth_mod, distributor_mod, distributor_pool_shutdown(), and endpoint_mod.
Referenced by ast_sip_initialize_distributor(), and unload_pjsip().
struct ast_sip_auth* ast_sip_get_artificial_auth | ( | void | ) |
Retrieves a reference to the artificial auth.
The | artificial auth |
Definition at line 631 of file pjsip_distributor.c.
References ao2_global_obj_ref.
Referenced by digest_check_auth(), and global_loaded().
struct ast_sip_endpoint* ast_sip_get_artificial_endpoint | ( | void | ) |
Retrieves a reference to the artificial endpoint.
The | artificial endpoint |
Definition at line 654 of file pjsip_distributor.c.
References ao2_ref, and artificial_endpoint.
Referenced by digest_check_auth(), digest_requires_authentication(), endpoint_lookup(), and get_account_id().
int ast_sip_initialize_distributor | ( | void | ) |
Definition at line 1260 of file pjsip_distributor.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, AO2_ALLOC_OPT_LOCK_RWLOCK, ao2_alloc_options, ao2_container_alloc_hash, ARRAY_LEN, ast_cli_register_multiple, ast_log, ast_sched_context_create(), ast_sched_start_thread(), ast_sip_destroy_distributor(), ast_sip_get_sorcery(), ast_sip_register_cli_formatter(), ast_sip_register_service(), ast_sorcery_observer_add(), ast_sorcery_reload_object(), auth_mod, cli_unid_get_container(), cli_unid_get_id(), cli_unid_iterate(), cli_unid_print_body(), cli_unid_print_header(), cli_unid_retrieve_by_id(), create_artificial_auth(), create_artificial_endpoint(), DEFAULT_SUSPECTS_BUCKETS, DIALOG_ASSOCIATIONS_BUCKETS, dialog_associations_cmp(), dialog_associations_hash(), distributor_mod, distributor_pool_setup(), endpoint_mod, ast_sip_cli_formatter_entry::get_container, ast_sip_cli_formatter_entry::get_id, ast_sip_cli_formatter_entry::iterate, LOG_ERROR, ast_sip_cli_formatter_entry::name, NULL, ast_sip_cli_formatter_entry::print_body, ast_sip_cli_formatter_entry::print_header, ast_sip_cli_formatter_entry::retrieve_by_id, suspects_compare(), and suspects_hash().
Referenced by load_module().
|
static |
Definition at line 880 of file pjsip_distributor.c.
References ao2_cleanup, ao2_find, ao2_ref, ao2_unlink, ast_assert, ast_pjsip_rdata_get_endpoint(), AST_SIP_AUTHENTICATION_CHALLENGE, AST_SIP_AUTHENTICATION_ERROR, AST_SIP_AUTHENTICATION_FAILED, AST_SIP_AUTHENTICATION_SUCCESS, ast_sip_check_authentication(), ast_sip_get_pjsip_endpoint(), ast_sip_report_auth_challenge_sent(), ast_sip_report_auth_failed_challenge_response(), ast_sip_report_auth_success(), ast_sip_requires_authentication(), log_failed_request(), NULL, OBJ_SEARCH_KEY, and RAII_VAR.
|
static |
Definition at line 210 of file pjsip_distributor.c.
References buf_hash_add().
Referenced by dialog_associations_hash().
|
static |
Definition at line 184 of file pjsip_distributor.c.
Referenced by buf_hash(), and pjstr_hash_add().
|
static |
Definition at line 683 of file pjsip_distributor.c.
References ao2_unlock, ao2_wrlock, apply_endpoint_acl(), apply_endpoint_contact_acl(), ast_sip_report_invalid_endpoint(), ast_tvdiff_ms(), ast_tvnow(), unidentified_request::count, unidentified_request::first_seen, log_failed_request(), unidentified_count, and unidentified_period.
Referenced by endpoint_lookup().
|
static |
Definition at line 1160 of file pjsip_distributor.c.
Referenced by global_loaded().
|
static |
Definition at line 1051 of file pjsip_distributor.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_container_alloc_list, ao2_container_dup(), ao2_ref, NULL, suspects_compare(), and suspects_sort().
Referenced by ast_sip_initialize_distributor().
|
static |
Definition at line 1081 of file pjsip_distributor.c.
References unidentified_request::src_name.
Referenced by ast_sip_initialize_distributor().
|
static |
Definition at line 1069 of file pjsip_distributor.c.
References ao2_callback.
Referenced by ast_sip_initialize_distributor().
|
static |
Definition at line 1105 of file pjsip_distributor.c.
References ast_assert, ast_str_append(), ast_tvdiff_ms(), ast_tvnow(), CLI_INDENT_TO_SPACES, CLI_LAST_TABSTOP, context, unidentified_request::count, unidentified_request::first_seen, ast_sip_cli_context::indent_level, NULL, ast_sip_cli_context::output_buffer, and unidentified_request::src_name.
Referenced by ast_sip_initialize_distributor().
|
static |
Definition at line 1088 of file pjsip_distributor.c.
References ao2_cleanup, ast_assert, ast_str_append(), CLI_HEADER_FILLER, CLI_INDENT_TO_SPACES, CLI_LAST_TABSTOP, context, ast_sip_cli_context::indent_level, NULL, ast_sip_cli_context::output_buffer, and RAII_VAR.
Referenced by ast_sip_initialize_distributor().
|
static |
Definition at line 1076 of file pjsip_distributor.c.
References ao2_find, and OBJ_SEARCH_KEY.
Referenced by ast_sip_initialize_distributor().
|
static |
Definition at line 614 of file pjsip_distributor.c.
References alloc_artificial_auth(), ao2_global_obj_replace_unref, ao2_ref, ast_log, ast_sip_get_default_realm(), default_realm, LOG_ERROR, and MAX_REALM_LENGTH.
Referenced by ast_sip_initialize_distributor().
|
static |
Definition at line 638 of file pjsip_distributor.c.
References ast_sip_get_sorcery(), ast_sorcery_alloc(), ast_strdup, AST_VECTOR_APPEND, AST_VECTOR_INIT, ast_sip_endpoint::inbound_auths, and NULL.
Referenced by ast_sip_initialize_distributor().
|
static |
Definition at line 239 of file pjsip_distributor.c.
References ast_assert, CMP_MATCH, distributor_dialog_data::dlg, OBJ_SEARCH_KEY, OBJ_SEARCH_MASK, OBJ_SEARCH_OBJECT, and OBJ_SEARCH_PARTIAL_KEY.
Referenced by ast_sip_initialize_distributor().
|
static |
Definition at line 215 of file pjsip_distributor.c.
References ast_assert, ast_str_hash_restrict(), buf, buf_hash(), OBJ_SEARCH_KEY, OBJ_SEARCH_MASK, and OBJ_SEARCH_OBJECT.
Referenced by ast_sip_initialize_distributor().
|
static |
Definition at line 943 of file pjsip_distributor.c.
References ao2_cleanup, ast_sip_get_pjsip_endpoint(), distributor_mod, endpoint_mod, and NULL.
Referenced by distributor().
|
static |
Definition at line 485 of file pjsip_distributor.c.
References ao2_bump, ao2_cleanup, ao2_find, ao2_lock, ao2_unlock, ast_debug, AST_OPT_FLAG_FULLY_BOOTED, ast_options, ast_sip_get_distributor_serializer(), ast_sip_get_pjsip_endpoint(), ast_sip_push_task(), ast_taskprocessor_alert_get(), ast_taskprocessor_get_subsystem_alert(), ast_taskprocessor_name(), ast_taskprocessor_unreference(), ast_test_flag, distribute(), distributor_dialog_data::endpoint, endpoint_mod, find_dialog(), find_request_serializer(), NULL, OBJ_SEARCH_KEY, overload_trigger, distributor_dialog_data::serializer, TASKPROCESSOR_OVERLOAD_TRIGGER_GLOBAL, and TASKPROCESSOR_OVERLOAD_TRIGGER_PJSIP_ONLY.
|
static |
Definition at line 1243 of file pjsip_distributor.c.
References ARRAY_LEN, ast_sip_create_serializer(), ast_taskprocessor_build_name(), and AST_TASKPROCESSOR_MAX_NAME.
Referenced by ast_sip_initialize_distributor().
|
static |
Definition at line 1225 of file pjsip_distributor.c.
References ARRAY_LEN, ast_taskprocessor_unreference(), and NULL.
Referenced by ast_sip_destroy_distributor().
|
static |
Definition at line 718 of file pjsip_distributor.c.
References AO2_ALLOC_OPT_LOCK_RWLOCK, ao2_alloc_options, ao2_find, ao2_link_flags, ao2_ref, ao2_unlink, ao2_unlock, ao2_wrlock, apply_acls(), ast_copy_pj_str(), ast_sip_get_artificial_endpoint(), ast_sip_get_pjsip_endpoint(), ast_sip_identify_endpoint(), ast_sip_report_invalid_endpoint(), ast_tvnow(), AST_UUID_STR_LEN, check_endpoint(), unidentified_request::count, endpoint_mod, unidentified_request::first_seen, log_failed_request(), name, NULL, OBJ_NOLOCK, OBJ_SEARCH_KEY, unidentified_request::src_name, and using_auth_username.
Referenced by ast_sip_get_distributor_serializer().
|
static |
Definition at line 1136 of file pjsip_distributor.c.
References ast_tvdiff_ms(), ast_tvnow(), CMP_MATCH, and unidentified_request::first_seen.
Referenced by prune_task().
|
static |
Definition at line 827 of file pjsip_distributor.c.
References AST_AF_UNSPEC, ast_copy_pj_str(), ast_sockaddr_resolve(), host, NULL, and PARSE_PORT_FORBID.
Referenced by apply_endpoint_contact_acl().
|
static |
Definition at line 339 of file pjsip_distributor.c.
References ast_debug, and NULL.
Referenced by distributor().
|
static |
Definition at line 112 of file pjsip_distributor.c.
References ast_debug, ast_strlen_zero, ast_taskprocessor_get(), distributor_mod, NULL, and TPS_REF_IF_EXISTS.
Referenced by distributor().
|
static |
Definition at line 1165 of file pjsip_distributor.c.
References alloc_artificial_auth(), ao2_cleanup, ao2_global_obj_replace_unref, ast_free, ast_sched_add_variable(), ast_sched_clean_by_callback(), ast_sip_get_artificial_auth(), ast_sip_get_default_realm(), ast_sip_get_endpoint_identifier_order(), ast_sip_get_taskprocessor_overload_trigger(), ast_sip_get_unidentified_request_thresholds(), ast_strdupa, ast_strip(), clean_task(), default_realm, MAX_REALM_LENGTH, NULL, overload_trigger, prune_task(), ast_sip_auth::realm, strsep(), unidentified_count, unidentified_period, unidentified_prune_interval, and using_auth_username.
|
static |
Definition at line 660 of file pjsip_distributor.c.
References ast_copy_pj_str(), ast_log, AST_SOCKADDR_BUFLEN, and LOG_NOTICE.
Referenced by apply_endpoint_acl(), apply_endpoint_contact_acl(), authenticate(), check_endpoint(), and endpoint_lookup().
|
static |
Definition at line 443 of file pjsip_distributor.c.
References pjstr_hash_add().
Referenced by ast_sip_get_distributor_serializer().
|
static |
Definition at line 426 of file pjsip_distributor.c.
References buf_hash_add().
Referenced by ast_sip_get_distributor_serializer(), and pjstr_hash().
|
static |
Definition at line 1149 of file pjsip_distributor.c.
References ao2_callback, ast_sip_get_unidentified_request_thresholds(), expire_requests(), OBJ_MULTIPLE, OBJ_NODATA, OBJ_UNLINK, unidentified_count, unidentified_period, and unidentified_prune_interval.
Referenced by global_loaded().
|
static |
Definition at line 77 of file pjsip_distributor.c.
References ast_strlen_zero, ast_taskprocessor_name(), ast_threadpool_serializer_get_current(), distributor_mod, and name.
|
static |
Definition at line 1002 of file pjsip_distributor.c.
References CMP_MATCH, OBJ_SEARCH_KEY, OBJ_SEARCH_MASK, OBJ_SEARCH_OBJECT, OBJ_SEARCH_PARTIAL_KEY, and unidentified_request::src_name.
Referenced by ast_sip_initialize_distributor(), and cli_unid_get_container().
|
static |
Definition at line 1030 of file pjsip_distributor.c.
References ast_assert, ast_str_hash(), OBJ_SEARCH_KEY, OBJ_SEARCH_MASK, and OBJ_SEARCH_OBJECT.
Referenced by ast_sip_initialize_distributor().
|
static |
Definition at line 978 of file pjsip_distributor.c.
References OBJ_SEARCH_KEY, OBJ_SEARCH_MASK, OBJ_SEARCH_OBJECT, OBJ_SEARCH_PARTIAL_KEY, and unidentified_request::src_name.
Referenced by cli_unid_get_container().
|
static |
Definition at line 636 of file pjsip_distributor.c.
Referenced by ast_sip_get_artificial_endpoint(), and digest_check_auth().
|
static |
Definition at line 937 of file pjsip_distributor.c.
Referenced by ast_sip_destroy_distributor(), and ast_sip_initialize_distributor().
|
static |
Definition at line 1127 of file pjsip_distributor.c.
|
static |
Definition at line 164 of file pjsip_distributor.c.
|
static |
Definition at line 34 of file pjsip_distributor.c.
Referenced by ast_sip_destroy_distributor(), ast_sip_initialize_distributor(), distribute(), find_request_serializer(), and record_serializer().
|
static |
Pool of serializers to use if not supplied.
Definition at line 66 of file pjsip_distributor.c.
|
static |
Definition at line 479 of file pjsip_distributor.c.
Referenced by apply_acls(), ast_pjsip_rdata_get_endpoint(), ast_sip_destroy_distributor(), ast_sip_initialize_distributor(), distribute(), distributor(), and endpoint_lookup().
|
static |
Observer which is used to update our interval and default_realm when the global setting changes.
Definition at line 1214 of file pjsip_distributor.c.
|
static |
Definition at line 54 of file pjsip_distributor.c.
Referenced by distributor(), and global_loaded().
struct ast_sched_context* prune_context |
Definition at line 42 of file pjsip_distributor.c.
struct ast_sip_cli_formatter_entry* unid_formatter |
Definition at line 1134 of file pjsip_distributor.c.
|
static |
Definition at line 50 of file pjsip_distributor.c.
Referenced by check_endpoint(), global_loaded(), and prune_task().
|
static |
Definition at line 51 of file pjsip_distributor.c.
Referenced by check_endpoint(), global_loaded(), and prune_task().
|
static |
Definition at line 52 of file pjsip_distributor.c.
Referenced by global_loaded(), and prune_task().
|
static |
Definition at line 49 of file pjsip_distributor.c.
|
static |
Definition at line 53 of file pjsip_distributor.c.
Referenced by endpoint_lookup(), and global_loaded().