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 <tzafrir.cohen@xorcom.com>
This commit is contained in:
parent
42850dba35
commit
cffc5158cc
38
dahdi_cfg.c
38
dahdi_cfg.c
@ -90,11 +90,9 @@ static struct dahdi_lineconfig lc[DAHDI_MAX_SPANS];
|
|||||||
|
|
||||||
static struct dahdi_chanconfig cc[DAHDI_MAX_CHANNELS];
|
static struct dahdi_chanconfig cc[DAHDI_MAX_CHANNELS];
|
||||||
|
|
||||||
static int current_span = 0;
|
|
||||||
static int only_span = 0;
|
static int only_span = 0;
|
||||||
static int restrict_channels = 0;
|
static int restrict_channels = 0;
|
||||||
static int selected_channels[DAHDI_MAX_CHANNELS];
|
static int selected_channels[DAHDI_MAX_CHANNELS];
|
||||||
static int chan2span[DAHDI_MAX_CHANNELS];
|
|
||||||
static int declared_spans[DAHDI_MAX_SPANS];
|
static int declared_spans[DAHDI_MAX_SPANS];
|
||||||
|
|
||||||
static struct dahdi_attach_echocan ae[DAHDI_MAX_CHANNELS];
|
static struct dahdi_attach_echocan ae[DAHDI_MAX_CHANNELS];
|
||||||
@ -333,20 +331,9 @@ static char *trim(char *buf)
|
|||||||
|
|
||||||
static int skip_channel(int x)
|
static int skip_channel(int x)
|
||||||
{
|
{
|
||||||
int spanno = chan2span[x];
|
|
||||||
|
|
||||||
if (restrict_channels) {
|
if (restrict_channels) {
|
||||||
if (!selected_channels[x])
|
if (!selected_channels[x])
|
||||||
return 1;
|
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 {
|
} else {
|
||||||
if (only_span && !declared_spans[only_span]) {
|
if (only_span && !declared_spans[only_span]) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@ -354,8 +341,6 @@ static int skip_channel(int x)
|
|||||||
only_span);
|
only_span);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (only_span && only_span != spanno)
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
return 0;
|
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]);
|
error("Span number should be a valid span number, not '%s'\n", realargs[0]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
current_span = span;
|
|
||||||
declared_spans[span] = 1;
|
declared_spans[span] = 1;
|
||||||
res = sscanf(realargs[1], "%d", &timing);
|
res = sscanf(realargs[1], "%d", &timing);
|
||||||
if ((res != 1) || (timing < 0) || (timing > MAX_TIMING)) {
|
if ((res != 1) || (timing < 0) || (timing > MAX_TIMING)) {
|
||||||
@ -615,7 +599,6 @@ static int chanconfig(char *keyword, char *args)
|
|||||||
int master=0;
|
int master=0;
|
||||||
int dacschan = 0;
|
int dacschan = 0;
|
||||||
char *idle;
|
char *idle;
|
||||||
int is_digital;
|
|
||||||
bzero(chans, sizeof(chans));
|
bzero(chans, sizeof(chans));
|
||||||
strtok(args, ":");
|
strtok(args, ":");
|
||||||
idle = strtok(NULL, ":");
|
idle = strtok(NULL, ":");
|
||||||
@ -627,7 +610,6 @@ static int chanconfig(char *keyword, char *args)
|
|||||||
if (res <= 0)
|
if (res <= 0)
|
||||||
return -1;
|
return -1;
|
||||||
for (x=1;x<DAHDI_MAX_CHANNELS;x++) {
|
for (x=1;x<DAHDI_MAX_CHANNELS;x++) {
|
||||||
is_digital = 0;
|
|
||||||
if (chans[x]) {
|
if (chans[x]) {
|
||||||
if (slineno[x]) {
|
if (slineno[x]) {
|
||||||
error("Channel %d already configured as '%s' at line %d\n", x, sig[x], slineno[x]);
|
error("Channel %d already configured as '%s' at line %d\n", x, sig[x], slineno[x]);
|
||||||
@ -673,7 +655,6 @@ static int chanconfig(char *keyword, char *args)
|
|||||||
return -1;
|
return -1;
|
||||||
cc[x].sigtype = DAHDI_SIG_CAS;
|
cc[x].sigtype = DAHDI_SIG_CAS;
|
||||||
sig[x] = sigtype_to_str(cc[x].sigtype);
|
sig[x] = sigtype_to_str(cc[x].sigtype);
|
||||||
is_digital = 1;
|
|
||||||
} else if (!strcasecmp(keyword, "dacs")) {
|
} else if (!strcasecmp(keyword, "dacs")) {
|
||||||
/* Setup channel for monitor */
|
/* Setup channel for monitor */
|
||||||
cc[x].idlebits = dacschan;
|
cc[x].idlebits = dacschan;
|
||||||
@ -684,7 +665,6 @@ static int chanconfig(char *keyword, char *args)
|
|||||||
cc[dacschan].sigtype = DAHDI_SIG_DACS;
|
cc[dacschan].sigtype = DAHDI_SIG_DACS;
|
||||||
sig[x] = sigtype_to_str(cc[dacschan].sigtype);
|
sig[x] = sigtype_to_str(cc[dacschan].sigtype);
|
||||||
dacschan++;
|
dacschan++;
|
||||||
is_digital = 1;
|
|
||||||
} else if (!strcasecmp(keyword, "dacsrbs")) {
|
} else if (!strcasecmp(keyword, "dacsrbs")) {
|
||||||
/* Setup channel for monitor */
|
/* Setup channel for monitor */
|
||||||
cc[x].idlebits = dacschan;
|
cc[x].idlebits = dacschan;
|
||||||
@ -694,7 +674,6 @@ static int chanconfig(char *keyword, char *args)
|
|||||||
cc[dacschan].idlebits = x;
|
cc[dacschan].idlebits = x;
|
||||||
cc[dacschan].sigtype = DAHDI_SIG_DACS_RBS;
|
cc[dacschan].sigtype = DAHDI_SIG_DACS_RBS;
|
||||||
sig[x] = sigtype_to_str(cc[dacschan].sigtype);
|
sig[x] = sigtype_to_str(cc[dacschan].sigtype);
|
||||||
is_digital = 1;
|
|
||||||
dacschan++;
|
dacschan++;
|
||||||
} else if (!strcasecmp(keyword, "unused")) {
|
} else if (!strcasecmp(keyword, "unused")) {
|
||||||
cc[x].sigtype = 0;
|
cc[x].sigtype = 0;
|
||||||
@ -702,7 +681,6 @@ static int chanconfig(char *keyword, char *args)
|
|||||||
} else if (!strcasecmp(keyword, "indclear") || !strcasecmp(keyword, "bchan")) {
|
} else if (!strcasecmp(keyword, "indclear") || !strcasecmp(keyword, "bchan")) {
|
||||||
cc[x].sigtype = DAHDI_SIG_CLEAR;
|
cc[x].sigtype = DAHDI_SIG_CLEAR;
|
||||||
sig[x] = sigtype_to_str(cc[x].sigtype);
|
sig[x] = sigtype_to_str(cc[x].sigtype);
|
||||||
is_digital = 1;
|
|
||||||
} else if (!strcasecmp(keyword, "clear")) {
|
} else if (!strcasecmp(keyword, "clear")) {
|
||||||
sig[x] = sigtype_to_str(DAHDI_SIG_CLEAR);
|
sig[x] = sigtype_to_str(DAHDI_SIG_CLEAR);
|
||||||
if (master) {
|
if (master) {
|
||||||
@ -712,7 +690,6 @@ static int chanconfig(char *keyword, char *args)
|
|||||||
cc[x].sigtype = DAHDI_SIG_CLEAR;
|
cc[x].sigtype = DAHDI_SIG_CLEAR;
|
||||||
master = x;
|
master = x;
|
||||||
}
|
}
|
||||||
is_digital = 1;
|
|
||||||
} else if (!strcasecmp(keyword, "rawhdlc")) {
|
} else if (!strcasecmp(keyword, "rawhdlc")) {
|
||||||
sig[x] = sigtype_to_str(DAHDI_SIG_HDLCRAW);
|
sig[x] = sigtype_to_str(DAHDI_SIG_HDLCRAW);
|
||||||
if (master) {
|
if (master) {
|
||||||
@ -722,7 +699,6 @@ static int chanconfig(char *keyword, char *args)
|
|||||||
cc[x].sigtype = DAHDI_SIG_HDLCRAW;
|
cc[x].sigtype = DAHDI_SIG_HDLCRAW;
|
||||||
master = x;
|
master = x;
|
||||||
}
|
}
|
||||||
is_digital = 1;
|
|
||||||
} else if (!strcasecmp(keyword, "nethdlc")) {
|
} else if (!strcasecmp(keyword, "nethdlc")) {
|
||||||
sig[x] = sigtype_to_str(DAHDI_SIG_HDLCNET);
|
sig[x] = sigtype_to_str(DAHDI_SIG_HDLCNET);
|
||||||
memset(cc[x].netdev_name, 0, sizeof(cc[x].netdev_name));
|
memset(cc[x].netdev_name, 0, sizeof(cc[x].netdev_name));
|
||||||
@ -736,7 +712,6 @@ static int chanconfig(char *keyword, char *args)
|
|||||||
}
|
}
|
||||||
master = x;
|
master = x;
|
||||||
}
|
}
|
||||||
is_digital = 1;
|
|
||||||
} else if (!strcasecmp(keyword, "fcshdlc")) {
|
} else if (!strcasecmp(keyword, "fcshdlc")) {
|
||||||
sig[x] = sigtype_to_str(DAHDI_SIG_HDLCFCS);
|
sig[x] = sigtype_to_str(DAHDI_SIG_HDLCFCS);
|
||||||
if (master) {
|
if (master) {
|
||||||
@ -746,19 +721,15 @@ static int chanconfig(char *keyword, char *args)
|
|||||||
cc[x].sigtype = DAHDI_SIG_HDLCFCS;
|
cc[x].sigtype = DAHDI_SIG_HDLCFCS;
|
||||||
master = x;
|
master = x;
|
||||||
}
|
}
|
||||||
is_digital = 1;
|
|
||||||
} else if (!strcasecmp(keyword, "dchan")) {
|
} else if (!strcasecmp(keyword, "dchan")) {
|
||||||
sig[x] = "D-channel";
|
sig[x] = "D-channel";
|
||||||
cc[x].sigtype = DAHDI_SIG_HDLCFCS;
|
cc[x].sigtype = DAHDI_SIG_HDLCFCS;
|
||||||
is_digital = 1;
|
|
||||||
} else if (!strcasecmp(keyword, "hardhdlc")) {
|
} else if (!strcasecmp(keyword, "hardhdlc")) {
|
||||||
sig[x] = "Hardware assisted D-channel";
|
sig[x] = "Hardware assisted D-channel";
|
||||||
cc[x].sigtype = DAHDI_SIG_HARDHDLC;
|
cc[x].sigtype = DAHDI_SIG_HARDHDLC;
|
||||||
is_digital = 1;
|
|
||||||
} else if (!strcasecmp(keyword, "mtp2")) {
|
} else if (!strcasecmp(keyword, "mtp2")) {
|
||||||
sig[x] = "MTP2";
|
sig[x] = "MTP2";
|
||||||
cc[x].sigtype = DAHDI_SIG_MTP2;
|
cc[x].sigtype = DAHDI_SIG_MTP2;
|
||||||
is_digital = 1;
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Huh? (%s)\n", keyword);
|
fprintf(stderr, "Huh? (%s)\n", keyword);
|
||||||
}
|
}
|
||||||
@ -770,11 +741,6 @@ static int chanconfig(char *keyword, char *args)
|
|||||||
fprintf(stderr, "WARNING: idlebits are not valid on %s channels.\n", sig[x]);
|
fprintf(stderr, "WARNING: idlebits are not valid on %s channels.\n", sig[x]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_digital)
|
|
||||||
chan2span[x] = current_span;
|
|
||||||
else
|
|
||||||
current_span = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -1617,6 +1583,10 @@ int main(int argc, char *argv[])
|
|||||||
fprintf(stderr, "%s\n", dahdi_tools_version);
|
fprintf(stderr, "%s\n", dahdi_tools_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!restrict_channels && only_span) {
|
||||||
|
error("-S requires -C\n");
|
||||||
|
goto finish;
|
||||||
|
}
|
||||||
if (!restrict_channels && !only_span) {
|
if (!restrict_channels && !only_span) {
|
||||||
bool all_assigned = wait_for_all_spans_assigned(5);
|
bool all_assigned = wait_for_all_spans_assigned(5);
|
||||||
|
|
||||||
|
@ -41,10 +41,8 @@ Only shutdown spans.
|
|||||||
|
|
||||||
.B \-S \fISPAN
|
.B \-S \fISPAN
|
||||||
.RS
|
.RS
|
||||||
Only apply changes to span no. \fISPAN\fR. For a digital span (with
|
Only apply changes to span no. \fISPAN\fR. You also need to specify the
|
||||||
a 'span=' line in the configuration file) this will do. For an analog
|
range of channels in the span explicitly with \-C.
|
||||||
span you'll have to explicitly tell dahdi_cfg the range of channels,
|
|
||||||
using \-C .
|
|
||||||
.RE
|
.RE
|
||||||
|
|
||||||
.B \-f
|
.B \-f
|
||||||
|
Loading…
Reference in New Issue
Block a user