Asterisk - The Open Source Telephony Project
21.4.1
|
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 = "da6642af068ee5e6490c5b1d2cc1d238" , .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.
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 rtp_reload().
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 rtp_reload().
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.
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 pjproject_log_intercept_lock.
void ast_pjproject_log_intercept_end | ( | void | ) |
End PJPROJECT log interception for CLI output.
Definition at line 288 of file res_pjproject.c.
References pjproject_log_intercept_lock.
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.
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(), and ast_strdupa.
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.
Referenced by rtp_add_candidates_to_ice().
|
static |
Definition at line 137 of file res_pjproject.c.
|
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().