~ubuntu-branches/ubuntu/saucy/dahdi-tools/saucy

« back to all changes in this revision

Viewing changes to dahdi_scan.c

  • Committer: Stefan Lesicnik
  • Date: 2011-05-08 12:22:46 UTC
  • mfrom: (2.1.4 sid)
  • Revision ID: stefan@lsd.co.za-20110508122246-lh6k2x1uy8pl3vdi
Tags: 1:2.4.1-1ubuntu1
* Merge from Debian. Remaining changes:
  - Bug Fix: If linux-headers are not installed, don't block, and print
    information for the user.
  - added debian/dahdi.postinst
  - added --error-handler=init_failed to debian/rules
  - Changes from Debian:
    - debian/control: Change Maintainer
    - debian/control: Removed Uploaders field.
    - debian/control: Removed Debian Vcs-Svn entry and replaced with
      ubuntu-voip Vcs-Bzr, to reflect divergence in packages.
    - debian/control: Package dahdi Depends on dahdi-dkms | dahdi-source
* debian/control: Added gawk as dependency for dkms build (LP: #493304)
* New upstream release (Closes: #581076, #582094).
* Patches hardware_rescan, perl_fix_noserial, perl_fix_transportdir,
  astribank_allow_ignoreend, init_unload_modules and wcb4xxp_extra_trunk
  dropped: merged upstream.
* dahdi-linux 2.3.0 is required (extra config options for dahdi_cfg).
* Convert to dpkg v.3 format.
* Standards version: 3.9.1.0 (No change needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
 
38
38
#include "dahdi_tools_version.h"
39
39
 
 
40
static inline int is_digital_span(struct dahdi_spaninfo *s)
 
41
{
 
42
        return (s->linecompat > 0);
 
43
}
 
44
 
40
45
int main(int argc, char *argv[])
41
46
{
42
47
        int ctl;
88
93
                                strcat(alarms,"BLU/");
89
94
                        if (s.alarms & DAHDI_ALARM_YELLOW)
90
95
                                strcat(alarms, "YEL/");
91
 
                        if (s.alarms & DAHDI_ALARM_RED)
 
96
                        if (s.alarms & DAHDI_ALARM_RED) {
92
97
                                strcat(alarms, "RED/");
 
98
 
 
99
/* Extended alarm feature test. Allows compilation with
 
100
 * versions of dahdi-linux prior to 2.4
 
101
 */
 
102
#ifdef DAHDI_ALARM_LFA
 
103
                                if (s.alarms & DAHDI_ALARM_LFA)
 
104
                                        strcat(alarms, "LFA/");
 
105
#endif /* ifdef DAHDI_ALARM_LFA */
 
106
                        }
93
107
                        if (s.alarms & DAHDI_ALARM_LOOPBACK)
94
108
                                strcat(alarms,"LB/");
95
109
                        if (s.alarms & DAHDI_ALARM_RECOVER)
103
117
                                alarms[strlen(alarms)-1]='\0';
104
118
                        }
105
119
                } else {
106
 
                        if (s.numchans)
107
 
                                strcpy(alarms, "OK");
108
 
                        else
 
120
                        if (s.numchans) {
 
121
#ifdef DAHDI_ALARM_LFA
 
122
                                /* If we continuously receive framing errors
 
123
                                 * but our span is still in service, and we
 
124
                                 * are configured for E1 & crc4. We've lost
 
125
                                 * crc4-multiframe alignment
 
126
                                 */
 
127
                                if ((s.linecompat & DAHDI_CONFIG_CRC4) &&
 
128
                                    (s.fecount > 0)) {
 
129
                                        struct dahdi_spaninfo t;
 
130
                                        memset(&t, 0, sizeof(t));
 
131
                                        t.spanno = x;
 
132
                                        sleep(1);
 
133
                                        if (ioctl(ctl, DAHDI_SPANSTAT, &t))
 
134
                                                continue;
 
135
 
 
136
                                        /* Test fecount at two separate time
 
137
                                         * intervals, if they differ, throw LMFA
 
138
                                         */
 
139
                                        if ((t.fecount > s.fecount) &&
 
140
                                                !t.alarms) {
 
141
                                                strcat(alarms, "LMFA/");
 
142
                                        }
 
143
                                }
 
144
#endif /* ifdef DAHDI_ALARM_LFA */
 
145
                                strcat(alarms, "OK");
 
146
                        } else {
109
147
                                strcpy(alarms, "UNCONFIGURED");
 
148
                        }
110
149
                }
111
150
 
112
151
                fprintf(stdout, "[%d]\n", x);
128
167
                        continue;
129
168
                }
130
169
 
131
 
                if (params.sigcap & (__DAHDI_SIG_DACS |  DAHDI_SIG_CAS)) {
 
170
                if (is_digital_span(&s)) {
132
171
                        /* this is a digital span */
133
172
                        fprintf(stdout, "type=digital-%s\n", s.spantype);
134
173
                        fprintf(stdout, "syncsrc=%d\n", s.syncsrc);
157
196
                        if (s.lineconfig & DAHDI_CONFIG_ESF) fprintf(stdout, "ESF");
158
197
                        else if (s.lineconfig & DAHDI_CONFIG_D4) fprintf(stdout, "D4");
159
198
                        else if (s.lineconfig & DAHDI_CONFIG_CCS) fprintf(stdout, "CCS");
160
 
                        else if (s.lineconfig & DAHDI_CONFIG_CRC4) fprintf(stdout, "/CRC4");
 
199
                        else fprintf(stdout, "CAS");
 
200
                        if (s.lineconfig & DAHDI_CONFIG_CRC4) fprintf(stdout, "/CRC4");
161
201
                        fprintf(stdout, "\n");
162
202
                } else {
163
203
                        /* this is an analog span */