[zaptel-commits] trunk - r872 in /trunk: zaptel.c zaptel.h ztcfg.c

zaptel-commits at lists.digium.com zaptel-commits at lists.digium.com
Fri Dec 16 20:52:19 CST 2005


Author: kpfleming
Date: Fri Dec 16 20:52:18 2005
New Revision: 872

URL: http://svn.digium.com/view/zaptel?rev=872&view=rev
Log:
allow userspace apps to extract version/echo canceller info
add version/echo canceller info to ztcfg verbose output

Modified:
    trunk/zaptel.c
    trunk/zaptel.h
    trunk/ztcfg.c

Modified: trunk/zaptel.c
URL: http://svn.digium.com/view/zaptel/trunk/zaptel.c?rev=872&r1=871&r2=872&view=diff
==============================================================================
--- trunk/zaptel.c (original)
+++ trunk/zaptel.c Fri Dec 16 20:52:18 2005
@@ -3108,6 +3108,7 @@
 	struct zt_dialparams tdp;
 	struct zt_maintinfo maint;
 	struct zt_indirect_data ind;
+	struct zt_versioninfo vi;
 	unsigned long flags;
 	int rv;
 	switch(cmd) {
@@ -3407,6 +3408,13 @@
 		tdp.reserved[2] = 0;
 		tdp.reserved[3] = 0;
 		if (copy_to_user((struct zt_dialparams *)data, &tdp, sizeof(tdp)))
+			return -EFAULT;
+		break;
+	case ZT_GETVERSION:
+		memset(&vi, 0, sizeof(vi));
+		strncpy(vi.version, ZAPTEL_VERSION, sizeof(vi.version) - 1);
+		strncpy(vi.echo_canceller, ZAPTEL_ECHO_CANCELLER, sizeof(vi.echo_canceller) - 1);
+		if (copy_to_user((struct zt_versioninfo *) data, &vi, sizeof(vi)))
 			return -EFAULT;
 		break;
 	case ZT_MAINT:  /* do maintence stuff */

Modified: trunk/zaptel.h
URL: http://svn.digium.com/view/zaptel/trunk/zaptel.h?rev=872&r1=871&r2=872&view=diff
==============================================================================
--- trunk/zaptel.h (original)
+++ trunk/zaptel.h Fri Dec 16 20:52:18 2005
@@ -304,6 +304,11 @@
 void	*data;
 } ZT_INDIRECT_DATA;	
 
+struct zt_versioninfo {
+	char version[80];
+	char echo_canceller[80];
+};
+
 
 /* ioctl definitions */
 #define ZT_CODE	'J'
@@ -595,6 +600,12 @@
  */
 #define ZT_INDIRECT _IOWR (ZT_CODE, 56, struct zt_indirect_data)
 
+
+/*
+ * Get the version of Zaptel that is running, and a description
+ * of the compiled-in echo canceller (if any)
+ */
+#define ZT_GETVERSION _IOR(ZT_CODE, 57, struct zt_versioninfo)
 
 /*
  *  60-80 are reserved for private drivers

Modified: trunk/ztcfg.c
URL: http://svn.digium.com/view/zaptel/trunk/ztcfg.c?rev=872&r1=871&r2=872&view=diff
==============================================================================
--- trunk/ztcfg.c (original)
+++ trunk/ztcfg.c Fri Dec 16 20:52:18 2005
@@ -1019,13 +1019,20 @@
 
 /* End Radio functions */
 
