[Pkg-voip-commits] r5161 - in /zaptel/trunk: ./ debian/ debian/patches/

tzafrir-guest at alioth.debian.org tzafrir-guest at alioth.debian.org
Wed Jan 16 22:16:39 UTC 2008


Author: tzafrir-guest
Date: Wed Jan 16 22:16:39 2008
New Revision: 5161

URL: http://svn.debian.org/wsvn/pkg-voip/?sc=1&rev=5161
Log:
* New upstream release: zaptel 1.4.8.
* bristuff.dpatch broken to smaller patches, as in bristuff 0.4.0-test6.
- ztpty.c is added as a source file.
- bri_dchan.dpatch, proc_read.dpatch, ztcfg-start_stop.dpatch and
  zt_alarm_notify_no_master_change.dpatch .
* Adapted ztcfg-start_stop.dpatch to zaptel 1.4.8 .
* Removing xpp_m_subdirs.dpatch: merged upstream.
* tones.h is no longer generated.

Added:
    zaptel/trunk/debian/patches/bri_dchan.dpatch
    zaptel/trunk/debian/patches/proc_read.dpatch
    zaptel/trunk/debian/patches/zt_alarm_notify_no_master_change.dpatch
    zaptel/trunk/debian/patches/ztcfg-start_stop.dpatch
    zaptel/trunk/ztpty.c
Removed:
    zaptel/trunk/debian/patches/xpp_m_subdirs.dpatch
Modified:
    zaptel/trunk/debian/changelog
    zaptel/trunk/debian/patches/00list
    zaptel/trunk/debian/rules

