| Asterisk - The Open Source Telephony Project GIT-master-27fb039
    | 
#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. | |
| 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. | |
| 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. | |
| static int | ip_identify_apply (const struct ast_sorcery *sorcery, void *obj) | 
| Apply handler for identify type. | |
| static void | ip_identify_destroy (void *obj) | 
| Destructor function for a matching object. | |
| static int | ip_identify_match_check (void *obj, void *arg, int flags) | 
| Comparator function for matching an object by IP address. | |
| static int | ip_identify_match_handler (const struct aco_option *opt, struct ast_variable *var, void *obj) | 
| Custom handler for match field. | |
| 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. | |
| 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. | |
| 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. | |
| 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 = ASTERISK_GPL_KEY , .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 | 
| #define HOSTS_BUCKETS 53 | 
The number of buckets for storing hosts for resolution.
Definition at line 162 of file res_pjsip_endpoint_identifier_ip.c.
| 
 | static | 
Definition at line 1035 of file res_pjsip_endpoint_identifier_ip.c.
| 
 | static | 
Definition at line 1035 of file res_pjsip_endpoint_identifier_ip.c.
| struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) | 
Definition at line 1035 of file res_pjsip_endpoint_identifier_ip.c.
| 
 | static | 
Definition at line 818 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 795 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(), callback(), container, ast_variable::name, NULL, and OBJ_NODATA.
Referenced by load_module().
| 
 | static | 
Definition at line 874 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, 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, and str.
Referenced by load_module().
| 
 | static | 
Definition at line 847 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, and NULL.
Referenced by load_module().
| 
 | static | 
Definition at line 842 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 349 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(), and request_identify().
| 
 | static | 
Definition at line 766 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 396 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 227 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 382 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 214 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 536 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, and ip_identify_match::srv_lookups.
Referenced by load_module().
| 
 | static | 
Destructor function for a matching object.
Definition at line 198 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 329 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 480 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 415 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 449 of file res_pjsip_endpoint_identifier_ip.c.
References ast_srv_cleanup(), ast_srv_lookup(), ip_identify_match_host_lookup(), NULL, prefix, and service.
Referenced by ip_identify_apply().
| 
 | static | 
Definition at line 968 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, and STRFLDSET.
| 
 | static | 
Definition at line 690 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 717 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 700 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 943 of file res_pjsip_endpoint_identifier_ip.c.
References a, and ast_sip_cli_traverse_objects().
| 
 | static | 
Definition at line 1009 of file res_pjsip_endpoint_identifier_ip.c.
References ast_sip_get_sorcery(), and ast_sorcery_reload_object().
| 
 | static | 
Definition at line 401 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 294 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 740 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 734 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 1016 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, and request_identifier.
| 
 | static | 
Definition at line 1035 of file res_pjsip_endpoint_identifier_ip.c.
| 
 | static | 
Definition at line 1035 of file res_pjsip_endpoint_identifier_ip.c.
| 
 | static | 
Definition at line 966 of file res_pjsip_endpoint_identifier_ip.c.
Referenced by load_module(), and unload_module().
| 
 | static | 
Definition at line 949 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 791 of file res_pjsip_endpoint_identifier_ip.c.
Referenced by load_module(), and unload_module().
| 
 | static | 
Definition at line 406 of file res_pjsip_endpoint_identifier_ip.c.
Referenced by load_module(), and unload_module().
| 
 | static | 
Definition at line 392 of file res_pjsip_endpoint_identifier_ip.c.
Referenced by load_module(), and unload_module().
| 
 | static | 
Definition at line 410 of file res_pjsip_endpoint_identifier_ip.c.
Referenced by load_module(), and unload_module().