The inalarm flag is not passed up from the sig_analog and sig_pri submodules.
authorRichard Mudgett <rmudgett@digium.com>
Tue, 4 May 2010 21:10:58 +0000 (21:10 +0000)
committerRichard Mudgett <rmudgett@digium.com>
Tue, 4 May 2010 21:10:58 +0000 (21:10 +0000)
The CLI "dahdi show channel" command was not correctly reporting the
InAlarm status.

The inalarm flag is now consistently passed between chan_dahdi and
submodules.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@261007 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_dahdi.c
channels/sig_analog.c
channels/sig_analog.h
channels/sig_pri.c
channels/sig_pri.h

index 931b8c6..73ef3dc 100644 (file)
@@ -2103,19 +2103,28 @@ static void my_set_cadence(void *pvt, int *cidrings, struct ast_channel *ast)
        }
 }
 
-static void my_set_dialing(void *pvt, int flag)
+static void my_set_alarm(void *pvt, int in_alarm)
 {
        struct dahdi_pvt *p = pvt;
-       p->dialing = flag;
+
+       p->inalarm = in_alarm;
+}
+
+static void my_set_dialing(void *pvt, int is_dialing)
+{
+       struct dahdi_pvt *p = pvt;
+
+       p->dialing = is_dialing;
 }
 
 #if defined(HAVE_PRI)
-static void my_set_digital(void *pvt, int flag)
+static void my_set_digital(void *pvt, int is_digital)
 {
        struct dahdi_pvt *p = pvt;
-       p->digital = flag;
+
+       p->digital = is_digital;
 }
-#endif
+#endif /* defined(HAVE_PRI) */
 
 static void my_set_ringtimeout(void *pvt, int ringt)
 {
@@ -2994,6 +3003,7 @@ static struct sig_pri_callback dahdi_pri_callbacks =
        .unlock_private = my_unlock_private,
        .new_ast_channel = my_new_pri_ast_channel,
        .fixup_chans = my_pri_fixup_chans,
+       .set_alarm = my_set_alarm,
        .set_dialing = my_set_dialing,
        .set_digital = my_set_digital,
        .set_callerid = my_pri_set_callerid,
@@ -3125,6 +3135,7 @@ static struct analog_callback dahdi_analog_callbacks =
        .get_sigpvt_bridged_channel = my_get_sigpvt_bridged_channel,
        .get_sub_fd = my_get_sub_fd,
        .set_cadence = my_set_cadence,
+       .set_alarm = my_set_alarm,
        .set_dialing = my_set_dialing,
        .set_ringtimeout = my_set_ringtimeout,
        .set_waitingfordt = my_set_waitingfordt,
@@ -7399,16 +7410,16 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                }
                break;
        case DAHDI_EVENT_ALARM:
-#ifdef HAVE_PRI
                switch (p->sig) {
+#if defined(HAVE_PRI)
                case SIG_PRI_LIB_HANDLE_CASES:
                        sig_pri_chan_alarm_notify(p->sig_pvt, 0);
                        break;
+#endif /* defined(HAVE_PRI) */
                default:
+                       p->inalarm = 1;
                        break;
                }
-#endif
-               p->inalarm = 1;
                res = get_alarms(p);
                handle_alarms(p, res);
 #ifdef HAVE_PRI
@@ -7731,16 +7742,16 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
        case DAHDI_EVENT_RINGERON:
                break;
        case DAHDI_EVENT_NOALARM:
-#ifdef HAVE_PRI
                switch (p->sig) {
+#if defined(HAVE_PRI)
                case SIG_PRI_LIB_HANDLE_CASES:
                        sig_pri_chan_alarm_notify(p->sig_pvt, 1);
                        break;
+#endif /* defined(HAVE_PRI) */
                default:
+                       p->inalarm = 0;
                        break;
                }
-#endif
-               p->inalarm = 0;
                handle_clear_alarms(p);
                break;
        case DAHDI_EVENT_WINKFLASH:
@@ -10308,10 +10319,20 @@ static void *mwi_thread(void *data)
                        case DAHDI_EVENT_BITSCHANGED:
                                break;
                        case DAHDI_EVENT_NOALARM:
+                               if (analog_lib_handles(mtd->pvt->sig, mtd->pvt->radio, mtd->pvt->oprmode)) {
+                                       struct analog_pvt *analog_p = mtd->pvt->sig_pvt;
+
+                                       analog_p->inalarm = 0;
+                               }
                                mtd->pvt->inalarm = 0;
                                handle_clear_alarms(mtd->pvt);
                                break;
                        case DAHDI_EVENT_ALARM:
+                               if (analog_lib_handles(mtd->pvt->sig, mtd->pvt->radio, mtd->pvt->oprmode)) {
+                                       struct analog_pvt *analog_p = mtd->pvt->sig_pvt;
+
+                                       analog_p->inalarm = 1;
+                               }
                                mtd->pvt->inalarm = 1;
                                res = get_alarms(mtd->pvt);
                                handle_alarms(mtd->pvt, res);
