[dahdi-commits] rmeyerriecks: branch linux/rmeyerriecks/dahdi-tools-maintmodes r7433 - /linux...

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Wed Oct 28 16:36:28 CDT 2009


Author: rmeyerriecks
Date: Wed Oct 28 16:36:24 2009
New Revision: 7433

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=7433
Log:
Added maint commandline utility for manipulating maintenance modes


Added:
    linux/team/rmeyerriecks/dahdi-tools-maintmodes/maint.c   (with props)

Added: linux/team/rmeyerriecks/dahdi-tools-maintmodes/maint.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/rmeyerriecks/dahdi-tools-maintmodes/maint.c?view=auto&rev=7433
==============================================================================
--- linux/team/rmeyerriecks/dahdi-tools-maintmodes/maint.c (added)
+++ linux/team/rmeyerriecks/dahdi-tools-maintmodes/maint.c Wed Oct 28 16:36:24 2009
@@ -1,0 +1,148 @@
+#include <stdio.h>
+#include <getopt.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <stdlib.h>
+
+#include <dahdi/user.h>
+
+#define DAHDI_CTL "/dev/dahdi/ctl"
+
+extern char *optarg;
+extern int optind;
+
+main(int argc, char *argv[]) {
+	static int ctl = -1;
+	int res;
+
+	int lflag = 0;
+	char *larg = NULL;
+	int rflag = 0;
+	char *rarg = NULL;
+	int sflag = 0;
+	int span = 0;
+	int dflag = 0;
+	char *darg = NULL;
+	int pflag = 0;
+	int c;
+
+	struct dahdi_maintinfo m;
+	struct dahdi_spaninfo s;
+
+	while((c = getopt(argc, argv, "l:r:s:d:p")) != -1) {
+			switch(c) {
+			case 'l':
+				larg = optarg;
+				lflag = 1;
+				break;
+			case 'r':
+				rarg = optarg;
+				rflag = 1;
+				break;
+			case 's':
+				span = atoi(optarg);
+				sflag = 1;
+				break;
+			case 'd':
+				darg = optarg;
+				dflag = 1;
+				break;
+			case 'p':
+				pflag = 1;
+				break;
+			}
+	}
+
+	ctl = open(DAHDI_CTL, O_RDWR);
+	if(ctl<0) {
+		fprintf(stderr, "Unable to open %s\n", DAHDI_CTL);
+		return -1;
+	}
+
+	if(!sflag) {
+		// Eventually Figure out how many spans are active
+		int i;
+		for(i = 1; i < 3; i++) {
+			s.spanno = i;
+			res = ioctl(ctl, DAHDI_SPANSTAT, &s);	
+			printf("Span %d:\n", i);
+			printf(">FEC : %d:\n", s.fecount);
+			printf(">CEC : %d:\n", s.crc4count);
+			printf(">CVC : %d:\n", s.cvcount);
+			printf(">EBC : %d:\n", s.ebitcount);
+			printf(">BEC : %d:\n", s.becount);
+			printf(">PRBS: %d:\n", s.prbscount);
+		}
+		return 0;
+	}
+
+	m.spanno = span;
+
+	if(lflag) {
+		if(!strcasecmp(larg, "on")) {
+			printf("Turning on local loopback for span: %d\n", span);
+			m.command = DAHDI_MAINT_LOCALLOOP;
+		} else if (!strcasecmp(larg, "off")) {
+			printf("Turning off local loopback for span: %d\n", span);
+			m.command = DAHDI_MAINT_NONE;
+		} else {
+			printf("Usage: maint -l <on|off>\n");
+		}
+
+		res = ioctl(ctl, DAHDI_MAINT, &m);
+	}
+
+	if(rflag) {
+		if(!strcasecmp(rarg, "on")) {
+			printf("Turning remote loopback on\n");
+		} else if (!strcasecmp(rarg, "off")) {
+			printf("Turning remote loopback off\n");
+		} else {
+			printf("Usage: maint -r <on|off>\n");
+		}
+	}
+
+	if(dflag) {
+		if(!strcasecmp(darg, "fas")) {
+			m.command = DAHDI_MAINT_FAS_DEFECT;
+			printf("Inserting a single FAS defect\n");
+		} else if (!strcasecmp(darg, "multi")) {
+			m.command = DAHDI_MAINT_MULTI_DEFECT;
+			printf("Inserting a single multiframe defect\n");
+		} else if (!strcasecmp(darg, "crc")) {
+			m.command = DAHDI_MAINT_CRC_DEFECT;
+			printf("Inserting a single CRC defect\n");
+		} else if (!strcasecmp(darg, "cas")) {
+			m.command = DAHDI_MAINT_CAS_DEFECT;
+			printf("Inserting a single CAS defect\n");
+		} else if (!strcasecmp(darg, "prbs")) {
+			m.command = DAHDI_MAINT_PRBS_DEFECT;
+			printf("Inserting a single PRBS defect\n");
+		} else if (!strcasecmp(darg, "bipolar")) {
+			m.command = DAHDI_MAINT_BIPOLAR_DEFECT;
+			printf("Inserting a single bipolar defect\n");
+		} else {
+			printf("Usage: maint -d <fas|multi|crc|cas|prbs|bipolar>\n");
+		}
+		res = ioctl(ctl, DAHDI_MAINT, &m);
+	}
+
+	if(pflag) {
+		printf("Enabled the Pseudo-Random Binary Sequence Generation and Monitor\n");
+		m.command = DAHDI_MAINT_PRBS;
+		res = ioctl(ctl, DAHDI_MAINT, &m);
+	}
+
+	return 0;
+}
+
+void local_loopback_enable() {
+
+}
+
+void local_loopback_disable() {
+
+}

Propchange: linux/team/rmeyerriecks/dahdi-tools-maintmodes/maint.c
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: linux/team/rmeyerriecks/dahdi-tools-maintmodes/maint.c
------------------------------------------------------------------------------
    svn:keywords = rmeyerriecks 555 1 1

Propchange: linux/team/rmeyerriecks/dahdi-tools-maintmodes/maint.c
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the dahdi-commits mailing list