[asterisk-commits] rmudgett: trunk r314735 - in /trunk/channels: chan_dahdi.c sig_pri.c sig_pri.h
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Apr 21 17:53:09 CDT 2011
Author: rmudgett
Date: Thu Apr 21 17:53:05 2011
New Revision: 314735
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=314735
Log:
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
Modified:
trunk/channels/chan_dahdi.c
trunk/channels/sig_pri.c
trunk/channels/sig_pri.h
Modified: trunk/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_dahdi.c?view=diff&rev=314735&r1=314734&r2=314735
==============================================================================
--- trunk/channels/chan_dahdi.c (original)
+++ trunk/channels/chan_dahdi.c Thu Apr 21 17:53:05 2011
@@ -248,6 +248,19 @@
</synopsis>
<syntax>
<xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
+ </syntax>
+ <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>
@@ -15874,6 +15887,60 @@
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 @@
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 @@
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);
Modified: trunk/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sig_pri.c?view=diff&rev=314735&r1=314734&r2=314735
==============================================================================
--- trunk/channels/sig_pri.c (original)
+++ trunk/channels/sig_pri.c Thu Apr 21 17:53:05 2011
@@ -7040,6 +7040,52 @@
return NULL;
}
+/*!
+ * \brief Output AMI show spans response events for the given PRI span.
+ * \since 1.10
+ *
+ * \param show_cmd AMI command name
+ * \param s AMI session to output span information.
+ * \param pri PRI span control structure.
+ * \param dchannels Array of D channel channel numbers.
+ * \param action_id Action ID line to use.
+ *
+ * \return Number of D channels on this span.
+ */
+int sig_pri_ami_show_spans(struct mansession *s, const char *show_cmd, struct sig_pri_span *pri, const int *dchannels, const char *action_id)
+{
+ int count;
+ int x;
+
+ count = 0;
+ for (x = 0; x < ARRAY_LEN(pri->dchans); ++x) {
+ if (pri->dchans[x]) {
+ ++count;
+
+ astman_append(s,
+ "Event: %s\r\n"
+ "Span: %d\r\n"
+ "DChannel: %d\r\n"
+ "Order: %s\r\n"
+ "Active: %s\r\n"
+ "Alarm: %s\r\n"
+ "Up: %s\r\n"
+ "%s"
+ "\r\n",
+ show_cmd,
+ pri->span,
+ dchannels[x],
+ pri_order(x),
+ (pri->dchans[x] == pri->pri) ? "Yes" : "No",
+ (pri->dchanavail[x] & DCHAN_NOTINALARM) ? "No" : "Yes",
+ (pri->dchanavail[x] & DCHAN_UP) ? "Yes" : "No",
+ action_id
+ );
+ }
+ }
+ return count;
+}
+
void sig_pri_init_pri(struct sig_pri_span *pri)
{
int i;
Modified: trunk/channels/sig_pri.h
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sig_pri.h?view=diff&rev=314735&r1=314734&r2=314735
==============================================================================
--- trunk/channels/sig_pri.h (original)
+++ trunk/channels/sig_pri.h Thu Apr 21 17:53:05 2011
@@ -615,6 +615,9 @@
int pri_is_up(struct sig_pri_span *pri);
+struct mansession;
+int sig_pri_ami_show_spans(struct mansession *s, const char *show_cmd, struct sig_pri_span *pri, const int *dchannels, const char *action_id);
+
void sig_pri_cli_show_channels_header(int fd);
void sig_pri_cli_show_channels(int fd, struct sig_pri_span *pri);
void sig_pri_cli_show_spans(int fd, int span, struct sig_pri_span *pri);
More information about the asterisk-commits
mailing list