[dahdi-commits] dahdi/tools.git branch "master" updated.

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Tue May 28 12:36:32 CDT 2013


branch "master" has been updated
       via  2889d6afee7d254990b2e5a52a7ef538f6a0d6fe (commit)
       via  7939579d9e901d85749eadbdd40bc1c79ecd6478 (commit)
      from  bab1ac48f552ba57495af1c5eb8cb2ed79b68778 (commit)

Summary of changes:
 dahdi_cfg.c |    8 ++++----
 fxstest.c   |   38 +++++++++++++++++++++++++++++++++++++-
 2 files changed, 41 insertions(+), 5 deletions(-)


- Log -----------------------------------------------------------------
commit 2889d6afee7d254990b2e5a52a7ef538f6a0d6fe
Author: Shaun Ruffell <sruffell at digium.com>
Date:   Thu May 9 14:03:46 2013 -0500

    dahdi_cfg: Make -S option based on spannumber instead of order in config file.
    
    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 at digium.com>
    Signed-off-by: Russ Meyerriecks <rmeyerriecks at digium.com>

diff --git a/dahdi_cfg.c b/dahdi_cfg.c
index 3ce9ef6..3dfaf42 100644
--- a/dahdi_cfg.c
+++ b/dahdi_cfg.c
@@ -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));

commit 7939579d9e901d85749eadbdd40bc1c79ecd6478
Author: Shaun Ruffell <sruffell at digium.com>
Date:   Thu May 9 10:34:20 2013 -0500

    fxstest: Use DAHDI_SPECIFY when opening by integer channel number.
    
    In DAHDI-Linux 2.7 the layout of the /dev/dahdi files changes so that they are
    grouped by span. When opening channels by number all utilities need to use
    DAHDI_SPECIFY now.
    
    Signed-off-by: Shaun Ruffell <sruffell at digium.com>
    Signed-off-by: Russ Meyerriecks <rmeyerriecks at digium.com>

diff --git a/fxstest.c b/fxstest.c
index 130fad5..94709c6 100644
--- a/fxstest.c
+++ b/fxstest.c
@@ -33,6 +33,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/ioctl.h>
+#include <sys/stat.h>
 #include <dahdi/user.h>
 #include <dahdi/wctdm_user.h>
 
@@ -101,6 +102,41 @@ static int dahdi_ring_phone(int fd)
 	return res;
 }
 
+int channel_open(const char *name)
+{
+	int	channo, fd;
+	struct	stat filestat;
+	const char *DEVICE = "/dev/dahdi/channel";
+
+	/* stat file, if character device, open it */
+	channo = strtoul(name, NULL, 10);
+	fd = stat(name, &filestat);
+	if (!fd && S_ISCHR(filestat.st_mode)) {
+		fd = open(name, O_RDWR, 0600);
+		if (fd < 0) {
+			perror(name);
+			return -1;
+		}
+	/* try out the dahdi_specify interface */
+	} else if (channo > 0) {
+		fd = open(DEVICE, O_RDWR, 0600);
+		if (fd < 0) {
+			perror(DEVICE);
+			return -1;
+		}
+		if (ioctl(fd, DAHDI_SPECIFY, &channo) < 0) {
+			perror("DAHDI_SPECIFY ioctl failed");
+			return -1;
+		}
+	/* die */
+	} else {
+		fprintf(stderr, "Specified channel is not a valid character "
+			"device or channel number");
+		return -1;
+	}
+	return fd;
+}
+
 int main(int argc, char *argv[])
 {
 	int fd;
@@ -121,7 +157,7 @@ int main(int argc, char *argv[])
 		       "       dtmfcid - create a dtmf cid spill without polarity reversal\n");
 		exit(1);
 	}
-	fd = open(argv[1], O_RDWR);
+	fd = channel_open(argv[1]);
 	if (fd < 0) {
 		fprintf(stderr, "Unable to open %s: %s\n", argv[1], strerror(errno));
 		exit(1);

-----------------------------------------------------------------------


-- 
dahdi/tools.git



More information about the dahdi-commits mailing list