| Asterisk - The Open Source Telephony Project GIT-master-27fb039
    | 
#include "asterisk.h"#include <netinet/in.h>#include <pjsip.h>#include "asterisk/res_pjsip.h"#include "asterisk/vector.h"#include "asterisk/module.h"#include "asterisk/logger.h"#include "asterisk/cli.h"#include "asterisk/netsock2.h"#include "asterisk/acl.h"
Go to the source code of this file.
| Data Structures | |
| struct | method_logging_info | 
| struct | pcap_ethernet_header | 
| PCAP Ethernet Header.  More... | |
| struct | pcap_header | 
| PCAP Header.  More... | |
| struct | pcap_ipv4_header | 
| PCAP IPv4 Header.  More... | |
| struct | pcap_ipv6_header | 
| PCAP IPv6 Header.  More... | |
| struct | pcap_record_header | 
| PCAP Packet Record Header.  More... | |
| struct | pcap_udp_header | 
| PCAP UDP Header.  More... | |
| struct | pjsip_logger_session | 
| PJSIP Logging Session.  More... | |
| Enumerations | |
| enum | pjsip_logger_mask { AST_PJSIP_LOGGER_UNSET = 0 , AST_PJSIP_LOGGER_NONE = (1 << 0) , AST_PJSIP_LOGGER_HOST = (1 << 1) , AST_PJSIP_LOGGER_METHOD = (1 << 2) , AST_PJSIP_LOGGER_VERBOSE = (1 << 3) , AST_PJSIP_LOGGER_PCAP = (1 << 4) , AST_PJSIP_LOGGER_ALL = (1 << 5) } | 
| Functions | |
| static void | __reg_module (void) | 
| static void | __unreg_module (void) | 
| static int | apply_method_filter (const struct pjsip_logger_session *session, const pjsip_method *method) | 
| struct ast_module * | AST_MODULE_SELF_SYM (void) | 
| static void | check_debug (void) | 
| static void | global_reloaded (const char *object_type) | 
| static int | load_module (void) | 
| static pj_bool_t | logging_on_rx_msg (pjsip_rx_data *rdata) | 
| static pj_status_t | logging_on_tx_msg (pjsip_tx_data *tdata) | 
| static struct method_logging_info * | method_logging_info_alloc (const char *method) | 
| static int | method_logging_info_cmp (const struct method_logging_info *element, const struct method_logging_info *candidate) | 
| static int | method_logging_info_sort_cmp (const void *a, const void *b) | 
| static char * | pjsip_disable_logger (int fd) | 
| static char * | pjsip_enable_logger_all (int fd) | 
| static char * | pjsip_enable_logger_host (int fd, const char *arg, unsigned int add_host) | 
| static char * | pjsip_enable_logger_method (int fd, const char *arg, int add_method) | 
| Add the current or an additional method to match for filtering. | |
| static int | pjsip_log_test_filter (const struct pjsip_logger_session *session, const char *address, int port, const pjsip_method *method) | 
| See if we pass debug filter. | |
| static struct pjsip_logger_session * | pjsip_logger_session_alloc (void) | 
| Allocator for logger session. | |
| static void | pjsip_logger_session_destroy (void *obj) | 
| Destructor for logger session. | |
| static void | pjsip_logger_write_to_pcap (struct pjsip_logger_session *session, const char *msg, size_t msg_len, pj_sockaddr *source, pj_sockaddr *destination) | 
| static char * | pjsip_set_logger (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) | 
| static char * | pjsip_set_logger_pcap (int fd, const char *arg) | 
| static char * | pjsip_set_logger_verbose (int fd, const char *arg) | 
| static int | unload_module (void) | 
| Variables | |
| static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "PJSIP Packet Logger" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND, .requires = "res_pjsip", } | 
| static const struct ast_module_info * | ast_module_info = &__mod_info | 
| static struct ast_cli_entry | cli_pjsip [] | 
| static struct pjsip_logger_session * | default_logger | 
| The default logger session. | |
| static const struct ast_sorcery_observer | global_observer | 
| static enum pjsip_logger_mask | logger_cli_settings = AST_PJSIP_LOGGER_UNSET | 
| static enum pjsip_logger_mask | logger_config_settings = AST_PJSIP_LOGGER_UNSET | 
| static pjsip_module | logging_module | 
| enum pjsip_logger_mask | 
| Enumerator | |
|---|---|
| AST_PJSIP_LOGGER_UNSET | |
| AST_PJSIP_LOGGER_NONE | |
| AST_PJSIP_LOGGER_HOST | |
| AST_PJSIP_LOGGER_METHOD | |
| AST_PJSIP_LOGGER_VERBOSE | |
| AST_PJSIP_LOGGER_PCAP | |
| AST_PJSIP_LOGGER_ALL | |
Definition at line 601 of file res_pjsip_logger.c.
| 
 | static | 
Definition at line 781 of file res_pjsip_logger.c.
| 
 | static | 
Definition at line 781 of file res_pjsip_logger.c.
| 
 | static | 
