1 diff -urN zaptel-1.2.6.orig/Makefile zaptel-1.2.6/Makefile
2 --- zaptel-1.2.6.orig/Makefile 2006-05-23 01:11:36.000000000 +0200
3 +++ zaptel-1.2.6/Makefile 2006-06-06 14:54:33.000000000 +0200
5 ifneq (,$(wildcard /usr/include/newt.h))
8 -BINS=ztcfg torisatool makefw ztmonitor ztspeed $(ZTTOOL) zttest fxotune
9 +BINS=ztcfg torisatool makefw ztmonitor ztspeed $(ZTTOOL) zttest fxotune ztpty
11 all: $(BUILDVER) $(LIBTONEZONE_SO)
15 ztmonitor.o: ztmonitor.c zaptel.h
30 sethdlc-new: sethdlc-new.o
33 diff -urN zaptel-1.2.6.orig/zaptel.c zaptel-1.2.6/zaptel.c
34 --- zaptel-1.2.6.orig/zaptel.c 2005-12-17 03:04:05.000000000 +0100
35 +++ zaptel-1.2.6/zaptel.c 2006-06-06 14:54:33.000000000 +0200
36 @@ -4913,11 +4913,40 @@
37 *(txb++) = fasthdlc_tx_run_nocheck(&ms->txhdlc);
40 +#ifdef CONFIG_ZAPATA_BRI_DCHANS
41 + } else if (ms->flags & ZT_FLAG_BRIDCHAN) {
43 + * Let's get this right, we want to transmit complete frames only.
44 + * The card driver will do the dirty HDLC work for us.
45 + * txb (transmit buffer) is supposed to be big enough to store one frame
46 + * we will make this as big as the D fifo (1KB or 2KB)
49 + /* there are 'left' bytes in the user buffer left to transmit */
50 + left = ms->writen[ms->outwritebuf] - ms->writeidx[ms->outwritebuf] - 2;
51 + if (left > ms->maxbytes2transmit) {
52 + memcpy(txb, buf + ms->writeidx[ms->outwritebuf], ms->maxbytes2transmit);
53 + ms->writeidx[ms->outwritebuf] += ms->maxbytes2transmit;
54 + txb += ms->maxbytes2transmit;
55 + ms->bytes2transmit = ms->maxbytes2transmit;
58 + memcpy(txb, buf + ms->writeidx[ms->outwritebuf], left);
59 + ms->writeidx[ms->outwritebuf] += left + 2;
61 + ms->bytes2transmit = left;
67 memcpy(txb, buf + ms->writeidx[ms->outwritebuf], left);
68 ms->writeidx[ms->outwritebuf]+=left;
71 +#if defined(CONFIG_ZAPATA_BRI_DCHANS)
72 + ms->bytes2transmit=ZT_CHUNKSIZE;
75 /* Check buffer status */
76 if (ms->writeidx[ms->outwritebuf] >= ms->writen[ms->outwritebuf]) {
77 @@ -4962,6 +4991,17 @@
78 /* Transmit a flag if this is an HDLC channel */
79 if (ms->flags & ZT_FLAG_HDLC)
80 fasthdlc_tx_frame_nocheck(&ms->txhdlc);
81 +#if defined(CONFIG_ZAPATA_BRI_DCHANS)
82 + if(ms->flags & ZT_FLAG_BRIDCHAN) {
83 + // if (ms->bytes2transmit > 0) {
85 + // ms->bytes2transmit -= 2;
88 +// printk(KERN_CRIT "zaptel EOF(%d) bytes2transmit %d\n",ms->eoftx,ms->bytes2transmit);
92 #ifdef CONFIG_ZAPATA_NET
93 if (ms->flags & ZT_FLAG_NETDEV)
94 netif_wake_queue(ztchan_to_dev(ms));
96 tasklet_schedule(&ms->ppp_calls);
101 } else if (ms->curtone && !(ms->flags & ZT_FLAG_PSEUDO)) {
102 left = ms->curtone->tonesamples - ms->tonep;
104 @@ -5018,6 +5058,10 @@
105 memset(txb, 0xFF, bytes);
108 +#if defined(CONFIG_ZAPATA_BRI_DCHANS)
109 + } else if(ms->flags & ZT_FLAG_BRIDCHAN) {
113 memset(txb, ZT_LIN2X(0, ms), bytes); /* Lastly we use silence on telephony channels */
115 @@ -5743,6 +5787,13 @@
118 int bytes = ZT_CHUNKSIZE;
119 +#if defined(CONFIG_ZAPATA_BRI_DCHANS)
120 + if (ms->flags & ZT_FLAG_BRIDCHAN) {
121 + bytes = ms->bytes2receive;
122 + if (bytes < 1) return;
123 +// printk(KERN_CRIT "bytes2receive %d\n",ms->bytes2receive);
128 #if defined(CONFIG_ZAPATA_NET) || defined(CONFIG_ZAPATA_PPP)
129 @@ -5801,6 +5852,19 @@
133 +#ifdef CONFIG_ZAPATA_BRI_DCHANS
134 + } else if (ms->flags & ZT_FLAG_BRIDCHAN) {
135 + memcpy(buf + ms->readidx[ms->inreadbuf], rxb, left);
137 + ms->readidx[ms->inreadbuf] += left;
139 + if (ms->eofrx == 1) {
142 +// printk(KERN_CRIT "receiving %d bytes\n",ms->bytes2receive);
143 + ms->bytes2receive = 0;
148 memcpy(buf + ms->readidx[ms->inreadbuf], rxb, left);
149 diff -urN zaptel-1.2.6.orig/zaptel.h zaptel-1.2.6/zaptel.h
150 --- zaptel-1.2.6.orig/zaptel.h 2005-12-17 03:04:05.000000000 +0100
151 +++ zaptel-1.2.6/zaptel.h 2006-06-06 14:54:33.000000000 +0200
154 struct sk_buff_head ppp_rq;
156 +#ifdef CONFIG_ZAPATA_BRI_DCHANS
158 + int maxbytes2transmit; /* size of the tx buffer in the card driver */
159 + int bytes2transmit;
164 char name[40]; /* Name */
165 /* Specified by zaptel */
166 @@ -1068,7 +1075,7 @@
167 int txbufpolicy; /* Buffer policy */
168 int rxbufpolicy; /* Buffer policy */
169 int txdisable; /* Disable transmitter */
170 - int rxdisable; /* Disable receiver */
171 + int rxdisable; /* Disable receiver */
174 /* Tone zone stuff */
175 @@ -1231,6 +1238,10 @@
176 #define ZT_FLAG_T1PPP (1 << 15)
177 #define ZT_FLAG_SIGFREEZE (1 << 16) /* Freeze signalling */
179 +#if defined(CONFIG_ZAPATA_BRI_DCHANS)
180 +#define ZT_FLAG_BRIDCHAN (1 << 17)
185 void *pvt; /* Private stuff */
186 diff -urN zaptel-1.2.6.orig/zconfig.h zaptel-1.2.6/zconfig.h
187 --- zaptel-1.2.6.orig/zconfig.h 2005-11-29 19:42:08.000000000 +0100
188 +++ zaptel-1.2.6/zconfig.h 2006-06-06 14:54:33.000000000 +0200
191 /* #define FXSFLASH */
194 + * Uncomment the following for BRI D channels
197 +#define CONFIG_ZAPATA_BRI_DCHANS
200 diff -urN zaptel-1.2.6.orig/ztpty.c zaptel-1.2.6/ztpty.c
201 --- zaptel-1.2.6.orig/ztpty.c 1970-01-01 01:00:00.000000000 +0100
202 +++ zaptel-1.2.6/ztpty.c 2006-06-06 14:54:33.000000000 +0200
210 +#include <sys/time.h>
211 +#include <sys/signal.h>
212 +#include <sys/select.h>
220 +void doit(int fd, int stdinfd) {
222 + char inbuffer[4096];
223 + char outbuffer[4096];
227 +// fprintf(stderr, "fd %d stdin fd %d\n", fd, stdinfd);
232 + FD_SET(stdinfd, &fds);
233 + /* Wait for *some* sort of I/O */
234 + res = select(stdinfd + 1, &fds, NULL, NULL, NULL);
236 + fprintf(stderr, "Error in select: %s\n", strerror(errno));
239 + if (FD_ISSET(stdinfd, &fds)) {
240 + res = read(stdinfd, inbuffer, sizeof(inbuffer));
242 +// fprintf(stderr, "read %d bytes from stdin\n", res);
244 + for (i=0; i < res ; i++) {
245 + if (inbuffer[i] == '\n') {
246 + if ((i > 0) && (inbuffer[i-1] == ' ')) {
247 + inbuffer[i-1] = 0x1a;
252 + res = write(fd, inbuffer, res+2);
253 +// res = write(STDOUT_FILENO, inbuffer, res);
254 +// fprintf(stderr, "wrote %d bytes to stdout\n", res);
258 + if (FD_ISSET(fd, &fds)) {
259 + res = read(fd, outbuffer, sizeof(outbuffer));
260 +// fprintf(stderr, "read %d bytes from fd\n", res);
262 + res = write(STDOUT_FILENO, outbuffer, res);
263 +// fprintf(stderr, "wrote %d bytes to stdout\n", res);
271 +int main(int argc, char *argv[])
275 + struct zt_params p;
276 + struct zt_bufferinfo bi;
278 + fd = open(argv[1], O_RDWR | O_NONBLOCK);
280 + fprintf(stderr, "Unable to open zap interface: %s\n", strerror(errno));
283 + if (ioctl(fd, ZT_GET_PARAMS, &p)) {
284 + fprintf(stderr, "Unable to get parameters on '%s': %s\n", argv[1], strerror(errno));
287 + if ((p.sigtype != ZT_SIG_HDLCRAW) && (p.sigtype != ZT_SIG_HDLCFCS)) {
288 + fprintf(stderr, "%s is in %d signalling, not FCS HDLC or RAW HDLC mode\n", argv[1], p.sigtype);
292 + if (ioctl(fd, ZT_GET_BLOCKSIZE, &blocksize)) {
293 + fprintf(stderr, "Unable to get blocksize on '%s': %s\n", argv[1], strerror(errno));
296 +// fprintf(stderr, "blocksize %d\n", blocksize);
299 + bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
300 + bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
303 + if (ioctl(fd, ZT_SET_BUFINFO, &bi)) {
304 + fprintf(stderr, "Unable to set buffer info on '%s': %s\n", argv[1], strerror(errno));
308 + stdinfd = open("/dev/stdin", O_RDONLY | O_NONBLOCK);