aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_dahdi.c
diff options
context:
space:
mode:
authormvanbaak <mvanbaak@f38db490-d61c-443f-a65b-d21fe96a405b>2008-09-28 23:32:14 +0000
committermvanbaak <mvanbaak@f38db490-d61c-443f-a65b-d21fe96a405b>2008-09-28 23:32:14 +0000
commitb6fa2c3b98f454c4b179f7e365c519b45d15bbd4 (patch)
treed5167b9db2e6c55e56def0e52038799c477d3e3d /channels/chan_dahdi.c
parent74e9c236bd6246f61bed0397adcf87adad399e2e (diff)
Merge the cli_cleanup branch.
This work is done by lmadsen, junky and mvanbaak during AstriDevCon. This is the second audit the CLI got, and this time lmadsen made sure he had _ALL_ modules loaded that have CLI commands in them. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@145121 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_dahdi.c')
-rw-r--r--channels/chan_dahdi.c194
1 files changed, 46 insertions, 148 deletions
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c
index f6e37cb65..db24a6d1c 100644
--- a/channels/chan_dahdi.c
+++ b/channels/chan_dahdi.c
@@ -11604,32 +11604,6 @@ static char *complete_span_4(const char *line, const char *word, int pos, int st
return complete_span_helper(line,word,pos,state,3);
}
-static char *complete_span_5(const char *line, const char *word, int pos, int state)
-{
- return complete_span_helper(line,word,pos,state,4);
-}
-
-static char *handle_pri_unset_debug_file(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
- switch (cmd) {
- case CLI_INIT:
- e->command = "pri unset debug file";
- e->usage = "Usage: pri unset debug file\n"
- " Stop sending debug output to the previously \n"
- " specified file\n";
- return NULL;
- case CLI_GENERATE:
- return NULL;
- }
- /* Assume it is unset */
- ast_mutex_lock(&pridebugfdlock);
- close(pridebugfd);
- pridebugfd = -1;
- ast_cli(a->fd, "PRI debug output to file disabled\n");
- ast_mutex_unlock(&pridebugfdlock);
- return CLI_SUCCESS;
-}
-
static char *handle_pri_set_debug_file(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
int myfd;
@@ -11670,92 +11644,29 @@ static char *handle_pri_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_a
{
int span;
int x;
+ int level = 0;
switch (cmd) {
case CLI_INIT:
- e->command = "pri debug span";
+ e->command = "pri set debug {<level>|on|off} span";
e->usage =
- "Usage: pri debug span <span>\n"
+ "Usage: pri set debug <level|on|off> span <span>\n"
" Enables debugging on a given PRI span\n";
return NULL;
case CLI_GENERATE:
return complete_span_4(a->line, a->word, a->pos, a->n);
}
- if (a->argc < 4) {
- return CLI_SHOWUSAGE;
- }
- span = atoi(a->argv[3]);
- if ((span < 1) || (span > NUM_SPANS)) {
- ast_cli(a->fd, "Invalid span %s. Should be a number %d to %d\n", a->argv[3], 1, NUM_SPANS);
- return CLI_SUCCESS;
- }
- if (!pris[span-1].pri) {
- ast_cli(a->fd, "No PRI running on span %d\n", span);
- return CLI_SUCCESS;
- }
- for (x = 0; x < NUM_DCHANS; x++) {
- if (pris[span-1].dchans[x])
- pri_set_debug(pris[span-1].dchans[x], PRI_DEBUG_APDU |
- PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE |
- PRI_DEBUG_Q921_STATE);
- }
- ast_cli(a->fd, "Enabled debugging on span %d\n", span);
- return CLI_SUCCESS;
-}
-
-
-
-static char *handle_pri_no_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
- int span;
- int x;
- switch (cmd) {
- case CLI_INIT:
- e->command = "pri no debug span";
- e->usage =
- "Usage: pri no debug span <span>\n"
- " Disables debugging on a given PRI span\n";
- return NULL;
- case CLI_GENERATE:
- return complete_span_5(a->line, a->word, a->pos, a->n);
- }
- if (a->argc < 5)
+ if (a->argc < 6) {
return CLI_SHOWUSAGE;
-
- span = atoi(a->argv[4]);
- if ((span < 1) || (span > NUM_SPANS)) {
- ast_cli(a->fd, "Invalid span %s. Should be a number %d to %d\n", a->argv[4], 1, NUM_SPANS);
- return CLI_SUCCESS;
- }
- if (!pris[span-1].pri) {
- ast_cli(a->fd, "No PRI running on span %d\n", span);
- return CLI_SUCCESS;
- }
- for (x = 0; x < NUM_DCHANS; x++) {
- if (pris[span-1].dchans[x])
- pri_set_debug(pris[span-1].dchans[x], 0);
}
- ast_cli(a->fd, "Disabled debugging on span %d\n", span);
- return CLI_SUCCESS;
-}
-static char *handle_pri_really_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
- int span;
- int x;
- switch (cmd) {
- case CLI_INIT:
- e->command = "pri intensive debug span";
- e->usage =
- "Usage: pri intensive debug span <span>\n"
- " Enables debugging down to the Q.921 level\n";
- return NULL;
- case CLI_GENERATE:
- return complete_span_5(a->line, a->word, a->pos, a->n);
+ if (!strcasecmp(a->argv[4], "on")) {
+ level = 1;
+ } else if (!strcasecmp(a->argv[4], "off")) {
+ level = 0;
+ } else {
+ level = atoi(a->argv[4]);
}
-
- if (a->argc < 5)
- return CLI_SHOWUSAGE;
- span = atoi(a->argv[4]);
+ span = atoi(a->argv[5]);
if ((span < 1) || (span > NUM_SPANS)) {
ast_cli(a->fd, "Invalid span %s. Should be a number %d to %d\n", a->argv[4], 1, NUM_SPANS);
return CLI_SUCCESS;
@@ -11765,12 +11676,28 @@ static char *handle_pri_really_debug(struct ast_cli_entry *e, int cmd, struct as
return CLI_SUCCESS;
}
for (x = 0; x < NUM_DCHANS; x++) {
- if (pris[span-1].dchans[x])
- pri_set_debug(pris[span-1].dchans[x], PRI_DEBUG_APDU |
- PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE |
- PRI_DEBUG_Q921_RAW | PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_STATE);
+ if (pris[span-1].dchans[x]) {
+ if (level == 1) {
+ pri_set_debug(pris[span-1].dchans[x], PRI_DEBUG_APDU |
+ PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE |
+ PRI_DEBUG_Q921_STATE);
+ ast_cli(a->fd, "Enabled debugging on span %d\n", span);
+ } else if (level == 0) {
+ pri_set_debug(pris[span-1].dchans[x], 0);
+ //close the file if it's set
+ ast_mutex_lock(&pridebugfdlock);
+ close(pridebugfd);
+ pridebugfd = -1;
+ ast_cli(a->fd, "PRI debug output to file disabled\n");
+ ast_mutex_unlock(&pridebugfdlock);
+ } else {
+ pri_set_debug(pris[span-1].dchans[x], PRI_DEBUG_APDU |
+ PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE |
+ PRI_DEBUG_Q921_RAW | PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_STATE);
+ ast_cli(a->fd, "Enabled debugging on span %d\n", span);
+ }
+ }
}
- ast_cli(a->fd, "Enabled EXTENSIVE debugging on span %d\n", span);
return CLI_SUCCESS;
}
@@ -11935,13 +11862,10 @@ static char *handle_pri_version(struct ast_cli_entry *e, int cmd, struct ast_cli
static struct ast_cli_entry dahdi_pri_cli[] = {
AST_CLI_DEFINE(handle_pri_debug, "Enables PRI debugging on a span"),
- AST_CLI_DEFINE(handle_pri_no_debug, "Disables PRI debugging on a span"),
- AST_CLI_DEFINE(handle_pri_really_debug, "Enables REALLY INTENSE PRI debugging"),
AST_CLI_DEFINE(handle_pri_show_spans, "Displays PRI Information"),
AST_CLI_DEFINE(handle_pri_show_span, "Displays PRI Information"),
AST_CLI_DEFINE(handle_pri_show_debug, "Displays current PRI debug settings"),
AST_CLI_DEFINE(handle_pri_set_debug_file, "Sends PRI debug output to the specified file"),
- AST_CLI_DEFINE(handle_pri_unset_debug_file, "Ends PRI debug output to file"),
AST_CLI_DEFINE(handle_pri_version, "Displays libpri version"),
};
@@ -13151,65 +13075,40 @@ static int linkset_addsigchan(int sigchan)
return 0;
}
-static char *handle_ss7_no_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
- int span;
- switch (cmd) {
- case CLI_INIT:
- e->command = "ss7 no debug linkset";
- e->usage =
- "Usage: ss7 no debug linkset <span>\n"
- " Disables debugging on a given SS7 linkset\n";
- return NULL;
- case CLI_GENERATE:
- return NULL;
- }
- if (a->argc < 5)
- return CLI_SHOWUSAGE;
- span = atoi(a->argv[4]);
- if ((span < 1) || (span > NUM_SPANS)) {
- ast_cli(a->fd, "Invalid linkset %s. Should be a number from %d to %d\n", a->argv[4], 1, NUM_SPANS);
- return CLI_SUCCESS;
- }
- if (!linksets[span-1].ss7) {
- ast_cli(a->fd, "No SS7 running on linkset %d\n", span);
- return CLI_SUCCESS;
- }
- if (linksets[span-1].ss7)
- ss7_set_debug(linksets[span-1].ss7, 0);
-
- ast_cli(a->fd, "Disabled debugging on linkset %d\n", span);
- return CLI_SUCCESS;
-}
-
static char *handle_ss7_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
int span;
switch (cmd) {
case CLI_INIT:
- e->command = "ss7 debug linkset";
+ e->command = "ss7 set debug {on|off} linkset";
e->usage =
- "Usage: ss7 debug linkset <linkset>\n"
+ "Usage: ss7 set debug {on|off} linkset <linkset>\n"
" Enables debugging on a given SS7 linkset\n";
return NULL;
case CLI_GENERATE:
return NULL;
}
- if (a->argc < 4)
+ if (a->argc < 6)
return CLI_SHOWUSAGE;
- span = atoi(a->argv[3]);
+ span = atoi(a->argv[5]);
if ((span < 1) || (span > NUM_SPANS)) {
- ast_cli(a->fd, "Invalid linkset %s. Should be a number from %d to %d\n", a->argv[3], 1, NUM_SPANS);
+ ast_cli(a->fd, "Invalid linkset %s. Should be a number from %d to %d\n", a->argv[5], 1, NUM_SPANS);
return CLI_SUCCESS;
}
if (!linksets[span-1].ss7) {
ast_cli(a->fd, "No SS7 running on linkset %d\n", span);
return CLI_SUCCESS;
}
- if (linksets[span-1].ss7)
- ss7_set_debug(linksets[span-1].ss7, SS7_DEBUG_MTP2 | SS7_DEBUG_MTP3 | SS7_DEBUG_ISUP);
+ if (linksets[span-1].ss7) {
+ if (strcasecmp(a->argv[4], "on")) {
+ ss7_set_debug(linksets[span-1].ss7, SS7_DEBUG_MTP2 | SS7_DEBUG_MTP3 | SS7_DEBUG_ISUP);
+ ast_cli(a->fd, "Enabled debugging on linkset %d\n", span);
+ } else {
+ ss7_set_debug(linksets[span-1].ss7, 0);
+ ast_cli(a->fd, "Disabled debugging on linkset %d\n", span);
+ }
+ }
- ast_cli(a->fd, "Enabled debugging on linkset %d\n", span);
return CLI_SUCCESS;
}
@@ -13470,7 +13369,6 @@ static char *handle_ss7_version(struct ast_cli_entry *e, int cmd, struct ast_cli
static struct ast_cli_entry dahdi_ss7_cli[] = {
AST_CLI_DEFINE(handle_ss7_debug, "Enables SS7 debugging on a linkset"),
- AST_CLI_DEFINE(handle_ss7_no_debug, "Disables SS7 debugging on a linkset"),
AST_CLI_DEFINE(handle_ss7_block_cic, "Blocks the given CIC"),
AST_CLI_DEFINE(handle_ss7_unblock_cic, "Unblocks the given CIC"),
AST_CLI_DEFINE(handle_ss7_block_linkset, "Blocks all CICs on a linkset"),