]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/patches/zaptel.patch
HinzugefĆ¼gt:
[people/pmueller/ipfire-2.x.git] / src / patches / zaptel.patch
CommitLineData
b684b13b
MT
1diff -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
4@@ -124,7 +124,7 @@
5 ifneq (,$(wildcard /usr/include/newt.h))
6 ZTTOOL:=zttool
7 endif
8-BINS=ztcfg torisatool makefw ztmonitor ztspeed $(ZTTOOL) zttest fxotune
9+BINS=ztcfg torisatool makefw ztmonitor ztspeed $(ZTTOOL) zttest fxotune ztpty
10
11 all: $(BUILDVER) $(LIBTONEZONE_SO)
12
13@@ -209,6 +209,9 @@
14
15 ztmonitor.o: ztmonitor.c zaptel.h
16
17+ztpty.o: ztpty.c
18+ $(CC) -o $@ -c $^
19+
20 ztspeed.o: ztspeed.c
21 $(CC) -o $@ -c $^
22
23@@ -221,6 +224,9 @@
24 ztspeed: ztspeed.o
25 $(CC) -o $@ $^
26
27+ztpty: ztpty.o
28+ $(CC) -o $@ $^
29+
30 sethdlc-new: sethdlc-new.o
31 $(CC) -o $@ $^
32
33diff -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
5e69ef1a
MT
36@@ -4913,11 +4913,40 @@
37 *(txb++) = fasthdlc_tx_run_nocheck(&ms->txhdlc);
38 }
39 bytes -= left;
40+#ifdef CONFIG_ZAPATA_BRI_DCHANS
41+ } else if (ms->flags & ZT_FLAG_BRIDCHAN) {
42+ /*
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)
47+ */
48+
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;
56+ ms->eoftx = 0;
57+ } else {
58+ memcpy(txb, buf + ms->writeidx[ms->outwritebuf], left);
59+ ms->writeidx[ms->outwritebuf] += left + 2;
60+ txb += left;
61+ ms->bytes2transmit = left;
62+ ms->eoftx = 1;
63+ }
64+ bytes = 0;
65+#endif
66 } else {
67 memcpy(txb, buf + ms->writeidx[ms->outwritebuf], left);
68 ms->writeidx[ms->outwritebuf]+=left;
69 txb += left;
70 bytes -= left;
71+#if defined(CONFIG_ZAPATA_BRI_DCHANS)
72+ ms->bytes2transmit=ZT_CHUNKSIZE;
73+#endif
74 }
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) {
84+ // txb += 2;
85+ // ms->bytes2transmit -= 2;
86+ bytes=0;
87+ ms->eoftx = 1;
88+// printk(KERN_CRIT "zaptel EOF(%d) bytes2transmit %d\n",ms->eoftx,ms->bytes2transmit);
89+ // }
90+ }
91+#endif
92 #ifdef CONFIG_ZAPATA_NET
93 if (ms->flags & ZT_FLAG_NETDEV)
94 netif_wake_queue(ztchan_to_dev(ms));
95@@ -4972,7 +5012,7 @@
96 tasklet_schedule(&ms->ppp_calls);
97 }
98 #endif
99- }
100+ }
101 } else if (ms->curtone && !(ms->flags & ZT_FLAG_PSEUDO)) {
102 left = ms->curtone->tonesamples - ms->tonep;
103 if (left > bytes)
104@@ -5018,6 +5058,10 @@
105 memset(txb, 0xFF, bytes);
106 }
107 bytes = 0;
108+#if defined(CONFIG_ZAPATA_BRI_DCHANS)
109+ } else if(ms->flags & ZT_FLAG_BRIDCHAN) {
110+ bytes = 0;
111+#endif
112 } else {
113 memset(txb, ZT_LIN2X(0, ms), bytes); /* Lastly we use silence on telephony channels */
114 bytes = 0;
115@@ -5743,6 +5787,13 @@
116 int left, x;
117
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);
124+ }
125+#endif
126
127 while(bytes) {
128 #if defined(CONFIG_ZAPATA_NET) || defined(CONFIG_ZAPATA_PPP)
129@@ -5801,6 +5852,19 @@
130 }
131 }
132 }
133+#ifdef CONFIG_ZAPATA_BRI_DCHANS
134+ } else if (ms->flags & ZT_FLAG_BRIDCHAN) {
135+ memcpy(buf + ms->readidx[ms->inreadbuf], rxb, left);
136+ rxb += left;
137+ ms->readidx[ms->inreadbuf] += left;
138+ bytes -= left;
139+ if (ms->eofrx == 1) {
140+ eof=1;
141+ }
142+// printk(KERN_CRIT "receiving %d bytes\n",ms->bytes2receive);
143+ ms->bytes2receive = 0;
144+ ms->eofrx = 0;
145+#endif
146 } else {
147 /* Not HDLC */
148 memcpy(buf + ms->readidx[ms->inreadbuf], rxb, left);
b684b13b
MT
149diff -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
5e69ef1a
MT
152@@ -994,6 +994,13 @@
153 int do_ppp_error;
154 struct sk_buff_head ppp_rq;
155 #endif
156+#ifdef CONFIG_ZAPATA_BRI_DCHANS
157+ int bytes2receive;
158+ int maxbytes2transmit; /* size of the tx buffer in the card driver */
159+ int bytes2transmit;
160+ int eofrx;
161+ int eoftx;
162+#endif
163 spinlock_t lock;
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 */
172
173
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 */
178
179+#if defined(CONFIG_ZAPATA_BRI_DCHANS)
180+#define ZT_FLAG_BRIDCHAN (1 << 17)
181+#endif
182+
183 struct zt_span {
184 spinlock_t lock;
185 void *pvt; /* Private stuff */
b684b13b
MT
186diff -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
5e69ef1a
MT
189@@ -152,4 +152,10 @@
190 */
191 /* #define FXSFLASH */
192
193+/*
194+ * Uncomment the following for BRI D channels
195+ *
196+ */
197+#define CONFIG_ZAPATA_BRI_DCHANS
198+
199 #endif
b684b13b
MT
200diff -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
203@@ -0,0 +1,112 @@
204+#include <stdio.h>
205+#include <stdlib.h>
206+#include <unistd.h>
207+#include <errno.h>
208+#include <string.h>
209+#include <fcntl.h>
210+#include <sys/time.h>
211+#include <sys/signal.h>
212+#include <sys/select.h>
213+#include <math.h>
214+#include "zaptel.h"
215+
216+#define SIZE 8000
217+
218+
219+
220+void doit(int fd, int stdinfd) {
221+ fd_set fds;
222+ char inbuffer[4096];
223+ char outbuffer[4096];
224+ int res = 0;
225+ int i = 0;
226+
227+// fprintf(stderr, "fd %d stdin fd %d\n", fd, stdinfd);
228+
229+ for (;;) {
230+ FD_ZERO(&fds);
231+ FD_SET(fd, &fds);
232+ FD_SET(stdinfd, &fds);
233+ /* Wait for *some* sort of I/O */
234+ res = select(stdinfd + 1, &fds, NULL, NULL, NULL);
235+ if (res < 0) {
236+ fprintf(stderr, "Error in select: %s\n", strerror(errno));
237+ return;
238+ }
239+ if (FD_ISSET(stdinfd, &fds)) {
240+ res = read(stdinfd, inbuffer, sizeof(inbuffer));
241+ if (res > 0) {
242+// fprintf(stderr, "read %d bytes from stdin\n", res);
243+ if (res > 0) {
244+ for (i=0; i < res ; i++) {
245+ if (inbuffer[i] == '\n') {
246+ if ((i > 0) && (inbuffer[i-1] == ' ')) {
247+ inbuffer[i-1] = 0x1a;
248+ }
249+ inbuffer[i] = 0xd;
250+ }
251+ }
252+ res = write(fd, inbuffer, res+2);
253+// res = write(STDOUT_FILENO, inbuffer, res);
254+// fprintf(stderr, "wrote %d bytes to stdout\n", res);
255+ }
256+ }
257+ }
258+ if (FD_ISSET(fd, &fds)) {
259+ res = read(fd, outbuffer, sizeof(outbuffer));
260+// fprintf(stderr, "read %d bytes from fd\n", res);
261+ if (res > 0) {
262+ res = write(STDOUT_FILENO, outbuffer, res);
263+// fprintf(stderr, "wrote %d bytes to stdout\n", res);
264+ }
265+ }
266+ }
267+
268+
269+}
270+
271+int main(int argc, char *argv[])
272+{
273+ int fd;
274+ int stdinfd;
275+ struct zt_params p;
276+ struct zt_bufferinfo bi;
277+ int blocksize=0;
278+ fd = open(argv[1], O_RDWR | O_NONBLOCK);
279+ if (fd < 0) {
280+ fprintf(stderr, "Unable to open zap interface: %s\n", strerror(errno));
281+ exit(1);
282+ }
283+ if (ioctl(fd, ZT_GET_PARAMS, &p)) {
284+ fprintf(stderr, "Unable to get parameters on '%s': %s\n", argv[1], strerror(errno));
285+ exit(1);
286+ }
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);
289+ exit(1);
290+ }
291+
292+ if (ioctl(fd, ZT_GET_BLOCKSIZE, &blocksize)) {
293+ fprintf(stderr, "Unable to get blocksize on '%s': %s\n", argv[1], strerror(errno));
294+ exit(1);
295+ } else {
296+// fprintf(stderr, "blocksize %d\n", blocksize);
297+ }
298+
299+ bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
300+ bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
301+ bi.numbufs = 16;
302+ bi.bufsize = 1024;
303+ if (ioctl(fd, ZT_SET_BUFINFO, &bi)) {
304+ fprintf(stderr, "Unable to set buffer info on '%s': %s\n", argv[1], strerror(errno));
305+ exit(1);
306+ }
307+
308+ stdinfd = open("/dev/stdin", O_RDONLY | O_NONBLOCK);
309+
310+
311+ doit(fd, stdinfd);
312+ close(stdinfd);
313+ close(fd);
314+ return 0;
315+}