dahdi_cfg: Make -S option based on spannumber instead of order in config file.
authorShaun Ruffell <sruffell@digium.com>
Thu, 9 May 2013 19:03:46 +0000 (14:03 -0500)
committerRuss Meyerriecks <rmeyerriecks@digium.com>
Tue, 28 May 2013 17:34:03 +0000 (12:34 -0500)
If the config file has two spans defined:

  span=1,1,0,esf,b8zs
  bchan=1-23
  dchan=24
  echocanceller=mg2,1-23
  span=2,2,0,esf,b8zs
  bchan=25-47
  dchan=48

And you only want to configure span-2, you would need to pass -S 1 to
dahdi_cfg. Now make the -S option take the span number as assigned in the
config file.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>

dahdi_cfg.c

index 3ce9ef6..3dfaf42 100644 (file)
@@ -1271,7 +1271,7 @@ static void printconfig(int fd)
               "Configuration\n"
               "======================\n\n", vi.version, vi.echo_canceller);
        for (x = 0; x < spans; x++) {
-               if (only_span && only_span != x)
+               if (only_span && only_span != lc[x].span)
                        continue;
                printf("SPAN %d: %3s/%4s Build-out: %s\n",
                       lc[x].span,
@@ -1564,7 +1564,7 @@ finish:
        }
        if (stopmode) {
                for (x=0;x<spans;x++) {
-                       if (only_span && x != only_span)
+                       if (only_span && lc[x].span != only_span)
                                continue;
                        if (ioctl(fd, DAHDI_SHUTDOWN, &lc[x].span)) {
                                fprintf(stderr, "DAHDI shutdown failed: %s\n", strerror(errno));
@@ -1575,7 +1575,7 @@ finish:
                exit(1);
        }
        for (x=0;x<spans;x++) {
-               if (only_span && x != only_span)
+               if (only_span && lc[x].span != only_span)
                        continue;
                if (ioctl(fd, DAHDI_SPANCONFIG, lc + x)) {
                        fprintf(stderr, "DAHDI_SPANCONFIG failed on span %d: %s (%d)\n", lc[x].span, strerror(errno), errno);
@@ -1754,7 +1754,7 @@ finish:
                }
        }
        for (x=0;x<spans;x++) {
-               if (only_span && x != only_span)
+               if (only_span && lc[x].span != only_span)
                        continue;
                if (ioctl(fd, DAHDI_STARTUP, &lc[x].span)) {
                        fprintf(stderr, "DAHDI startup failed: %s\n", strerror(errno));