Definition at line 166 of file res_pjsip_logger.c.
References AST_VECTOR_GET, AST_VECTOR_SIZE, method, method_logging_info::method, and session.
Referenced by pjsip_log_test_filter().
| struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) | 
Definition at line 781 of file res_pjsip_logger.c.
| 
 | static | 
Definition at line 684 of file res_pjsip_logger.c.
References ast_debug, ast_false(), ast_free, ast_log, AST_PJSIP_LOGGER_ALL, AST_PJSIP_LOGGER_HOST, AST_PJSIP_LOGGER_NONE, AST_PJSIP_LOGGER_UNSET, ast_sip_get_debug(), ast_true(), CLI_SUCCESS, debug, LOG_WARNING, logger_cli_settings, logger_config_settings, pjsip_disable_logger(), pjsip_enable_logger_all(), pjsip_enable_logger_host(), and RAII_VAR.
Referenced by global_reloaded(), and load_module().
| 
 | static | 
Definition at line 729 of file res_pjsip_logger.c.
References check_debug().
| 
 | static | 
Definition at line 738 of file res_pjsip_logger.c.
References ARRAY_LEN, ast_cli_register_multiple, ast_log, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_sip_get_sorcery(), ast_sip_register_service(), ast_sorcery_observer_add(), ast_sorcery_observer_remove(), check_debug(), cli_pjsip, default_logger, global_observer, LOG_WARNING, logging_module, and pjsip_logger_session_alloc().
| 
 | static | 
Definition at line 338 of file res_pjsip_logger.c.
References ao2_rdlock, ao2_unlock, AST_SOCKADDR_BUFLEN, ast_verbose, default_logger, pjsip_logger_session::log_to_pcap, pjsip_logger_session::log_to_verbose, NULL, pjsip_log_test_filter(), and pjsip_logger_write_to_pcap().
| 
 | static | 
Definition at line 310 of file res_pjsip_logger.c.
References ao2_rdlock, ao2_unlock, AST_SOCKADDR_BUFLEN, ast_verbose, default_logger, pjsip_logger_session::log_to_pcap, pjsip_logger_session::log_to_verbose, NULL, pjsip_log_test_filter(), and pjsip_logger_write_to_pcap().
| 
 | static | 
Definition at line 438 of file res_pjsip_logger.c.
References ast_calloc, method, and NULL.
Referenced by pjsip_enable_logger_method().
| 
 | static | 
Definition at line 455 of file res_pjsip_logger.c.
References CMP_MATCH, CMP_STOP, and method_logging_info::method.
Referenced by pjsip_enable_logger_method().
| 
 | static | 
Definition at line 463 of file res_pjsip_logger.c.
Referenced by pjsip_enable_logger_method().
| 
 | static | 
Definition at line 525 of file res_pjsip_logger.c.
References ao2_unlock, ao2_wrlock, ast_cli(), ast_free, ast_free_ha(), AST_VECTOR_RESET, CLI_SUCCESS, default_logger, pjsip_logger_session::enabled, pjsip_logger_session::log_all_traffic, pjsip_logger_session::log_methods, pjsip_logger_session::log_to_pcap, pjsip_logger_session::log_to_verbose, pjsip_logger_session::matches, NULL, pjsip_logger_session::pcap_file, and pjsip_logger_session::pcap_filename.
Referenced by check_debug(), and pjsip_set_logger().
| 
 | static | 
Definition at line 379 of file res_pjsip_logger.c.
References ao2_unlock, ao2_wrlock, ast_cli(), CLI_SUCCESS, default_logger, pjsip_logger_session::enabled, and pjsip_logger_session::log_all_traffic.
Referenced by check_debug(), and pjsip_set_logger().
| 
 | static | 
Definition at line 393 of file res_pjsip_logger.c.
References ao2_unlock, ao2_wrlock, AST_AF_UNSPEC, ast_append_ha_with_port(), ast_cli(), ast_free_ha(), ast_sockaddr_parse(), ast_sockaddr_resolve_first_af(), ast_sockaddr_stringify(), ast_sockaddr_stringify_addr(), CLI_SHOWUSAGE, CLI_SUCCESS, default_logger, pjsip_logger_session::enabled, error(), pjsip_logger_session::matches, and NULL.
Referenced by check_debug(), and pjsip_set_logger().
| 
 | static | 
Add the current or an additional method to match for filtering.
Definition at line 471 of file res_pjsip_logger.c.
References ao2_unlock, ao2_wrlock, ast_cli(), ast_free, ast_log, ast_str_append(), ast_str_buffer(), ast_str_create, ast_str_strlen(), AST_VECTOR_APPEND, AST_VECTOR_CALLBACK, AST_VECTOR_GET, AST_VECTOR_RESET, AST_VECTOR_SIZE, AST_VECTOR_SORT, CLI_FAILURE, CLI_SUCCESS, default_logger, pjsip_logger_session::enabled, LOG_ERROR, pjsip_logger_session::log_methods, method, method_logging_info_alloc(), method_logging_info_cmp(), method_logging_info_sort_cmp(), NULL, and str.
Referenced by pjsip_set_logger().
| 
 | inlinestatic | 