-static void printconfig()
+static void printconfig(int fd)
 {
 	int x,y;
 	int ps;
 	int configs=0;
-	printf("\nZaptel Configuration\n"
-	       "======================\n\n");
+	struct zt_versioninfo vi;
+
+	if (ioctl(fd, ZT_GETVERSION, &vi))
+		error("Unable to read Zaptel version information.\n");
+
+	printf("\nZaptel Version: %s\n"
+	       "Echo Canceller: %s\n"
+	       "Configuration\n"
+	       "======================\n\n", vi.version, vi.echo_canceller);
 	for (x=0;x<spans;x++) 
 		printf("SPAN %d: %3s/%4s Build-out: %s\n",
 		       x+1, ( lc[x].lineconfig & ZT_CONFIG_D4 ? "D4" :
@@ -1226,134 +1233,129 @@
 
 	if (!errcnt) {
 		if (verbose) {
-			printconfig();
+			printconfig(fd);
 		}
 		if (fo_real) {
 			if (debug & DEBUG_APPLY) {
 				printf("About to open Master device\n");
 				fflush(stdout);
 			}
-			if (fd == -1) fd = open(MASTER_DEVICE, O_RDWR);
-			if (fd < 0) 
-				error("Unable to open master device '%s'\n", MASTER_DEVICE);
-			else {
+			for (x=0;x<numdynamic;x++) {
+				/* destroy them all */
+				ioctl(fd, ZT_DYNAMIC_DESTROY, &zds[x]);
+			}
+			if (stopmode) {
+				for (x=0;x<spans;x++) {
+					if (ioctl(fd, ZT_SHUTDOWN, &lc[x].span)) {
+						fprintf(stderr, "Zaptel shutdown failed: %s\n", strerror(errno));
+						close(fd);
+						exit(1);
+					}
+				}
+			} else {
+				for (x=0;x<spans;x++) {
+					if (ioctl(fd, ZT_SPANCONFIG, lc + x)) {
+						fprintf(stderr, "ZT_SPANCONFIG failed on span %d: %s (%d)\n", lc[x].span, strerror(errno), errno);
+						close(fd);
+						exit(1);
+					}
+				}
 				for (x=0;x<numdynamic;x++) {
-					/* destroy them all */
-					ioctl(fd, ZT_DYNAMIC_DESTROY, &zds[x]);
-				}
-				if (stopmode) {
-					for (x=0;x<spans;x++) {
-						if (ioctl(fd, ZT_SHUTDOWN, &lc[x].span)) {
-							fprintf(stderr, "Zaptel shutdown failed: %s\n", strerror(errno));
-							close(fd);
-							exit(1);
+					if (ioctl(fd, ZT_DYNAMIC_CREATE, &zds[x])) {
+						fprintf(stderr, "Zaptel dynamic span creation failed: %s\n", strerror(errno));
+						close(fd);
+						exit(1);
+					}
+				}
+				for (x=1;x<ZT_MAX_CHANNELS;x++) {
+					struct zt_params current_state;
+					int master;
+					int needupdate = force;
+					
+					if (debug & DEBUG_APPLY) {
+						printf("Configuring device %d\n", x);
+						fflush(stdout);
+					}
+					if (!cc[x].sigtype)
+						continue;
+					
+					if (!needupdate) {
+						memset(&current_state, 0, sizeof(current_state));
+						current_state.channo = cc[x].chan | ZT_GET_PARAMS_RETURN_MASTER;
+						if (ioctl(fd, ZT_GET_PARAMS, &current_state))
+							needupdate = 1;
+					}
+					
+					if (!needupdate) {
+						master = current_state.channo >> 16;
+						
+						if (cc[x].sigtype != current_state.sigtype) {
+							needupdate++;
+							if (verbose > 1)
+								printf("Changing signalling on channel %d from %s to %s\n",
+								       cc[x].chan, sigtype_to_str(current_state.sigtype),
+								       sigtype_to_str(cc[x].sigtype));
+						}
+						
+						if ((cc[x].deflaw != ZT_LAW_DEFAULT) && (cc[x].deflaw != current_state.curlaw)) {
+							needupdate++;
+							if (verbose > 1)
+								printf("Changing law on channel %d from %s to %s\n",
+								       cc[x].chan, laws[current_state.curlaw],
+								       laws[cc[x].deflaw]);
+						}
+						
+						if (cc[x].master != master) {
+							needupdate++;
+							if (verbose > 1)
+								printf("Changing master of channel %d from %d to %d\n",
+								       cc[x].chan, master,
+								       cc[x].master);
+						}
+						
+						if (cc[x].idlebits != current_state.idlebits) {
+							needupdate++;
+							if (verbose > 1)
+								printf("Changing idle bits of channel %d from %d to %d\n",
+								       cc[x].chan, current_state.idlebits,
+								       cc[x].idlebits);
 						}
 					}
-				} else {
-					for (x=0;x<spans;x++) {
-						if (ioctl(fd, ZT_SPANCONFIG, lc + x)) {
-							fprintf(stderr, "ZT_SPANCONFIG failed on span %d: %s (%d)\n", lc[x].span, strerror(errno), errno);
-							close(fd);
-							exit(1);
+					
+					if (needupdate && ioctl(fd, ZT_CHANCONFIG, &cc[x])) {
+						fprintf(stderr, "ZT_CHANCONFIG failed on channel %d: %s (%d)\n", x, strerror(errno), errno);
+						if (errno == EINVAL) {
+							fprintf(stderr, "Did you forget that FXS interfaces are configured with FXO signalling\n"
+								"and that FXO interfaces use FXS signalling?\n");
 						}
+						close(fd);
+						exit(1);
 					}
-					for (x=0;x<numdynamic;x++) {
-						if (ioctl(fd, ZT_DYNAMIC_CREATE, &zds[x])) {
-							fprintf(stderr, "Zaptel dynamic span creation failed: %s\n", strerror(errno));
-							close(fd);
-							exit(1);
-						}
-					}
-					for (x=1;x<ZT_MAX_CHANNELS;x++) {
-						struct zt_params current_state;
-						int master;
-						int needupdate = force;
-
-						if (debug & DEBUG_APPLY) {
-							printf("Configuring device %d\n", x);
-							fflush(stdout);
-						}
-						if (!cc[x].sigtype)
-							continue;
-
-						if (!needupdate) {
-							memset(&current_state, 0, sizeof(current_state));
-							current_state.channo = cc[x].chan | ZT_GET_PARAMS_RETURN_MASTER;
-							if (ioctl(fd, ZT_GET_PARAMS, &current_state))
-								needupdate = 1;
-						}
-
-						if (!needupdate) {
-							master = current_state.channo >> 16;
-							
-							if (cc[x].sigtype != current_state.sigtype) {
-								needupdate++;
-								if (verbose > 1)
-									printf("Changing signalling on channel %d from %s to %s\n",
-									       cc[x].chan, sigtype_to_str(current_state.sigtype),
-									       sigtype_to_str(cc[x].sigtype));
-							}
-							
-							if ((cc[x].deflaw != ZT_LAW_DEFAULT) && (cc[x].deflaw != current_state.curlaw)) {
-								needupdate++;
-								if (verbose > 1)
-									printf("Changing law on channel %d from %s to %s\n",
-									       cc[x].chan, laws[current_state.curlaw],
-									       laws[cc[x].deflaw]);
-							}
-							
-							if (cc[x].master != master) {
-								needupdate++;
-								if (verbose > 1)
-									printf("Changing master of channel %d from %d to %d\n",
-									       cc[x].chan, master,
-									       cc[x].master);
-							}
-							
-							if (cc[x].idlebits != current_state.idlebits) {
-								needupdate++;
-								if (verbose > 1)
-									printf("Changing idle bits of channel %d from %d to %d\n",
-									       cc[x].chan, current_state.idlebits,
-									       cc[x].idlebits);
-							}
-						}
-
-						if (needupdate && ioctl(fd, ZT_CHANCONFIG, &cc[x])) {
-							fprintf(stderr, "ZT_CHANCONFIG failed on channel %d: %s (%d)\n", x, strerror(errno), errno);
-							if (errno == EINVAL) {
-								fprintf(stderr, "Did you forget that FXS interfaces are configured with FXO signalling\n"
-									"and that FXO interfaces use FXS signalling?\n");
-							}
-							close(fd);
-							exit(1);
-						}
-					}
-					for (x=0;x<numzones;x++) {
-						if (debug & DEBUG_APPLY) {
-							printf("Loading tone zone for %s\n", zonestoload[x]);
-							fflush(stdout);
-						}
-						if (tone_zone_register(fd, zonestoload[x]))
-							error("Unable to register tone zone '%s'\n", zonestoload[x]);
-					}
+				}
+				for (x=0;x<numzones;x++) {
 					if (debug & DEBUG_APPLY) {
-						printf("Doing startup\n");
+						printf("Loading tone zone for %s\n", zonestoload[x]);
 						fflush(stdout);
 					}
-					if (deftonezone > -1) {
-						if (ioctl(fd, ZT_DEFAULTZONE, &deftonezone)) {
-							fprintf(stderr, "ZT_DEFAULTZONE failed: %s (%d)\n", strerror(errno), errno);
-							close(fd);
-							exit(1);
-						}
+					if (tone_zone_register(fd, zonestoload[x]))
+						error("Unable to register tone zone '%s'\n", zonestoload[x]);
+				}
+				if (debug & DEBUG_APPLY) {
+					printf("Doing startup\n");
+					fflush(stdout);
+				}
+				if (deftonezone > -1) {
+					if (ioctl(fd, ZT_DEFAULTZONE, &deftonezone)) {
+						fprintf(stderr, "ZT_DEFAULTZONE failed: %s (%d)\n", strerror(errno), errno);
+						close(fd);
+						exit(1);
 					}
-					for (x=0;x<spans;x++) {
-						if (ioctl(fd, ZT_STARTUP, &lc[x].span)) {
-							fprintf(stderr, "Zaptel startup failed: %s\n", strerror(errno));
-							close(fd);
-							exit(1);
-						}
+				}
+				for (x=0;x<spans;x++) {
+					if (ioctl(fd, ZT_STARTUP, &lc[x].span)) {
+						fprintf(stderr, "Zaptel startup failed: %s\n", strerror(errno));
+						close(fd);
+						exit(1);
 					}
 				}
 			}



More information about the zaptel-commits mailing list