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-07-31 14:12:08.000000000 +0200
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 @@
48 +void zt_alarm_notify_no_master_change(struct zt_span *span)
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)) {
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);
72 #define VALID_SPAN(j) do { \
73 if ((j >= ZT_MAX_SPANS) || (j < 1)) \
75 @@ -4913,11 +4938,40 @@
76 *(txb++) = fasthdlc_tx_run_nocheck(&ms->txhdlc);
79 +#ifdef CONFIG_ZAPATA_BRI_DCHANS
80 + } else if (ms->flags & ZT_FLAG_BRIDCHAN) {
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)
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;
97 + memcpy(txb, buf + ms->writeidx[ms->outwritebuf], left);
98 + ms->writeidx[ms->outwritebuf] += left + 2;
100 + ms->bytes2transmit = left;
106 memcpy(txb, buf + ms->writeidx[ms->outwritebuf], left);
107 ms->writeidx[ms->outwritebuf]+=left;
110 +#if defined(CONFIG_ZAPATA_BRI_DCHANS)
111 + ms->bytes2transmit=ZT_CHUNKSIZE;
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) {
124 + // ms->bytes2transmit -= 2;
127 +// printk(KERN_CRIT "zaptel EOF(%d) bytes2transmit %d\n",ms->eoftx,ms->bytes2transmit);
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);
140 } else if (ms->curtone && !(ms->flags & ZT_FLAG_PSEUDO)) {
141 left = ms->curtone->tonesamples - ms->tonep;
143 @@ -5018,6 +5083,10 @@
144 memset(txb, 0xFF, bytes);
147 +#if defined(CONFIG_ZAPATA_BRI_DCHANS)
148 + } else if(ms->flags & ZT_FLAG_BRIDCHAN) {
152 memset(txb, ZT_LIN2X(0, ms), bytes); /* Lastly we use silence on telephony channels */
154 @@ -5743,6 +5812,13 @@
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);
167 #if defined(CONFIG_ZAPATA_NET) || defined(CONFIG_ZAPATA_PPP)
168 @@ -5801,6 +5877,19 @@
172 +#ifdef CONFIG_ZAPATA_BRI_DCHANS
173 + } else if (ms->flags & ZT_FLAG_BRIDCHAN) {
174 + memcpy(buf + ms->readidx[ms->inreadbuf], rxb, left);
176 + ms->readidx[ms->inreadbuf] += left;
178 + if (ms->eofrx == 1) {
181 +// printk(KERN_CRIT "receiving %d bytes\n",ms->bytes2receive);
182 + ms->bytes2receive = 0;
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
193 struct sk_buff_head ppp_rq;
195 +#ifdef CONFIG_ZAPATA_BRI_DCHANS
197 + int maxbytes2transmit; /* size of the tx buffer in the card driver */
198 + int bytes2transmit;
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 */
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 */
218 +#if defined(CONFIG_ZAPATA_BRI_DCHANS)
219 +#define ZT_FLAG_BRIDCHAN (1 << 17)
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);
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);
232 /* Initialize a tone state */
233 extern void zt_init_tone_state(struct zt_tone_state *ts, struct zt_tone *zt);
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
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,
247 -/* #define ECHO_CAN_MG2 */
248 +#define ECHO_CAN_MG2
251 * Uncomment for aggressive residual echo supression under
254 /* #define FXSFLASH */
257 + * Uncomment the following for BRI D channels
260 +#define CONFIG_ZAPATA_BRI_DCHANS
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
273 +#include <sys/time.h>
274 +#include <sys/signal.h>
275 +#include <sys/select.h>
283 +void doit(int fd, int stdinfd) {
285 + char inbuffer[4096];
286 + char outbuffer[4096];
290 +// fprintf(stderr, "fd %d stdin fd %d\n", fd, stdinfd);
295 + FD_SET(stdinfd, &fds);
296 + /* Wait for *some* sort of I/O */
297 + res = select(stdinfd + 1, &fds, NULL, NULL, NULL);
299 + fprintf(stderr, "Error in select: %s\n", strerror(errno));
302 + if (FD_ISSET(stdinfd, &fds)) {
303 + res = read(stdinfd, inbuffer, sizeof(inbuffer));
305 +// fprintf(stderr, "read %d bytes from stdin\n", res);
307 + for (i=0; i < res ; i++) {
308 + if (inbuffer[i] == '\n') {
309 + if ((i > 0) && (inbuffer[i-1] == ' ')) {
310 + inbuffer[i-1] = 0x1a;
315 + res = write(fd, inbuffer, res+2);
316 +// res = write(STDOUT_FILENO, inbuffer, res);
317 +// fprintf(stderr, "wrote %d bytes to stdout\n", res);
321 + if (FD_ISSET(fd, &fds)) {
322 + res = read(fd, outbuffer, sizeof(outbuffer));
323 +// fprintf(stderr, "read %d bytes from fd\n", res);
325 + res = write(STDOUT_FILENO, outbuffer, res);
326 +// fprintf(stderr, "wrote %d bytes to stdout\n", res);
334 +int main(int argc, char *argv[])
338 + struct zt_params p;
339 + struct zt_bufferinfo bi;
341 + fd = open(argv[1], O_RDWR | O_NONBLOCK);
343 + fprintf(stderr, "Unable to open zap interface: %s\n", strerror(errno));
346 + if (ioctl(fd, ZT_GET_PARAMS, &p)) {
347 + fprintf(stderr, "Unable to get parameters on '%s': %s\n", argv[1], strerror(errno));
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);
355 + if (ioctl(fd, ZT_GET_BLOCKSIZE, &blocksize)) {
356 + fprintf(stderr, "Unable to get blocksize on '%s': %s\n", argv[1], strerror(errno));
359 +// fprintf(stderr, "blocksize %d\n", blocksize);
362 + bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
363 + bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
366 + if (ioctl(fd, ZT_SET_BUFINFO, &bi)) {
367 + fprintf(stderr, "Unable to set buffer info on '%s': %s\n", argv[1], strerror(errno));
371 + stdinfd = open("/dev/stdin", O_RDONLY | O_NONBLOCK);