See if we pass debug filter.
Definition at line 188 of file res_pjsip_logger.c.
References apply_method_filter(), ast_apply_ha(), AST_SENSE_ALLOW, ast_sockaddr_parse(), ast_sockaddr_set_port, ast_strlen_zero(), AST_VECTOR_SIZE, method, PARSE_PORT_IGNORE, and session.
Referenced by logging_on_rx_msg(), and logging_on_tx_msg().
| 
 | static | 
Allocator for logger session.
Definition at line 148 of file res_pjsip_logger.c.
References AO2_ALLOC_OPT_LOCK_RWLOCK, ao2_alloc_options, AST_VECTOR_INIT, NULL, pjsip_logger_session_destroy(), and session.
Referenced by load_module().
| 
 | static | 
Destructor for logger session.
Definition at line 133 of file res_pjsip_logger.c.
References ast_free, ast_free_ha(), AST_VECTOR_FREE, AST_VECTOR_RESET, and session.
Referenced by pjsip_logger_session_alloc().
| 
 | static | 
Definition at line 222 of file res_pjsip_logger.c.
References ao2_unlock, ao2_wrlock, ast_log, ast_tvnow(), pcap_udp_header::dst, errno, pcap_record_header::incl_len, pcap_ipv6_header::ip6_ctlun, pcap_ipv6_header::ip6_dst, pcap_ipv6_header::ip6_src, pcap_ipv6_header::ip6_un1, pcap_ipv6_header::ip6_un2_vfc, pcap_ipv4_header::ip_dst, pcap_ipv4_header::ip_len, pcap_ipv4_header::ip_protocol, pcap_ipv4_header::ip_src, pcap_udp_header::length, LOG_WARNING, pcap_record_header::orig_len, session, pcap_udp_header::src, pcap_record_header::ts_sec, pcap_ethernet_header::type, and pcap_ipv4_header::ver_ihl.
Referenced by logging_on_rx_msg(), and logging_on_tx_msg().
| 
 | static | 
Definition at line 614 of file res_pjsip_logger.c.
References a, ast_cli_entry::args, ast_cli_complete(), AST_PJSIP_LOGGER_ALL, AST_PJSIP_LOGGER_HOST, AST_PJSIP_LOGGER_METHOD, AST_PJSIP_LOGGER_NONE, AST_PJSIP_LOGGER_PCAP, AST_PJSIP_LOGGER_VERBOSE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, ast_cli_entry::command, logger_cli_settings, NULL, pjsip_disable_logger(), pjsip_enable_logger_all(), pjsip_enable_logger_host(), pjsip_enable_logger_method(), pjsip_set_logger_pcap(), pjsip_set_logger_verbose(), and ast_cli_entry::usage.
| 
 | static | 
Definition at line 567 of file res_pjsip_logger.c.
References ao2_unlock, ao2_wrlock, ast_cli(), ast_copy_string(), CLI_SUCCESS, default_logger, pjsip_logger_session::log_to_pcap, pcap_header::magic_number, NULL, pjsip_logger_session::pcap_file, and pjsip_logger_session::pcap_filename.
Referenced by pjsip_set_logger().
| 
 | static | 
Definition at line 556 of file res_pjsip_logger.c.
References ao2_unlock, ao2_wrlock, ast_cli(), ast_true(), CLI_SUCCESS, default_logger, and pjsip_logger_session::log_to_verbose.
Referenced by pjsip_set_logger().
| 
 | static | 
Definition at line 761 of file res_pjsip_logger.c.
References ao2_cleanup, ARRAY_LEN, ast_cli_unregister_multiple(), ast_sip_get_sorcery(), ast_sip_unregister_service(), ast_sorcery_observer_remove(), cli_pjsip, default_logger, global_observer, logging_module, and NULL.
| 
 | static | 
Definition at line 781 of file res_pjsip_logger.c.
| 
 | static | 
Definition at line 781 of file res_pjsip_logger.c.
| 
 | static | 
Definition at line 680 of file res_pjsip_logger.c.
Referenced by load_module(), and unload_module().
| 
 | static | 
The default logger session.
Definition at line 130 of file res_pjsip_logger.c.
Referenced by load_module(), logging_on_rx_msg(), logging_on_tx_msg(), pjsip_disable_logger(), pjsip_enable_logger_all(), pjsip_enable_logger_host(), pjsip_enable_logger_method(), pjsip_set_logger_pcap(), pjsip_set_logger_verbose(), and unload_module().
| 
 | static | 
Definition at line 734 of file res_pjsip_logger.c.
Referenced by load_module(), and unload_module().
| 
 | static | 
Definition at line 611 of file res_pjsip_logger.c.
Referenced by check_debug(), and pjsip_set_logger().
| 
 | static | 
Definition at line 612 of file res_pjsip_logger.c.
Referenced by check_debug().
| 
 | static | 
Definition at line 370 of file res_pjsip_logger.c.
Referenced by load_module(), and unload_module().