[svn-commits] mattf: tools/trunk r4818 - /tools/trunk/dahdi_cfg.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sun Aug 24 00:54:12 CDT 2008


Author: mattf
Date: Sun Aug 24 00:54:11 2008
New Revision: 4818

URL: http://svn.digium.com/view/dahdi?view=rev&rev=4818
Log:
Add support for 56 KB HDLC as well as selectable rate in system.conf

Modified:
    tools/trunk/dahdi_cfg.c

Modified: tools/trunk/dahdi_cfg.c
URL: http://svn.digium.com/view/dahdi/tools/trunk/dahdi_cfg.c?view=diff&rev=4818&r1=4817&r2=4818
==============================================================================
--- tools/trunk/dahdi_cfg.c (original)
+++ tools/trunk/dahdi_cfg.c Sun Aug 24 00:54:11 2008
@@ -85,6 +85,8 @@
 static const char *sig[DAHDI_MAX_CHANNELS];		/* Signalling */
 
 static int slineno[DAHDI_MAX_CHANNELS];	/* Line number where signalling specified */
+
+static int fiftysixkhdlc[DAHDI_MAX_CHANNELS];
 
 static int spans=0;
 
@@ -646,6 +648,49 @@
 	return 0;
 }
 
+static int setfiftysixkhdlc(char *keyword, char *args)
+{
+	int res;
+
+	res = apply_channels(fiftysixkhdlc, args);
+	if (res <= 0)
+		return -1;
+
+	return 0;
+}
+
+static void apply_fiftysix(void)
+{
+	int x;
+	int rate;
+	int chanfd;
+
+	for (x = 1; x < DAHDI_MAX_CHANNELS; x++) {
+		chanfd = open("/dev/dahdi/channel", O_RDWR);
+		if (chanfd == -1) {
+			fprintf(stderr, "Couldn't open /dev/zap/channel\n");
+			exit(-1);
+		}
+
+		if (ioctl(chanfd, DAHDI_SPECIFY, &x)) {
+			continue;
+		}
+
+		if (fiftysixkhdlc[x]) {
+			printf("Setting channel %d to 56K mode (only valid on HDLC channels)\n", x);
+			rate = 56;
+		} else {
+			rate = 64;
+		}
+
+		if (ioctl(chanfd, DAHDI_HDLC_RATE, &rate)) {
+			fprintf(stderr, "Error setting HDLC rate\n");
+			exit(-1);
+		}
+		close(chanfd);
+	}
+}
+
 static int setechocan(char *keyword, char *args)
 {
 	int res;
@@ -1310,6 +1355,7 @@
 	{ "channel", rad_chanconfig },
 	{ "channels", rad_chanconfig },
 	{ "echocanceller", setechocan },
+	{ "56k", setfiftysixkhdlc },
 };
 
 static char *readline()
@@ -1586,5 +1632,6 @@
 		fprintf(stderr, "\n%d error(s) detected\n\n", errcnt);
 		exit(1);
 	}
+	apply_fiftysix();
 	exit(0);
 }




More information about the svn-commits mailing list