Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
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 | buildopts |
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_pj_sockaddr_cmp (const struct ast_sockaddr *addr, const pj_sockaddr *pjaddr) |
Compare an ast_sockaddr to 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... | |
static void | capture_buildopts_cb (int level, const char *data, int 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 = AST_BUILDOPT_SUM, .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 struct buildopts | buildopts |
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 ast_mutex_t | pjproject_log_intercept_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } |
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 176 of file res_pjproject.c.
|
static |
Definition at line 808 of file res_pjproject.c.
|
static |
Definition at line 808 of file res_pjproject.c.
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 808 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 484 of file res_pjproject.c.
Referenced by 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 477 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 256 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 279 of file res_pjproject.c.
References ast_mutex_lock, pjproject_log_intercept_data::fd, pjproject_log_intercept, pjproject_log_intercept_lock, 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 288 of file res_pjproject.c.
References ast_mutex_unlock, AST_PTHREADT_NULL, pjproject_log_intercept_data::fd, pjproject_log_intercept, pjproject_log_intercept_lock, 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 514 of file res_pjproject.c.
References ast_sockaddr::len, and ast_sockaddr::ss.
Referenced by ast_sockaddr_pj_sockaddr_cmp().
int ast_sockaddr_pj_sockaddr_cmp | ( | const struct ast_sockaddr * | addr, |
const pj_sockaddr * | pjaddr | ||
) |
Compare an ast_sockaddr to a pj_sockaddr.
addr | pointer to ast_sockaddr structure |
pjaddr | pointer to pj_sockaddr structure |
-1 | addr is lexicographically smaller than pjaddr |
0 | addr is equal to pjaddr |
1 | pjaddr is lexicographically smaller than addr |
Definition at line 542 of file res_pjproject.c.
References ast_debug, ast_sockaddr_cmp(), ast_sockaddr_from_pj_sockaddr(), ast_sockaddr_stringify(), ast_strdupa, and DEBUG_ATLEAST.
Referenced by __rtp_recvfrom().
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 489 of file res_pjproject.c.
References ast_sockaddr::ss.
|
static |
Definition at line 241 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 178 of file res_pjproject.c.
References __LOG_DEBUG, __LOG_ERROR, __LOG_NOTICE, __LOG_SUPPRESS, __LOG_TRACE, __LOG_VERBOSE, __LOG_WARNING, ao2_ref, get_log_mappings(), and mappings.
Referenced by log_forwarder().
|
static |
Definition at line 164 of file res_pjproject.c.
References ao2_bump, ast_sorcery_retrieve_by_id(), default_log_mappings, mappings, and pjproject_sorcery.
Referenced by get_log_level(), and handle_pjproject_show_log_mappings().
|
static |
Definition at line 388 of file res_pjproject.c.
References a, 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, MAX_PJ_LOG_MAX_LEVEL, NULL, and ast_cli_entry::usage.
|
static |
Definition at line 296 of file res_pjproject.c.
References a, ast_cli(), AST_VECTOR_GET, AST_VECTOR_SIZE, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, NULL, and ast_cli_entry::usage.
|
static |
Definition at line 443 of file res_pjproject.c.
References a, ast_cli(), ast_option_pjproject_log_level, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, DEFAULT_PJ_LOG_MAX_LEVEL, NULL, and ast_cli_entry::usage.
|
static |
Definition at line 339 of file res_pjproject.c.
References a, ao2_ref, ast_cli(), ast_log, ast_sorcery_objectset_create, ast_variables_destroy(), CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, get_log_mappings(), LOG_ERROR, mappings, ast_variable::name, ast_variable::next, NULL, pjproject_sorcery, ast_cli_entry::usage, and ast_variable::value.
|
static |
Definition at line 689 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, default_log_mappings, 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, pjproject_cli, pjproject_sorcery, and STRFLDSET.
|
static |
Definition at line 211 of file res_pjproject.c.
References __LOG_SUPPRESS, ast_cli(), ast_log, pjproject_log_intercept_data::fd, get_log_level(), pjproject_log_intercept, and pjproject_log_intercept_data::thread.
Referenced by load_module().
|
static |
Definition at line 328 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 321 of file res_pjproject.c.
References ast_string_field_free_memory.
Referenced by mapping_alloc().
|
static |
Definition at line 792 of file res_pjproject.c.
References AST_MODULE_LOAD_SUCCESS, ast_sorcery_reload(), and pjproject_sorcery.
|
static |
Definition at line 768 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, default_log_mappings, log_cb_orig, NULL, pjproject_cli, and pjproject_sorcery.
|
static |
Definition at line 808 of file res_pjproject.c.
|
static |
Definition at line 808 of file res_pjproject.c.
|
static |
Definition at line 125 of file res_pjproject.c.
Referenced by load_module(), and unload_module().
|
static |
Definition at line 162 of file res_pjproject.c.
Referenced by get_log_mappings(), load_module(), and unload_module().
|
static |
Definition at line 124 of file res_pjproject.c.
Referenced by load_module(), and unload_module().
|
static |
Definition at line 470 of file res_pjproject.c.
Referenced by load_module(), and unload_module().
|
static |
Definition at line 137 of file res_pjproject.c.
Referenced by ast_pjproject_log_intercept_begin(), ast_pjproject_log_intercept_end(), and log_forwarder().
|
static |
Protection from other log intercept instances. There can be only one at a time.
Definition at line 130 of file res_pjproject.c.
Referenced by ast_pjproject_log_intercept_begin(), and ast_pjproject_log_intercept_end().
|
static |
Definition at line 123 of file res_pjproject.c.
Referenced by get_log_mappings(), handle_pjproject_show_log_mappings(), load_module(), reload_module(), and unload_module().