Asterisk - The Open Source Telephony Project
18.5.0
|
Bridge PJPROJECT logging to Asterisk logging. More...
#include "asterisk.h"
#include <stdarg.h>
#include <pjlib.h>
#include <pjsip.h>
#include <pj/log.h>
#include "asterisk/options.h"
#include "asterisk/logger.h"
#include "asterisk/module.h"
#include "asterisk/cli.h"
#include "asterisk/res_pjproject.h"
#include "asterisk/vector.h"
#include "asterisk/sorcery.h"
#include "asterisk/test.h"
#include "asterisk/netsock2.h"
Go to the source code of this file.
Data Structures | |
struct | log_mappings |
struct | max_pjproject_log_level_check |
struct | pjproject_log_intercept_data |
Macros | |
#define | __LOG_SUPPRESS -1 |
#define | NOT_EQUALS(a, b) (a != b) |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
void | ast_pjproject_caching_pool_destroy (pj_caching_pool *cp) |
Destroy caching pool factory and all cached pools. More... | |
void | ast_pjproject_caching_pool_init (pj_caching_pool *cp, const pj_pool_factory_policy *policy, pj_size_t max_capacity) |
Initialize the caching pool factory. More... | |
int | ast_pjproject_get_buildopt (char *option, char *format_string,...) |
Retrieve a pjproject build option. More... | |
void | ast_pjproject_log_intercept_begin (int fd) |
Begin PJPROJECT log interception for CLI output. More... | |
void | ast_pjproject_log_intercept_end (void) |
End PJPROJECT log interception for CLI output. More... | |
int | ast_sockaddr_from_pj_sockaddr (struct ast_sockaddr *addr, const pj_sockaddr *pjaddr) |
Fill an ast_sockaddr from a pj_sockaddr. More... | |
int | ast_sockaddr_to_pj_sockaddr (const struct ast_sockaddr *addr, pj_sockaddr *pjaddr) |
Fill a pj_sockaddr from an ast_sockaddr. More... | |
AST_TEST_DEFINE (ast_sockaddr_to_pj_sockaddr_test) | |
AST_TEST_DEFINE (ast_sockaddr_from_pj_sockaddr_test) | |
static | AST_VECTOR (buildopts, char *) |
static void | capture_buildopts_cb (int level, const char *data, int len) |
static void | fill_with_garbage (void *x, ssize_t len) |
static int | get_log_level (int pj_level) |
static struct log_mappings * | get_log_mappings (void) |
static char * | handle_pjproject_set_log_level (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_pjproject_show_buildopts (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_pjproject_show_log_level (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_pjproject_show_log_mappings (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static int | load_module (void) |
static void | log_forwarder (int level, const char *data, int len) |
static void * | mapping_alloc (const char *name) |
static void | mapping_destroy (void *object) |
static int | reload_module (void) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "PJPROJECT Log and Utility Support" , .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, .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND - 6, .requires = "res_sorcery_config", } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static unsigned | decor_orig |
static struct log_mappings * | default_log_mappings |
static pj_log_func * | log_cb_orig |
static struct ast_cli_entry | pjproject_cli [] |
static struct pjproject_log_intercept_data | pjproject_log_intercept |
static struct ast_sorcery * | pjproject_sorcery |
Bridge PJPROJECT logging to Asterisk logging.
PJPROJECT logging doesn't exactly match Asterisk logging, but mapping the two is not too bad. PJPROJECT log levels are identified by a single int. Limits are not specified by PJPROJECT, but their implementation used 1 through 6.
The mapping is as follows:
Definition in file res_pjproject.c.
#define __LOG_SUPPRESS -1 |
Definition at line 168 of file res_pjproject.c.
Referenced by get_log_level(), and log_forwarder().
|
static |
Definition at line 772 of file res_pjproject.c.
|
static |
Definition at line 772 of file res_pjproject.c.
struct ast_module* AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 772 of file res_pjproject.c.
void ast_pjproject_caching_pool_destroy | ( | pj_caching_pool * | cp | ) |
Destroy caching pool factory and all cached pools.
cp | Caching pool factory to destroy |
Definition at line 472 of file res_pjproject.c.
Referenced by rtp_terminate_pjproject(), unload_module(), and unload_pjsip().
void ast_pjproject_caching_pool_init | ( | pj_caching_pool * | cp, |
const pj_pool_factory_policy * | policy, | ||
pj_size_t | max_capacity | ||
) |
Initialize the caching pool factory.
cp | Caching pool factory to initialize |
policy | Pool factory policy |
max_capacity | Total capacity to be retained in the cache. Zero disables caching. |
Definition at line 465 of file res_pjproject.c.
References ast_option_pjproject_cache_pools.
Referenced by load_module(), and load_pjsip().
int ast_pjproject_get_buildopt | ( | char * | option, |
char * | format_string, | ||
... | |||
) |
Retrieve a pjproject build option.
option | The build option requested |
format_string | A scanf-style format string to parse the option value into |
... | Pointers to variables to receive the values parsed |
The | number of values parsed |
Sample Usage:
Definition at line 246 of file res_pjproject.c.
References ast_alloca, AST_VECTOR_GET, and AST_VECTOR_SIZE.
Referenced by ast_sip_initialize_sorcery_location(), and load_module().
void ast_pjproject_log_intercept_begin | ( | int | fd | ) |
Begin PJPROJECT log interception for CLI output.
fd | CLI file descriptior to send intercepted output. |
Definition at line 269 of file res_pjproject.c.
References ast_mutex_lock, pjproject_log_intercept_data::fd, and pjproject_log_intercept_data::thread.
Referenced by do_cli_dump_endpt().
void ast_pjproject_log_intercept_end | ( | void | ) |
End PJPROJECT log interception for CLI output.
Definition at line 278 of file res_pjproject.c.
References ast_mutex_unlock, AST_PTHREADT_NULL, pjproject_log_intercept_data::fd, and pjproject_log_intercept_data::thread.
Referenced by do_cli_dump_endpt().
int ast_sockaddr_from_pj_sockaddr | ( | struct ast_sockaddr * | addr, |
const pj_sockaddr * | pjaddr | ||
) |
Fill an ast_sockaddr from a pj_sockaddr.
addr | The target address to receive the copied address |
pjaddr | The source address to copy |
0 | Success |
-1 | Failure |
Definition at line 502 of file res_pjproject.c.
References HAVE_PJPROJECT_BUNDLED, ast_sockaddr::len, and ast_sockaddr::ss.
Referenced by AST_TEST_DEFINE().
int ast_sockaddr_to_pj_sockaddr | ( | const struct ast_sockaddr * | addr, |
pj_sockaddr * | pjaddr | ||
) |
Fill a pj_sockaddr from an ast_sockaddr.
addr | The source address to copy |
pjaddr | The target address to receive the copied address |
0 | Success |
-1 | Failure |
Definition at line 477 of file res_pjproject.c.
References ast_sockaddr::ss.
Referenced by AST_TEST_DEFINE(), and rtp_add_candidates_to_ice().
AST_TEST_DEFINE | ( | ast_sockaddr_to_pj_sockaddr_test | ) |
Definition at line 541 of file res_pjproject.c.
References ast_sockaddr_parse(), ast_sockaddr_to_pj_sockaddr(), AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, fill_with_garbage(), sip_to_pjsip::info(), NULL, TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | ast_sockaddr_from_pj_sockaddr_test | ) |
Definition at line 596 of file res_pjproject.c.
References ast_sockaddr_from_pj_sockaddr(), ast_sockaddr_stringify(), AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, fill_with_garbage(), sip_to_pjsip::info(), NULL, TEST_EXECUTE, and TEST_INIT.
|
static |
Protection from other log intercept instances. There can be only one at a time.
Definition at line 121 of file res_pjproject.c.
|
static |
Definition at line 231 of file res_pjproject.c.
References ast_free, ast_skip_blanks(), ast_strdup, and AST_VECTOR_ADD_SORTED.
Referenced by load_module().
|
static |
Definition at line 530 of file res_pjproject.c.
References ast_random().
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 170 of file res_pjproject.c.
References __LOG_DEBUG, __LOG_ERROR, __LOG_NOTICE, __LOG_SUPPRESS, __LOG_VERBOSE, __LOG_WARNING, ao2_ref, log_mappings::asterisk_debug, log_mappings::asterisk_error, log_mappings::asterisk_notice, log_mappings::asterisk_verbose, log_mappings::asterisk_warning, get_log_mappings(), and mappings.
Referenced by log_forwarder().
|
static |
Definition at line 156 of file res_pjproject.c.
References ao2_bump, ast_sorcery_retrieve_by_id(), and mappings.
Referenced by get_log_level(), and handle_pjproject_show_log_mappings().
|
static |
Definition at line 378 of file res_pjproject.c.
References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_option_pjproject_log_level, ast_pjproject_max_log_level, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, DEFAULT_PJ_LOG_MAX_LEVEL, ast_cli_args::fd, MAX_PJ_LOG_MAX_LEVEL, NULL, and ast_cli_entry::usage.
|
static |
Definition at line 286 of file res_pjproject.c.
References ast_cli(), AST_VECTOR_GET, AST_VECTOR_SIZE, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, NULL, and ast_cli_entry::usage.
|
static |
Definition at line 431 of file res_pjproject.c.
References ast_cli_args::argc, ast_cli(), ast_option_pjproject_log_level, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, DEFAULT_PJ_LOG_MAX_LEVEL, ast_cli_args::fd, NULL, and ast_cli_entry::usage.
|
static |
Definition at line 329 of file res_pjproject.c.
References ao2_ref, ast_cli(), ast_log, ast_sorcery_objectset_create, ast_variables_destroy(), CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, get_log_mappings(), LOG_ERROR, mappings, ast_variable::name, ast_variable::next, NULL, ast_cli_entry::usage, and ast_variable::value.
|
static |
Definition at line 655 of file res_pjproject.c.
References ARRAY_LEN, ast_cli_register_multiple, ast_debug, ast_log, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_option_pjproject_log_level, AST_PJPROJECT_INIT_LOG_LEVEL, ast_pjproject_max_log_level, ast_sorcery_alloc(), ast_sorcery_apply_default, ast_sorcery_load(), ast_sorcery_object_field_register, ast_sorcery_object_register, ast_sorcery_open, ast_sorcery_unref, ast_string_field_set, AST_TEST_REGISTER, AST_VECTOR_INIT, AST_VECTOR_SIZE, capture_buildopts_cb(), decor_orig, log_cb_orig, LOG_ERROR, log_forwarder(), LOG_NOTICE, LOG_WARNING, mapping_alloc(), MAX_PJ_LOG_MAX_LEVEL, NULL, OPT_NOOP_T, OPT_STRINGFIELD_T, and STRFLDSET.
Referenced by reload_module().
|
static |
Definition at line 201 of file res_pjproject.c.
References __LOG_SUPPRESS, ast_cli(), ast_log, pjproject_log_intercept_data::fd, get_log_level(), and pjproject_log_intercept_data::thread.
Referenced by load_module().
|
static |
Definition at line 318 of file res_pjproject.c.
References ast_sorcery_generic_alloc(), ast_string_field_init, mapping_destroy(), mappings, and NULL.
Referenced by load_module().
|
static |
Definition at line 311 of file res_pjproject.c.
References ast_string_field_free_memory.
Referenced by mapping_alloc().
|
static |
Definition at line 756 of file res_pjproject.c.
References AST_MODFLAG_GLOBAL_SYMBOLS, AST_MODFLAG_LOAD_ORDER, AST_MODPRI_CHANNEL_DEPEND, AST_MODULE_INFO(), AST_MODULE_LOAD_SUCCESS, AST_MODULE_SUPPORT_CORE, ast_sorcery_reload(), ASTERISK_GPL_KEY, load_module(), reload(), and unload_module().
|
static |
Definition at line 732 of file res_pjproject.c.
References ao2_cleanup, ARRAY_LEN, ast_cli_unregister_multiple(), ast_debug, ast_free, ast_sorcery_unref, AST_TEST_UNREGISTER, AST_VECTOR_CALLBACK_VOID, AST_VECTOR_FREE, decor_orig, log_cb_orig, and NULL.
Referenced by reload_module().
|
static |
Definition at line 772 of file res_pjproject.c.
|
static |
Definition at line 772 of file res_pjproject.c.
|
static |
Definition at line 119 of file res_pjproject.c.
Referenced by load_module(), and unload_module().
|
static |
Definition at line 154 of file res_pjproject.c.
|
static |
Definition at line 118 of file res_pjproject.c.
Referenced by load_module(), and unload_module().
|
static |
Definition at line 458 of file res_pjproject.c.
|
static |
Definition at line 131 of file res_pjproject.c.
|
static |
Definition at line 117 of file res_pjproject.c.