summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2016-01-13 09:48:54 -0600
committerGerrit Code Review <gerrit2@gerrit.digium.api>2016-01-13 09:48:54 -0600
commitf18ad96b77d2f6fd2434b52eb62e5f3b1e079512 (patch)
tree0da45f488f1b03bb8c82ee7939e3840ea8c2d34a
parente7cfda0b384897c6f52db0c7d7b126f5158461cb (diff)
parent5586abc95728996ce9e36c54a1ee8f6d8de9c525 (diff)
Merge "res_pjsip_log_forwarder.c: Add CLI "pjsip show buildopts"." into 13
-rwxr-xr-x[-rw-r--r--]contrib/scripts/autosupport12
-rw-r--r--res/res_pjsip_log_forwarder.c61
2 files changed, 68 insertions, 5 deletions
diff --git a/contrib/scripts/autosupport b/contrib/scripts/autosupport
index e41215f40..3e0213afe 100644..100755
--- a/contrib/scripts/autosupport
+++ b/contrib/scripts/autosupport
@@ -3,7 +3,7 @@
# Autosupport Version 2.1.0
# Collect support information
#
-# Copyright (C) 2005-2013, Digium, Inc.
+# Copyright (C) 2005-2016, Digium, Inc.
#
# Written by John Bigelow (support@digium.com)
# Charles Moye (cmoye@digium.com)
@@ -38,7 +38,7 @@ then
-h | --help)
echo
echo "Digium autosupport script"
- echo "Copyright (C) 2005-2013, Digium, Inc."
+ echo "Copyright (C) 2005-2016, Digium, Inc."
echo "Licensed under the terms of the GNU General Public License"
echo
echo "usage: autosupport [prefix]"
@@ -186,7 +186,9 @@ asterisk -V >> $OUTPUT;
echo >> $OUTPUT;
# Add check to see if asterisk is running.
if [ -e /var/run/asterisk.ctl ] || [ -e /var/run/asterisk/asterisk.ctl ]; then
- for command in "core show version" "pri show version" "dahdi show version" "core show translation" \
+ for command in "core show version" "pri show version" "dahdi show version" \
+ "pjsip show version" "pjsip show buildopts" \
+ "core show translation" \
"core show uptime" "core show settings" "core show sysinfo" "core show channels" \
"pri show spans" "dahdi show status" "dahdi show channels" "dahdi show channel 1" \
"pjsip show endpoints" "pjsip show registrations" "pjsip list channels" \
@@ -194,9 +196,9 @@ if [ -e /var/run/asterisk.ctl ] || [ -e /var/run/asterisk/asterisk.ctl ]; then
"show g729" "g729 show version" "g729 show licenses" "g729 show hostid" \
"digium_phones show version" "digium_phones show alerts" "digium_phones show applications" \
"digium_phones show firmwares" "digium_phones show lines" "digium_phones show networks" \
- "digium_phones show phones" "digium_phones show sessions" "digium_phones show settings" \
+ "digium_phones show phones" "digium_phones show sessions" "digium_phones show settings" \
"digium_phones show translations" ;
- do
+ do
echo "asterisk -rx \"$command\"" >> $OUTPUT;
asterisk -rx "$command" >> $OUTPUT;
echo >> $OUTPUT;
diff --git a/res/res_pjsip_log_forwarder.c b/res/res_pjsip_log_forwarder.c
index 7b095bb1f..7a7128054 100644
--- a/res/res_pjsip_log_forwarder.c
+++ b/res/res_pjsip_log_forwarder.c
@@ -46,10 +46,24 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/logger.h"
#include "asterisk/module.h"
+#include "asterisk/cli.h"
static pj_log_func *log_cb_orig;
static unsigned decor_orig;
+/*! Protection from other CLI instances. */
+AST_MUTEX_DEFINE_STATIC(show_buildopts_lock);
+
+struct pjsip_show_buildopts {
+ pthread_t thread;
+ int fd;
+};
+
+static struct pjsip_show_buildopts show_buildopts = {
+ .thread = AST_PTHREADT_NULL,
+ .fd = -1,
+};
+
static void log_cb(int level, const char *data, int len)
{
int ast_level;
@@ -59,6 +73,15 @@ static void log_cb(int level, const char *data, int len)
const char *log_func = "<?>";
int mod_level;
+ if (show_buildopts.fd != -1 && show_buildopts.thread == pthread_self()) {
+ /*
+ * We are handling the CLI command dumping the
+ * PJPROJECT compile time config option settings.
+ */
+ ast_cli(show_buildopts.fd, "%s\n", data);
+ return;
+ }
+
/* Lower number indicates higher importance */
switch (level) {
case 0: /* level zero indicates fatal error, according to docs */
@@ -86,6 +109,40 @@ static void log_cb(int level, const char *data, int len)
ast_log(ast_level, log_source, log_line, log_func, "\t%s\n", data);
}
+static char *handle_pjsip_show_buildopts(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ switch(cmd) {
+ case CLI_INIT:
+ e->command = "pjsip show buildopts";
+ e->usage =
+ "Usage: pjsip show buildopts\n"
+ " Show the compile time config of pjproject that res_pjsip is\n"
+ " running against.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ ast_cli(a->fd, "PJPROJECT compile time config currently running against:\n");
+
+ /* Protect from other CLI instances trying to do this at the same time. */
+ ast_mutex_lock(&show_buildopts_lock);
+
+ show_buildopts.thread = pthread_self();
+ show_buildopts.fd = a->fd;
+ pj_dump_config();
+ show_buildopts.fd = -1;
+ show_buildopts.thread = AST_PTHREADT_NULL;
+
+ ast_mutex_unlock(&show_buildopts_lock);
+
+ return CLI_SUCCESS;
+}
+
+static struct ast_cli_entry pjsip_cli[] = {
+ AST_CLI_DEFINE(handle_pjsip_show_buildopts, "Show the compiled config of pjproject in use"),
+};
+
static int load_module(void)
{
pj_init();
@@ -102,11 +159,15 @@ static int load_module(void)
pj_log_set_decor(PJ_LOG_HAS_SENDER | PJ_LOG_HAS_INDENT);
pj_log_set_log_func(log_cb);
+ ast_cli_register_multiple(pjsip_cli, ARRAY_LEN(pjsip_cli));
+
return AST_MODULE_LOAD_SUCCESS;
}
static int unload_module(void)
{
+ ast_cli_unregister_multiple(pjsip_cli, ARRAY_LEN(pjsip_cli));
+
pj_log_set_log_func(log_cb_orig);
pj_log_set_decor(decor_orig);