Made output libpri event names if pri debugging is enabled when sig_pri processes them.

* Simplified CLI "pri debug xx span xx" command code and removed redundant
debugging enabled messages.

* Made CLI "pri debug xx span xx" command only close the debugging log
file if it was opened.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@284779 65c4cc65-6c06-0410-ace0-fbb531ad65f3
certified/1.8.6
Richard Mudgett 15 years ago
parent b5f428dee5
commit c271acacda

@ -13709,25 +13709,36 @@ static char *handle_pri_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_a
ast_cli(a->fd, "No PRI running on span %d\n", span); ast_cli(a->fd, "No PRI running on span %d\n", span);
return CLI_SUCCESS; return CLI_SUCCESS;
} }
/* Set debug level in libpri */
for (x = 0; x < SIG_PRI_NUM_DCHANS; x++) { for (x = 0; x < SIG_PRI_NUM_DCHANS; x++) {
if (pris[span-1].pri.dchans[x]) { if (pris[span - 1].pri.dchans[x]) {
if (level == 1) { switch (level) {
pri_set_debug(pris[span-1].pri.dchans[x], SIG_PRI_DEBUG_NORMAL); case 0:
ast_cli(a->fd, "Enabled debugging on span %d\n", span); pri_set_debug(pris[span - 1].pri.dchans[x], 0);
} else if (level == 0) { break;
pri_set_debug(pris[span-1].pri.dchans[x], 0); case 1:
/* close the file if it's set */ 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;
}
}
}
if (level == 0) {
/* Close the debugging file if it's set */
ast_mutex_lock(&pridebugfdlock); ast_mutex_lock(&pridebugfdlock);
if (0 <= pridebugfd) {
close(pridebugfd); close(pridebugfd);
pridebugfd = -1; pridebugfd = -1;
ast_cli(a->fd, "PRI debug output to file disabled\n"); ast_cli(a->fd, "Disabled PRI debug output to file '%s'\n",
ast_mutex_unlock(&pridebugfdlock); pridebugfilename);
} else {
pri_set_debug(pris[span-1].pri.dchans[x], SIG_PRI_DEBUG_INTENSE);
ast_cli(a->fd, "Enabled debugging on span %d\n", span);
}
} }
ast_mutex_unlock(&pridebugfdlock);
} }
pris[span - 1].pri.debug = (level) ? 1 : 0;
ast_cli(a->fd, "%s debugging on span %d\n", (level) ? "Enabled" : "Disabled", span);
return CLI_SUCCESS; return CLI_SUCCESS;
} }
#endif /* defined(HAVE_PRI) */ #endif /* defined(HAVE_PRI) */
@ -13944,7 +13955,7 @@ static char *handle_pri_show_debug(struct ast_cli_entry *e, int cmd, struct ast_
int x; int x;
int span; int span;
int count=0; int count=0;
int debug=0; int debug;
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
@ -13960,7 +13971,6 @@ static char *handle_pri_show_debug(struct ast_cli_entry *e, int cmd, struct ast_
for (span = 0; span < NUM_SPANS; span++) { for (span = 0; span < NUM_SPANS; span++) {
if (pris[span].pri.pri) { if (pris[span].pri.pri) {
for (x = 0; x < SIG_PRI_NUM_DCHANS; x++) { for (x = 0; x < SIG_PRI_NUM_DCHANS; x++) {
debug = 0;
if (pris[span].pri.dchans[x]) { if (pris[span].pri.dchans[x]) {
debug = pri_get_debug(pris[span].pri.dchans[x]); debug = pri_get_debug(pris[span].pri.dchans[x]);
ast_cli(a->fd, "Span %d: Debug: %s\tIntense: %s\n", span+1, (debug&PRI_DEBUG_Q931_STATE)? "Yes" : "No" ,(debug&PRI_DEBUG_Q921_RAW)? "Yes" : "No" ); ast_cli(a->fd, "Span %d: Debug: %s\tIntense: %s\n", span+1, (debug&PRI_DEBUG_Q931_STATE)? "Yes" : "No" ,(debug&PRI_DEBUG_Q921_RAW)? "Yes" : "No" );
@ -13976,7 +13986,7 @@ static char *handle_pri_show_debug(struct ast_cli_entry *e, int cmd, struct ast_
ast_mutex_unlock(&pridebugfdlock); ast_mutex_unlock(&pridebugfdlock);
if (!count) if (!count)
ast_cli(a->fd, "No debug set or no PRI running\n"); ast_cli(a->fd, "No PRI running\n");
return CLI_SUCCESS; return CLI_SUCCESS;
} }
#endif /* defined(HAVE_PRI) */ #endif /* defined(HAVE_PRI) */

@ -4243,8 +4243,10 @@ static void *pri_dchannel(void *vpri)
ast_log(LOG_WARNING, "pri_event returned error %d (%s)\n", errno, strerror(errno)); ast_log(LOG_WARNING, "pri_event returned error %d (%s)\n", errno, strerror(errno));
if (e) { if (e) {
if (pri->debug) if (pri->debug) {
pri_dump_event(pri->dchans[which], e); ast_verbose("Span: %d Processing event: %s\n",
pri->span, pri_event2str(e->e));
}
if (e->e != PRI_EVENT_DCHAN_DOWN) { if (e->e != PRI_EVENT_DCHAN_DOWN) {
if (!(pri->dchanavail[which] & DCHAN_UP)) { if (!(pri->dchanavail[which] & DCHAN_UP)) {

@ -389,7 +389,7 @@ struct sig_pri_span {
int num_call_waiting_calls; int num_call_waiting_calls;
#endif /* defined(HAVE_PRI_CALL_WAITING) */ #endif /* defined(HAVE_PRI_CALL_WAITING) */
int dchanavail[SIG_PRI_NUM_DCHANS]; /*!< Whether each channel is available */ int dchanavail[SIG_PRI_NUM_DCHANS]; /*!< Whether each channel is available */
int debug; /*!< set to true if to dump PRI event info (tested but never set) */ int debug; /*!< set to true if to dump PRI event info */
int span; /*!< span number put into user output messages */ int span; /*!< span number put into user output messages */
int resetting; /*!< true if span is being reset/restarted */ int resetting; /*!< true if span is being reset/restarted */
int resetpos; /*!< current position during a reset (-1 if not started) */ int resetpos; /*!< current position during a reset (-1 if not started) */

Loading…
Cancel
Save