dahdi_scan: Support gaps in channel numbering.
If, via the sysfs attributed introduced in DAHDI-Linux 2.5.0, a user has configured spans that do not have contiguous channel numbers, dahdi_scan will not print several of the span attributes in addition to a bad basechan number. This patch allows dahdi_scan to try and get the basechan for a span from sysfs as opposed to calculating based on the number of channels in the previous span scanned. Signed-off-by: Shaun Ruffell <sruffell@digium.com>
This commit is contained in:
parent
eacc071afe
commit
17027df04b
31
dahdi_scan.c
31
dahdi_scan.c
@ -42,12 +42,35 @@ static inline int is_digital_span(struct dahdi_spaninfo *s)
|
|||||||
return (s->linecompat > 0);
|
return (s->linecompat > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int get_basechan(unsigned int spanno)
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
int basechan;
|
||||||
|
char filename[256];
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
snprintf(filename, sizeof(filename),
|
||||||
|
"/sys/bus/dahdi_spans/devices/span-%u/basechan", spanno);
|
||||||
|
fp = fopen(filename, "r");
|
||||||
|
if (NULL == fp) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
res = fscanf(fp, "%d", &basechan);
|
||||||
|
fclose(fp);
|
||||||
|
if (EOF == res) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return basechan;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int ctl;
|
int ctl;
|
||||||
int x, y, z;
|
int x, y, z;
|
||||||
struct dahdi_params params;
|
struct dahdi_params params;
|
||||||
unsigned int basechan = 1;
|
unsigned int basechan = 1;
|
||||||
|
int direct_basechan;
|
||||||
struct dahdi_spaninfo s;
|
struct dahdi_spaninfo s;
|
||||||
char buf[100];
|
char buf[100];
|
||||||
char alarms[50];
|
char alarms[50];
|
||||||
@ -87,6 +110,14 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* DAHDI-Linux 2.5.x exposes the base channel in sysfs. Let's
|
||||||
|
* try to look for it there in case there are holes in the span
|
||||||
|
* numbering. */
|
||||||
|
direct_basechan = get_basechan(x);
|
||||||
|
if (-1 != direct_basechan) {
|
||||||
|
basechan = direct_basechan;
|
||||||
|
}
|
||||||
|
|
||||||
alarms[0] = '\0';
|
alarms[0] = '\0';
|
||||||
if (s.alarms) {
|
if (s.alarms) {
|
||||||
if (s.alarms & DAHDI_ALARM_BLUE)
|
if (s.alarms & DAHDI_ALARM_BLUE)
|
||||||
|
Loading…
Reference in New Issue
Block a user