Modified: zaptel/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-voip/zaptel/trunk/debian/changelog?rev=5161&op=diff
==============================================================================
--- zaptel/trunk/debian/changelog (original)
+++ zaptel/trunk/debian/changelog Wed Jan 16 22:16:39 2008
@@ -1,8 +1,16 @@
-zaptel (1:1.4.7.1~dfsg-2) UNRELEASED; urgency=low
-
+zaptel (1:1.4.8~dfsg-1) UNRELEASED; urgency=low
+
+  * New upstream release
+  * bristuff.dpatch broken to smaller patches, as in bristuff 0.4.0-test6.
+  - ztpty.c is added as a source file.
+  - bri_dchan.dpatch, proc_read.dpatch, ztcfg-start_stop.dpatch and
+    zt_alarm_notify_no_master_change.dpatch .
   * beronet.dpatch: Support for Bero.net cards (Closes: #453496).
-
- -- Tzafrir Cohen <tzafrir.cohen at xorcom.com>  Sun, 30 Dec 2007 11:29:21 +0200
+  * Adapted ztcfg-start_stop.dpatch to zaptel 1.4.8 .
+  * Removing xpp_m_subdirs.dpatch: merged upstream.
+  * tones.h is no longer generated.
+
+ -- Tzafrir Cohen <tzafrir.cohen at xorcom.com>  Wed, 16 Jan 2008 23:57:30 +0200
 
 zaptel (1:1.4.7.1~dfsg-1) unstable; urgency=low
 

Modified: zaptel/trunk/debian/patches/00list
URL: http://svn.debian.org/wsvn/pkg-voip/zaptel/trunk/debian/patches/00list?rev=5161&op=diff
==============================================================================
--- zaptel/trunk/debian/patches/00list (original)
+++ zaptel/trunk/debian/patches/00list Wed Jan 16 22:16:39 2008
@@ -1,6 +1,9 @@
 Makefile_bristuff
 oslec_zaptel
-bristuff
+#bristuff
+bri_dchan
+proc_read
+zt_alarm_notify_no_master_change
+ztcfg-start_stop
 zaphfc-florz
 zaptel_perl
-xpp_m_subdirs

Added: zaptel/trunk/debian/patches/bri_dchan.dpatch
URL: http://svn.debian.org/wsvn/pkg-voip/zaptel/trunk/debian/patches/bri_dchan.dpatch?rev=5161&op=file
==============================================================================
--- zaptel/trunk/debian/patches/bri_dchan.dpatch (added)
+++ zaptel/trunk/debian/patches/bri_dchan.dpatch Wed Jan 16 22:16:39 2008
@@ -1,0 +1,163 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+#
+# Translate the D channels to a standard channel data.
+# The HFC chipset provides us the D channel as data, but
+# Zaptel expects it as a standard channel with 1000 samples
+# per second.
+
+ at DPATCH@
+Index: zaptel-1.2.22/zaptel.h
+===================================================================
+--- zaptel-1.2.22.orig/zaptel.h	2007-12-04 10:40:30.000000000 +0100
++++ zaptel-1.2.22/zaptel.h	2007-12-04 14:35:14.545043151 +0100
+@@ -1056,6 +1056,13 @@
+ 	int do_ppp_error;
+ 	struct sk_buff_head ppp_rq;
+ #endif
++#ifdef CONFIG_ZAPATA_BRI_DCHANS
++	int bytes2receive;
++	int maxbytes2transmit; /* size of the tx buffer in the card driver */
++	int bytes2transmit;
++	int eofrx;
++	int eoftx;
++#endif
+ 	spinlock_t lock;
+ 	char name[40];		/* Name */
+ 	/* Specified by zaptel */
+@@ -1294,6 +1301,10 @@
+ #define ZT_FLAG_T1PPP			(1 << 15)
+ #define ZT_FLAG_SIGFREEZE		(1 << 16)	/* Freeze signalling */
+ 
++#if defined(CONFIG_ZAPATA_BRI_DCHANS)
++#define ZT_FLAG_BRIDCHAN		(1 << 19)
++#endif
++
+ struct zt_span {
+ 	spinlock_t lock;
+ 	void *pvt;			/* Private stuff */
+Index: zaptel-1.2.22/zconfig.h
+===================================================================
+--- zaptel-1.2.22.orig/zconfig.h	2007-12-04 10:40:29.000000000 +0100
++++ zaptel-1.2.22/zconfig.h	2007-12-04 14:35:01.329541263 +0100
+@@ -166,4 +166,10 @@
+  */
+ /* #define FXSFLASH */
+ 
++/*
++ * Uncomment the following for BRI D channels
++ *
++ */
++#define CONFIG_ZAPATA_BRI_DCHANS
++
+ #endif
+Index: zaptel-1.2.22/zaptel-base.c
+===================================================================
+--- zaptel-1.2.22.orig/zaptel-base.c	2007-12-04 10:40:31.000000000 +0100
++++ zaptel-1.2.22/zaptel-base.c	2007-12-04 14:35:14.553042850 +0100
+@@ -5226,11 +5255,40 @@
+ 					*(txb++) = fasthdlc_tx_run_nocheck(&ms->txhdlc);
+ 				}
+ 				bytes -= left;
++#ifdef CONFIG_ZAPATA_BRI_DCHANS
++			} else if (ms->flags & ZT_FLAG_BRIDCHAN) {
++			    /*
++			     * Let's get this right, we want to transmit complete frames only.
++			     * The card driver will do the dirty HDLC work for us.
++			     * txb (transmit buffer) is supposed to be big enough to store one frame
++			     * we will make this as big as the D fifo (1KB or 2KB)
++			     */
++
++			    /* there are 'left' bytes in the user buffer left to transmit */
++			    left = ms->writen[ms->outwritebuf] - ms->writeidx[ms->outwritebuf] - 2;
++			    if (left > ms->maxbytes2transmit) {
++				memcpy(txb, buf + ms->writeidx[ms->outwritebuf], ms->maxbytes2transmit);
++				ms->writeidx[ms->outwritebuf] += ms->maxbytes2transmit;
++				txb += ms->maxbytes2transmit;
++				ms->bytes2transmit = ms->maxbytes2transmit;
++				ms->eoftx = 0;
++			    } else {
++				memcpy(txb, buf + ms->writeidx[ms->outwritebuf], left);
++				ms->writeidx[ms->outwritebuf] += left + 2;
++				txb += left + 2;
++				ms->bytes2transmit = left;
++				ms->eoftx = 1;
++			    }
++			    bytes = 0;
++#endif
+ 			} else {
+ 				memcpy(txb, buf + ms->writeidx[ms->outwritebuf], left);
+ 				ms->writeidx[ms->outwritebuf]+=left;
+ 				txb += left;
+ 				bytes -= left;
++#if defined(CONFIG_ZAPATA_BRI_DCHANS)	
++				ms->bytes2transmit=ZT_CHUNKSIZE;
++#endif
+ 			}
+ 			/* Check buffer status */
+ 			if (ms->writeidx[ms->outwritebuf] >= ms->writen[ms->outwritebuf]) {
+@@ -5275,6 +5333,17 @@
+ 				/* Transmit a flag if this is an HDLC channel */
+ 				if (ms->flags & ZT_FLAG_HDLC)
+ 					fasthdlc_tx_frame_nocheck(&ms->txhdlc);
++#if defined(CONFIG_ZAPATA_BRI_DCHANS)	
++				if(ms->flags & ZT_FLAG_BRIDCHAN) { 
++			//	    if (ms->bytes2transmit > 0) {
++					// txb += 2;
++					// ms->bytes2transmit -= 2;
++					bytes=0;
++					ms->eoftx = 1;
++//					printk(KERN_CRIT "zaptel EOF(%d) bytes2transmit %d\n",ms->eoftx,ms->bytes2transmit);
++			//	    }
++				}
++#endif
+ #ifdef CONFIG_ZAPATA_NET
+ 				if (ms->flags & ZT_FLAG_NETDEV)
+ 					netif_wake_queue(ztchan_to_dev(ms));
+@@ -5335,6 +5404,12 @@
+ 				memset(txb, 0xFF, bytes);
+ 			}
+ 			bytes = 0;
++#if defined(CONFIG_ZAPATA_BRI_DCHANS)	
++		} else if(ms->flags & ZT_FLAG_BRIDCHAN) { 
++		    ms->bytes2transmit = 0;
++		    ms->eoftx = 0;
++		    bytes = 0;
++#endif
+ 		} else {
+ 			memset(txb, ZT_LIN2X(0, ms), bytes);	/* Lastly we use silence on telephony channels */
+ 			bytes = 0;
+@@ -6153,6 +6228,14 @@
+ 	int res;
+ 	int left, x;
+ 
++#if defined(CONFIG_ZAPATA_BRI_DCHANS)	
++	if (ms->flags & ZT_FLAG_BRIDCHAN) {
++	    bytes = ms->bytes2receive;
++	    if (bytes < 1) return;
++//	    printk(KERN_CRIT "bytes2receive %d\n",ms->bytes2receive);
++	}
++#endif
++
+ 	while(bytes) {
+ #if defined(CONFIG_ZAPATA_NET)  || defined(CONFIG_ZAPATA_PPP)
+ 		skb = NULL;
+@@ -6210,6 +6293,19 @@
+ 						}
+ 					}
+ 				}
++#ifdef CONFIG_ZAPATA_BRI_DCHANS
++			} else if (ms->flags & ZT_FLAG_BRIDCHAN) {
++			    memcpy(buf + ms->readidx[ms->inreadbuf], rxb, left);
++			    rxb += left;
++			    ms->readidx[ms->inreadbuf] += left;
++			    bytes -= left;
++			    if (ms->eofrx == 1) {
++				eof=1;
++			    }
++//			    printk(KERN_CRIT "receiving %d bytes\n",ms->bytes2receive);
++			    ms->bytes2receive = 0;
++			    ms->eofrx = 0;
++#endif
+ 			} else {
+ 				/* Not HDLC */
+ 				memcpy(buf + ms->readidx[ms->inreadbuf], rxb, left);

Added: zaptel/trunk/debian/patches/proc_read.dpatch
URL: http://svn.debian.org/wsvn/pkg-voip/zaptel/trunk/debian/patches/proc_read.dpatch?rev=5161&op=file
==============================================================================
--- zaptel/trunk/debian/patches/proc_read.dpatch (added)
+++ zaptel/trunk/debian/patches/proc_read.dpatch Wed Jan 16 22:16:39 2008
@@ -1,0 +1,43 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+#
+# Adds an extra Zaptel span method: proc_read. 
+# This allows a span to add some arbitrary text at the end 
+# of the /proc/zaptel/NNN file.
+#
+# This is currently only used by cwain.
+#
+# My personal opinion is that such methods are not recommended.
+# sysfs support should be used instead (Tzafrir). It is likely to break 
+# zapconf and genzaptelconf for drivers using it.
+
+ at DPATCH@
+Index: zaptel-1.2.22/zaptel.h
+===================================================================
+--- zaptel-1.2.22.orig/zaptel.h	2007-12-04 10:40:30.000000000 +0100
++++ zaptel-1.2.22/zaptel.h	2007-12-04 14:35:14.545043151 +0100
+@@ -1394,6 +1405,10 @@
+ 	int watchcounter;
+ 	int watchstate;
+ #endif	
++#ifdef CONFIG_PROC_FS
++	/* Allow subordinate drivers to print out their own stuff */
++	int (*proc_read)(struct zt_span *span, char *start);
++#endif
+ };
+ 
+ struct zt_transcoder_channel {
+Index: zaptel-1.2.22/zaptel-base.c
+===================================================================
+--- zaptel-1.2.22.orig/zaptel-base.c	2007-12-04 10:40:31.000000000 +0100
++++ zaptel-1.2.22/zaptel-base.c	2007-12-04 14:35:14.553042850 +0100
+@@ -584,6 +585,10 @@
+ 		len += sprintf(page + len, "\tIRQ misses: %d\n", spans[span]->irqmisses);
+ 	len += sprintf(page + len, "\n");
+ 
++	if (spans[span]->proc_read) {
++		len += spans[span]->proc_read(spans[span], page + len);
++	}
++
+ 
+         for (x=1;x<ZT_MAX_CHANNELS;x++) {	
+ 		if (chans[x]) {

Added: zaptel/trunk/debian/patches/zt_alarm_notify_no_master_change.dpatch
URL: http://svn.debian.org/wsvn/pkg-voip/zaptel/trunk/debian/patches/zt_alarm_notify_no_master_change.dpatch?rev=5161&op=file
==============================================================================
--- zaptel/trunk/debian/patches/zt_alarm_notify_no_master_change.dpatch (added)
+++ zaptel/trunk/debian/patches/zt_alarm_notify_no_master_change.dpatch Wed Jan 16 22:16:39 2008
@@ -1,0 +1,65 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+#
+# This patch adds an extra function to Zaptel to set a span ini alarm
+# yet still not look for a new Zaptel sync master.
+# 
+# Currently only used by qozap.
+
+ at DPATCH@
+Index: zaptel-1.2.22/zaptel.h
+===================================================================
+--- zaptel-1.2.22.orig/zaptel.h	2007-12-04 10:40:30.000000000 +0100
++++ zaptel-1.2.22/zaptel.h	2007-12-04 14:35:14.545043151 +0100
+@@ -1508,6 +1523,9 @@
+ /* Notify a change possible change in alarm status */
+ void zt_alarm_notify(struct zt_span *span);
+ 
++/* Notify a change possible change in alarm status, DONT change the zaptel master! */
++extern void zt_alarm_notify_no_master_change(struct zt_span *span);
++
+ /* Initialize a tone state */
+ void zt_init_tone_state(struct zt_tone_state *ts, struct zt_tone *zt);
+ 
+Index: zaptel-1.2.22/zaptel-base.c
+===================================================================
+--- zaptel-1.2.22.orig/zaptel-base.c	2007-12-04 10:40:31.000000000 +0100
++++ zaptel-1.2.22/zaptel-base.c	2007-12-04 14:35:14.553042850 +0100
+@@ -138,6 +138,7 @@
+ EXPORT_SYMBOL(zt_qevent_lock);
+ EXPORT_SYMBOL(zt_hooksig);
+ EXPORT_SYMBOL(zt_alarm_notify);
++EXPORT_SYMBOL(zt_alarm_notify_no_master_change);
+ EXPORT_SYMBOL(zt_set_dynamic_ioctl);
+ EXPORT_SYMBOL(zt_ec_chunk);
+ EXPORT_SYMBOL(zt_ec_span);
+@@ -2783,6 +2788,30 @@
+ 	}
+ }
+ 
++void zt_alarm_notify_no_master_change(struct zt_span *span)
++{
++	int j;
++	int x;
++
++	span->alarms &= ~ZT_ALARM_LOOPBACK;
++	/* Determine maint status */
++	if (span->maintstat || span->mainttimer)
++		span->alarms |= ZT_ALARM_LOOPBACK;
++	/* DON'T CHANGE THIS AGAIN. THIS WAS DONE FOR A REASON.
++ 	   The expression (a != b) does *NOT* do the same thing
++	   as ((!a) != (!b)) */
++	/* if change in general state */
++	if ((!span->alarms) != (!span->lastalarms)) {
++		if (span->alarms)
++			j = ZT_EVENT_ALARM;
++		else
++			j = ZT_EVENT_NOALARM;
++		span->lastalarms = span->alarms;
++		for (x=0;x < span->channels;x++)
++			zt_qevent_lock(&span->chans[x], j);
++	}
++}
++
+ #define VALID_SPAN(j) do { \
+ 	if ((j >= ZT_MAX_SPANS) || (j < 1)) \
+ 		return -EINVAL; \

Added: zaptel/trunk/debian/patches/ztcfg-start_stop.dpatch
URL: http://svn.debian.org/wsvn/pkg-voip/zaptel/trunk/debian/patches/ztcfg-start_stop.dpatch?rev=5161&op=file
==============================================================================
--- zaptel/trunk/debian/patches/ztcfg-start_stop.dpatch (added)
+++ zaptel/trunk/debian/patches/ztcfg-start_stop.dpatch Wed Jan 16 22:16:39 2008
@@ -1,0 +1,163 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+#
+## DP: ztcfg: Add options to activate a specific span (or all of them) or 
+## DP: shut down just a specific span (not just all of them).
+
+ at DPATCH@
+diff -urN zaptel-1.4.4.orig/ztcfg.c zaptel-1.4.4/ztcfg.c
+--- zaptel-1.4.4.orig/ztcfg.c	2007-02-07 17:51:27.000000000 +0100
++++ zaptel-1.4.4/ztcfg.c	2007-07-18 14:33:17.884803750 +0200
+@@ -96,6 +96,10 @@
+ 
+ static int stopmode = 0;
+ 
++static int stopwhich = -1;
++
++static int startwhich = -1;
++
+ static int numdynamic = 0;
+ 
+ static char zonestoload[ZT_TONE_ZONE_MAX][10];
+@@ -1261,7 +1265,8 @@
+ 		"  -d [level]        -- Generate debugging output. (Default level is 1.)\n"
+ 		"  -f                -- Always reconfigure every channel\n"
+ 		"  -h                -- Generate this help statement\n"
+-		"  -s                -- Shutdown spans only\n"
++		"  -s[span]          -- Deactivate/shutdown span [span]. Deactivates all spans if no [span] is given.\n"
++		"  -a[span]          -- Activate/start span [span]. Activates all spans if no [span] is given.\n"
+ 		"  -t                -- Test mode only, do not apply\n"
+ 		"  -v                -- Verbose (more -v's means more verbose)\n"
+ 	,c);
+@@ -1274,7 +1279,7 @@
+ 	char *buf;
+ 	char *key, *value;
+ 	int x,found;
+-	while((c = getopt(argc, argv, "fthc:vsd::")) != -1) {
++	while((c = getopt(argc, argv, "fthc:vs::a::d::")) != -1) {
+ 		switch(c) {
+ 		case 'c':
+ 			filename=optarg;
+@@ -1295,8 +1300,20 @@
+ 			fo_real = 0;
+ 			break;
+ 		case 's':
++			if (optarg) {
++			    stopwhich = atoi(optarg);
++			} else {
++			    stopwhich = -1;
++			}
+ 			stopmode = 1;
+ 			break;
++		case 'a':
++			if (optarg) {
++			    startwhich = atoi(optarg);
++			} else {
++			    startwhich = -1;
++			}
++			break;
+ 		case 'd':
+ 			if (optarg)
+ 				debug = atoi(optarg);
+@@ -1358,29 +1375,42 @@
+ 				ioctl(fd, ZT_DYNAMIC_DESTROY, &zds[x]);
+ 			}
+ 			if (stopmode) {
+-				for (x=0;x<spans;x++) {
++				if (stopwhich > 0){
++				    if ((stopwhich > spans) || (ioctl(fd, ZT_SHUTDOWN, &lc[stopwhich - 1].span))) {
++					fprintf(stderr, "Zaptel shutdown failed: %s\n", strerror(errno));
++					close(fd);
++					exit(1);						
++				    } else {
++					if (verbose) {
++					    printf("Deactivated span %d\n", stopwhich);
++					}
++				    }					    
++				} else {
++				    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 (startwhich == -1) {
++				    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++) {
++				    }
++				    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++) {
++				    }
++				    for (x=1;x<ZT_MAX_CHANNELS;x++) {
+ 					struct zt_params current_state;
+ 					int master;
+ 					int needupdate = force;
+@@ -1454,33 +1484,46 @@
+ 						close(fd);
+ 						exit(1);
+ 					}
+-				}
+-				for (x=0;x<numzones;x++) {
++				    }
++				    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]))
+ 						if (errno != EBUSY)
+ 							error("Unable to register tone zone '%s'\n", zonestoload[x]);
+-				}
+-				if (debug & DEBUG_APPLY) {
++				    }
++				    if (debug & DEBUG_APPLY) {
+ 					printf("Doing startup\n");
+ 					fflush(stdout);
+-				}
+-				if (deftonezone > -1) {
++				    }
++				    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 (startwhich > 0) {
++					if ((startwhich > spans) || (ioctl(fd, ZT_STARTUP, &lc[startwhich - 1].span))) {
++					    fprintf(stderr, "Zaptel startup failed: %s\n", strerror(errno));
++					    close(fd);
++					    exit(1);
++					} else {
++					    if (verbose) {
++					        printf("Activated span %d\n", startwhich);
++					    }
++					}
++				} else {
++				    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);
+ 					}
++				    }
+ 				}
+ 			}
+ 		}

