--- chan_dahdi.c 2009-08-24 06:54:38.000000000 +0200 +++ /root/chan_dahdi.c 2009-09-29 00:03:27.000000000 +0200 @@ -15360,6 +15368,61 @@ return 0; } +#if defined(HAVE_PRI) +static int action_dahdishowspans(struct mansession *s, const struct message *m) +{ + int span, count, x; + struct dahdi_pvt *tmp = NULL; + const char *id = astman_get_header(m, "ActionID"); + char idText[256] = ""; + + astman_send_ack(s, m, "DAHDI span status will follow"); + if (!ast_strlen_zero(id)) + snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id); + + for (span = count = 0; span < NUM_SPANS; span++) { + if (pris[span].pri) { + for (x = 0; x < NUM_DCHANS; x++) { + if (pris[span].dchannels[x]) { + + count++; + + astman_append(s, + "Event: DAHDIShowSpans\r\n" + "DAHDISpan: %d/%d\r\n" + "Channel: %d\r\n" + "DChannel: %d\r\n" + "Provisioned: %d\r\n" + "Alarm: %d\r\n" + "Up: %d\r\n" + "Active: %d\r\n" + "%s" + "\r\n", + span + 1, x, + span + 1, + x, + pris[span].dchanavail[x] & DCHAN_PROVISIONED ? 1 : 0, + pris[span].dchanavail[x] & DCHAN_NOTINALARM ? 0 : 1, + pris[span].dchanavail[x] & DCHAN_UP ? 1 : 0, + pris[span].dchans[x] == pris[span].pri ? 1 : 0, + idText + ); + } + } + } + } + + astman_append(s, + "Event: DAHDIShowSpansComplete\r\n" + "Items: %d\r\n" + "%s" + "\r\n", + count, + idText); + return 0; +} +#endif + #if defined(HAVE_SS7) static int linkset_addsigchan(int sigchan) { @@ -15841,6 +15904,9 @@ ast_manager_unregister( "DAHDIDNDoff" ); ast_manager_unregister( "DAHDIDNDon" ); ast_manager_unregister("DAHDIShowChannels"); +#if defined(HAVE_PRI) + ast_manager_unregister("DAHDIShowSpans"); +#endif ast_manager_unregister("DAHDIRestart"); ast_channel_unregister(&dahdi_tech); ast_mutex_lock(&iflock); @@ -17327,6 +17394,9 @@ ast_manager_register( "DAHDIDNDon", 0, action_dahdidndon, "Toggle DAHDI channel Do Not Disturb status ON" ); ast_manager_register( "DAHDIDNDoff", 0, action_dahdidndoff, "Toggle DAHDI channel Do Not Disturb status OFF" ); ast_manager_register("DAHDIShowChannels", 0, action_dahdishowchannels, "Show status DAHDI channels"); +#if defined(HAVE_PRI) + ast_manager_register("DAHDIShowSpans", 0, action_dahdishowspans, "Show status DAHDI spans"); +#endif ast_manager_register("DAHDIRestart", 0, action_dahdirestart, "Fully Restart DAHDI channels (terminates calls)"); ast_cond_init(&ss_thread_complete, NULL);