@@ -10726,11 +10747,29 @@ static struct dahdi_pvt *handle_init_event(struct dahdi_pvt *i, int event)
                }
                break;
        case DAHDI_EVENT_NOALARM:
-               i->inalarm = 0;
+               switch (i->sig) {
+#if defined(HAVE_PRI)
+               case SIG_PRI_LIB_HANDLE_CASES:
+                       sig_pri_chan_alarm_notify(i->sig_pvt, 1);
+                       break;
+#endif /* defined(HAVE_PRI) */
+               default:
+                       i->inalarm = 0;
+                       break;
+               }
                handle_clear_alarms(i);
                break;
        case DAHDI_EVENT_ALARM:
-               i->inalarm = 1;
+               switch (i->sig) {
+#if defined(HAVE_PRI)
+               case SIG_PRI_LIB_HANDLE_CASES:
+                       sig_pri_chan_alarm_notify(i->sig_pvt, 0);
+                       break;
+#endif /* defined(HAVE_PRI) */
+               default:
+                       i->inalarm = 1;
+                       break;
+               }
                res = get_alarms(i);
                handle_alarms(i, res);
                /* fall thru intentionally */
@@ -12030,9 +12069,9 @@ static struct dahdi_pvt *mkintf(int channel, const struct dahdi_chan_conf *conf,
 #endif
                                default:
                                        tmp->inalarm = 1;
-                                       handle_alarms(tmp, res);
                                        break;
                                }
+                               handle_alarms(tmp, res);
                        }
                }
 
index 5fe5ac3..53804a6 100644 (file)
@@ -760,11 +760,19 @@ static void analog_set_cadence(struct analog_pvt *p, struct ast_channel *chan)
        }
 }
 
-static void analog_set_dialing(struct analog_pvt *p, int flag)
+static void analog_set_dialing(struct analog_pvt *p, int is_dialing)
 {
-       p->dialing = flag;
+       p->dialing = is_dialing;
        if (p->calls->set_dialing) {
-               return p->calls->set_dialing(p->chan_pvt, flag);
+               return p->calls->set_dialing(p->chan_pvt, is_dialing);
+       }
+}
+
+static void analog_set_alarm(struct analog_pvt *p, int in_alarm)
+{
+       p->inalarm = in_alarm;
+       if (p->calls->set_alarm) {
+               return p->calls->set_alarm(p->chan_pvt, in_alarm);
        }
 }
 
