[Pkg-voip-commits] [dahdi-tools] 98/285: dahdi_scan: Support gaps in channel numbering.
tzafrir at debian.org
tzafrir at debian.org
Thu Jul 7 19:18:37 UTC 2016
This is an automated email from the git hooks/post-receive script.
tzafrir pushed a commit to branch master
in repository dahdi-tools.
commit 17027df04b5aa2d49258f74adf0152ac4a5aeb46
Author: Shaun Ruffell <sruffell at digium.com>
Date: Tue Apr 16 21:33:05 2013 -0500
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 at digium.com>
---
dahdi_scan.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/dahdi_scan.c b/dahdi_scan.c
index 20a9a4b..7b28a52 100644
--- a/dahdi_scan.c
+++ b/dahdi_scan.c
@@ -42,12 +42,35 @@ static inline int is_digital_span(struct dahdi_spaninfo *s)
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 ctl;
int x, y, z;
struct dahdi_params params;
unsigned int basechan = 1;
+ int direct_basechan;
struct dahdi_spaninfo s;
char buf[100];
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';
if (s.alarms) {
if (s.alarms & DAHDI_ALARM_BLUE)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-voip/dahdi-tools.git
More information about the Pkg-voip-commits
mailing list