summaryrefslogtreecommitdiff
path: root/channels/sig_pri.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2011-10-25 21:54:31 +0000
committerRichard Mudgett <rmudgett@digium.com>2011-10-25 21:54:31 +0000
commit6cf08ad5506b40542f4821429f2630c9b308ecee (patch)
treebe554c14dd1f1f72a843bd574a9c203ea2a986fc /channels/sig_pri.c
parent6e730a6806fff6735793e112c72ef6f0738588cb (diff)
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 ........ Merged revisions 342485 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@342486 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/sig_pri.c')
-rw-r--r--channels/sig_pri.c94
1 files changed, 68 insertions, 26 deletions
diff --git a/channels/sig_pri.c b/channels/sig_pri.c
index 5135e07cc..394491447 100644
--- a/channels/sig_pri.c
+++ b/channels/sig_pri.c
@@ -1012,7 +1012,7 @@ int pri_is_up(struct sig_pri_span *pri)
return 0;
}
-static char *pri_order(int level)
+static const char *pri_order(int level)
{
switch (level) {
case 0:
@@ -1042,37 +1042,74 @@ static int pri_active_dchan_index(struct sig_pri_span *pri)
return -1;
}
-static int pri_find_dchan(struct sig_pri_span *pri)
+static void pri_find_dchan(struct sig_pri_span *pri)
{
- int oldslot = -1;
struct pri *old;
+ int oldslot = -1;
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;
+ 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;
}
}
- 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);
+ /* 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 (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;
+ }
}
- if (old && (oldslot != newslot))
- ast_log(LOG_NOTICE, "Switching from d-channel fd %d to fd %d!\n",
- pri->fds[oldslot], pri->fds[newslot]);
pri->pri = pri->dchans[newslot];
- return 0;
}
/*!
@@ -1936,8 +1973,9 @@ static void *pri_ss_thread(void *data)
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 @@ static void *pri_dchannel(void *vpri)
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 @@ static void *pri_dchannel(void *vpri)
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 */