[asterisk-commits] rmudgett: branch 10 r342485 - in /branches/10: ./ channels/sig_pri.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Oct 25 16:50:25 CDT 2011
Author: rmudgett
Date: Tue Oct 25 16:50:21 2011
New Revision: 342485
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=342485
Log:
Change D-channel warning to be less confusing on non-NFAS setups.
The "No D-channels available! Using Primary channel as D-channel anyway!"
WARNING message has been confusing on non-NFAS setups. The message refers
to things that are NFAS specific.
* Changed the warning to several different warnings to be more accurate
for the situation and less confusing as a result:
"No D-channels up! Switching selected D-channel from X to Y.",
"No D-channels up!", and
"D-channel is down!".
........
Merged revisions 342484 from http://svn.asterisk.org/svn/asterisk/branches/1.8
Modified:
branches/10/ (props changed)
branches/10/channels/sig_pri.c
Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.
Modified: branches/10/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/channels/sig_pri.c?view=diff&rev=342485&r1=342484&r2=342485
==============================================================================
--- branches/10/channels/sig_pri.c (original)
+++ branches/10/channels/sig_pri.c Tue Oct 25 16:50:21 2011
@@ -1012,7 +1012,7 @@
return 0;
}
-static char *pri_order(int level)
+static const char *pri_order(int level)
{
switch (level) {
case 0:
@@ -1042,37 +1042,74 @@
return -1;
}
-static int pri_find_dchan(struct sig_pri_span *pri)
-{
+static void pri_find_dchan(struct sig_pri_span *pri)
+{
+ struct pri *old;
int oldslot = -1;
- struct pri *old;
int newslot = -1;
- int x;
+ int idx;
+
old = pri->pri;
- for (x = 0; x < SIG_PRI_NUM_DCHANS; x++) {
- if ((pri->dchanavail[x] == DCHAN_AVAILABLE) && (newslot < 0))
- newslot = x;
- if (pri->dchans[x] == old) {
- oldslot = x;
- }
- }
- if (newslot < 0) {
- newslot = 0;
- /* This is annoying to see on non persistent layer 2 connections. Let's not complain in that case */
- if (pri->sig != SIG_BRI_PTMP && !pri->no_d_channels) {
- pri->no_d_channels = 1;
- ast_log(LOG_WARNING,
- "Span %d: No D-channels available! Using Primary channel as D-channel anyway!\n",
- pri->span);
+ for (idx = 0; idx < SIG_PRI_NUM_DCHANS; ++idx) {
+ if (!pri->dchans[idx]) {
+ /* No more D channels defined on the span. */
+ break;
+ }
+ if (pri->dchans[idx] == old) {
+ oldslot = idx;
+ }
+ if (newslot < 0 && pri->dchanavail[idx] == DCHAN_AVAILABLE) {
+ newslot = idx;
+ }
+ }
+ /* At this point, idx is a count of how many D-channels are defined on the span. */
+
+ if (1 < idx) {
+ /* We have several D-channels defined on the span. (NFAS PRI setup) */
+ if (newslot < 0) {
+ /* No D-channels available. Default to the primary D-channel. */
+ newslot = 0;
+
+ if (!pri->no_d_channels) {
+ pri->no_d_channels = 1;
+ if (old && oldslot != newslot) {
+ ast_log(LOG_WARNING,
+ "Span %d: No D-channels up! Switching selected D-channel from %s to %s.\n",
+ pri->span, pri_order(oldslot), pri_order(newslot));
+ } else {
+ ast_log(LOG_WARNING, "Span %d: No D-channels up!\n", pri->span);
+ }
+ }
+ } else {
+ pri->no_d_channels = 0;
+ }
+ if (old && oldslot != newslot) {
+ ast_log(LOG_NOTICE,
+ "Switching selected D-channel from %s (fd %d) to %s (fd %d)!\n",
+ pri_order(oldslot), pri->fds[oldslot],
+ pri_order(newslot), pri->fds[newslot]);
}
} else {
- pri->no_d_channels = 0;
- }
- if (old && (oldslot != newslot))
- ast_log(LOG_NOTICE, "Switching from d-channel fd %d to fd %d!\n",
- pri->fds[oldslot], pri->fds[newslot]);
+ if (newslot < 0) {
+ /* The only D-channel is not up. */
+ newslot = 0;
+
+ if (!pri->no_d_channels) {
+ pri->no_d_channels = 1;
+
+ /*
+ * This is annoying to see on non-persistent layer 2
+ * connections. Let's not complain in that case.
+ */
+ if (pri->sig != SIG_BRI_PTMP) {
+ ast_log(LOG_WARNING, "Span %d: D-channel is down!\n", pri->span);
+ }
+ }
+ } else {
+ pri->no_d_channels = 0;
+ }
+ }
pri->pri = pri->dchans[newslot];
- return 0;
}
/*!
@@ -1936,8 +1973,9 @@
void pri_event_alarm(struct sig_pri_span *pri, int index, int before_start_pri)
{
pri->dchanavail[index] &= ~(DCHAN_NOTINALARM | DCHAN_UP);
- if (!before_start_pri)
+ if (!before_start_pri) {
pri_find_dchan(pri);
+ }
}
void pri_event_noalarm(struct sig_pri_span *pri, int index, int before_start_pri)
@@ -5601,7 +5639,9 @@
switch (e->e) {
case PRI_EVENT_DCHAN_UP:
pri->no_d_channels = 0;
- if (!pri->pri) pri_find_dchan(pri);
+ if (!pri->pri) {
+ pri_find_dchan(pri);
+ }
/* Note presense of D-channel */
time(&pri->lastreset);
@@ -5624,8 +5664,10 @@
pri_find_dchan(pri);
if (!pri_is_up(pri)) {
if (pri->sig == SIG_BRI_PTMP) {
- /* For PTMP connections with non persistent layer 2 we want
- * to *not* declare inalarm unless there actually is an alarm */
+ /*
+ * For PTMP connections with non-persistent layer 2 we want to
+ * *not* declare inalarm unless there actually is an alarm.
+ */
break;
}
/* Hangup active channels and put them in alarm mode */
More information about the asterisk-commits
mailing list