@@ -2202,7 +2210,7 @@ static void *__analog_ss_thread(void *data)
 
                                                if (res == 1) {
                                                        if (ev == ANALOG_EVENT_NOALARM) {
-                                                               p->inalarm = 0;
+                                                               analog_set_alarm(p, 0);
                                                        }
                                                        if (p->cid_signalling == CID_SIG_V23_JP) {
                                                                if (ev == ANALOG_EVENT_RINGBEGIN) {
@@ -2291,7 +2299,7 @@ static void *__analog_ss_thread(void *data)
 
                                        if (res == 1 || res == 2) {
                                                if (ev == ANALOG_EVENT_NOALARM) {
-                                                       p->inalarm = 0;
+                                                       analog_set_alarm(p, 0);
                                                } else if (ev == ANALOG_EVENT_POLARITY && p->hanguponpolarityswitch && p->polarity == POLARITY_REV) {
                                                        ast_debug(1, "Hanging up due to polarity reversal on channel %d while detecting callerid\n", p->channel);
                                                        p->polarity = POLARITY_IDLE;
@@ -2507,7 +2515,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                }
                break;
        case ANALOG_EVENT_ALARM:
-               p->inalarm = 1;
+               analog_set_alarm(p, 1);
                analog_get_and_handle_alarms(p);
 
        case ANALOG_EVENT_ONHOOK:
@@ -2803,7 +2811,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
        case ANALOG_EVENT_RINGERON:
                break;
        case ANALOG_EVENT_NOALARM:
-               p->inalarm = 0;
+               analog_set_alarm(p, 0);
                if (!p->unknown_alarm) {
                        ast_log(LOG_NOTICE, "Alarm cleared on channel %d\n", p->channel);
                        manager_event(EVENT_FLAG_SYSTEM, "AlarmClear",
@@ -3403,7 +3411,7 @@ void *analog_handle_init_event(struct analog_pvt *i, int event)
                }
                break;
        case ANALOG_EVENT_NOALARM:
-               i->inalarm = 0;
+               analog_set_alarm(i, 0);
                if (!i->unknown_alarm) {
                        ast_log(LOG_NOTICE, "Alarm cleared on channel %d\n", i->channel);
                        manager_event(EVENT_FLAG_SYSTEM, "AlarmClear",
@@ -3413,7 +3421,7 @@ void *analog_handle_init_event(struct analog_pvt *i, int event)
                }
                break;
        case ANALOG_EVENT_ALARM:
-               i->inalarm = 1;
+               analog_set_alarm(i, 1);
                analog_get_and_handle_alarms(i);
 
                /* fall thru intentionally */
index e6c0728..bc9f926 100644 (file)
@@ -205,7 +205,8 @@ struct analog_callback {
        void * (* const get_sigpvt_bridged_channel)(struct ast_channel *chan);
        int (* const get_sub_fd)(void *pvt, enum analog_sub sub);
        void (* const set_cadence)(void *pvt, int *cidrings, struct ast_channel *chan);
-       void (* const set_dialing)(void *pvt, int flag);
+       void (* const set_alarm)(void *pvt, int in_alarm);
+       void (* const set_dialing)(void *pvt, int is_dialing);
        void (* const set_ringtimeout)(void *pvt, int ringt);
        void (* const set_waitingfordt)(void *pvt, struct ast_channel *ast);
        int (* const check_waitingfordt)(void *pvt);
index 82410a3..887f4c4 100644 (file)
@@ -128,17 +128,27 @@ static void sig_pri_handle_dchan_exception(struct sig_pri_pri *pri, int index)
                pri->calls->handle_dchan_exception(pri, index);
 }
 
-static void sig_pri_set_dialing(struct sig_pri_chan *p, int flag)
+static void sig_pri_set_dialing(struct sig_pri_chan *p, int is_dialing)
 {
-       if (p->calls->set_dialing)
-               p->calls->set_dialing(p->chan_pvt, flag);
+       if (p->calls->set_dialing) {
+               p->calls->set_dialing(p->chan_pvt, is_dialing);
+       }
 }
 
-static void sig_pri_set_digital(struct sig_pri_chan *p, int flag)
+static void sig_pri_set_digital(struct sig_pri_chan *p, int is_digital)
 {
-       p->digital = flag;
-       if (p->calls->set_digital)
-               p->calls->set_digital(p->chan_pvt, flag);
+       p->digital = is_digital;
+       if (p->calls->set_digital) {
+               p->calls->set_digital(p->chan_pvt, is_digital);
+       }
+}
+
+static void sig_pri_set_alarm(struct sig_pri_chan *p, int in_alarm)
+{
+       p->inalarm = in_alarm;
+       if (p->calls->set_alarm) {
+               p->calls->set_alarm(p->chan_pvt, in_alarm);
+       }
 }
 
 static const char *sig_pri_get_orig_dialstring(struct sig_pri_chan *p)
@@ -2830,7 +2840,7 @@ static void *pri_dchannel(void *vpri)
                                /* Take the channels from inalarm condition */
                                for (i = 0; i < pri->numchans; i++) {
                                        if (pri->pvts[i]) {
-                                               pri->pvts[i]->inalarm = 0;
+                                               sig_pri_set_alarm(pri->pvts[i], 0);
                                        }
                                }
                                sig_pri_span_devstate_changed(pri);
@@ -2861,7 +2871,7 @@ static void *pri_dchannel(void *vpri)
                                                                if (p->owner)
                                                                        ast_softhangup_nolock(p->owner, AST_SOFTHANGUP_DEV);
                                                        }
-                                                       p->inalarm = 1;
+                                                       sig_pri_set_alarm(p, 1);
                                                }
                                        }
                                        sig_pri_span_devstate_changed(pri);
@@ -4854,8 +4864,8 @@ int sig_pri_start_pri(struct sig_pri_pri *pri)
 
 void sig_pri_chan_alarm_notify(struct sig_pri_chan *p, int noalarm)
 {
+       sig_pri_set_alarm(p, !noalarm);
        if (!noalarm) {
-               p->inalarm = 1;
                if (!p->pri || !p->pri->pri || (pri_get_timer(p->pri->pri, PRI_TIMER_T309) < 0)) {
                        /* T309 is not enabled : hangup calls when alarm occurs */
                        if (p->call) {
@@ -4873,8 +4883,6 @@ void sig_pri_chan_alarm_notify(struct sig_pri_chan *p, int noalarm)
                        if (p->owner)
                                ast_softhangup_nolock(p->owner, AST_SOFTHANGUP_DEV);
                }
-       } else {
-               p->inalarm = 0;
        }
 }
 
index 9aff565..ecdc0b7 100644 (file)
@@ -103,8 +103,9 @@ struct sig_pri_callback {
 
        /* Note: Called with PRI lock held */
        void (* const handle_dchan_exception)(struct sig_pri_pri *pri, int index);
-       void (* const set_dialing)(void *pvt, int flag);
-       void (* const set_digital)(void *pvt, int flag);
+       void (* const set_alarm)(void *pvt, int in_alarm);
+       void (* const set_dialing)(void *pvt, int is_dialing);
+       void (* const set_digital)(void *pvt, int is_digital);
        void (* const set_callerid)(void *pvt, const struct ast_party_caller *caller);
        void (* const set_dnid)(void *pvt, const char *dnid);
        void (* const set_rdnis)(void *pvt, const char *rdnis);