Index: channels/chan_zap.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_zap.c,v retrieving revision 1.365 diff -u -r1.365 chan_zap.c --- channels/chan_zap.c 26 Oct 2004 02:57:18 -0000 1.365 +++ channels/chan_zap.c 27 Oct 2004 16:36:11 -0000 @@ -8179,7 +8179,35 @@ return RESULT_SUCCESS; } - +static int handle_pri_restart(int fd, int argc, char *argv[]) +{ + int span; + struct zt_pri *pri; + if (argc != 4) { + return RESULT_SHOWUSAGE; + } + span = atoi(argv[3]); + if ((span < 1) || (span > NUM_SPANS)) { + ast_cli(fd, "Invalid span %s. Should be a number %d to %d\n", argv[4], 1, NUM_SPANS); + return RESULT_SUCCESS; + } + if (!pris[span-1].pri) { + ast_cli(fd, "No PRI running on span %d\n", span); + return RESULT_SUCCESS; + } + ast_cli(fd, "Forcing restart on span %d\n", span); + pri = &(pris[span-1]); + pri->resetpos = -1; + while (pri->resetpos + 1 < pri->numchans) { + /* Mark the channel as resetting and restart it */ + pri->resetpos++; + if ((pri->pvts[pri->resetpos]) && (!pri->pvts[pri->resetpos]->resetting)) { + pri->pvts[pri->resetpos]->resetting = 1; + pri_reset(pri->pri, PVT_TO_CHANNEL(pri->pvts[pri->resetpos])); + } + } + return RESULT_SUCCESS; +} static int handle_pri_no_debug(int fd, int argc, char *argv[]) { @@ -8301,6 +8329,10 @@ "Usage: pri show span \n" " Displays PRI Information\n"; +static char pri_restart_span_help[] = + "Usage: pri restart span \n" + " Force a PRI restart\n"; + static struct ast_cli_entry pri_debug = { { "pri", "debug", "span", NULL }, handle_pri_debug, "Enables PRI debugging on a span", pri_debug_help, complete_span_4 }; @@ -8313,6 +8345,9 @@ static struct ast_cli_entry pri_show_span = { { "pri", "show", "span", NULL }, handle_pri_show_span, "Displays PRI Information", pri_show_span_help, complete_span_4 }; +static struct ast_cli_entry pri_restart_span = { + { "pri", "restart", "span", NULL }, handle_pri_restart, "Force PRI restart", pri_restart_span_help, complete_span_4 }; + #endif /* ZAPATA_PRI */ @@ -8878,6 +8913,7 @@ ast_cli_unregister(&pri_no_debug); ast_cli_unregister(&pri_really_debug); ast_cli_unregister(&pri_show_span); + ast_cli_unregister(&pri_restart_span); #endif #ifdef ZAPATA_R2 ast_cli_unregister(&r2_debug); @@ -9711,6 +9747,7 @@ ast_cli_register(&pri_no_debug); ast_cli_register(&pri_really_debug); ast_cli_register(&pri_show_span); + ast_cli_register(&pri_restart_span); #endif #ifdef ZAPATA_R2 ast_cli_register(&r2_debug);