diff options
author | rmudgett <rmudgett@f38db490-d61c-443f-a65b-d21fe96a405b> | 2011-04-21 22:53:05 +0000 |
---|---|---|
committer | rmudgett <rmudgett@f38db490-d61c-443f-a65b-d21fe96a405b> | 2011-04-21 22:53:05 +0000 |
commit | 89bdb960570cc8c9140bd25e5796c0973b8cf231 (patch) | |
tree | 30f81ccc30556c9db6a3f7e2e182b437744e6cae /channels/chan_dahdi.c | |
parent | dc187db91362ddb82f0ce147d6982d3c3d299032 (diff) |
Implement AMI action PRIShowSpans.
PRIShowSpans works like the AMI action DAHDIShowChannels but for PRI
spans. It is similar to the CLI command "pri show spans".
(closes issue #15980)
Reported by: dwery
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@314735 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_dahdi.c')
-rw-r--r-- | channels/chan_dahdi.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index c8391c204..26a2d0100 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -252,6 +252,19 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") <description> </description> </manager> + <manager name="PRIShowSpans" language="en_US"> + <synopsis> + Show status of PRI spans. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Span"> + <para>Specify the specific span to show. Show all spans if zero or not present.</para> + </parameter> + </syntax> + <description> + </description> + </manager> ***/ #define SMDI_MD_WAIT_TIMEOUT 1500 /* 1.5 seconds */ @@ -15874,6 +15887,60 @@ static int action_dahdishowchannels(struct mansession *s, const struct message * return 0; } +#if defined(HAVE_PRI) +static int action_prishowspans(struct mansession *s, const struct message *m) +{ + int count; + int idx; + int span_query; + struct dahdi_pri *dspan; + const char *id = astman_get_header(m, "ActionID"); + const char *span_str = astman_get_header(m, "Span"); + char action_id[256]; + const char *show_cmd = "PRIShowSpans"; + + /* NOTE: Asking for span 0 gets all spans. */ + if (!ast_strlen_zero(span_str)) { + span_query = atoi(span_str); + } else { + span_query = 0; + } + + if (!ast_strlen_zero(id)) { + snprintf(action_id, sizeof(action_id), "ActionID: %s\r\n", id); + } else { + action_id[0] = '\0'; + } + + astman_send_ack(s, m, "Span status will follow"); + + count = 0; + for (idx = 0; idx < ARRAY_LEN(pris); ++idx) { + dspan = &pris[idx]; + + /* If a specific span is asked for, only deliver status for that span. */ + if (0 < span_query && dspan->pri.span != span_query) { + continue; + } + + if (dspan->pri.pri) { + count += sig_pri_ami_show_spans(s, show_cmd, &dspan->pri, dspan->dchannels, + action_id); + } + } + + astman_append(s, + "Event: %sComplete\r\n" + "Items: %d\r\n" + "%s" + "\r\n", + show_cmd, + count, + action_id); + return 0; +} +#endif /* defined(HAVE_PRI) */ + #if defined(HAVE_SS7) static int linkset_addsigchan(int sigchan) { @@ -16449,6 +16516,9 @@ static int __unload_module(void) ast_manager_unregister("DAHDIDNDon"); ast_manager_unregister("DAHDIShowChannels"); ast_manager_unregister("DAHDIRestart"); +#if defined(HAVE_PRI) + ast_manager_unregister("PRIShowSpans"); +#endif /* defined(HAVE_PRI) */ ast_data_unregister(NULL); ast_channel_unregister(&dahdi_tech); @@ -18431,6 +18501,9 @@ static int load_module(void) ast_manager_register_xml("DAHDIDNDoff", 0, action_dahdidndoff); ast_manager_register_xml("DAHDIShowChannels", 0, action_dahdishowchannels); ast_manager_register_xml("DAHDIRestart", 0, action_dahdirestart); +#if defined(HAVE_PRI) + ast_manager_register_xml("PRIShowSpans", 0, action_prishowspans); +#endif /* defined(HAVE_PRI) */ ast_cond_init(&ss_thread_complete, NULL); |