]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
OPENZAP-176 --resolve
authorMoises Silva <moy@sangoma.com>
Fri, 30 Dec 2011 22:14:36 +0000 (17:14 -0500)
committerMoises Silva <moy@sangoma.com>
Fri, 30 Dec 2011 22:14:36 +0000 (17:14 -0500)
Fix DAHDI/Zaptel incorrect FXO signaling status on module load

libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c
libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.h

index 677bcbbd56da5217af5426dba3ccd39fd600aca5..87632c8f664f1f2b83d0f4a16cab9d39c3192cba 100644 (file)
@@ -34,6 +34,7 @@
  *
  * Moises Silva <moy@sangoma.com>
  * W McRoberts <fs@whmcr.com>
+ * Puskás Zsolt <errotan@gmail.com>
  *
  */
 
@@ -877,10 +878,13 @@ static FIO_COMMAND_FUNCTION(zt_command)
 static FIO_GET_ALARMS_FUNCTION(zt_get_alarms)
 {
        struct zt_spaninfo info;
+       zt_params_t params;
 
        memset(&info, 0, sizeof(info));
        info.span_no = ftdmchan->physical_span_id;
 
+       memset(&params, 0, sizeof(params));
+
        if (ioctl(CONTROL_FD, codes.SPANSTAT, &info)) {
                snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "ioctl failed (%s)", strerror(errno));
                snprintf(ftdmchan->span->last_error, sizeof(ftdmchan->span->last_error), "ioctl failed (%s)", strerror(errno));
@@ -889,6 +893,27 @@ static FIO_GET_ALARMS_FUNCTION(zt_get_alarms)
 
        ftdmchan->alarm_flags = info.alarms;
 
+       /* get channel alarms if span has no alarms */
+       if (info.alarms == FTDM_ALARM_NONE) {
+               if (ioctl(ftdmchan->sockfd, codes.GET_PARAMS, &params)) {
+                       snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "ioctl failed (%s)", strerror(errno));
+                       snprintf(ftdmchan->span->last_error, sizeof(ftdmchan->span->last_error), "ioctl failed (%s)", strerror(errno));
+                       return FTDM_FAIL;
+               }
+
+               if (params.chan_alarms > 0) {
+                       if (params.chan_alarms == DAHDI_ALARM_YELLOW) {
+                               ftdmchan->alarm_flags = FTDM_ALARM_YELLOW;
+                       }
+                       else if (params.chan_alarms == DAHDI_ALARM_BLUE) {
+                               ftdmchan->alarm_flags = FTDM_ALARM_BLUE;
+                       }
+                       else {
+                               ftdmchan->alarm_flags = FTDM_ALARM_RED;
+                       }
+               }
+       }
+
        return FTDM_SUCCESS;
 }
 
index 065d7e63e2ef4957d2f81246ff8ee127b3146f47..40b5a4e71d33e6d9ea2493d8cce36cd45e831493 100644 (file)
@@ -339,6 +339,10 @@ ZT_ABIT = 8
 #define                DAHDI_HDLCRAWMODE       _IOW (DAHDI_CODE, 36, int)                              /* Set a clear channel into HDLC w/out FCS checking/calculation mode */
 #define                DAHDI_HDLCFCSMODE       _IOW (DAHDI_CODE, 37, int)                              /* Set a clear channel into HDLC w/ FCS mode */
 
+/* Dahdi channel alarms */
+#define                DAHDI_ALARM_YELLOW (1 << 2) /* Yellow Alarm */
+#define                DAHDI_ALARM_BLUE (1 << 4) /* Blue Alarm */
+
 /* Specify a channel on /dev/dahdi/chan -- must be done before any other ioctl's and is only valid on /dev/dahdi/chan */
 #define                DAHDI_SPECIFY           _IOW  (DAHDI_CODE, 38, int)