Skip to content
Snippets Groups Projects
Commit 49ed50d8 authored by Kinsey Moore's avatar Kinsey Moore
Browse files

Allow more control over the output of pri debug

This changes the debuglevel of 'pri set debug' to a bit mask allowing the user
to independently select bits of output:
1 libpri internals including state machine
2 Decoded Q.931 messages
4 Decoded Q.921 headers
8 raw hex dump of the full frames

Additionally, this ensures that the meaning of "on" does not change and
intrudces intense and hex to simplify usage.

(closes issue ASTERISK-17159)
Original-patch-by: wimpy


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@354165 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent d162e859
No related branches found
No related tags found
No related merge requests found
......@@ -14319,13 +14319,22 @@ static char *handle_pri_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_a
{
int span;
int x;
int debugmask = 0;
int level = 0;
switch (cmd) {
case CLI_INIT:
e->command = "pri set debug {on|off|0|1|2} span";
e->command = "pri set debug {on|off|hex|intense|0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15} span";
e->usage =
"Usage: pri set debug {<level>|on|off} span <span>\n"
" Enables debugging on a given PRI span\n";
"Usage: pri set debug {<level>|on|off|hex|intense} span <span>\n"
" Enables debugging on a given PRI span\n"
" Level is a bitmap of the following values:\n"
" 1 General debugging incl. state changes\n"
" 2 Decoded Q.931 messages\n"
" 4 Decoded Q.921 messages\n"
" 8 Raw hex dumps of Q.921 frames\n"
" on - equivalent to 3\n"
" hex - equivalent to 8\n"
" intense - equivalent to 15\n";
return NULL;
case CLI_GENERATE:
return complete_span_4(a->line, a->word, a->pos, a->n);
......@@ -14335,9 +14344,13 @@ static char *handle_pri_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_a
}
 
if (!strcasecmp(a->argv[3], "on")) {
level = 1;
level = 3;
} else if (!strcasecmp(a->argv[3], "off")) {
level = 0;
} else if (!strcasecmp(a->argv[3], "intense")) {
level = 15;
} else if (!strcasecmp(a->argv[3], "hex")) {
level = 8;
} else {
level = atoi(a->argv[3]);
}
......@@ -14351,20 +14364,15 @@ static char *handle_pri_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_a
return CLI_SUCCESS;
}
 
if (level & 1) debugmask |= SIG_PRI_DEBUG_NORMAL;
if (level & 2) debugmask |= PRI_DEBUG_Q931_DUMP;
if (level & 4) debugmask |= PRI_DEBUG_Q921_DUMP;
if (level & 8) debugmask |= PRI_DEBUG_Q921_RAW;
/* Set debug level in libpri */
for (x = 0; x < SIG_PRI_NUM_DCHANS; x++) {
if (pris[span - 1].pri.dchans[x]) {
switch (level) {
case 0:
pri_set_debug(pris[span - 1].pri.dchans[x], 0);
break;
case 1:
pri_set_debug(pris[span - 1].pri.dchans[x], SIG_PRI_DEBUG_NORMAL);
break;
default:
pri_set_debug(pris[span - 1].pri.dchans[x], SIG_PRI_DEBUG_INTENSE);
break;
}
pri_set_debug(pris[span - 1].pri.dchans[x], debugmask);
}
}
if (level == 0) {
......
......@@ -35,24 +35,12 @@
#if defined(HAVE_PRI_CCSS)
/*! PRI debug message flags when normal PRI debugging is turned on at the command line. */
#define SIG_PRI_DEBUG_NORMAL \
(PRI_DEBUG_APDU | PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q921_STATE \
| PRI_DEBUG_CC)
/*! PRI debug message flags when intense PRI debugging is turned on at the command line. */
#define SIG_PRI_DEBUG_INTENSE \
(PRI_DEBUG_APDU | PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q921_STATE \
| PRI_DEBUG_CC | PRI_DEBUG_Q921_RAW | PRI_DEBUG_Q921_DUMP)
(PRI_DEBUG_APDU | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q921_STATE | PRI_DEBUG_CC)
#else
/*! PRI debug message flags when normal PRI debugging is turned on at the command line. */
#define SIG_PRI_DEBUG_NORMAL \
(PRI_DEBUG_APDU | PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q921_STATE)
/*! PRI debug message flags when intense PRI debugging is turned on at the command line. */
#define SIG_PRI_DEBUG_INTENSE \
(PRI_DEBUG_APDU | PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q921_STATE \
| PRI_DEBUG_Q921_RAW | PRI_DEBUG_Q921_DUMP)
(PRI_DEBUG_APDU | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q921_STATE)
#endif /* !defined(HAVE_PRI_CCSS) */
#if 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment