Asterisk - The Open Source Telephony Project GIT-master-7e7a603
|
#include "asterisk.h"
#include <pjsip.h>
#include "asterisk/res_pjsip.h"
#include "asterisk/res_pjsip_cli.h"
#include "asterisk/module.h"
#include "asterisk/acl.h"
#include "asterisk/manager.h"
#include "res_pjsip/include/res_pjsip_private.h"
Go to the source code of this file.
Data Structures | |
struct | ast_sockaddr_with_tp |
Structure for a socket address with transport. More... | |
struct | ip_identify_match |
Structure for an IP identification matching object. More... | |
Macros | |
#define | HOSTS_BUCKETS 53 |
The number of buckets for storing hosts for resolution. More... | |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
static struct ao2_container * | cli_get_container (const char *regex) |
static int | cli_iterator (void *container, ao2_callback_fn callback, void *args) |
static int | cli_print_body (void *obj, void *arg, int flags) |
static int | cli_print_header (void *obj, void *arg, int flags) |
static void * | cli_retrieve_by_id (const char *id) |
static struct ast_sip_endpoint * | common_identify (ao2_callback_fn *identify_match_cb, void *arg) |
static int | format_ami_endpoint_identify (const struct ast_sip_endpoint *endpoint, struct ast_sip_ami *ami) |
static struct ast_sip_endpoint * | header_identify (pjsip_rx_data *rdata) |
static int | header_identify_match_check (void *obj, void *arg, int flags) |
Comparator function for matching an object by header. More... | |
static struct ast_sip_endpoint * | ip_identify (pjsip_rx_data *rdata) |
static void * | ip_identify_alloc (const char *name) |
Allocator function for a matching object. More... | |
static int | ip_identify_apply (const struct ast_sorcery *sorcery, void *obj) |
Apply handler for identify type. More... | |
static void | ip_identify_destroy (void *obj) |
Destructor function for a matching object. More... | |
static int | ip_identify_match_check (void *obj, void *arg, int flags) |
Comparator function for matching an object by IP address. More... | |
static int | ip_identify_match_handler (const struct aco_option *opt, struct ast_variable *var, void *obj) |
Custom handler for match field. More... | |
static int | ip_identify_match_host_lookup (struct ip_identify_match *identify, const char *host) |
Helper function which performs a host lookup and adds result to identify match. More... | |
static int | ip_identify_match_srv_lookup (struct ip_identify_match *identify, const char *prefix, const char *host, int results) |
Helper function which performs an SRV lookup and then resolves the hostname. More... | |
static int | load_module (void) |
static int | match_to_str (const void *obj, const intptr_t *args, char **buf) |
static int | match_to_var_list (const void *obj, struct ast_variable **fields) |
static void | match_to_var_list_append (struct ast_variable **head, struct ast_ha *ha) |
static char * | my_cli_traverse_objects (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static int | reload_module (void) |
static struct ast_sip_endpoint * | request_identify (pjsip_rx_data *rdata) |
static int | request_identify_match_check (void *obj, void *arg, int flags) |
Comparator function for matching an object by request URI. More... | |
static int | send_identify_ami_event (void *obj, void *arg, void *data, int flags) |
static int | sip_identify_to_ami (const struct ip_identify_match *identify, struct ast_str **buf) |
static struct ast_sip_endpoint * | transport_identify (pjsip_rx_data *rdata) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "PJSIP IP endpoint identifier" , .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, .reload = reload_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND - 4, .requires = "res_pjsip", } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_sip_cli_formatter_entry * | cli_formatter |
static struct ast_cli_entry | cli_identify [] |
struct ast_sip_endpoint_formatter | endpoint_identify_formatter |
static struct ast_sip_endpoint_identifier | header_identifier |
static struct ast_sip_endpoint_identifier | ip_identifier |
static struct ast_sip_endpoint_identifier | request_identifier |
static struct ast_sip_endpoint_identifier | transport_identifier |
#define HOSTS_BUCKETS 53 |
The number of buckets for storing hosts for resolution.
Definition at line 146 of file res_pjsip_endpoint_identifier_ip.c.
|
static |
Definition at line 1090 of file res_pjsip_endpoint_identifier_ip.c.
|
static |
Definition at line 1090 of file res_pjsip_endpoint_identifier_ip.c.
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 1090 of file res_pjsip_endpoint_identifier_ip.c.
|
static |
Definition at line 863 of file res_pjsip_endpoint_identifier_ip.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_cleanup, ao2_container_alloc_list, ao2_container_dup(), ao2_ref, ast_sip_get_sorcery(), ast_sorcery_object_id_compare(), ast_sorcery_object_id_sort(), ast_sorcery_retrieve_by_regex(), container, NULL, RAII_VAR, and regex().
Referenced by load_module().
|
static |
Definition at line 840 of file res_pjsip_endpoint_identifier_ip.c.
References ao2_callback, ao2_cleanup, args, AST_RETRIEVE_FLAG_MULTIPLE, ast_sip_get_sorcery(), ast_sorcery_object_get_id(), ast_sorcery_retrieve_by_fields(), container, ast_variable::name, NULL, and OBJ_NODATA.
Referenced by load_module().
|
static |
Definition at line 919 of file res_pjsip_endpoint_identifier_ip.c.
References ast_ha::addr, ast_assert, ast_free, AST_SENSE_ALLOW, ast_sip_cli_print_sorcery_objectset(), ast_sockaddr_cidr_bits(), ast_sockaddr_port, ast_sockaddr_stringify(), ast_sockaddr_stringify_addr(), ast_sorcery_object_get_id(), ast_str_append(), ast_str_create, ast_strlen_zero(), CLI_INDENT_TO_SPACES, voicemailpwcheck::context, ip_identify_match::endpoint_name, match(), ip_identify_match::match_header, ip_identify_match::match_request_uri, ip_identify_match::matches, MAX_OBJECT_FIELD, NULL, RAII_VAR, str, and ip_identify_match::transport.
Referenced by load_module().
|
static |
Definition at line 892 of file res_pjsip_endpoint_identifier_ip.c.
References ast_assert, ast_str_append(), CLI_HEADER_FILLER, CLI_INDENT_TO_SPACES, CLI_LAST_TABSTOP, CLI_MAX_WIDTH, voicemailpwcheck::context, and NULL.
Referenced by load_module().
|
static |
Definition at line 887 of file res_pjsip_endpoint_identifier_ip.c.
References ast_sip_get_sorcery(), and ast_sorcery_retrieve_by_id().
Referenced by load_module().
|
static |
Definition at line 352 of file res_pjsip_endpoint_identifier_ip.c.
References ao2_callback, ao2_cleanup, ao2_container_count(), ao2_ref, ast_debug, ast_log, AST_RETRIEVE_FLAG_ALL, AST_RETRIEVE_FLAG_MULTIPLE, ast_sip_get_sorcery(), ast_sorcery_object_get_id(), ast_sorcery_retrieve_by_fields(), ast_sorcery_retrieve_by_id(), LOG_WARNING, match(), NULL, and RAII_VAR.
Referenced by header_identify(), ip_identify(), request_identify(), and transport_identify().
|
static |
Definition at line 811 of file res_pjsip_endpoint_identifier_ip.c.
References ao2_callback_data, ao2_ref, AST_RETRIEVE_FLAG_MULTIPLE, ast_sip_get_sorcery(), ast_sorcery_object_get_id(), ast_sorcery_retrieve_by_fields(), ast_variable::name, OBJ_MULTIPLE, OBJ_NODATA, and send_identify_ami_event().
|
static |
Definition at line 435 of file res_pjsip_endpoint_identifier_ip.c.
References common_identify(), and header_identify_match_check().
|
static |
Comparator function for matching an object by header.
Definition at line 219 of file res_pjsip_endpoint_identifier_ip.c.
References ast_assert, ast_debug, ast_sorcery_object_get_id(), ast_strip(), ast_strlen_zero(), buf, CMP_MATCH, ip_identify_match::is_header_regex, len(), ip_identify_match::match_header, ip_identify_match::match_header_name, ip_identify_match::match_header_value, header::next, NULL, PATH_MAX, and ip_identify_match::regex_header_buf.
Referenced by header_identify().
|
static |
Definition at line 385 of file res_pjsip_endpoint_identifier_ip.c.
References ast_sockaddr_with_tp::addr, ast_sockaddr_parse(), ast_sockaddr_set_port, common_identify(), ip_identify_match_check(), PARSE_PORT_FORBID, and ast_sockaddr_with_tp::tp.
|
static |
Allocator function for a matching object.
Definition at line 206 of file res_pjsip_endpoint_identifier_ip.c.
References ao2_cleanup, ast_sorcery_generic_alloc(), ast_string_field_init, ip_identify_destroy(), and NULL.
Referenced by load_module().
|
static |
Apply handler for identify type.
Definition at line 575 of file res_pjsip_endpoint_identifier_ip.c.
References ao2_container_count(), ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_log, ast_sorcery_object_get_id(), ast_sorcery_object_set_has_dynamic_contents(), ast_strdupa, ast_string_field_set, ast_strip(), ast_strlen_zero(), ip_identify_match::endpoint_name, ip_identify_match::hosts, ip_identify_match_host_lookup(), ip_identify_match_srv_lookup(), ip_identify_match::is_header_regex, ip_identify_match::is_request_uri_regex, len(), LOG_ERROR, LOG_WARNING, ip_identify_match::match_header, ip_identify_match::match_request_uri, ip_identify_match::matches, NULL, ip_identify_match::regex_header_buf, ip_identify_match::regex_request_uri_buf, ip_identify_match::srv_lookups, and ip_identify_match::transport.
Referenced by load_module().
|
static |
Destructor function for a matching object.
Definition at line 190 of file res_pjsip_endpoint_identifier_ip.c.
References ao2_cleanup, ast_free_ha(), ast_string_field_free_memory, ip_identify_match::hosts, ip_identify_match::is_header_regex, ip_identify_match::is_request_uri_regex, ip_identify_match::matches, ip_identify_match::regex_header_buf, and ip_identify_match::regex_request_uri_buf.
Referenced by ip_identify_alloc().
|
static |
Comparator function for matching an object by IP address.
Definition at line 321 of file res_pjsip_endpoint_identifier_ip.c.
References ast_sockaddr_with_tp::addr, ast_apply_ha(), ast_debug, AST_SENSE_ALLOW, ast_sockaddr_stringify(), ast_sorcery_object_get_id(), ast_strlen_zero(), CMP_MATCH, ip_identify_match::matches, ast_sockaddr_with_tp::tp, and ip_identify_match::transport.
Referenced by ip_identify(), and transport_identify().
|
static |
Custom handler for match field.
Definition at line 519 of file res_pjsip_endpoint_identifier_ip.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ast_append_ha_with_port(), ast_log, ast_sockaddr_parse(), ast_sorcery_object_get_id(), ast_str_container_add(), ast_str_container_alloc_options(), ast_strdupa, ast_strip(), ast_strlen_zero(), error(), ip_identify_match::hosts, HOSTS_BUCKETS, LOG_ERROR, ip_identify_match::matches, strsep(), and var.
Referenced by load_module().
|
static |
Helper function which performs a host lookup and adds result to identify match.
Definition at line 454 of file res_pjsip_endpoint_identifier_ip.c.
References AST_AF_UNSPEC, ast_append_ha_with_port(), ast_apply_ha(), ast_free, AST_SENSE_ALLOW, ast_sockaddr_resolve(), ast_sockaddr_stringify(), error(), and ip_identify_match::matches.
Referenced by ip_identify_apply(), and ip_identify_match_srv_lookup().
|
static |
Helper function which performs an SRV lookup and then resolves the hostname.
Definition at line 488 of file res_pjsip_endpoint_identifier_ip.c.
References ast_srv_cleanup(), ast_srv_lookup(), voicemailpwcheck::context, ip_identify_match_host_lookup(), NULL, prefix, and service.
Referenced by ip_identify_apply().
|
static |
Definition at line 1020 of file res_pjsip_endpoint_identifier_ip.c.
References ao2_alloc, ARRAY_LEN, ast_cli_register_multiple, ast_log, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_sip_get_sorcery(), ast_sip_register_cli_formatter(), ast_sip_register_endpoint_formatter(), ast_sip_register_endpoint_identifier_with_name(), ast_sorcery_apply_config, ast_sorcery_apply_default, ast_sorcery_load_object(), ast_sorcery_object_field_register, ast_sorcery_object_field_register_custom, ast_sorcery_object_get_id(), ast_sorcery_object_register, cli_formatter, cli_get_container(), cli_identify, cli_iterator(), cli_print_body(), cli_print_header(), cli_retrieve_by_id(), endpoint_identify_formatter, FLDSET, ast_sip_cli_formatter_entry::get_container, ast_sip_cli_formatter_entry::get_id, header_identifier, ip_identifier, ip_identify_alloc(), ip_identify_apply(), ip_identify_match_handler(), ast_sip_cli_formatter_entry::iterate, LOG_ERROR, match_to_str(), match_to_var_list(), ast_sip_cli_formatter_entry::name, NULL, OPT_BOOL_T, OPT_NOOP_T, OPT_STRINGFIELD_T, ast_sip_cli_formatter_entry::print_body, ast_sip_cli_formatter_entry::print_header, request_identifier, ast_sip_cli_formatter_entry::retrieve_by_id, STRFLDSET, and transport_identifier.
|
static |
Definition at line 735 of file res_pjsip_endpoint_identifier_ip.c.
References ast_free, ast_ha_join(), ast_str_buffer(), ast_str_create, ast_strdup, buf, ip_identify_match::matches, MAX_OBJECT_FIELD, RAII_VAR, and str.
Referenced by load_module().
|
static |
Definition at line 762 of file res_pjsip_endpoint_identifier_ip.c.
References match_to_var_list_append(), ip_identify_match::matches, ast_ha::next, and NULL.
Referenced by load_module().
|
static |
Definition at line 745 of file res_pjsip_endpoint_identifier_ip.c.
References ast_ha::addr, AST_SENSE_ALLOW, ast_sockaddr_port, ast_sockaddr_stringify(), ast_sockaddr_stringify_addr(), ast_strdupa, ast_variable_list_append, ast_variable_new, MAX_OBJECT_FIELD, ast_ha::netmask, ast_ha::sense, and str.
Referenced by match_to_var_list().
|
static |
Definition at line 995 of file res_pjsip_endpoint_identifier_ip.c.
References a, and ast_sip_cli_traverse_objects().
|
static |
Definition at line 1063 of file res_pjsip_endpoint_identifier_ip.c.
References ast_sip_get_sorcery(), and ast_sorcery_reload_object().
|
static |
Definition at line 440 of file res_pjsip_endpoint_identifier_ip.c.
References common_identify(), and request_identify_match_check().
|
static |
Comparator function for matching an object by request URI.
Definition at line 286 of file res_pjsip_endpoint_identifier_ip.c.
References ast_assert, ast_debug, ast_sorcery_object_get_id(), ast_strlen_zero(), buf, CMP_MATCH, ip_identify_match::is_request_uri_regex, len(), ip_identify_match::match_request_uri, NULL, and ip_identify_match::regex_request_uri_buf.
Referenced by request_identify().
|
static |
Definition at line 785 of file res_pjsip_endpoint_identifier_ip.c.
References ast_free, ast_sip_create_ami_event(), ast_str_append(), ast_str_buffer(), astman_append(), buf, CMP_STOP, ast_sip_ami::count, ip_identify_match::endpoint_name, ast_sip_ami::s, and sip_identify_to_ami().
Referenced by format_ami_endpoint_identify().
|
static |
Definition at line 779 of file res_pjsip_endpoint_identifier_ip.c.
References ast_sip_sorcery_object_to_ami(), and buf.
Referenced by send_identify_ami_event().
|
static |
Definition at line 396 of file res_pjsip_endpoint_identifier_ip.c.
References ast_sockaddr_with_tp::addr, ast_log, ast_sockaddr_parse(), ast_sockaddr_set_port, common_identify(), ip_identify_match_check(), LOG_WARNING, NULL, PARSE_PORT_FORBID, status, and ast_sockaddr_with_tp::tp.
|
static |
Definition at line 1070 of file res_pjsip_endpoint_identifier_ip.c.
References ARRAY_LEN, ast_cli_unregister_multiple(), ast_sip_unregister_cli_formatter(), ast_sip_unregister_endpoint_formatter(), ast_sip_unregister_endpoint_identifier(), cli_formatter, cli_identify, endpoint_identify_formatter, header_identifier, ip_identifier, request_identifier, and transport_identifier.
|
static |
Definition at line 1090 of file res_pjsip_endpoint_identifier_ip.c.
|
static |
Definition at line 1090 of file res_pjsip_endpoint_identifier_ip.c.
|
static |
Definition at line 1018 of file res_pjsip_endpoint_identifier_ip.c.
Referenced by load_module(), and unload_module().
|
static |
Definition at line 1001 of file res_pjsip_endpoint_identifier_ip.c.
Referenced by load_module(), and unload_module().
struct ast_sip_endpoint_formatter endpoint_identify_formatter |
Definition at line 836 of file res_pjsip_endpoint_identifier_ip.c.
Referenced by load_module(), and unload_module().
|
static |
Definition at line 445 of file res_pjsip_endpoint_identifier_ip.c.
Referenced by load_module(), and unload_module().
|
static |
Definition at line 427 of file res_pjsip_endpoint_identifier_ip.c.
Referenced by load_module(), and unload_module().
|
static |
Definition at line 449 of file res_pjsip_endpoint_identifier_ip.c.
Referenced by load_module(), and unload_module().
|
static |
Definition at line 431 of file res_pjsip_endpoint_identifier_ip.c.
Referenced by load_module(), and unload_module().