Modified: zaptel/trunk/debian/rules
URL: http://svn.debian.org/wsvn/pkg-voip/zaptel/trunk/debian/rules?rev=5161&op=diff
==============================================================================
--- zaptel/trunk/debian/rules (original)
+++ zaptel/trunk/debian/rules Wed Jan 16 22:16:39 2008
@@ -39,7 +39,7 @@
 # between kernel and userspace. As things stand now I'd like to work
 # around problems with bilding stuff with HOSTCC by simply providing 
 # the generated headers as part of the source:
-GENERATED_SOURCES := version.h radfw.h tor2fw.h tones.h 
+GENERATED_SOURCES := version.h radfw.h tor2fw.h
 
 EXTRA_MODS=ds1x1f opvxa1200
 

Added: zaptel/trunk/ztpty.c
URL: http://svn.debian.org/wsvn/pkg-voip/zaptel/trunk/ztpty.c?rev=5161&op=file
==============================================================================
--- zaptel/trunk/ztpty.c (added)
+++ zaptel/trunk/ztpty.c Wed Jan 16 22:16:39 2008
@@ -1,0 +1,112 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/time.h>
+#include <sys/signal.h>
+#include <sys/select.h>
+#include <math.h>
+#include "zaptel.h"
+
+#define SIZE 8000
+
+
+
+void doit(int fd, int stdinfd) {
+    fd_set fds;
+    char inbuffer[4096];
+    char outbuffer[4096];
+    int res = 0;
+    int i = 0;
+
+//    fprintf(stderr, "fd %d stdin fd %d\n", fd, stdinfd);
+
+    for (;;) {
+	FD_ZERO(&fds);
+        FD_SET(fd, &fds);
+	FD_SET(stdinfd, &fds);
+        /* Wait for *some* sort of I/O */
+        res = select(stdinfd + 1, &fds, NULL, NULL, NULL);
+        if (res < 0) {
+                fprintf(stderr, "Error in select: %s\n", strerror(errno));
+                return;
+        }
+        if (FD_ISSET(stdinfd, &fds)) {
+            res = read(stdinfd, inbuffer, sizeof(inbuffer));
+	    if (res > 0) {
+//		fprintf(stderr, "read %d bytes from stdin\n", res);
+		if (res > 0) {
+		    for (i=0; i < res ; i++) {
+			if (inbuffer[i] == '\n') {
+			    if ((i > 0) && (inbuffer[i-1] == ' ')) {
+				inbuffer[i-1] = 0x1a;
+			    }
+			    inbuffer[i] = 0xd;
+			}
+		    }
+		res = write(fd, inbuffer, res+2);
+//		res = write(STDOUT_FILENO, inbuffer, res);
+//		fprintf(stderr, "wrote %d bytes to stdout\n", res);
+		}
+	    }
+        }
+        if (FD_ISSET(fd, &fds)) {
+            res = read(fd, outbuffer, sizeof(outbuffer));
+//	    fprintf(stderr, "read %d bytes from fd\n", res);
+	    if (res > 0) {
+		res = write(STDOUT_FILENO, outbuffer, res);
+//		fprintf(stderr, "wrote %d bytes to stdout\n", res);
+	    }
+        }
+    }
+
+
+}
+
+int main(int argc, char *argv[])
+{
+	int fd;
+	int stdinfd;
+	struct zt_params p;
+	struct zt_bufferinfo bi;
+	int blocksize=0;
+	fd = open(argv[1], O_RDWR | O_NONBLOCK);
+	if (fd < 0) {
+		fprintf(stderr, "Unable to open zap interface: %s\n", strerror(errno));
+		exit(1);
+	}
+	if (ioctl(fd, ZT_GET_PARAMS, &p)) {
+		fprintf(stderr, "Unable to get parameters on '%s': %s\n", argv[1], strerror(errno));
+		exit(1);
+	}
+	if ((p.sigtype != ZT_SIG_HDLCRAW) && (p.sigtype != ZT_SIG_HDLCFCS)) {
+		fprintf(stderr, "%s is in %d signalling, not FCS HDLC or RAW HDLC mode\n", argv[1], p.sigtype);
+		exit(1);
+	}
+
+	if (ioctl(fd, ZT_GET_BLOCKSIZE, &blocksize)) {
+		fprintf(stderr, "Unable to get blocksize on '%s': %s\n", argv[1], strerror(errno));
+		exit(1);
+	} else {
+//		fprintf(stderr, "blocksize %d\n", blocksize);
+	}
+
+	bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
+        bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
+	bi.numbufs = 16;
+	bi.bufsize = 1024;
+	if (ioctl(fd, ZT_SET_BUFINFO, &bi)) {
+		fprintf(stderr, "Unable to set buffer info on '%s': %s\n", argv[1], strerror(errno));
+		exit(1);
+	}
+
+	stdinfd = open("/dev/stdin", O_RDONLY | O_NONBLOCK);
+
+
+	doit(fd, stdinfd);
+	close(stdinfd);
+	close(fd);
+	return 0;
+}




More information about the Pkg-voip-commits mailing list