From cffc5158cc4ca9edba83387af97f6d28d74d6a0d Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Mon, 16 Nov 2015 15:01:52 +0200 Subject: [PATCH] dahdi_cfg: -S has assumtions on system.conf order dahdi_cfg's -S (apply only to a specific span) uses the array chan2span to map channel numbers to span numbers. The problem is that it assumes that channels first appear in system.conf immediately after the span line of a specific span. Thus the following configuration breaks it: span=1,... span=2,... clear=1-2,4-5 dchan=3,6 The best fix for that is to require -C to be used when -S is used (which is already the case in our udev hooks). Fixes DAHTOOL-69. Signed-off-by: Tzafrir Cohen --- dahdi_cfg.c | 38 ++++---------------------------------- doc/dahdi_cfg.8 | 6 ++---- 2 files changed, 6 insertions(+), 38 deletions(-) diff --git a/dahdi_cfg.c b/dahdi_cfg.c index 30add83..ecd4477 100644 --- a/dahdi_cfg.c +++ b/dahdi_cfg.c @@ -90,11 +90,9 @@ static struct dahdi_lineconfig lc[DAHDI_MAX_SPANS]; static struct dahdi_chanconfig cc[DAHDI_MAX_CHANNELS]; -static int current_span = 0; static int only_span = 0; static int restrict_channels = 0; static int selected_channels[DAHDI_MAX_CHANNELS]; -static int chan2span[DAHDI_MAX_CHANNELS]; static int declared_spans[DAHDI_MAX_SPANS]; static struct dahdi_attach_echocan ae[DAHDI_MAX_CHANNELS]; @@ -333,20 +331,9 @@ static char *trim(char *buf) static int skip_channel(int x) { - int spanno = chan2span[x]; - if (restrict_channels) { if (!selected_channels[x]) return 1; - /* sanity check */ - if (only_span) { - if (spanno != 0 && only_span != spanno) { - fprintf(stderr, - "Only span %d. Skip selected channel %d from span %d\n", - only_span, x, spanno); - return 1; - } - } } else { if (only_span && !declared_spans[only_span]) { fprintf(stderr, @@ -354,8 +341,6 @@ static int skip_channel(int x) only_span); exit(1); } - if (only_span && only_span != spanno) - return 1; } return 0; } @@ -442,7 +427,6 @@ int spanconfig(char *keyword, char *args) error("Span number should be a valid span number, not '%s'\n", realargs[0]); return -1; } - current_span = span; declared_spans[span] = 1; res = sscanf(realargs[1], "%d", &timing); if ((res != 1) || (timing < 0) || (timing > MAX_TIMING)) { @@ -615,7 +599,6 @@ static int chanconfig(char *keyword, char *args) int master=0; int dacschan = 0; char *idle; - int is_digital; bzero(chans, sizeof(chans)); strtok(args, ":"); idle = strtok(NULL, ":"); @@ -627,7 +610,6 @@ static int chanconfig(char *keyword, char *args) if (res <= 0) return -1; for (x=1;x