Asterisk - The Open Source Telephony Project
18.5.0
|
#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 | 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 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 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 = "30ef0c93b36035ec78c9cfd712d36d9b" , .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 |
#define HOSTS_BUCKETS 53 |
The number of buckets for storing hosts for resolution.
Definition at line 122 of file res_pjsip_endpoint_identifier_ip.c.
Referenced by ip_identify_match_handler().
|
static |
Definition at line 905 of file res_pjsip_endpoint_identifier_ip.c.
|
static |
Definition at line 905 of file res_pjsip_endpoint_identifier_ip.c.
struct ast_module* AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 905 of file res_pjsip_endpoint_identifier_ip.c.
|
static |
Definition at line 698 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, and RAII_VAR.
Referenced by load_module().
|
static |
Definition at line 675 of file res_pjsip_endpoint_identifier_ip.c.
References ao2_callback, ao2_cleanup, 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 754 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, context, ip_identify_match::endpoint_name, ast_sip_cli_context::indent_level, match(), ip_identify_match::match_header, ip_identify_match::matches, MAX_OBJECT_FIELD, ast_ha::netmask, ast_ha::next, NULL, ast_sip_cli_context::output_buffer, RAII_VAR, ast_sip_cli_context::recurse, ast_ha::sense, ast_sip_cli_context::show_details, ast_sip_cli_context::show_details_only_level_0, and str.
Referenced by load_module().
|
static |
Definition at line 727 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, context, ast_sip_cli_context::indent_level, NULL, ast_sip_cli_context::output_buffer, and ast_sip_cli_context::recurse.
Referenced by load_module().
|
static |
Definition at line 722 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 265 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(), ip_identify_match::endpoint_name, LOG_WARNING, match(), NULL, and RAII_VAR.
Referenced by header_identify(), and ip_identify().
|
static |
Definition at line 646 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 312 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 178 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_regex, len(), ip_identify_match::match_header, ip_identify_match::match_header_name, ip_identify_match::match_header_value, NULL, PATH_MAX, and ip_identify_match::regex_buf.
Referenced by header_identify().
|
static |
Definition at line 298 of file res_pjsip_endpoint_identifier_ip.c.
References ast_sockaddr_parse(), ast_sockaddr_set_port, common_identify(), ip_identify_match_check(), and PARSE_PORT_FORBID.
|
static |
Allocator function for a matching object.
Definition at line 165 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 443 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_regex, len(), LOG_ERROR, LOG_WARNING, ip_identify_match::match_header, ip_identify_match::match_header_name, ip_identify_match::match_header_value, ip_identify_match::matches, NULL, ip_identify_match::regex_buf, and ip_identify_match::srv_lookups.
Referenced by load_module().
|
static |
Destructor function for a matching object.
Definition at line 152 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_regex, ip_identify_match::matches, and ip_identify_match::regex_buf.
Referenced by ip_identify_alloc().
|
static |
Comparator function for matching an object by IP address.
Definition at line 245 of file res_pjsip_endpoint_identifier_ip.c.
References ast_apply_ha(), ast_debug, AST_SENSE_ALLOW, ast_sockaddr_stringify(), ast_sorcery_object_get_id(), CMP_MATCH, and ip_identify_match::matches.
Referenced by ip_identify().
|
static |
Custom handler for match field.
Definition at line 387 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 ast_variable::value.
Referenced by load_module().
|
static |
Helper function which performs a host lookup and adds result to identify match.
Definition at line 322 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 356 of file res_pjsip_endpoint_identifier_ip.c.
References ast_srv_cleanup(), ast_srv_lookup(), context, ip_identify_match::hosts, ip_identify_match_host_lookup(), NULL, and service.
Referenced by ip_identify_apply().
|
static |
Definition at line 841 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_get_container(), cli_iterator(), cli_print_body(), cli_print_header(), cli_retrieve_by_id(), ip_identify_match::endpoint_name, FLDSET, ast_sip_cli_formatter_entry::get_container, ast_sip_cli_formatter_entry::get_id, ip_identify_alloc(), ip_identify_apply(), ip_identify_match_handler(), ast_sip_cli_formatter_entry::iterate, LOG_ERROR, ip_identify_match::match_header, 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, ast_sip_cli_formatter_entry::retrieve_by_id, ip_identify_match::srv_lookups, and STRFLDSET.
Referenced by unload_module().
|
static |
Definition at line 570 of file res_pjsip_endpoint_identifier_ip.c.
References ast_free, ast_ha_join(), ast_str_buffer(), ast_str_create, ast_strdup, ip_identify_match::matches, MAX_OBJECT_FIELD, RAII_VAR, and str.
Referenced by load_module().
|
static |
Definition at line 597 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 580 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 816 of file res_pjsip_endpoint_identifier_ip.c.
References ast_sip_cli_traverse_objects().
|
static |
Definition at line 880 of file res_pjsip_endpoint_identifier_ip.c.
References ast_sip_get_sorcery(), and ast_sorcery_reload_object().
Referenced by unload_module().
|
static |
Definition at line 620 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 614 of file res_pjsip_endpoint_identifier_ip.c.
References ast_sip_sorcery_object_to_ami().
Referenced by send_identify_ami_event().
|
static |
Definition at line 887 of file res_pjsip_endpoint_identifier_ip.c.
References ARRAY_LEN, ast_cli_unregister_multiple(), AST_MODFLAG_LOAD_ORDER, AST_MODPRI_CHANNEL_DEPEND, AST_MODULE_INFO(), AST_MODULE_SUPPORT_CORE, ast_sip_unregister_cli_formatter(), ast_sip_unregister_endpoint_formatter(), ast_sip_unregister_endpoint_identifier(), ASTERISK_GPL_KEY, load_module(), reload(), and reload_module().
|
static |
Definition at line 905 of file res_pjsip_endpoint_identifier_ip.c.
|
static |
Definition at line 905 of file res_pjsip_endpoint_identifier_ip.c.
|
static |
Definition at line 839 of file res_pjsip_endpoint_identifier_ip.c.
|
static |
Definition at line 822 of file res_pjsip_endpoint_identifier_ip.c.
struct ast_sip_endpoint_formatter endpoint_identify_formatter |
Definition at line 671 of file res_pjsip_endpoint_identifier_ip.c.
|
static |
Definition at line 317 of file res_pjsip_endpoint_identifier_ip.c.
|
static |
Definition at line 308 of file res_pjsip_endpoint_identifier_ip.c.