]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/zaptel.patch
Kernel-Update und umfassende Arbeiten daran.
[people/pmueller/ipfire-2.x.git] / src / patches / zaptel.patch
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
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
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-07-31 14:12:08.000000000 +0200
36 @@ -139,6 +139,7 @@
37 EXPORT_SYMBOL(zt_qevent_lock);
38 EXPORT_SYMBOL(zt_hooksig);
39 EXPORT_SYMBOL(zt_alarm_notify);
40 +EXPORT_SYMBOL(zt_alarm_notify_no_master_change);
41 EXPORT_SYMBOL(zt_set_dynamic_ioctl);
42 EXPORT_SYMBOL(zt_ec_chunk);
43 EXPORT_SYMBOL(zt_ec_span);
44 @@ -2685,6 +2686,30 @@
45 }
46 }
47
48 +void zt_alarm_notify_no_master_change(struct zt_span *span)
49 +{
50 + int j;
51 + int x;
52 +
53 + span->alarms &= ~ZT_ALARM_LOOPBACK;
54 + /* Determine maint status */
55 + if (span->maintstat || span->mainttimer)
56 + span->alarms |= ZT_ALARM_LOOPBACK;
57 + /* DON'T CHANGE THIS AGAIN. THIS WAS DONE FOR A REASON.
58 + The expression (a != b) does *NOT* do the same thing
59 + as ((!a) != (!b)) */
60 + /* if change in general state */
61 + if ((!span->alarms) != (!span->lastalarms)) {
62 + if (span->alarms)
63 + j = ZT_EVENT_ALARM;
64 + else
65 + j = ZT_EVENT_NOALARM;
66 + span->lastalarms = span->alarms;
67 + for (x=0;x < span->channels;x++)
68 + zt_qevent_lock(&span->chans[x], j);
69 + }
70 +}
71 +
72 #define VALID_SPAN(j) do { \
73 if ((j >= ZT_MAX_SPANS) || (j < 1)) \
74 return -EINVAL; \
75 @@ -4913,11 +4938,40 @@
76 *(txb++) = fasthdlc_tx_run_nocheck(&ms->txhdlc);
77 }
78 bytes -= left;
79 +#ifdef CONFIG_ZAPATA_BRI_DCHANS
80 + } else if (ms->flags & ZT_FLAG_BRIDCHAN) {
81 + /*
82 + * Let's get this right, we want to transmit complete frames only.
83 + * The card driver will do the dirty HDLC work for us.
84 + * txb (transmit buffer) is supposed to be big enough to store one frame
85 + * we will make this as big as the D fifo (1KB or 2KB)
86 + */
87 +
88 + /* there are 'left' bytes in the user buffer left to transmit */
89 + left = ms->writen[ms->outwritebuf] - ms->writeidx[ms->outwritebuf] - 2;
90 + if (left > ms->maxbytes2transmit) {
91 + memcpy(txb, buf + ms->writeidx[ms->outwritebuf], ms->maxbytes2transmit);
92 + ms->writeidx[ms->outwritebuf] += ms->maxbytes2transmit;
93 + txb += ms->maxbytes2transmit;
94 + ms->bytes2transmit = ms->maxbytes2transmit;
95 + ms->eoftx = 0;
96 + } else {
97 + memcpy(txb, buf + ms->writeidx[ms->outwritebuf], left);
98 + ms->writeidx[ms->outwritebuf] += left + 2;
99 + txb += left;
100 + ms->bytes2transmit = left;
101 + ms->eoftx = 1;
102 + }
103 + bytes = 0;
104 +#endif
105 } else {
106 memcpy(txb, buf + ms->writeidx[ms->outwritebuf], left);
107 ms->writeidx[ms->outwritebuf]+=left;
108 txb += left;
109 bytes -= left;
110 +#if defined(CONFIG_ZAPATA_BRI_DCHANS)
111 + ms->bytes2transmit=ZT_CHUNKSIZE;
112 +#endif
113 }
114 /* Check buffer status */
115 if (ms->writeidx[ms->outwritebuf] >= ms->writen[ms->outwritebuf]) {
116 @@ -4962,6 +5016,17 @@
117 /* Transmit a flag if this is an HDLC channel */
118 if (ms->flags & ZT_FLAG_HDLC)
119 fasthdlc_tx_frame_nocheck(&ms->txhdlc);
120 +#if defined(CONFIG_ZAPATA_BRI_DCHANS)
121 + if(ms->flags & ZT_FLAG_BRIDCHAN) {
122 + // if (ms->bytes2transmit > 0) {
123 + // txb += 2;
124 + // ms->bytes2transmit -= 2;
125 + bytes=0;
126 + ms->eoftx = 1;
127 +// printk(KERN_CRIT "zaptel EOF(%d) bytes2transmit %d\n",ms->eoftx,ms->bytes2transmit);
128 + // }
129 + }
130 +#endif
131 #ifdef CONFIG_ZAPATA_NET
132 if (ms->flags & ZT_FLAG_NETDEV)
133 netif_wake_queue(ztchan_to_dev(ms));
134 @@ -4972,7 +5037,7 @@
135 tasklet_schedule(&ms->ppp_calls);
136 }
137 #endif
138 - }
139 + }
140 } else if (ms->curtone && !(ms->flags & ZT_FLAG_PSEUDO)) {
141 left = ms->curtone->tonesamples - ms->tonep;
142 if (left > bytes)
143 @@ -5018,6 +5083,10 @@
144 memset(txb, 0xFF, bytes);
145 }
146 bytes = 0;
147 +#if defined(CONFIG_ZAPATA_BRI_DCHANS)
148 + } else if(ms->flags & ZT_FLAG_BRIDCHAN) {
149 + bytes = 0;
150 +#endif
151 } else {
152 memset(txb, ZT_LIN2X(0, ms), bytes); /* Lastly we use silence on telephony channels */
153 bytes = 0;
154 @@ -5743,6 +5812,13 @@
155 int left, x;
156
157 int bytes = ZT_CHUNKSIZE;
158 +#if defined(CONFIG_ZAPATA_BRI_DCHANS)
159 + if (ms->flags & ZT_FLAG_BRIDCHAN) {
160 + bytes = ms->bytes2receive;
161 + if (bytes < 1) return;
162 +// printk(KERN_CRIT "bytes2receive %d\n",ms->bytes2receive);
163 + }
164 +#endif
165
166 while(bytes) {
167 #if defined(CONFIG_ZAPATA_NET) || defined(CONFIG_ZAPATA_PPP)
168 @@ -5801,6 +5877,19 @@
169 }
170 }
171 }
172 +#ifdef CONFIG_ZAPATA_BRI_DCHANS
173 + } else if (ms->flags & ZT_FLAG_BRIDCHAN) {
174 + memcpy(buf + ms->readidx[ms->inreadbuf], rxb, left);
175 + rxb += left;
176 + ms->readidx[ms->inreadbuf] += left;
177 + bytes -= left;
178 + if (ms->eofrx == 1) {
179 + eof=1;
180 + }
181 +// printk(KERN_CRIT "receiving %d bytes\n",ms->bytes2receive);
182 + ms->bytes2receive = 0;
183 + ms->eofrx = 0;
184 +#endif
185 } else {
186 /* Not HDLC */
187 memcpy(buf + ms->readidx[ms->inreadbuf], rxb, left);
188 diff -urN zaptel-1.2.6.orig/zaptel.h zaptel-1.2.6/zaptel.h
189 --- zaptel-1.2.6.orig/zaptel.h 2005-12-17 03:04:05.000000000 +0100
190 +++ zaptel-1.2.6/zaptel.h 2006-07-31 12:58:04.000000000 +0200
191 @@ -994,6 +994,13 @@
192 int do_ppp_error;
193 struct sk_buff_head ppp_rq;
194 #endif
195 +#ifdef CONFIG_ZAPATA_BRI_DCHANS
196 + int bytes2receive;
197 + int maxbytes2transmit; /* size of the tx buffer in the card driver */
198 + int bytes2transmit;
199 + int eofrx;
200 + int eoftx;
201 +#endif
202 spinlock_t lock;
203 char name[40]; /* Name */
204 /* Specified by zaptel */
205 @@ -1068,7 +1075,7 @@
206 int txbufpolicy; /* Buffer policy */
207 int rxbufpolicy; /* Buffer policy */
208 int txdisable; /* Disable transmitter */
209 - int rxdisable; /* Disable receiver */
210 + int rxdisable; /* Disable receiver */
211
212
213 /* Tone zone stuff */
214 @@ -1231,6 +1238,10 @@
215 #define ZT_FLAG_T1PPP (1 << 15)
216 #define ZT_FLAG_SIGFREEZE (1 << 16) /* Freeze signalling */
217
218 +#if defined(CONFIG_ZAPATA_BRI_DCHANS)
219 +#define ZT_FLAG_BRIDCHAN (1 << 17)
220 +#endif
221 +
222 struct zt_span {
223 spinlock_t lock;
224 void *pvt; /* Private stuff */
225 @@ -1404,6 +1415,9 @@
226 /* Notify a change possible change in alarm status */
227 extern void zt_alarm_notify(struct zt_span *span);
228
229 +/* Notify a change possible change in alarm status, DONT change the zaptel master! */
230 +extern void zt_alarm_notify_no_master_change(struct zt_span *span);
231 +
232 /* Initialize a tone state */
233 extern void zt_init_tone_state(struct zt_tone_state *ts, struct zt_tone *zt);
234
235 diff -urN zaptel-1.2.6.orig/zconfig.h zaptel-1.2.6/zconfig.h
236 --- zaptel-1.2.6.orig/zconfig.h 2005-11-29 19:42:08.000000000 +0100
237 +++ zaptel-1.2.6/zconfig.h 2006-08-02 20:34:43.000000000 +0200
238 @@ -49,11 +49,11 @@
239 /* #define ECHO_CAN_MARK */
240 /* #define ECHO_CAN_MARK2 */
241 /* #define ECHO_CAN_MARK3 */
242 -#define ECHO_CAN_KB1
243 +/* #define ECHO_CAN_KB1 */
244 /* MG2 is a version of KB1 that has some changes to it that are
245 * supposed to improve how it performs. If you have echo problems,
246 * try it out! */
247 -/* #define ECHO_CAN_MG2 */
248 +#define ECHO_CAN_MG2
249
250 /*
251 * Uncomment for aggressive residual echo supression under
252 @@ -152,4 +152,10 @@
253 */
254 /* #define FXSFLASH */
255
256 +/*
257 + * Uncomment the following for BRI D channels
258 + *
259 + */
260 +#define CONFIG_ZAPATA_BRI_DCHANS
261 +
262 #endif
263 diff -urN zaptel-1.2.6.orig/ztpty.c zaptel-1.2.6/ztpty.c
264 --- zaptel-1.2.6.orig/ztpty.c 1970-01-01 01:00:00.000000000 +0100
265 +++ zaptel-1.2.6/ztpty.c 2006-06-06 14:54:33.000000000 +0200
266 @@ -0,0 +1,112 @@
267 +#include <stdio.h>
268 +#include <stdlib.h>
269 +#include <unistd.h>
270 +#include <errno.h>
271 +#include <string.h>
272 +#include <fcntl.h>
273 +#include <sys/time.h>
274 +#include <sys/signal.h>
275 +#include <sys/select.h>
276 +#include <math.h>
277 +#include "zaptel.h"
278 +
279 +#define SIZE 8000
280 +
281 +
282 +
283 +void doit(int fd, int stdinfd) {
284 + fd_set fds;
285 + char inbuffer[4096];
286 + char outbuffer[4096];
287 + int res = 0;
288 + int i = 0;
289 +
290 +// fprintf(stderr, "fd %d stdin fd %d\n", fd, stdinfd);
291 +
292 + for (;;) {
293 + FD_ZERO(&fds);
294 + FD_SET(fd, &fds);
295 + FD_SET(stdinfd, &fds);
296 + /* Wait for *some* sort of I/O */
297 + res = select(stdinfd + 1, &fds, NULL, NULL, NULL);
298 + if (res < 0) {
299 + fprintf(stderr, "Error in select: %s\n", strerror(errno));
300 + return;
301 + }
302 + if (FD_ISSET(stdinfd, &fds)) {
303 + res = read(stdinfd, inbuffer, sizeof(inbuffer));
304 + if (res > 0) {
305 +// fprintf(stderr, "read %d bytes from stdin\n", res);
306 + if (res > 0) {
307 + for (i=0; i < res ; i++) {
308 + if (inbuffer[i] == '\n') {
309 + if ((i > 0) && (inbuffer[i-1] == ' ')) {
310 + inbuffer[i-1] = 0x1a;
311 + }
312 + inbuffer[i] = 0xd;
313 + }
314 + }
315 + res = write(fd, inbuffer, res+2);
316 +// res = write(STDOUT_FILENO, inbuffer, res);
317 +// fprintf(stderr, "wrote %d bytes to stdout\n", res);
318 + }
319 + }
320 + }
321 + if (FD_ISSET(fd, &fds)) {
322 + res = read(fd, outbuffer, sizeof(outbuffer));
323 +// fprintf(stderr, "read %d bytes from fd\n", res);
324 + if (res > 0) {
325 + res = write(STDOUT_FILENO, outbuffer, res);
326 +// fprintf(stderr, "wrote %d bytes to stdout\n", res);
327 + }
328 + }
329 + }
330 +
331 +
332 +}
333 +
334 +int main(int argc, char *argv[])
335 +{
336 + int fd;
337 + int stdinfd;
338 + struct zt_params p;
339 + struct zt_bufferinfo bi;
340 + int blocksize=0;
341 + fd = open(argv[1], O_RDWR | O_NONBLOCK);
342 + if (fd < 0) {
343 + fprintf(stderr, "Unable to open zap interface: %s\n", strerror(errno));
344 + exit(1);
345 + }
346 + if (ioctl(fd, ZT_GET_PARAMS, &p)) {
347 + fprintf(stderr, "Unable to get parameters on '%s': %s\n", argv[1], strerror(errno));
348 + exit(1);
349 + }
350 + if ((p.sigtype != ZT_SIG_HDLCRAW) && (p.sigtype != ZT_SIG_HDLCFCS)) {
351 + fprintf(stderr, "%s is in %d signalling, not FCS HDLC or RAW HDLC mode\n", argv[1], p.sigtype);
352 + exit(1);
353 + }
354 +
355 + if (ioctl(fd, ZT_GET_BLOCKSIZE, &blocksize)) {
356 + fprintf(stderr, "Unable to get blocksize on '%s': %s\n", argv[1], strerror(errno));
357 + exit(1);
358 + } else {
359 +// fprintf(stderr, "blocksize %d\n", blocksize);
360 + }
361 +
362 + bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
363 + bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
364 + bi.numbufs = 16;
365 + bi.bufsize = 1024;
366 + if (ioctl(fd, ZT_SET_BUFINFO, &bi)) {
367 + fprintf(stderr, "Unable to set buffer info on '%s': %s\n", argv[1], strerror(errno));
368 + exit(1);
369 + }
370 +
371 + stdinfd = open("/dev/stdin", O_RDONLY | O_NONBLOCK);
372 +
373 +
374 + doit(fd, stdinfd);
375 + close(stdinfd);
376 + close(fd);
377 + return 0;
378 +}