1 diff -urN asterisk-1.2.7.1.orig/.version asterisk-1.2.7.1/.version
2 --- asterisk-1.2.7.1.orig/.version 2006-04-13 19:50:06.000000000 +0200
3 +++ asterisk-1.2.7.1/.version 2006-04-18 14:39:46.000000000 +0200
6 +1.2.7.1-BRIstuffed-0.3.0-PRE-1o-with-florz-patch-for-ipfire
7 diff -urN asterisk-1.2.7.1.orig/HARDWARE asterisk-1.2.7.1/HARDWARE
8 --- asterisk-1.2.7.1.orig/HARDWARE 2005-11-29 19:24:39.000000000 +0100
9 +++ asterisk-1.2.7.1/HARDWARE 2006-04-18 14:39:28.000000000 +0200
11 * Wildcard TE410P - Quad T1/E1 switchable interface. Supports PRI and
12 RBS signalling, as well as PPP, FR, and HDLC data modes.
14 +-- Junghanns.NET (Primary author of BRIstuff)
15 + http://www.junghanns.net
17 + * quadBRI PCI ISDN - 4port BRI ISDN interface, supports NT and TE mode
19 + * octoBRI PCI ISDN - 8port BRI ISDN interface, supports NT and TE mode
21 + * singleE1 PCI ISDN - Single E1 interface
23 + * doubleE1 PCI ISDN - Double E1 interface
25 + * uno/duo/quad GSM PCI - 1/2/4 channel GSM interface cards
27 Non-zaptel compatible hardware
28 ==============================
30 diff -urN asterisk-1.2.7.1.orig/LICENSE asterisk-1.2.7.1/LICENSE
31 --- asterisk-1.2.7.1.orig/LICENSE 2005-11-29 19:24:39.000000000 +0100
32 +++ asterisk-1.2.7.1/LICENSE 2006-04-18 14:39:28.000000000 +0200
34 -Asterisk is distributed under the GNU General Public License version 2
35 -and is also available under alternative licenses negotiated directly
36 -with Digium, Inc. If you obtained Asterisk under the GPL, then the GPL
37 -applies to all loadable Asterisk modules used on your system as well,
38 +BRIstuffed Asterisk is distributed under the GNU General Public License version 2
39 +and is not available under any alternative licenses.
40 +If you obtained BRIstuffed Asterisk under the GPL, then the GPL
41 +applies to all loadable BRIstuffed Asterisk modules used on your system as well,
42 except as defined below. The GPL (version 2) is included in this
43 source tree in the file COPYING.
45 diff -urN asterisk-1.2.7.1.orig/Makefile asterisk-1.2.7.1/Makefile
46 --- asterisk-1.2.7.1.orig/Makefile 2006-04-11 23:58:47.000000000 +0200
47 +++ asterisk-1.2.7.1/Makefile 2006-04-18 14:39:28.000000000 +0200
49 echo ";astctlowner = root" ; \
50 echo ";astctlgroup = apache" ; \
51 echo ";astctl = asterisk.ctl" ; \
52 + echo "[options]" ; \
53 + echo "uniquename = asterisk" ;\
54 + echo "silence_suppression = yes" ;\
55 ) > $(DESTDIR)$(ASTCONFPATH) ; \
57 echo "Skipping asterisk.conf creation"; \
58 diff -urN asterisk-1.2.7.1.orig/README asterisk-1.2.7.1/README
59 --- asterisk-1.2.7.1.orig/README 2006-03-03 09:12:33.000000000 +0100
60 +++ asterisk-1.2.7.1/README 2006-04-18 14:39:28.000000000 +0200
63 Copyright (C) 2001-2005 Digium, Inc.
64 and other copyright holders.
65 +Copyright (C) 2002-2005 Junghanns.NET GmbH
66 +and other copyright holders.
67 ================================================================
70 diff -urN asterisk-1.2.7.1.orig/README.chan_capi asterisk-1.2.7.1/README.chan_capi
71 --- asterisk-1.2.7.1.orig/README.chan_capi 1970-01-01 01:00:00.000000000 +0100
72 +++ asterisk-1.2.7.1/README.chan_capi 2006-04-18 14:39:28.000000000 +0200
74 +(CAPI*) chan_capi a Common ISDN API 2.0 implementation for Asterisk
75 +(C) 2002, 2003, 2004, 2005 Junghanns.NET GmbH
76 +Klaus-Peter Junghanns <kpj@junghanns.net>
78 +This program is free software and may be modified and distributed under
79 +the terms of the GNU Public License. There is _NO_ warranty for this!
81 +Thanks go to the debuggers and bugfixers (listed in chronological order) :)
82 +===========================================================================
83 +Lele Forzani <lele@windmill.it>
84 +Florian Overkamp <florian@obsimref.com>
85 +Gareth Watts <gareth@omnipotent.net>
86 +Jeff Noxon <jeff@planetfall.com>
87 +Petr Michalek <petr.michalek@aca.cz>
89 +(...and all the others that i forgot..) :-)
91 +chan_capi version 0.4.0-PRE1 includes:
92 +======================================
94 +- multiple controller support
95 +- CID,DNID (callling party, called party)
97 +- supplementary services, CD,HOLD,RETRIEVE,ECT
98 +- DTMF (dependend on card) + software DTMF support
99 +- early B3 connects (always,success,never)
100 +- digital audio (what did you think?)
101 +- incoming/outgoing calls
102 +- overlap sending (dialtone)
103 +- E(xplicit) C(all) T(ransfer) (...although it's done implicit .. but dont tell!)
104 +- tuneable latency ;) you can configure the size of B3 blocks at compile time
105 + (in chan_capi_pvt.h, AST_CAPI_MAX_B3_BLOCK_SIZE)
106 + the default is 160 samples, for non-VoIP use you can tune it down to 130
107 +- use asterisk's internal dsp functions for dtmf
110 +- Eicon CAPI echo cancelation (echocancel=1)
111 +- reject call waiting (ACO)
112 +- DID for Point to Point mode (a.k.a overlap receiving)
113 +- experimental echo squelching (echosquelch=1)
114 +- call progress, no need to add ||r to your dialstring anymore
115 +- rx/tx gains (rxgain=1.0)
116 +- call deflection on circuitbusy (makefile option) (deflect=12345678)
117 +- (inter)national dialing prefix (for callerid) configurable in capi.conf
118 +- CLI command "capi info" shows B channel status
119 +- capiECT will announce the callerID since it gets lost on most isdn pbxes
120 + the called party can press # to drop the call
121 +- audio syncing (timing outgoing dataB3 on incoming dataB3), supposed to fix
122 + the DATA_B3_REQ (error = 0x1103) problem
123 +- catch all MSN (incomingmsn=*)
124 +- some configuration enhancements (msn=123,124,125 and controller=1,2,3,4)
125 +- accountcode= added.
126 +- finally the echo squelching works!
129 +- updated to support the new frame->delivery field
130 +- compiles with latest cvs with a makefile option (LOOK AT THE MAKEFILE)
131 +- fixed channel name bug in p2p mode
132 +- added app_capiNoES for disabling the primitive echo suppressor, use this before
133 + you start recording voicemail or your files may get choppy
134 +- fixed for latest cvs (AST_MUTEX_DEFINE_STATIC)
135 +- fixed for latest cvs (asterisk/parking.h -> asterisk/features.h)
136 +- fixed for latest cvs ast_pthread_create
138 +- ATTENTION! the dialstring syntax now uses the zaptel dialstring syntax
139 + it used to be: Dial(CAPI/[@]<outgoingMSN>:[b|B]<destination>)
141 + now it is: Dial(CAPI/g<group>/[b|B]<destination>)
142 + or: Dial(CAPI/contr<controller>/[b|B]<destination>)
144 + CLIP/CLIR is now uses the calling presentation of the calling channel, this can
145 + be modified using the CallingPres() application. Use CallinPres(32) for CLIR.
146 + That is why the msn= param in capi.conf is now obsolete. The callerID is also
147 + taken from the calling channel.
149 +- fixes for BSD (Jan Stocker)
153 +kapejod says: "No No No, dont use those yet....!" (except maybe HOLD,ECT...)
155 +app_capiCD.c forwards an unanswered call to another phone (does not rely on sservice CD)
157 + exten => s,1,Wait,1
158 + exten => s,2,capiCD,12345678
160 +app_capiHOLD.c puts an answered call on hold, this has nothing to do with asterisk's onhold thingie (music et al)
161 + after putting a call onhold, never use the Wait application!
163 +app_capiRETRIEVE.c gets the holded call back
165 +app_capiECT.c explicit call transfer of the holded call (must put call on hold first!)
167 + exten => s,1,Answer
168 + exten => s,2,capiHOLD
169 + exten => s,3,capiECT,55:50
170 + will ECT the call to 50 using 55 as the callerid/outgoing msn
175 +Use the CallingPres() application before you dial:
176 +exten => _X.,1,CallingPres(32)
177 +exten => _X.,2,Dial(CAPI/contr1/${EXTEN})
179 +Enjoying early B3 connects (inband call progress, tones and announcements)
180 +==========================================================================
181 +early B3 is now configurable in the dialstring :)
182 +if you prefix the destination number with a 'b' early B3 will always be used, also if the call fails
183 +because the number is unprovisioned, etc ...
184 +if you prefix it with a 'B' early B3 will only be used on successful calls, giving you ring indication,etc...
186 +dont use indications in the Dial command, your local exchange will do that for you:
187 +exten => _X.,1,Dial(CAPI/contr1/B${EXTEN},30) (early B3 on success)
188 +exten => _X.,1,Dial(CAPI/contr1/b${EXTEN},30) (always early B3)
189 +exten => _X.,1,Dial(CAPI/contr1/${EXTEN},30,r) (no early B3, fake ring indication)
191 +exten => _X.,1,Dial(CAPI/contr1/b${EXTEN},30,r) (always early B3, fake indicatons if the exchange
192 + does not give us indications)
193 +exten => _X.,1,Dial(CAPI/contr1/B${EXTEN},30,r) (early B3 on success, fake indicatons if the exchange
194 + does not give us indications)
196 +you can totally turn B3 off in the Makefile at buildtime (-DNEVER_EVER_EARLY_B3_CONNECTS).
198 +For normal PBX usage you would use the "b" option, always early B3.
200 +Overlap sending (a.k.a. real dialtone)
201 +======================================
202 +when you dial an empty number, and have early B3 enabled, with:
204 +the channel will come up at once and give you the dialtone it gets from the local exchange.
205 +at this point the channel is like a legacy phone, now you can send dtmf digits to dial.
207 +Example context for incoming calls on MSN 12345678:
208 +===================================================
211 +exten => 12345678,1,Dial(SIP/phone1)
212 +exten => 12345678,2,Hangup
215 +More information/documentation and commercial support can be found at:
216 + http://www.junghanns.net/asterisk/
220 diff -urN asterisk-1.2.7.1.orig/agi/Makefile asterisk-1.2.7.1/agi/Makefile
221 --- asterisk-1.2.7.1.orig/agi/Makefile 2006-03-28 22:22:05.000000000 +0200
222 +++ asterisk-1.2.7.1/agi/Makefile 2006-04-18 14:39:28.000000000 +0200
224 # the GNU General Public License
227 -AGIS=agi-test.agi eagi-test eagi-sphinx-test
228 +AGIS=agi-test.agi eagi-test eagi-sphinx-test xagi-test
233 $(CC) $(CFLAGS) -o eagi-sphinx-test eagi-sphinx-test.o $(LIBS)
236 - rm -f *.so *.o look .depend eagi-test eagi-sphinx-test
237 + rm -f *.so *.o look .depend eagi-test eagi-sphinx-test xagi-test
240 $(CC) -shared -Xlinker -x -o $@ $<
241 diff -urN asterisk-1.2.7.1.orig/agi/xagi-test.c asterisk-1.2.7.1/agi/xagi-test.c
242 --- asterisk-1.2.7.1.orig/agi/xagi-test.c 1970-01-01 01:00:00.000000000 +0100
243 +++ asterisk-1.2.7.1/agi/xagi-test.c 2006-04-24 09:55:45.000000000 +0200
246 + * Asterisk -- A telephony toolkit for Linux.
248 + * XAGI sample script
250 + * Copyright (C) 2005 Junghanns.NET GmbH
251 + * Klaus-Peter Junghanns <kpj@junghanns.net>
253 + * based on eagi-test.c
255 + * This program is free software, distributed under the terms of
256 + * the GNU General Public License
264 +#include <sys/select.h>
266 +#include <solaris-compat/compat.h>
269 +#define AUDIO_FILENO_IN (STDERR_FILENO + 1)
270 +#define AUDIO_FILENO_OUT (STDERR_FILENO + 2)
272 +static int read_environment(void)
276 + /* Read environment */
278 + fgets(buf, sizeof(buf), stdin);
281 + buf[strlen(buf) - 1] = '\0';
282 + /* Check for end of environment */
285 + val = strchr(buf, ':');
287 + fprintf(stderr, "Invalid environment: '%s'\n", buf);
294 + // fprintf(stderr, "Environment: '%s' is '%s'\n", buf, val);
296 + /* Load into normal environment */
297 + setenv(buf, val, 1);
300 + /* Never reached */
304 +static void app_echo(void)
309 + static char astresp[256];
310 + char audiobuf[16000]; /* 1 second of audio */
313 + FD_SET(STDIN_FILENO, &fds);
314 + FD_SET(AUDIO_FILENO_IN, &fds);
315 + /* Wait for *some* sort of I/O */
316 + res = select(AUDIO_FILENO_IN + 1, &fds, NULL, NULL, NULL);
318 + fprintf(stderr, "Error in select: %s\n", strerror(errno));
321 + if (FD_ISSET(STDIN_FILENO, &fds)) {
322 + fgets(astresp, sizeof(astresp), stdin);
326 + astresp[strlen(astresp) - 1] = '\0';
327 + fprintf(stderr, "Ooh, got a response from Asterisk: '%s'\n", astresp);
330 + if (FD_ISSET(AUDIO_FILENO_IN, &fds)) {
331 + /* what goes in.... */
332 + res = read(AUDIO_FILENO_IN, audiobuf, sizeof(audiobuf));
335 + /* must come out */
336 + write(AUDIO_FILENO_OUT, audiobuf, bytes);
342 +static char *wait_result(void)
346 + static char astresp[256];
347 + char audiobuf[4096];
350 + FD_SET(STDIN_FILENO, &fds);
351 + FD_SET(AUDIO_FILENO_IN, &fds);
352 + /* Wait for *some* sort of I/O */
353 + res = select(AUDIO_FILENO_IN + 1, &fds, NULL, NULL, NULL);
355 + fprintf(stderr, "Error in select: %s\n", strerror(errno));
358 + if (FD_ISSET(STDIN_FILENO, &fds)) {
359 + fgets(astresp, sizeof(astresp), stdin);
361 + fprintf(stderr, "Got hungup on apparently\n");
364 + astresp[strlen(astresp) - 1] = '\0';
365 + fprintf(stderr, "Ooh, got a response from Asterisk: '%s'\n", astresp);
368 + if (FD_ISSET(AUDIO_FILENO_IN, &fds)) {
369 + res = read(AUDIO_FILENO_IN, audiobuf, sizeof(audiobuf));
370 + /* drop it, like it's hot */
376 +static char *run_command(char *command)
378 + fprintf(stdout, "%s\n", command);
379 + return wait_result();
383 +static int run_script(void)
386 + res = run_command("STREAM FILE demo-echotest \"\"");
388 + fprintf(stderr, "Failed to execute command\n");
395 +int main(int argc, char *argv[])
400 + /* Setup stdin/stdout for line buffering */
402 + setlinebuf(stdout);
403 + if (read_environment()) {
404 + fprintf(stderr, "Failed to read environment: %s\n", strerror(errno));
407 + tmp = getenv("agi_enhanced");
409 + if (sscanf(tmp, "%d.%d", &ver, &subver) != 2)
413 + fprintf(stderr, "No XAGI services available. Use XAGI, not AGI or EAGI\n");
420 diff -urN asterisk-1.2.7.1.orig/apps/Makefile asterisk-1.2.7.1/apps/Makefile
421 --- asterisk-1.2.7.1.orig/apps/Makefile 2006-02-09 03:31:21.000000000 +0100
422 +++ asterisk-1.2.7.1/apps/Makefile 2006-04-18 14:39:28.000000000 +0200
424 app_test.so app_forkcdr.so app_math.so app_realtime.so \
425 app_dumpchan.so app_waitforsilence.so app_while.so app_setrdnis.so \
426 app_md5.so app_readfile.so app_chanspy.so app_settransfercapability.so \
427 + app_pickup.so app_segfault.so app_callingpres.so app_devstate.so \
428 app_dictate.so app_externalivr.so app_directed_pickup.so \
429 - app_mixmonitor.so app_stack.so
430 + app_mixmonitor.so app_stack.so
433 +ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/capi20.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/capi20.h),)
434 + APPS+= app_capiNoES.so app_capiCD.so app_capiECT.so
440 diff -urN asterisk-1.2.7.1.orig/apps/app_callingpres.c asterisk-1.2.7.1/apps/app_callingpres.c
441 --- asterisk-1.2.7.1.orig/apps/app_callingpres.c 1970-01-01 01:00:00.000000000 +0100
442 +++ asterisk-1.2.7.1/apps/app_callingpres.c 2006-04-18 14:39:28.000000000 +0200
445 + * An application to change the CallingPresentation for an Asterisk channel.
447 + * Copyright (C) 2005 Junghanns.NET GmbH
448 + * Klaus-Peter Junghanns <kpj@junghanns.net>
450 + * This program is free software, distributed under the terms of
451 + * the GNU General Public License.
459 +#include <asterisk/lock.h>
460 +#include <asterisk/file.h>
461 +#include <asterisk/logger.h>
462 +#include <asterisk/channel.h>
463 +#include <asterisk/pbx.h>
464 +#include <asterisk/module.h>
466 +static char *synopsis_callingpres = "Change the presentation for the callerid";
467 +static char *descrip_callingpres = "Callingpres(number): Changes the presentation for the callerid. Should be called before placing an outgoing call\n";
468 +static char *app_callingpres = "CallingPres";
469 +STANDARD_LOCAL_USER;
473 +static int change_callingpres(struct ast_channel *chan, void *data)
476 + struct localuser *u;
479 + mode = atoi((char *)data);
480 + chan->cid.cid_pres = mode;
482 + ast_log(LOG_NOTICE, "Application %s requres an argument: %s(number)\n", app_callingpres,app_callingpres);
483 + LOCAL_USER_REMOVE(u);
487 +int unload_module(void)
489 + STANDARD_HANGUP_LOCALUSERS;
490 + return ast_unregister_application(app_callingpres);
493 +int load_module(void)
495 + return ast_register_application(app_callingpres, change_callingpres, synopsis_callingpres, descrip_callingpres);
498 +char *description(void)
500 + return descrip_callingpres;
506 + STANDARD_USECOUNT(res);
512 + return ASTERISK_GPL_KEY;
514 diff -urN asterisk-1.2.7.1.orig/apps/app_capiCD.c asterisk-1.2.7.1/apps/app_capiCD.c
515 --- asterisk-1.2.7.1.orig/apps/app_capiCD.c 1970-01-01 01:00:00.000000000 +0100
516 +++ asterisk-1.2.7.1/apps/app_capiCD.c 2006-04-18 14:39:28.000000000 +0200
521 + * An implementation of Common ISDN API 2.0 for Asterisk
523 + * Call Deflection, inspired by capircvd by Alexander Brickwedde
525 + * Copyright (C) 2002,2003,2004,2005 Junghanns.NET GmbH
527 + * Klaus-Peter Junghanns <kapejod@ns1.jnetdns.de>
529 + * This program is free software and may be modified and
530 + * distributed under the terms of the GNU Public License.
537 +#include <linux/capi.h>
540 +#include <asterisk/file.h>
541 +#include <asterisk/logger.h>
542 +#include <asterisk/channel.h>
543 +#include <asterisk/pbx.h>
544 +#include <asterisk/module.h>
545 +#include <asterisk/chan_capi.h>
546 +#include <asterisk/chan_capi_app.h>
550 +static char *tdesc = "(CAPI*) Call Deflection, the magic thing.";
551 +static char *app = "capiCD";
552 +static char *synopsis = "call deflection";
554 +STANDARD_LOCAL_USER;
558 +static int capiCD_exec(struct ast_channel *chan, void *data)
560 + struct ast_capi_pvt *i = chan->tech_pvt;
561 + MESSAGE_EXCHANGE_ERROR Info;
567 + struct localuser *u;
570 + ast_log(LOG_WARNING, "cd requires an argument (destination phone number)\n");
574 + /* Do our thing here */
576 + if ((i->state == CAPI_STATE_CONNECTED) || (i->state == CAPI_STATE_BCONNECTED)) {
577 + ast_log(LOG_ERROR, "call deflection does not work with calls that are already connected!\n");
578 + LOCAL_USER_REMOVE(u);
581 + // wait until the channel is alerting, so we dont drop the call and interfer with msgs
582 + while ((ms > 0) && (i->state != CAPI_STATE_ALERTING)) {
587 + // make sure we hang up correctly
588 + i->state = CAPI_STATE_CONNECTPENDING;
592 + fac[2]=0x01; // Use D-Chan
593 + fac[3]=0; // Keypad len
594 + fac[4]=31; // user user data? len = 31 = 29 + 2
595 + fac[5]=0x1c; // magic?
596 + fac[6]=0x1d; // strlen destination + 18 = 29
599 + fac[9]=0x1A; // strlen destination + 15 = 26
607 + fac[17]=0x12; // strlen destination + 7 = 18
608 + fac[18]=0x30; // ...hm 0x30
609 + fac[19]=0x0d; // strlen destination + 2
610 + fac[20]=0x80; // CLIP
611 + fac[21]=0x0b; // strlen destination
612 + fac[22]=0x01; // destination start
623 + fac[33]=0x01; // 0x1 = sending complete
627 + memcpy((unsigned char *)fac+22,data,strlen(data));
628 + fac[22+strlen(data)]=0x01; // fill with 0x01 if number is only 6 numbers (local call)
629 + fac[23+strlen(data)]=0x01;
630 + fac[24+strlen(data)]=0x01;
631 + fac[25+strlen(data)]=0x01;
632 + fac[26+strlen(data)]=0x01;
634 + fac[6]=18+strlen(data);
635 + fac[9]=15+strlen(data);
636 + fac[17]=7+strlen(data);
637 + fac[19]=2+strlen(data);
638 + fac[21]=strlen(data);
640 + bchaninfo[0] = 0x1;
641 + INFO_REQ_HEADER(&CMSG,ast_capi_ApplID,ast_capi_MessageNumber++,0);
642 + INFO_REQ_CONTROLLER(&CMSG) = i->controller;
643 + INFO_REQ_PLCI(&CMSG) = i->PLCI;
644 + INFO_REQ_BCHANNELINFORMATION(&CMSG) = (unsigned char*)bchaninfo; // use D-Channel
645 + INFO_REQ_KEYPADFACILITY(&CMSG) = 0;
646 + INFO_REQ_USERUSERDATA(&CMSG) = 0;
647 + INFO_REQ_FACILITYDATAARRAY(&CMSG) = (unsigned char*) fac + 4;
649 + if ((Info = _capi_put_cmsg(&CMSG)) != 0) {
650 + ast_log(LOG_ERROR,"Error sending INFO_REQ\n");
654 + // ast_log(LOG_NOTICE,"%s\n",capi_cmsg2str(&CMSG));
655 + ast_log(LOG_NOTICE,"sent INFO_REQ PLCI = %#x\n",i->PLCI);
659 + LOCAL_USER_REMOVE(u);
663 +int unload_module(void)
665 + STANDARD_HANGUP_LOCALUSERS;
666 + return ast_unregister_application(app);
669 +int load_module(void)
671 + return ast_register_application(app, capiCD_exec,synopsis,tdesc);
674 +char *description(void)
682 + STANDARD_USECOUNT(res);
688 + return ASTERISK_GPL_KEY;
690 diff -urN asterisk-1.2.7.1.orig/apps/app_capiECT.c asterisk-1.2.7.1/apps/app_capiECT.c
691 --- asterisk-1.2.7.1.orig/apps/app_capiECT.c 1970-01-01 01:00:00.000000000 +0100
692 +++ asterisk-1.2.7.1/apps/app_capiECT.c 2006-04-18 14:39:28.000000000 +0200
697 + * An implementation of Common ISDN API 2.0 for Asterisk
699 + * ECT transfer the held call
701 + * Copyright (C) 2002,2003,2004,2005 Junghanns.NET GmbH
703 + * Klaus-Peter Junghanns <kapejod@ns1.jnetdns.de>
705 + * This program is free software and may be modified and
706 + * distributed under the terms of the GNU Public License.
713 +#include <linux/capi.h>
715 +#include <asterisk/file.h>
716 +#include <asterisk/logger.h>
717 +#include <asterisk/channel.h>
718 +#include <asterisk/pbx.h>
719 +#include <asterisk/module.h>
720 +#include <asterisk/say.h>
721 +#include <asterisk/chan_capi.h>
722 +#include <asterisk/chan_capi_app.h>
725 +static char *tdesc = "(CAPI*) ECT";
726 +static char *app = "capiECT";
727 +static char *synopsis = "transfer the call that is on hold";
729 +STANDARD_LOCAL_USER;
734 +static int capiECT_exec(struct ast_channel *chan, void *data)
736 + struct ast_capi_pvt *i = chan->tech_pvt;
737 + MESSAGE_EXCHANGE_ERROR Info;
739 + unsigned char fac[8];
741 + struct localuser *u;
742 + char *ecodes = "*#";
745 + ast_log(LOG_WARNING, "ECT requires an argument (destination phone number)\n");
749 + /* Do our thing here */
750 + if (i->onholdPLCI <= 0) {
751 + ast_log(LOG_WARNING, "no call on hold that could be transfered\n");
755 + ast_log(LOG_NOTICE,"ECT to %s\n",(char *)data);
756 + capi_call(chan,data,0);
758 + while ((i->state != CAPI_STATE_BCONNECTED) && (i->onholdPLCI != 0)) {
763 + if (i->state == CAPI_STATE_BCONNECTED) {
764 + ast_log(LOG_NOTICE,"call was answered\n");
766 + capi_detect_dtmf(chan,1);
768 + // put the stuff to play announcement message here ---> <-----
769 + res = ast_say_digit_str(chan,i->cid,ecodes,chan->language);
771 + ast_log(LOG_NOTICE,"res = %d\n",res);
772 + // user pressed #, hangup
773 + // first the holded user
774 +// ast_exec("capiRETRIEVE",chan);
776 + DISCONNECT_REQ_HEADER(&CMSG, ast_capi_ApplID, ast_capi_MessageNumber++, 0);
777 + DISCONNECT_REQ_PLCI(&CMSG) = i->onholdPLCI;
779 + if ((Info = _capi_put_cmsg(&CMSG)) != 0) {
780 + ast_log(LOG_NOTICE, "error sending DISCONNECT_REQ PLCI=%#x\n",i->onholdPLCI);
782 + ast_log(LOG_NOTICE, "sent DISCONNECT_REQ PLCI=%#x\n",i->onholdPLCI);
785 + // then the destination
787 + DISCONNECT_B3_REQ_HEADER(&CMSG, ast_capi_ApplID, ast_capi_MessageNumber++, 0);
788 + DISCONNECT_B3_REQ_NCCI(&CMSG) = i->NCCI;
790 + if ((Info = _capi_put_cmsg(&CMSG)) != 0) {
791 + ast_log(LOG_NOTICE, "error sending DISCONNECT_B3_REQ NCCI=%#x\n",i->NCCI);
793 + ast_log(LOG_NOTICE, "sent DISCONNECT_B3_REQ NCCI=%#x\n",i->NCCI);
796 + // wait for the B3 layer to go down
797 + while (i->state != CAPI_STATE_CONNECTED) {
801 + DISCONNECT_REQ_HEADER(&CMSG, ast_capi_ApplID, ast_capi_MessageNumber++, 0);
802 + DISCONNECT_REQ_PLCI(&CMSG) = i->PLCI;
804 + if ((Info = _capi_put_cmsg(&CMSG)) != 0) {
805 + ast_log(LOG_NOTICE, "error sending DISCONNECT_REQ PLCI=%#x\n",i->PLCI);
807 + ast_log(LOG_NOTICE, "sent DISCONNECT_REQ PLCI=%#x\n",i->PLCI);
811 + LOCAL_USER_REMOVE(u);
815 + // now drop the bchannel
816 + DISCONNECT_B3_REQ_HEADER(&CMSG, ast_capi_ApplID, ast_capi_MessageNumber++, 0);
817 + DISCONNECT_B3_REQ_NCCI(&CMSG) = i->NCCI;
819 + if ((Info = _capi_put_cmsg(&CMSG)) != 0) {
820 + ast_log(LOG_NOTICE, "error sending DISCONNECT_B3_REQ NCCI=%#x\n",i->NCCI);
822 + ast_log(LOG_NOTICE, "sent DISCONNECT_B3_REQ NCCI=%#x\n",i->NCCI);
825 + // wait for the B3 layer to go down
826 + while (i->state != CAPI_STATE_CONNECTED) {
832 + // the caller onhold hungup or died away, drop the answered call
833 + if (i->onholdPLCI == 0) {
834 + DISCONNECT_REQ_HEADER(&CMSG, ast_capi_ApplID, ast_capi_MessageNumber++, 0);
835 + DISCONNECT_REQ_PLCI(&CMSG) = i->PLCI;
837 + if ((Info = _capi_put_cmsg(&CMSG)) != 0) {
838 + ast_log(LOG_NOTICE, "error sending DISCONNECT_REQ PLCI=%#x\n",i->PLCI);
840 + ast_log(LOG_NOTICE, "sent DISCONNECT_REQ PLCI=%#x\n",i->PLCI);
845 + ast_log(LOG_NOTICE,"onholdPLCI = %d\n",i->onholdPLCI);
849 + fac[1] = 0x06; // ECT (function)
851 + fac[3] = 4; //len //sservice specific parameter , cstruct
852 + fac[4] = (i->onholdPLCI << 8 ) >> 8;
853 + fac[5] = i->onholdPLCI >> 8;
857 + FACILITY_REQ_HEADER(&CMSG,ast_capi_ApplID,ast_capi_MessageNumber++,0);
858 + FACILITY_REQ_CONTROLLER(&CMSG) = i->controller;
859 + FACILITY_REQ_PLCI(&CMSG) = i->onholdPLCI;
860 + FACILITY_REQ_FACILITYSELECTOR(&CMSG) = 0x0003; // sservices
861 + FACILITY_REQ_FACILITYREQUESTPARAMETER(&CMSG) = (unsigned char *)&fac;
863 + if ((Info = _capi_put_cmsg(&CMSG)) != 0) {
864 + ast_log(LOG_ERROR,"Error sending FACILITY_REQ\n");
867 + ast_log(LOG_NOTICE,"sent FACILITY_REQ PLCI = %#x (%#x %#x) onholdPLCI = %#x\n ",i->PLCI,fac[4],fac[5],i->onholdPLCI);
868 + ast_log(LOG_NOTICE,"%s\n",capi_cmsg2str(&CMSG));
871 +// i->outgoing = -1; // incoming + outgoing, this is a magic channel :)
873 + LOCAL_USER_REMOVE(u);
877 +int unload_module(void)
879 + STANDARD_HANGUP_LOCALUSERS;
880 + return ast_unregister_application(app);
883 +int load_module(void)
885 + return ast_register_application(app, capiECT_exec,synopsis,tdesc);
888 +char *description(void)
896 + STANDARD_USECOUNT(res);
902 + return ASTERISK_GPL_KEY;
904 diff -urN asterisk-1.2.7.1.orig/apps/app_capiNoES.c asterisk-1.2.7.1/apps/app_capiNoES.c
905 --- asterisk-1.2.7.1.orig/apps/app_capiNoES.c 1970-01-01 01:00:00.000000000 +0100
906 +++ asterisk-1.2.7.1/apps/app_capiNoES.c 2006-04-18 14:39:28.000000000 +0200
911 + * An implementation of Common ISDN API 2.0 for Asterisk
913 + * Disable echo suppression (useful for fax and voicemail!)
915 + * Copyright (C) 2004,2005 Junghanns.NET GmbH
917 + * Klaus-Peter Junghanns <kapejod@ns1.jnetdns.de>
919 + * This program is free software and may be modified and
920 + * distributed under the terms of the GNU Public License.
927 +#include <linux/capi.h>
930 +#include <asterisk/file.h>
931 +#include <asterisk/logger.h>
932 +#include <asterisk/channel.h>
933 +#include <asterisk/pbx.h>
934 +#include <asterisk/module.h>
935 +#include <asterisk/chan_capi_app.h>
940 +static char *tdesc = "(CAPI*) No Echo Suppression.";
941 +static char *app = "capiNoES";
942 +static char *synopsis = "Disable Echo Suppression";
944 +static char *tdesc = "(CAPI*) No Echo Suppression at all!";
945 +static char *app = "capiNoES";
946 +static char *synopsis = "Bogus Application";
948 +STANDARD_LOCAL_USER;
952 +static int capiNoES_exec(struct ast_channel *chan, void *data)
955 + struct localuser *u;
959 + if (strcasecmp("CAPI",chan->type) == 0) {
961 + struct ast_capi_pvt *i = chan->tech_pvt;
963 + struct ast_capi_pvt *i = chan->pvt->pvt;
965 + if (i->doES == 1) {
969 + ast_log(LOG_WARNING, "capiNoES only works on CAPI channels, check your extensions.conf!\n");
973 + LOCAL_USER_REMOVE(u);
977 +int unload_module(void)
979 + STANDARD_HANGUP_LOCALUSERS;
980 + return ast_unregister_application(app);
983 +int load_module(void)
985 + return ast_register_application(app, capiNoES_exec,synopsis,tdesc);
988 +char *description(void)
996 + STANDARD_USECOUNT(res);
1002 + return ASTERISK_GPL_KEY;
1004 diff -urN asterisk-1.2.7.1.orig/apps/app_chanisavail.c asterisk-1.2.7.1/apps/app_chanisavail.c
1005 --- asterisk-1.2.7.1.orig/apps/app_chanisavail.c 2005-11-29 19:24:39.000000000 +0100
1006 +++ asterisk-1.2.7.1/apps/app_chanisavail.c 2006-04-18 14:39:28.000000000 +0200
1008 snprintf(trychan, sizeof(trychan), "%s/%s",cur,number);
1009 status = inuse = ast_device_state(trychan);
1011 - if ((inuse <= 1) && (tempchan = ast_request(tech, chan->nativeformats, number, &status))) {
1012 + if ((inuse <= 1) && (tempchan = ast_request(tech, chan->nativeformats, number, &status, NULL))) {
1013 pbx_builtin_setvar_helper(chan, "AVAILCHAN", tempchan->name);
1014 /* Store the originally used channel too */
1015 snprintf(tmp, sizeof(tmp), "%s/%s", tech, number);
1016 diff -urN asterisk-1.2.7.1.orig/apps/app_devstate.c asterisk-1.2.7.1/apps/app_devstate.c
1017 --- asterisk-1.2.7.1.orig/apps/app_devstate.c 1970-01-01 01:00:00.000000000 +0100
1018 +++ asterisk-1.2.7.1/apps/app_devstate.c 2006-04-18 14:39:28.000000000 +0200
1021 + * Devstate application
1023 + * Since we like the snom leds so much, a little app to
1024 + * light the lights on the snom on demand ....
1026 + * Copyright (C) 2005, Druid Software
1028 + * This program is free software, distributed under the terms of
1029 + * the GNU General Public License
1032 +#include <stdlib.h>
1033 +#include <unistd.h>
1034 +#include <string.h>
1036 +#include <asterisk/lock.h>
1037 +#include <asterisk/file.h>
1038 +#include <asterisk/logger.h>
1039 +#include <asterisk/channel.h>
1040 +#include <asterisk/pbx.h>
1041 +#include <asterisk/module.h>
1042 +#include <asterisk/astdb.h>
1043 +#include <asterisk/utils.h>
1044 +#include <asterisk/cli.h>
1045 +#include <asterisk/manager.h>
1046 +#include <asterisk/devicestate.h>
1049 +static char type[] = "DS";
1050 +static char tdesc[] = "Application for sending device state messages";
1052 +static char app[] = "Devstate";
1054 +static char synopsis[] = "Generate a device state change event given the input parameters";
1056 +static char descrip[] = " Devstate(device|state): Generate a device state change event given the input parameters. Returns 0. State values match the asterisk device states. They are 0 = unknown, 1 = not inuse, 2 = inuse, 3 = busy, 4 = invalid, 5 = unavailable, 6 = ringing\n";
1058 +static char devstate_cli_usage[] =
1059 +"Usage: devstate device state\n"
1060 +" Generate a device state change event given the input parameters.\n Mainly used for lighting the LEDs on the snoms.\n";
1062 +static int devstate_cli(int fd, int argc, char *argv[]);
1063 +static struct ast_cli_entry cli_dev_state =
1064 + { { "devstate", NULL }, devstate_cli, "Set the device state on one of the \"pseudo devices\".", devstate_cli_usage };
1066 +STANDARD_LOCAL_USER;
1071 +static int devstate_cli(int fd, int argc, char *argv[])
1073 + char devName[128];
1074 + if ((argc != 3) && (argc != 4))
1075 + return RESULT_SHOWUSAGE;
1077 + if (ast_db_put("DEVSTATES", argv[1], argv[2]))
1079 + ast_log(LOG_DEBUG, "ast_db_put failed\n");
1081 + snprintf(devName, sizeof(devName), "DS/%s", argv[1]);
1083 + ast_log(LOG_NOTICE, "devname %s cid %s\n", devName, argv[3]);
1084 + ast_device_state_changed_literal(devName, argv[3], NULL);
1086 + ast_device_state_changed_literal(devName, NULL, NULL);
1088 + return RESULT_SUCCESS;
1091 +static int devstate_exec(struct ast_channel *chan, void *data)
1093 + struct localuser *u;
1094 + char *device, *state, *info;
1095 + char devName[128];
1096 + if (!(info = ast_strdupa(data))) {
1097 + ast_log(LOG_WARNING, "Unable to dupe data :(\n");
1100 + LOCAL_USER_ADD(u);
1103 + state = strchr(info, '|');
1110 + ast_log(LOG_DEBUG, "No state argument supplied\n");
1114 + if (ast_db_put("DEVSTATES", device, state))
1116 + ast_log(LOG_DEBUG, "ast_db_put failed\n");
1119 + snprintf(devName, sizeof(devName), "DS/%s", device);
1120 + ast_device_state_changed_literal(devName, NULL, NULL);
1122 + LOCAL_USER_REMOVE(u);
1127 +static int ds_devicestate(void *data)
1129 + char *dest = data;
1130 + char stateStr[16];
1131 + if (ast_db_get("DEVSTATES", dest, stateStr, sizeof(stateStr)))
1133 + ast_log(LOG_DEBUG, "ds_devicestate couldnt get state in astdb\n");
1138 + ast_log(LOG_DEBUG, "ds_devicestate dev=%s returning state %d\n",
1139 + dest, atoi(stateStr));
1140 + return (atoi(stateStr));
1144 +static struct ast_channel_tech devstate_tech = {
1146 + .description = tdesc,
1147 + .capabilities = ((AST_FORMAT_MAX_AUDIO << 1) - 1),
1148 + .devicestate = ds_devicestate,
1149 + .requester = NULL,
1150 + .send_digit = NULL,
1151 + .send_text = NULL,
1158 + .exception = NULL,
1161 + .setoption = NULL,
1164 +static char mandescr_devstate[] =
1165 +"Description: Put a value into astdb\n"
1171 +static int action_devstate(struct mansession *s, struct message *m)
1173 + char *devstate = astman_get_header(m, "Devstate");
1174 + char *value = astman_get_header(m, "Value");
1175 + char *id = astman_get_header(m,"ActionID");
1176 + char devName[128];
1178 + if (!strlen(devstate)) {
1179 + astman_send_error(s, m, "No Devstate specified");
1182 + if (!strlen(value)) {
1183 + astman_send_error(s, m, "No Value specified");
1187 + if (!ast_db_put("DEVSTATES", devstate, value)) {
1188 + snprintf(devName, sizeof(devName), "DS/%s", devstate);
1189 + ast_device_state_changed(devName);
1190 + ast_cli(s->fd, "Response: Success\r\n");
1192 + ast_log(LOG_DEBUG, "ast_db_put failed\n");
1193 + ast_cli(s->fd, "Response: Failed\r\n");
1195 + if (id && !ast_strlen_zero(id))
1196 + ast_cli(s->fd, "ActionID: %s\r\n",id);
1197 + ast_cli(s->fd, "\r\n");
1201 +int load_module(void)
1203 + if (ast_channel_register(&devstate_tech)) {
1204 + ast_log(LOG_DEBUG, "Unable to register channel class %s\n", type);
1207 + ast_cli_register(&cli_dev_state);
1208 + ast_manager_register2( "Devstate", EVENT_FLAG_CALL, action_devstate, "Change a device state", mandescr_devstate );
1209 + return ast_register_application(app, devstate_exec, synopsis, descrip);
1212 +int unload_module(void)
1215 + STANDARD_HANGUP_LOCALUSERS;
1216 + ast_manager_unregister( "Devstate");
1217 + ast_cli_unregister(&cli_dev_state);
1218 + res = ast_unregister_application(app);
1219 + ast_channel_unregister(&devstate_tech);
1223 +char *description(void)
1231 + STANDARD_USECOUNT(res);
1237 + return ASTERISK_GPL_KEY;
1239 diff -urN asterisk-1.2.7.1.orig/apps/app_dial.c asterisk-1.2.7.1/apps/app_dial.c
1240 --- asterisk-1.2.7.1.orig/apps/app_dial.c 2006-04-12 00:39:59.000000000 +0200
1241 +++ asterisk-1.2.7.1/apps/app_dial.c 2006-04-18 14:40:13.000000000 +0200
1243 * the project provides a web site, mailing lists and IRC
1244 * channels for your use.
1246 + * Copyright (C) 2004, Junghanns.NET GmbH
1248 + * Klaus-Peter Junghanns <kpj@junghanns.net>
1250 * This program is free software, distributed under the terms of
1251 * the GNU General Public License Version 2. See the LICENSE file
1252 * at the top of the source tree.
1254 " Otherwise, the current extension is used.\n"
1255 " h - Allow the called party to hang up by sending the '*' DTMF digit.\n"
1256 " H - Allow the calling party to hang up by hitting the '*' DTMF digit.\n"
1257 -" j - Jump to priority n+101 if all of the requested channels were busy.\n"
1258 +" j - Jump to priority n+101 if the called party was busy.\n"
1259 +" Jump to priority n+201 if all of the requested channels were busy.\n"
1260 " L(x[:y][:z]) - Limit the call to 'x' ms. Play a warning when 'y' ms are\n"
1261 " left. Repeat the warning every 'z' ms. The following special\n"
1262 " variables can be used with this option:\n"
1263 @@ -159,8 +164,11 @@
1264 " family/key is not specified.\n"
1265 " r - Indicate ringing to the calling party. Pass no audio to the calling\n"
1266 " party until the called channel has answered.\n"
1267 +" R - indicate ringing to the calling party when the called party indicates\n"
1268 +" ringing, pass no audio until answered.\n"
1269 " S(x) - Hang up the call after 'x' seconds *after* the called party has\n"
1270 -" answered the call.\n"
1271 +" answered the call.\n"
1272 +" c - callback initiation, ring once and hangup.\n"
1273 " t - Allow the called party to transfer the calling party by sending the\n"
1274 " DTMF sequence defined in features.conf.\n"
1275 " T - Allow the calling party to transfer the called party by sending the\n"
1277 OPT_CALLEE_MONITOR = (1 << 21),
1278 OPT_CALLER_MONITOR = (1 << 22),
1279 OPT_GOTO = (1 << 23),
1280 + OPT_NOINBAND = (1 << 24),
1281 + OPT_CALLBACK_INIT = (1 << 25),
1282 } dial_exec_option_flags;
1284 #define DIAL_STILLGOING (1 << 30)
1286 AST_APP_OPTION('p', OPT_SCREENING),
1287 AST_APP_OPTION_ARG('P', OPT_PRIVACY, OPT_ARG_PRIVACY),
1288 AST_APP_OPTION('r', OPT_RINGBACK),
1289 + AST_APP_OPTION('R', OPT_NOINBAND),
1290 + AST_APP_OPTION('c', OPT_CALLBACK_INIT),
1291 AST_APP_OPTION_ARG('S', OPT_DURATION_STOP, OPT_ARG_DURATION_STOP),
1292 AST_APP_OPTION('t', OPT_CALLEE_TRANSFER),
1293 AST_APP_OPTION('T', OPT_CALLER_TRANSFER),
1295 char *context = NULL;
1296 char cidname[AST_MAX_EXTENSION];
1298 - single = (outgoing && !outgoing->next && !ast_test_flag(outgoing, OPT_MUSICBACK | OPT_RINGBACK));
1299 + single = (outgoing && !outgoing->next && !ast_test_flag(outgoing, OPT_MUSICBACK | OPT_RINGBACK | OPT_NOINBAND));
1302 /* Turn off hold music, etc */
1304 if (option_verbose > 2)
1305 ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", in->name, tech, stuff, o->chan->name);
1306 /* Setup parameters */
1307 - o->chan = ast_request(tech, in->nativeformats, stuff, &cause);
1308 + o->chan = ast_request(tech, in->nativeformats, stuff, &cause, NULL);
1310 ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause);
1312 @@ -581,12 +593,18 @@
1313 HANDLE_CAUSE(AST_CAUSE_CONGESTION, in);
1315 case AST_CONTROL_RINGING:
1316 - if (option_verbose > 2)
1317 - ast_verbose( VERBOSE_PREFIX_3 "%s is ringing\n", o->chan->name);
1318 - if (!(*sentringing) && !ast_test_flag(outgoing, OPT_MUSICBACK)) {
1319 - ast_indicate(in, AST_CONTROL_RINGING);
1322 + if (ast_test_flag(peerflags, OPT_CALLBACK_INIT)) {
1323 + if (option_verbose > 2)
1324 + ast_verbose( VERBOSE_PREFIX_3 "%s is ringing, hanging up.\n", o->chan->name);
1327 + if (option_verbose > 2)
1328 + ast_verbose( VERBOSE_PREFIX_3 "%s is ringing\n", o->chan->name);
1329 + if (!(*sentringing) && !ast_test_flag(outgoing, OPT_MUSICBACK)) {
1330 + ast_indicate(in, AST_CONTROL_RINGING);
1335 case AST_CONTROL_PROGRESS:
1336 if (option_verbose > 2)
1338 int digit = 0, result = 0;
1339 time_t start_time, answer_time, end_time;
1340 struct ast_app *app = NULL;
1344 AST_DECLARE_APP_ARGS(args,
1345 @@ -934,17 +953,24 @@
1348 if( privdb_val == AST_PRIVACY_DENY ) {
1349 + ast_copy_string(status, "NOANSWER", sizeof(status));
1350 ast_verbose( VERBOSE_PREFIX_3 "Privacy DB reports PRIVACY_DENY for this callerid. Dial reports unavailable\n");
1354 else if( privdb_val == AST_PRIVACY_KILL ) {
1355 - ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 201);
1356 + ast_copy_string(status, "DONTCALL", sizeof(status));
1357 + if (option_priority_jumping || ast_test_flag(&opts, OPT_PRIORITY_JUMP)) {
1358 + ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 201);
1361 goto out; /* Is this right? */
1363 else if( privdb_val == AST_PRIVACY_TORTURE ) {
1364 - ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 301);
1365 + ast_copy_string(status, "TORTURE", sizeof(status));
1366 + if (option_priority_jumping || ast_test_flag(&opts, OPT_PRIORITY_JUMP)) {
1367 + ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 301);
1370 goto out; /* is this right??? */
1372 @@ -981,7 +1007,7 @@
1373 /* If a channel group has been specified, get it for use when we create peer channels */
1374 outbound_group = pbx_builtin_getvar_helper(chan, "OUTBOUND_GROUP");
1376 - ast_copy_flags(peerflags, &opts, OPT_DTMF_EXIT | OPT_GO_ON | OPT_ORIGINAL_CLID | OPT_CALLER_HANGUP);
1377 + ast_copy_flags(peerflags, &opts, OPT_DTMF_EXIT | OPT_GO_ON | OPT_ORIGINAL_CLID | OPT_CALLER_HANGUP| OPT_CALLBACK_INIT | OPT_NOINBAND);
1380 /* Remember where to start next time */
1381 @@ -1023,7 +1049,7 @@
1382 ast_log(LOG_DEBUG, "Dialing by extension %s\n", numsubst);
1384 /* Request the peer */
1385 - tmp->chan = ast_request(tech, chan->nativeformats, numsubst, &cause);
1386 + tmp->chan = ast_request(tech, chan->nativeformats, numsubst, &cause, NULL);
1388 /* If we can't, just go on to the next call */
1389 ast_log(LOG_NOTICE, "Unable to create channel of type '%s' (cause %d - %s)\n", tech, cause, ast_cause2str(cause));
1390 @@ -1054,7 +1080,7 @@
1391 ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", chan->name, tech, stuff, tmp->chan->name);
1392 ast_hangup(tmp->chan);
1393 /* Setup parameters */
1394 - tmp->chan = ast_request(tech, chan->nativeformats, stuff, &cause);
1395 + tmp->chan = ast_request(tech, chan->nativeformats, stuff, &cause, NULL);
1397 ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause);
1399 @@ -1173,8 +1199,11 @@
1400 ast_indicate(chan, AST_CONTROL_RINGING);
1405 strcpy(status, "CHANUNAVAIL");
1406 + /* See if there is a special message */
1407 + ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 201);
1411 peer = wait_for_answer(chan, outgoing, &to, peerflags, &sentringing, status, sizeof(status), numbusy, numnochan, numcongestion, ast_test_flag(&opts, OPT_PRIORITY_JUMP), &result);
1412 @@ -1303,6 +1332,8 @@
1413 opt_args[OPT_ARG_PRIVACY], privcid);
1414 ast_privacy_set(opt_args[OPT_ARG_PRIVACY], privcid, AST_PRIVACY_DENY);
1416 + ast_copy_string(status, "NOANSWER", sizeof(status));
1418 if (ast_test_flag(&opts, OPT_MUSICBACK)) {
1420 } else if (ast_test_flag(&opts, OPT_RINGBACK)) {
1421 @@ -1585,7 +1616,16 @@
1423 snprintf(toast, sizeof(toast), "%ld", (long)(end_time - start_time));
1424 pbx_builtin_setvar_helper(chan, "DIALEDTIME", toast);
1427 + /* forward AOC-E units from peer, if possible */
1428 + aoceunits = pbx_builtin_getvar_helper(peer, "AOCEUNITS");
1431 + snprintf(toast, sizeof(toast), "%d", atoi(aoceunits));
1432 + // ast_log(LOG_NOTICE, "AOCEUNITS %s\n" , toast);
1433 + pbx_builtin_setvar_helper(chan, "AOCEUNITS", toast);
1436 if (res != AST_PBX_NO_HANGUP_PEER) {
1437 if (!chan->_softhangup)
1438 chan->hangupcause = peer->hangupcause;
1439 diff -urN asterisk-1.2.7.1.orig/apps/app_directed_pickup.c asterisk-1.2.7.1/apps/app_directed_pickup.c
1440 --- asterisk-1.2.7.1.orig/apps/app_directed_pickup.c 2006-04-06 19:00:10.000000000 +0200
1441 +++ asterisk-1.2.7.1/apps/app_directed_pickup.c 2006-04-18 14:39:28.000000000 +0200
1443 #include "asterisk/app.h"
1445 static const char *tdesc = "Directed Call Pickup Application";
1446 -static const char *app = "Pickup";
1447 +static const char *app = "DPickup";
1448 static const char *synopsis = "Directed Call Pickup";
1449 static const char *descrip =
1450 " Pickup(extension[@context]): This application can pickup any ringing channel\n"
1451 diff -urN asterisk-1.2.7.1.orig/apps/app_meetme.c asterisk-1.2.7.1/apps/app_meetme.c
1452 --- asterisk-1.2.7.1.orig/apps/app_meetme.c 2006-04-07 00:15:20.000000000 +0200
1453 +++ asterisk-1.2.7.1/apps/app_meetme.c 2006-04-18 14:39:28.000000000 +0200
1455 ast_copy_string(cnf->pin, pin, sizeof(cnf->pin));
1456 ast_copy_string(cnf->pinadmin, pinadmin, sizeof(cnf->pinadmin));
1457 cnf->markedusers = 0;
1458 - cnf->chan = ast_request("zap", AST_FORMAT_ULAW, "pseudo", NULL);
1459 + cnf->chan = ast_request("zap", AST_FORMAT_ULAW, "pseudo", NULL, NULL);
1461 cnf->fd = cnf->chan->fds[0]; /* for use by conf_play() */
1464 char exitcontext[AST_MAX_CONTEXT] = "";
1465 char recordingtmp[AST_MAX_EXTENSION] = "";
1467 + int dyna_buff = CONF_SIZE;
1469 - char __buf[CONF_SIZE + AST_FRIENDLY_OFFSET];
1470 + char __buf[ZT_MAX_BUF_SPACE / ZT_DEFAULT_NUM_BUFS + AST_FRIENDLY_OFFSET];
1471 char *buf = __buf + AST_FRIENDLY_OFFSET;
1476 /* Setup buffering information */
1477 memset(&bi, 0, sizeof(bi));
1478 - bi.bufsize = CONF_SIZE/2;
1479 + bi.bufsize = dyna_buff / 2;
1480 bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
1481 bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
1482 bi.numbufs = audio_buffers;
1483 @@ -1277,6 +1278,14 @@
1487 + if (f->datalen && f->datalen != dyna_buff) {
1488 + ast_log(LOG_NOTICE, "Audio bytes: %d Buffer size: %d\n", f->datalen, dyna_buff);
1489 + if (f->datalen < ZT_MAX_BUF_SPACE/audio_buffers) { /* skip too large frame to avoid overflow */
1490 + dyna_buff = f->datalen;
1495 if ((f->frametype == AST_FRAME_VOICE) && (f->subclass == AST_FORMAT_SLINEAR)) {
1496 if (user->talk.actual)
1497 ast_frame_adjust_volume(f, user->talk.actual);
1498 @@ -1508,7 +1517,7 @@
1501 } else if (outfd > -1) {
1502 - res = read(outfd, buf, CONF_SIZE);
1503 + res = read(outfd, buf, dyna_buff);
1505 memset(&fr, 0, sizeof(fr));
1506 fr.frametype = AST_FRAME_VOICE;
1507 diff -urN asterisk-1.2.7.1.orig/apps/app_milliwatt.c asterisk-1.2.7.1/apps/app_milliwatt.c
1508 --- asterisk-1.2.7.1.orig/apps/app_milliwatt.c 2006-01-19 05:17:45.000000000 +0100
1509 +++ asterisk-1.2.7.1/apps/app_milliwatt.c 2006-04-18 14:39:28.000000000 +0200
1512 struct ast_frame wf;
1513 unsigned char buf[AST_FRIENDLY_OFFSET + 640];
1514 + const int maxsamples = (sizeof (buf) - AST_FRIENDLY_OFFSET) / sizeof (buf[0]);
1515 int i,*indexp = (int *) data;
1517 - if (len + AST_FRIENDLY_OFFSET > sizeof(buf))
1519 - ast_log(LOG_WARNING,"Only doing %d bytes (%d bytes requested)\n",(int)(sizeof(buf) - AST_FRIENDLY_OFFSET),len);
1520 - len = sizeof(buf) - AST_FRIENDLY_OFFSET;
1522 + /* Instead of len, use samples, because channel.c generator_force
1523 + * generate(chan, tmp, 0, 160) ignores len. In any case, len is
1524 + * a multiple of samples, given by number of samples times bytes per
1525 + * sample. In the case of ulaw, len = samples. for signed linear
1526 + * len = 2 * samples */
1528 + if (samples > maxsamples)
1530 + ast_log(LOG_WARNING, "Only doing %d samples (%d requested)\n", maxsamples, samples);
1531 + samples = maxsamples;
1533 + len = samples * sizeof (buf[0]);
1534 wf.frametype = AST_FRAME_VOICE;
1535 wf.subclass = AST_FORMAT_ULAW;
1536 wf.offset = AST_FRIENDLY_OFFSET;
1538 wf.data = buf + AST_FRIENDLY_OFFSET;
1540 - wf.samples = wf.datalen;
1541 + wf.samples = samples;
1542 wf.src = "app_milliwatt";
1543 wf.delivery.tv_sec = 0;
1544 wf.delivery.tv_usec = 0;
1545 diff -urN asterisk-1.2.7.1.orig/apps/app_page.c asterisk-1.2.7.1/apps/app_page.c
1546 --- asterisk-1.2.7.1.orig/apps/app_page.c 2006-04-13 19:40:21.000000000 +0200
1547 +++ asterisk-1.2.7.1/apps/app_page.c 2006-04-18 14:39:28.000000000 +0200
1550 struct calloutdata *cd = data;
1551 ast_pbx_outgoing_app(cd->tech, AST_FORMAT_SLINEAR, cd->resource, 30000,
1552 - "MeetMe", cd->meetmeopts, NULL, 0, cd->cidnum, cd->cidname, cd->variables, NULL, NULL);
1553 + "MeetMe", cd->meetmeopts, NULL, 0, 0, cd->cidnum, cd->cidname, cd->variables, NULL, NULL, NULL);
1557 diff -urN asterisk-1.2.7.1.orig/apps/app_parkandannounce.c asterisk-1.2.7.1/apps/app_parkandannounce.c
1558 --- asterisk-1.2.7.1.orig/apps/app_parkandannounce.c 2005-11-29 19:24:39.000000000 +0100
1559 +++ asterisk-1.2.7.1/apps/app_parkandannounce.c 2006-04-18 14:39:28.000000000 +0200
1562 memset(&oh, 0, sizeof(oh));
1563 oh.parent_channel = chan;
1564 - dchan = __ast_request_and_dial(dialtech, AST_FORMAT_SLINEAR, dialstr,30000, &outstate, chan->cid.cid_num, chan->cid.cid_name, &oh);
1565 + dchan = __ast_request_and_dial(dialtech, AST_FORMAT_SLINEAR, dialstr,30000, &outstate, 0, chan->cid.cid_num, chan->cid.cid_name, &oh, NULL);
1568 if(dchan->_state == AST_STATE_UP) {
1569 diff -urN asterisk-1.2.7.1.orig/apps/app_pickup.c asterisk-1.2.7.1/apps/app_pickup.c
1570 --- asterisk-1.2.7.1.orig/apps/app_pickup.c 1970-01-01 01:00:00.000000000 +0100
1571 +++ asterisk-1.2.7.1/apps/app_pickup.c 2006-04-18 14:39:28.000000000 +0200
1574 + * Asterisk -- A telephony toolkit for Linux.
1576 + * Pickup, channel independent call pickup
1578 + * Copyright (C) 2004, Junghanns.NET GmbH
1580 + * Klaus-Peter Junghanns <kpj@junghanns.net>
1582 + * Copyright (C) 2004, Florian Overkamp <florian@obsimref.com>
1584 + * This program is free software, distributed under the terms of
1585 + * the GNU General Public License
1588 +#include <stdlib.h>
1589 +#include <unistd.h>
1590 +#include <string.h>
1592 +#include <signal.h>
1593 +#include <pthread.h>
1594 +#include <asterisk/lock.h>
1595 +#include <asterisk/file.h>
1596 +#include <asterisk/logger.h>
1597 +#include <asterisk/channel.h>
1598 +#include <asterisk/pbx.h>
1599 +#include <asterisk/module.h>
1600 +#include <asterisk/features.h>
1601 +#include <asterisk/options.h>
1604 +static char *tdesc = "PickUp/PickDown/Steal/PickupChan/StealChan";
1606 +static char *app = "PickUp";
1608 +static char *synopsis = "Channel independent call pickup.";
1610 +static char *descrip =
1611 +" PickDown([group]): Tries to pickup the first ringing channel with callgroup == group.\n"
1612 +" If called without the group argument, the pickupgroup of the channel will be used.\n";
1614 +static char *app2 = "Steal";
1616 +static char *synopsis2 = "Channel independent call stealing. Just like pickup but for answered channels.";
1618 +static char *descrip2 =
1619 +" Steal([group]): Tries to steal the first bridged channel with callgroup == group.\n"
1620 +" If called without the group argument, the pickupgroup of the channel will be used.\n";
1622 +static char *app3 = "PickDown";
1624 +static char *synopsis3 = "Channel independent call pickdown.";
1626 +static char *descrip3 =
1627 +" PickDown([group]): Tries to hangup the first ringing channel with callgroup == group.\n"
1628 +" If called without the group argument, the pickupgroup of the channel will be used.\n";
1630 +static char *app4 = "PickupChan";
1632 +static char *synopsis4 = "Channel independent call pickup.";
1634 +static char *descrip4 =
1635 +" PickupChan(Technology/resource[&Technology2/resource2...]): Tries to pickup the first ringing channel in the parameter list.\n";
1637 +static char *app5 = "StealChan";
1639 +static char *synopsis5 = "Channel independent call stealing. Just like pickup but for answered channels.";
1641 +static char *descrip5 =
1642 +" StealChan(Technology/resource[&Technology2/resource2...]): Tries to steal the first ringing channel in the parameter list.\n";
1644 +STANDARD_LOCAL_USER;
1648 +static int my_pickup_call(struct ast_channel *chan, unsigned int pickupgroup, int chanstate, int bridge) {
1649 + struct ast_channel *cur;
1651 + cur = ast_channel_walk_locked(NULL);
1653 + if ((cur != chan) &&
1654 + (pickupgroup & cur->callgroup) &&
1655 + (cur->_state == chanstate)) {
1658 + ast_mutex_unlock(&cur->lock);
1659 + cur = ast_channel_walk_locked(cur);
1662 + if(option_verbose > 2) {
1663 + if (chanstate == AST_STATE_RINGING) {
1664 + if (bridge == 1) {
1665 + ast_verbose(VERBOSE_PREFIX_3 "Channel %s picked up ringing channel %s\n",chan->name,cur->name);
1667 + ast_verbose(VERBOSE_PREFIX_3 "Channel %s hung up ringing channel %s\n",chan->name,cur->name);
1670 + ast_verbose(VERBOSE_PREFIX_3 "Channel %s stole channel %s\n",chan->name,cur->name);
1673 + if (bridge == 1) {
1674 + if (chan->_state != AST_STATE_UP) {
1677 + if (ast_channel_masquerade(cur, chan)) {
1678 + ast_log(LOG_ERROR, "unable to masquerade\n");
1680 + ast_mutex_unlock(&cur->lock);
1681 + ast_mutex_unlock(&chan->lock);
1683 + cur->_softhangup = AST_SOFTHANGUP_DEV;
1684 + ast_mutex_unlock(&cur->lock);
1687 + if(option_verbose > 2) {
1688 + ast_verbose(VERBOSE_PREFIX_3 "No channel found %d.\n",pickupgroup);
1694 +static int my_pickup_channel(struct ast_channel *chan, void *data, int chanstate, int bridge) {
1695 + struct ast_channel *cur;
1696 + char channels[256];
1697 + char evalchan[256];
1700 + cur = ast_channel_walk_locked(NULL);
1701 + strncpy(channels, (char *)data, sizeof(channels) - 1);
1703 + if ((cur != chan) &&
1704 + (cur->_state == chanstate)) {
1705 + /* This call is a candidate (correct ringstate and not ourselves), now check if the channel is in our list */
1706 + strncpy(evalchan, (char *)cur->name, sizeof(evalchan) - 1);
1707 + /* strip the subchannel tag */
1708 + endptr = strrchr(evalchan, '-');
1712 + endptr = strrchr(evalchan, '/');
1716 + /* check for each of the members if they match (probably a stristr will do ?) */
1717 + /* if we match the code, break */
1718 + if(strstr(channels, evalchan) != NULL) {
1719 + ast_verbose(VERBOSE_PREFIX_1 "Nice channel, I'll take it: %s\n",evalchan);
1723 + ast_mutex_unlock(&cur->lock);
1724 + cur = ast_channel_walk_locked(cur);
1727 + if(option_verbose > 2) {
1728 + if (chanstate == AST_STATE_RINGING) {
1729 + if (bridge == 1) {
1730 + ast_verbose(VERBOSE_PREFIX_3 "Channel %s picked up ringing channel %s\n",chan->name,cur->name);
1732 + ast_verbose(VERBOSE_PREFIX_3 "Channel %s hung up ringing channel %s\n",chan->name,cur->name);
1735 + ast_verbose(VERBOSE_PREFIX_3 "Channel %s stole channel %s\n",chan->name,cur->name);
1738 + if (bridge == 1) {
1739 + if (chan->_state != AST_STATE_UP) {
1742 + if (ast_channel_masquerade(cur, chan)) {
1743 + ast_log(LOG_ERROR, "unable to masquerade\n");
1745 + ast_mutex_unlock(&cur->lock);
1746 + ast_mutex_unlock(&chan->lock);
1748 + cur->_softhangup = AST_SOFTHANGUP_DEV;
1749 + ast_mutex_unlock(&cur->lock);
1752 + if(option_verbose > 2) {
1753 + ast_verbose(VERBOSE_PREFIX_3 "No channel found %s.\n",channels);
1760 +static int pickup_exec(struct ast_channel *chan, void *data)
1763 + unsigned int pickupgroup=0;
1764 + struct localuser *u;
1765 + if (!data || !strlen(data)) {
1766 + pickupgroup = chan->pickupgroup;
1768 + pickupgroup = ast_get_group(data);
1770 + LOCAL_USER_ADD(u);
1772 + res = my_pickup_call(chan, pickupgroup, AST_STATE_RINGING, 1);
1776 + LOCAL_USER_REMOVE(u);
1780 +static int steal_exec(struct ast_channel *chan, void *data)
1783 + unsigned int pickupgroup=0;
1784 + struct localuser *u;
1785 + if (!data || !strlen(data)) {
1786 + pickupgroup = chan->pickupgroup;
1788 + pickupgroup = ast_get_group(data);
1790 + LOCAL_USER_ADD(u);
1792 + res = my_pickup_call(chan, pickupgroup, AST_STATE_UP, 1);
1796 + LOCAL_USER_REMOVE(u);
1800 +static int pickdown_exec(struct ast_channel *chan, void *data)
1803 + unsigned int pickupgroup=0;
1804 + struct localuser *u;
1805 + if (!data || !strlen(data)) {
1806 + pickupgroup = chan->pickupgroup;
1808 + pickupgroup = ast_get_group(data);
1810 + LOCAL_USER_ADD(u);
1812 + res = my_pickup_call(chan, pickupgroup, AST_STATE_RINGING, 0);
1816 + LOCAL_USER_REMOVE(u);
1820 +static int pickupchan_exec(struct ast_channel *chan, void *data) {
1822 + struct localuser *u;
1824 + ast_log(LOG_WARNING, "PickupChan requires an argument (technology1/number1&technology2/number2...)\n");
1827 + LOCAL_USER_ADD(u);
1829 + res = my_pickup_channel(chan, data, AST_STATE_RINGING, 1);
1833 + LOCAL_USER_REMOVE(u);
1837 +static int stealchan_exec(struct ast_channel *chan, void *data)
1840 + struct localuser *u;
1842 + ast_log(LOG_WARNING, "StealChan requires an argument (technology1/number1&technology2/number2...)\n");
1846 + LOCAL_USER_ADD(u);
1848 + res = my_pickup_channel(chan, data, AST_STATE_UP, 1);
1852 + LOCAL_USER_REMOVE(u);
1857 +int unload_module(void)
1859 + STANDARD_HANGUP_LOCALUSERS;
1860 + ast_unregister_application(app5);
1861 + ast_unregister_application(app4);
1862 + ast_unregister_application(app3);
1863 + ast_unregister_application(app2);
1864 + return ast_unregister_application(app);
1867 +int load_module(void)
1869 + ast_register_application(app5, stealchan_exec, synopsis5, descrip5);
1870 + ast_register_application(app4, pickupchan_exec, synopsis4, descrip4);
1871 + ast_register_application(app3, pickdown_exec, synopsis3, descrip3);
1872 + ast_register_application(app2, steal_exec, synopsis2, descrip2);
1873 + return ast_register_application(app, pickup_exec, synopsis, descrip);
1876 +char *description(void)
1884 + STANDARD_USECOUNT(res);
1890 + return ASTERISK_GPL_KEY;
1892 diff -urN asterisk-1.2.7.1.orig/apps/app_queue.c asterisk-1.2.7.1/apps/app_queue.c
1893 --- asterisk-1.2.7.1.orig/apps/app_queue.c 2006-04-04 19:59:18.000000000 +0200
1894 +++ asterisk-1.2.7.1/apps/app_queue.c 2006-04-18 14:39:28.000000000 +0200
1899 -static int statechange_queue(const char *dev, int state, void *ign)
1900 +static int statechange_queue(const char *dev, int state, void *ign, char *cid_num, char *cid_name)
1902 /* Avoid potential for deadlocks by spawning a new thread to handle
1904 @@ -1386,7 +1386,7 @@
1907 /* Request the peer */
1908 - tmp->chan = ast_request(tech, qe->chan->nativeformats, location, &status);
1909 + tmp->chan = ast_request(tech, qe->chan->nativeformats, location, &status, NULL);
1910 if (!tmp->chan) { /* If we can't, just go on to the next call */
1912 ast_log(LOG_NOTICE, "Unable to create channel of type '%s' for Queue\n", cur->tech);
1913 @@ -1692,7 +1692,7 @@
1914 if (option_verbose > 2)
1915 ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", in->name, tech, stuff, o->chan->name);
1916 /* Setup parameters */
1917 - o->chan = ast_request(tech, in->nativeformats, stuff, &status);
1918 + o->chan = ast_request(tech, in->nativeformats, stuff, &status, NULL);
1919 if (status != o->oldstatus)
1920 update_dial_status(qe->parent, o->member, status);
1922 diff -urN asterisk-1.2.7.1.orig/apps/app_readfile.c asterisk-1.2.7.1/apps/app_readfile.c
1923 --- asterisk-1.2.7.1.orig/apps/app_readfile.c 2006-03-23 21:13:48.000000000 +0100
1924 +++ asterisk-1.2.7.1/apps/app_readfile.c 2006-04-18 14:39:28.000000000 +0200
1926 #include "asterisk/app.h"
1927 #include "asterisk/module.h"
1929 -static char *tdesc = "Stores output of file into a variable";
1930 +static char *tdesc = "Stores content of file into a variable";
1932 static char *app_readfile = "ReadFile";
1934 diff -urN asterisk-1.2.7.1.orig/apps/app_segfault.c asterisk-1.2.7.1/apps/app_segfault.c
1935 --- asterisk-1.2.7.1.orig/apps/app_segfault.c 1970-01-01 01:00:00.000000000 +0100
1936 +++ asterisk-1.2.7.1/apps/app_segfault.c 2006-04-18 14:39:28.000000000 +0200
1939 + * Segfault application
1941 + * An application to provoke a segmentation fault from the dialplan.
1942 + * (I know what you are thinking now...., but since Asterisk is too stable...
1943 + * I needed something to test my failover switches.)
1945 + * Copyright (C) 2005 Junghanns.NET GmbH
1946 + * Klaus-Peter Junghanns <kpj@junghanns.net>
1948 + * This program is free software, distributed under the terms of
1949 + * the GNU General Public License. THIS APPLICATION _WILL_ CRASH YOUR
1950 + * ASTERISK SERVER SO OF COURSE THERE IS NOT LIABILITY FOR NOTHING!
1953 +#include <stdlib.h>
1954 +#include <unistd.h>
1955 +#include <string.h>
1957 +#include <asterisk/lock.h>
1958 +#include <asterisk/file.h>
1959 +#include <asterisk/logger.h>
1960 +#include <asterisk/channel.h>
1961 +#include <asterisk/pbx.h>
1962 +#include <asterisk/module.h>
1964 +static char *tdesc = "Application for crashing Asterisk with a segmentation fault";
1966 +static char *app = "Segfault";
1968 +static char *synopsis = "This application will crash Asterisk with a segmentation fault.";
1970 +static char *descrip =
1971 +" Segfault(): Crash with a segfault. Never returns nufin.\n";
1973 +STANDARD_LOCAL_USER;
1977 +static int segfault_exec(struct ast_channel *chan, void *data)
1979 + struct localuser *u;
1980 + LOCAL_USER_ADD(u);
1981 + ((char *)0)[0] = 0;
1982 + LOCAL_USER_REMOVE(u);
1986 +int unload_module(void)
1988 + STANDARD_HANGUP_LOCALUSERS;
1989 + return ast_unregister_application(app);
1992 +int load_module(void)
1994 + return ast_register_application(app, segfault_exec, synopsis, descrip);
1997 +char *description(void)
2005 + STANDARD_USECOUNT(res);
2011 + return ASTERISK_GPL_KEY;
2013 diff -urN asterisk-1.2.7.1.orig/apps/app_sms.c asterisk-1.2.7.1/apps/app_sms.c
2014 --- asterisk-1.2.7.1.orig/apps/app_sms.c 2005-12-26 19:19:12.000000000 +0100
2015 +++ asterisk-1.2.7.1/apps/app_sms.c 2006-04-18 14:39:28.000000000 +0200
2016 @@ -1179,32 +1179,31 @@
2018 struct ast_frame f = { 0 };
2019 unsigned char waste[AST_FRIENDLY_OFFSET];
2020 +#define MAXSAMPLES (800)
2022 - unsigned char buf[800];
2023 + unsigned char buf[MAXSAMPLES];
2025 - signed short buf[800];
2026 + signed short buf[MAXSAMPLES];
2028 +#define SAMPLE2LEN (sizeof (buf[0]))
2032 - if (len > sizeof (buf)) {
2033 - ast_log (LOG_WARNING, "Only doing %d bytes (%d bytes requested)\n", (int)(sizeof (buf) / sizeof (signed short)), len);
2034 - len = sizeof (buf);
2038 - samples = len / 2;
2040 + if (samples > MAXSAMPLES) {
2041 + ast_log (LOG_WARNING, "Only doing %d samples (%d requested)\n",
2042 + MAXSAMPLES, samples);
2043 + samples = MAXSAMPLES;
2045 - waste[0] = 0; /* make compiler happy */
2046 + len = samples * SAMPLE2LEN;
2048 + waste[0] = 0; /* make compiler happy */
2049 f.frametype = AST_FRAME_VOICE;
2051 f.subclass = AST_FORMAT_ALAW;
2052 - f.datalen = samples;
2054 f.subclass = AST_FORMAT_SLINEAR;
2055 - f.datalen = samples * 2;
2058 f.offset = AST_FRIENDLY_OFFSET;
2061 @@ -1256,6 +1255,8 @@
2069 static void sms_process (sms_t * h, int samples, signed short *data)
2070 diff -urN asterisk-1.2.7.1.orig/apps/app_zapras.c asterisk-1.2.7.1/apps/app_zapras.c
2071 --- asterisk-1.2.7.1.orig/apps/app_zapras.c 2005-11-29 19:24:39.000000000 +0100
2072 +++ asterisk-1.2.7.1/apps/app_zapras.c 2006-04-18 14:39:28.000000000 +0200
2076 /* Throw back into audio mode */
2079 ioctl(chan->fds[0], ZT_AUDIOMODE, &x);
2081 /* Restore saved values */
2082 diff -urN asterisk-1.2.7.1.orig/asterisk.c asterisk-1.2.7.1/asterisk.c
2083 --- asterisk-1.2.7.1.orig/asterisk.c 2006-04-11 23:55:51.000000000 +0200
2084 +++ asterisk-1.2.7.1/asterisk.c 2006-04-18 14:39:28.000000000 +0200
2086 char ast_config_AST_CTL_OWNER[AST_CONFIG_MAX_PATH] = "\0";
2087 char ast_config_AST_CTL_GROUP[AST_CONFIG_MAX_PATH] = "\0";
2088 char ast_config_AST_CTL[AST_CONFIG_MAX_PATH] = "asterisk.ctl";
2089 +char ast_config_AST_SYMBOLIC_NAME[20];
2091 static char *_argv[256];
2092 static int shuttingdown = 0;
2093 @@ -1887,6 +1888,7 @@
2094 ast_copy_string(ast_config_AST_PID, AST_PID, sizeof(ast_config_AST_PID));
2095 ast_copy_string(ast_config_AST_SOCKET, AST_SOCKET, sizeof(ast_config_AST_SOCKET));
2096 ast_copy_string(ast_config_AST_RUN_DIR, AST_RUN_DIR, sizeof(ast_config_AST_RUN_DIR));
2097 + ast_copy_string(ast_config_AST_SYMBOLIC_NAME, AST_SYMBOLIC_NAME, sizeof(ast_config_AST_SYMBOLIC_NAME));
2099 /* no asterisk.conf? no problem, use buildtime config! */
2101 @@ -1926,6 +1928,8 @@
2102 ast_copy_string(ast_config_AST_RUN_DIR, v->value, sizeof(ast_config_AST_RUN_DIR));
2103 } else if (!strcasecmp(v->name, "astmoddir")) {
2104 ast_copy_string(ast_config_AST_MODULE_DIR, v->value, sizeof(ast_config_AST_MODULE_DIR));
2105 + } else if (!strcasecmp(v->name, "uniquename")) {
2106 + strncpy(ast_config_AST_SYMBOLIC_NAME,v->value,sizeof(ast_config_AST_SYMBOLIC_NAME));
2110 diff -urN asterisk-1.2.7.1.orig/build_tools/make_defaults_h asterisk-1.2.7.1/build_tools/make_defaults_h
2111 --- asterisk-1.2.7.1.orig/build_tools/make_defaults_h 2005-06-20 19:26:08.000000000 +0200
2112 +++ asterisk-1.2.7.1/build_tools/make_defaults_h 2006-04-18 14:39:28.000000000 +0200
2114 #define AST_KEY_DIR "${INSTALL_PATH}${ASTVARLIBDIR}/keys"
2115 #define AST_DB "${INSTALL_PATH}${ASTVARLIBDIR}/astdb"
2116 #define AST_TMP_DIR "${INSTALL_PATH}${ASTSPOOLDIR}/tmp"
2117 +#define AST_SYMBOLIC_NAME "asterisk"
2119 #define AST_CONFIG_FILE "${INSTALL_PATH}${ASTCONFPATH}"
2121 diff -urN asterisk-1.2.7.1.orig/channel.c asterisk-1.2.7.1/channel.c
2122 --- asterisk-1.2.7.1.orig/channel.c 2006-04-11 23:35:52.000000000 +0200
2123 +++ asterisk-1.2.7.1/channel.c 2006-04-18 14:39:28.000000000 +0200
2126 static int shutting_down = 0;
2128 -AST_MUTEX_DEFINE_STATIC(uniquelock);
2129 static int uniqueint = 0;
2130 +AST_MUTEX_DEFINE_EXPORTED(uniquelock);
2132 unsigned long global_fin = 0, global_fout = 0;
2134 @@ -512,6 +512,17 @@
2135 .description = "Null channel (should not see this)",
2138 +char *ast_alloc_uniqueid(void) {
2140 + uniqueid = malloc(64);
2141 + if (!uniqueid) return NULL;
2142 + ast_mutex_lock(&uniquelock);
2143 + snprintf(uniqueid, 63, "%s-%d-%li.%d", ast_config_AST_SYMBOLIC_NAME, ast_mainpid, (long)time(NULL), uniqueint++);
2144 + ast_mutex_unlock(&uniquelock);
2149 /*--- ast_channel_alloc: Create a new channel structure */
2150 struct ast_channel *ast_channel_alloc(int needqueue)
2155 struct varshead *headp;
2156 + char *tmpuniqueid;
2159 /* If shutting down, don't allocate any new channels */
2160 @@ -584,9 +596,12 @@
2162 tmp->fin = global_fin;
2163 tmp->fout = global_fout;
2164 - ast_mutex_lock(&uniquelock);
2165 - snprintf(tmp->uniqueid, sizeof(tmp->uniqueid), "%li.%d", (long) time(NULL), uniqueint++);
2166 - ast_mutex_unlock(&uniquelock);
2167 + tmpuniqueid = ast_alloc_uniqueid();
2168 + snprintf(tmp->uniqueid, sizeof(tmp->uniqueid), tmpuniqueid);
2169 + if (tmpuniqueid) {
2170 + free(tmpuniqueid);
2171 + tmpuniqueid = NULL;
2173 headp = &tmp->varshead;
2174 ast_mutex_init(&tmp->lock);
2175 AST_LIST_HEAD_INIT_NOLOCK(headp);
2178 static struct ast_channel *channel_find_locked(const struct ast_channel *prev,
2179 const char *name, const int namelen,
2180 - const char *context, const char *exten)
2181 + const char *context, const char *exten, const char *uniqueid)
2183 const char *msg = prev ? "deadlock" : "initial deadlock";
2185 @@ -740,9 +755,14 @@
2186 for (c = channels; c; c = c->next) {
2188 /* want head of list */
2189 - if (!name && !exten)
2190 + if (!name && !exten && !uniqueid)
2194 + if (!strcasecmp(c->uniqueid, uniqueid))
2198 + } else if (name) {
2199 /* want match by full name */
2201 if (!strcasecmp(c->name, name))
2202 @@ -793,33 +813,39 @@
2203 /*--- ast_channel_walk_locked: Browse channels in use */
2204 struct ast_channel *ast_channel_walk_locked(const struct ast_channel *prev)
2206 - return channel_find_locked(prev, NULL, 0, NULL, NULL);
2207 + return channel_find_locked(prev, NULL, 0, NULL, NULL, NULL);
2210 /*--- ast_get_channel_by_name_locked: Get channel by name and lock it */
2211 struct ast_channel *ast_get_channel_by_name_locked(const char *name)
2213 - return channel_find_locked(NULL, name, 0, NULL, NULL);
2214 + return channel_find_locked(NULL, name, 0, NULL, NULL, NULL);
2217 /*--- ast_get_channel_by_name_prefix_locked: Get channel by name prefix and lock it */
2218 struct ast_channel *ast_get_channel_by_name_prefix_locked(const char *name, const int namelen)
2220 - return channel_find_locked(NULL, name, namelen, NULL, NULL);
2221 + return channel_find_locked(NULL, name, namelen, NULL, NULL, NULL);
2224 /*--- ast_walk_channel_by_name_prefix_locked: Get next channel by name prefix and lock it */
2225 struct ast_channel *ast_walk_channel_by_name_prefix_locked(struct ast_channel *chan, const char *name, const int namelen)
2227 - return channel_find_locked(chan, name, namelen, NULL, NULL);
2228 + return channel_find_locked(chan, name, namelen, NULL, NULL, NULL);
2231 /*--- ast_get_channel_by_exten_locked: Get channel by exten (and optionally context) and lock it */
2232 struct ast_channel *ast_get_channel_by_exten_locked(const char *exten, const char *context)
2234 - return channel_find_locked(NULL, NULL, 0, context, exten);
2235 + return channel_find_locked(NULL, NULL, 0, context, exten, NULL);
2238 +struct ast_channel *ast_get_channel_by_uniqueid_locked(const char *uniqueid)
2240 + return channel_find_locked(NULL, NULL, 0, NULL, NULL, uniqueid);
2244 /*--- ast_safe_sleep_conditional: Wait, look for hangups and condition arg */
2245 int ast_safe_sleep_conditional( struct ast_channel *chan, int ms,
2246 int (*cond)(void*), void *data )
2247 @@ -912,8 +938,10 @@
2248 free(chan->tech_pvt);
2252 - sched_context_destroy(chan->sched);
2253 + if (chan->sched) {
2254 + sched_context_destroy(chan->sched);
2255 + chan->sched = NULL;
2258 ast_copy_string(name, chan->name, sizeof(name));
2260 @@ -956,10 +984,11 @@
2261 while ((vardata = AST_LIST_REMOVE_HEAD(headp, entries)))
2262 ast_var_delete(vardata);
2266 ast_mutex_unlock(&chlock);
2268 - ast_device_state_changed_literal(name);
2269 + ast_device_state_changed_literal(name, NULL, NULL);
2272 int ast_channel_spy_add(struct ast_channel *chan, struct ast_channel_spy *spy)
2273 @@ -2362,7 +2391,7 @@
2274 &chan->writetrans, 1);
2277 -struct ast_channel *__ast_request_and_dial(const char *type, int format, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name, struct outgoing_helper *oh)
2278 +struct ast_channel *__ast_request_and_dial(const char *type, int format, void *data, int timeout, int *outstate, int callingpres, const char *cid_num, const char *cid_name, struct outgoing_helper *oh, char* uniqueid)
2282 @@ -2370,7 +2399,7 @@
2283 struct ast_frame *f;
2286 - chan = ast_request(type, format, data, &cause);
2287 + chan = ast_request(type, format, data, &cause, uniqueid);
2291 @@ -2384,6 +2413,7 @@
2293 ast_set_callerid(chan, cid_num, cid_name, cid_num);
2295 + chan->cid.cid_pres = callingpres;
2296 if (!ast_call(chan, data, 0)) {
2297 res = 1; /* in case chan->_state is already AST_STATE_UP */
2298 while (timeout && (chan->_state != AST_STATE_UP)) {
2299 @@ -2407,6 +2437,7 @@
2300 if (f->subclass == AST_CONTROL_RINGING)
2301 state = AST_CONTROL_RINGING;
2302 else if ((f->subclass == AST_CONTROL_BUSY) || (f->subclass == AST_CONTROL_CONGESTION)) {
2304 state = f->subclass;
2307 @@ -2476,12 +2507,12 @@
2311 -struct ast_channel *ast_request_and_dial(const char *type, int format, void *data, int timeout, int *outstate, const char *cidnum, const char *cidname)
2312 +struct ast_channel *ast_request_and_dial(const char *type, int format, void *data, int timeout, int *outstate, int callingpres, const char *cidnum, const char *cidname, char *uniqueid)
2314 - return __ast_request_and_dial(type, format, data, timeout, outstate, cidnum, cidname, NULL);
2315 + return __ast_request_and_dial(type, format, data, timeout, outstate, 0, cidnum, cidname, NULL, uniqueid);
2318 -struct ast_channel *ast_request(const char *type, int format, void *data, int *cause)
2319 +struct ast_channel *ast_request(const char *type, int format, void *data, int *cause, char *uniqueid)
2321 struct chanlist *chan;
2322 struct ast_channel *c;
2323 @@ -2518,6 +2549,7 @@
2324 if (!(c = chan->tech->requester(type, capabilities, data, cause)))
2327 + if (uniqueid) strncpy(c->uniqueid, uniqueid, sizeof(c->uniqueid));
2328 if (c->_state == AST_STATE_DOWN) {
2329 manager_event(EVENT_FLAG_CALL, "Newchannel",
2331 @@ -2765,6 +2797,29 @@
2335 +int ast_channel_masquerade_locked(struct ast_channel *original, struct ast_channel *clone)
2337 + struct ast_frame null = { AST_FRAME_NULL, };
2339 + ast_log(LOG_DEBUG, "Planning to masquerade %s into the structure of %s\n",
2340 + clone->name, original->name);
2341 + if (original->masq) {
2342 + ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
2343 + original->masq->name, original->name);
2344 + } else if (clone->masqr) {
2345 + ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
2346 + clone->name, clone->masqr->name);
2348 + original->masq = clone;
2349 + clone->masqr = original;
2350 + ast_queue_frame(original, &null);
2351 + ast_queue_frame(clone, &null);
2352 + ast_log(LOG_DEBUG, "Done planning to masquerade %s into the structure of %s\n", original->name, clone->name);
2358 void ast_change_name(struct ast_channel *chan, char *newname)
2361 @@ -3131,15 +3186,14 @@
2365 -int ast_setstate(struct ast_channel *chan, int state)
2367 +int ast_setstate_and_cid(struct ast_channel *chan, int state, char *cid_num, char *cid_name) {
2368 int oldstate = chan->_state;
2370 if (oldstate == state)
2373 chan->_state = state;
2374 - ast_device_state_changed_literal(chan->name);
2375 + ast_device_state_changed_literal(chan->name, cid_num, cid_name);
2376 manager_event(EVENT_FLAG_CALL,
2377 (oldstate == AST_STATE_DOWN) ? "Newchannel" : "Newstate",
2379 @@ -3155,6 +3209,10 @@
2383 +int ast_setstate(struct ast_channel *chan, int state) {
2384 + return ast_setstate_and_cid(chan, state, NULL, NULL);
2387 /*--- Find bridged channel */
2388 struct ast_channel *ast_bridged_channel(struct ast_channel *chan)
2390 @@ -3332,6 +3390,7 @@
2391 char callee_warning = 0;
2396 ast_log(LOG_WARNING, "%s is already in a bridge with %s\n",
2397 c0->name, c0->_bridge->name);
2398 @@ -3342,6 +3401,10 @@
2399 c1->name, c1->_bridge->name);
2403 + if (IS_DIGITAL(c0->transfercapability) || IS_DIGITAL(c1->transfercapability)) {
2404 + config->flags = 0;
2407 /* Stop if we're a zombie or need a soft hangup */
2408 if (ast_test_flag(c0, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) ||
2409 diff -urN asterisk-1.2.7.1.orig/channels/Makefile asterisk-1.2.7.1/channels/Makefile
2410 --- asterisk-1.2.7.1.orig/channels/Makefile 2005-12-15 11:52:30.000000000 +0100
2411 +++ asterisk-1.2.7.1/channels/Makefile 2006-04-18 14:39:28.000000000 +0200
2412 @@ -102,6 +102,11 @@
2416 +ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/lib/libgsmat.so.1)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/lib/libgsmat.so.1),)
2417 + CFLAGS+=-DZAPATA_GSM
2421 ALSA_SRC=chan_alsa.c
2423 ifneq ($(wildcard alsa-monitor.h),)
2424 @@ -122,6 +127,35 @@
2426 endif # WITHOUT_ZAPTEL
2428 +ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/capi20.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/capi20.h),)
2429 + CHANNEL_LIBS+=chan_capi.so
2430 +# uncomment the following line if you really never ever want early b3 connects,
2431 +# you can also configure it in the dialstring, this is just for performance
2432 +# NOTE: this is probably obsolete by using the "R" dial option
2433 +#CFLAGS+=-DCAPI_NEVER_EVER_EARLY_B3_CONNECTS
2435 +# uncommnet next line to force dtmf software detection/generation, can also be configured
2436 +# in capi.conf on a perdevice basis (softdtmf=1)
2437 +#CFLAGS+=-DCAPI_FORCE_SOFTWARE_DTMF
2439 +# uncomment the next line if you are in the ulaw world
2440 +#CFLAGS+=-DCAPI_ULAW
2442 +# very experimental echo squelching
2446 +CFLAGS+=-DCAPI_GAIN
2448 +# what do to with call waiting connect indications?
2449 +# uncomment the next line for call deflection in that case
2450 +CFLAGS+=-DCAPI_DEFLECT_ON_CIRCUITBUSY
2453 +CFLAGS+=-DCAPI_SYNC
2457 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/vpbapi.h),)
2458 CHANNEL_LIBS+=chan_vpb.so
2461 $(CC) -c $(CFLAGS) -o chan_zap.o chan_zap.c
2463 chan_zap.so: chan_zap.o
2464 - $(CC) $(SOLINK) -o $@ $< $(ZAPPRI) $(ZAPR2) -ltonezone
2465 + $(CC) $(SOLINK) -o $@ $< $(ZAPPRI) $(ZAPGSM) $(ZAPR2) -ltonezone
2467 chan_sip.so: chan_sip.o
2468 $(CC) $(SOLINK) -o $@ ${CYGSOLINK} chan_sip.o ${CYGSOLIB}
2470 chan_nbs.so: chan_nbs.o
2471 $(CC) $(SOLINK) -o $@ $< -lnbs
2473 +chan_capi.so: chan_capi.o
2474 + $(CC) $(SOLINK) -o $@ $< -lcapi20
2476 chan_vpb.o: chan_vpb.c
2477 $(CXX) -c $(CFLAGS) -o $@ chan_vpb.c
2479 diff -urN asterisk-1.2.7.1.orig/channels/chan_agent.c asterisk-1.2.7.1/channels/chan_agent.c
2480 --- asterisk-1.2.7.1.orig/channels/chan_agent.c 2006-02-15 02:21:33.000000000 +0100
2481 +++ asterisk-1.2.7.1/channels/chan_agent.c 2006-04-18 14:39:28.000000000 +0200
2482 @@ -1331,7 +1331,7 @@
2483 chan = agent_new(p, AST_STATE_DOWN);
2484 } else if (!p->owner && !ast_strlen_zero(p->loginchan)) {
2485 /* Adjustable agent */
2486 - p->chan = ast_request("Local", format, p->loginchan, cause);
2487 + p->chan = ast_request("Local", format, p->loginchan, cause, NULL);
2489 chan = agent_new(p, AST_STATE_DOWN);
2491 diff -urN asterisk-1.2.7.1.orig/channels/chan_capi.c asterisk-1.2.7.1/channels/chan_capi.c
2492 --- asterisk-1.2.7.1.orig/channels/chan_capi.c 1970-01-01 01:00:00.000000000 +0100
2493 +++ asterisk-1.2.7.1/channels/chan_capi.c 2006-04-18 14:39:28.000000000 +0200
2498 + * An implementation of Common ISDN API 2.0 for Asterisk
2500 + * Copyright (C) 2002, 2003, 2004, 2005 Junghanns.NET GmbH
2502 + * Klaus-Peter Junghanns <kapejod@ns1.jnetdns.de>
2504 + * This program is free software and may be modified and
2505 + * distributed under the terms of the GNU Public License.
2508 +#include <sys/time.h>
2509 +#include <sys/signal.h>
2510 +#include <stdlib.h>
2512 +#include <string.h>
2514 +#include <unistd.h>
2516 +#include <sys/types.h>
2517 +#include <asterisk/lock.h>
2518 +#include <asterisk/frame.h>
2519 +#include <asterisk/channel.h>
2520 +#include <asterisk/logger.h>
2521 +#include <asterisk/module.h>
2522 +#include <asterisk/pbx.h>
2523 +#include <asterisk/config.h>
2524 +#include <asterisk/options.h>
2525 +#include <asterisk/features.h>
2526 +#include <asterisk/utils.h>
2527 +#include <asterisk/cli.h>
2528 +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__)
2529 +#include <capi_bsd.h>
2531 +#include <linux/capi.h>
2533 +#include <capi20.h>
2534 +#include <asterisk/dsp.h>
2535 +#include <asterisk/xlaw.h>
2536 +#include <asterisk/chan_capi.h>
2538 +unsigned ast_capi_ApplID;
2539 +_cword ast_capi_MessageNumber=1;
2540 +static char desc[] = "Common ISDN API for Asterisk";
2542 +static char tdesc[] = "Common ISDN API Driver (0.4.0) muLaw";
2544 +static char tdesc[] = "Common ISDN API Driver (0.4.0) aLaw ";
2546 +static char type[] = "CAPI";
2550 +AST_MUTEX_DEFINE_STATIC(usecnt_lock);
2551 +AST_MUTEX_DEFINE_STATIC(iflock);
2552 +AST_MUTEX_DEFINE_STATIC(pipelock);
2553 +AST_MUTEX_DEFINE_STATIC(monlock);
2554 +AST_MUTEX_DEFINE_STATIC(contrlock);
2555 +AST_MUTEX_DEFINE_STATIC(capi_send_buffer_lock);
2556 +AST_MUTEX_DEFINE_STATIC(capi_put_lock);
2559 +static int capi_capability = AST_FORMAT_ULAW;
2561 +static int capi_capability = AST_FORMAT_ALAW;
2564 +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__)
2565 +static CAPIProfileBuffer_t profile;
2567 +static struct ast_capi_profile profile;
2569 +static pthread_t monitor_thread = -1;
2571 +static struct ast_capi_pvt *iflist = NULL;
2572 +static struct capi_pipe *pipelist = NULL;
2573 +static int capi_last_plci = 0;
2574 +static struct ast_capi_controller *capi_controllers[AST_CAPI_MAX_CONTROLLERS];
2575 +static int capi_num_controllers = 0;
2576 +static int capi_counter = 0;
2577 +static unsigned long capi_used_controllers=0;
2579 +static char capi_send_buffer[AST_CAPI_MAX_B3_BLOCKS * AST_CAPI_MAX_B3_BLOCK_SIZE];
2580 +static int capi_send_buffer_handle = 0;
2582 +char capi_national_prefix[AST_MAX_EXTENSION];
2583 +char capi_international_prefix[AST_MAX_EXTENSION];
2587 +static const struct ast_channel_tech capi_tech;
2589 +MESSAGE_EXCHANGE_ERROR _capi_put_cmsg(_cmsg *CMSG) {
2590 + MESSAGE_EXCHANGE_ERROR error;
2591 + if (ast_mutex_lock(&capi_put_lock)) {
2592 + ast_log(LOG_WARNING,"Unable to lock capi put!\n");
2595 + error = capi20_put_cmsg(CMSG);
2596 + if (ast_mutex_unlock(&capi_put_lock)) {
2597 + ast_log(LOG_WARNING,"Unable to unlock capi put!\n");
2604 +MESSAGE_EXCHANGE_ERROR check_wait_get_cmsg(_cmsg *CMSG) {
2605 + MESSAGE_EXCHANGE_ERROR Info;
2606 + struct timeval tv;
2608 + tv.tv_usec = 10000;
2609 + Info = capi20_waitformessage(ast_capi_ApplID,&tv);
2610 + if ((Info != 0x0000) && (Info != 0x1104)) {
2612 + ast_log(LOG_DEBUG, "Error waiting for cmsg... INFO = %#x\n", Info);
2617 + if (Info == 0x0000) {
2618 + Info = capi_get_cmsg(CMSG,ast_capi_ApplID);
2624 +unsigned ListenOnController(unsigned long CIPmask,unsigned controller) {
2625 + MESSAGE_EXCHANGE_ERROR error;
2628 + LISTEN_REQ_HEADER(&CMSG, ast_capi_ApplID, ast_capi_MessageNumber++, controller);
2629 +#ifdef CAPI_NEVER_EVER_EARLY_B3_CONNECTS
2630 + LISTEN_REQ_INFOMASK(&CMSG) = 0x00ff; // lots of info ;)
2632 + LISTEN_REQ_INFOMASK(&CMSG) = 0x03ff; // lots of info ;) + early B3 connect
2634 + LISTEN_REQ_CIPMASK(&CMSG) = CIPmask;
2635 + if ((error = _capi_put_cmsg(&CMSG)) != 0) {
2638 + while (!IS_LISTEN_CONF(&CMSG2)) {
2639 + error = check_wait_get_cmsg(&CMSG2);
2644 +// Echo cancellation is for cards w/ integrated echo cancellation only
2645 +// (i.e. Eicon active cards support it)
2647 +#define EC_FUNCTION_ENABLE 1
2648 +#define EC_FUNCTION_DISABLE 2
2649 +#define EC_FUNCTION_FREEZE 3
2650 +#define EC_FUNCTION_RESUME 4
2651 +#define EC_FUNCTION_RESET 5
2652 +#define EC_OPTION_DISABLE_NEVER 0
2653 +#define EC_OPTION_DISABLE_G165 (1<<1)
2654 +#define EC_OPTION_DISABLE_G164_OR_G165 (1<<1 | 1<<2)
2655 +#define EC_DEFAULT_TAIL 64
2657 +static int capi_echo_canceller(struct ast_channel *c, int function) {
2658 + struct ast_capi_pvt *i = c->tech_pvt;
2659 + MESSAGE_EXCHANGE_ERROR error;
2661 + unsigned char buf[7];
2663 + /* If echo cancellation is not requested or supported, don't attempt to enable it */
2664 + ast_mutex_lock(&contrlock);
2665 + if (!capi_controllers[i->controller]->echocancel || !i->doEC) {
2666 + ast_mutex_unlock(&contrlock);
2669 + ast_mutex_unlock(&contrlock);
2671 + if (option_verbose > 2)
2672 + ast_verbose(VERBOSE_PREFIX_3 "Setting up echo canceller (PLCI=%#x, function=%d, options=%d, tail=%d)\n",i->PLCI,function,i->ecOption,i->ecTail);
2674 + FACILITY_REQ_HEADER(&CMSG, ast_capi_ApplID, ast_capi_MessageNumber++, 0);
2675 + FACILITY_REQ_NCCI(&CMSG) = i->NCCI;
2676 + FACILITY_REQ_FACILITYSELECTOR(&CMSG) = 6; /* Echo canceller */
2678 + buf[0]=6; /* msg size */
2680 + if (function == EC_FUNCTION_ENABLE) {
2681 + buf[3]=i->ecOption; /* bit field - ignore echo canceller disable tone */
2682 + buf[5]=i->ecTail; /* Tail length, ms */
2694 + FACILITY_REQ_FACILITYREQUESTPARAMETER(&CMSG) = buf;
2696 + if ((error = _capi_put_cmsg(&CMSG)) != 0) {
2697 + ast_log(LOG_ERROR,"error sending FACILITY_REQ (error=%#x)\n",error);
2701 + if (option_verbose > 5)
2702 + ast_verbose(VERBOSE_PREFIX_4 "sent FACILITY_REQ (PLCI=%#x)\n",i->PLCI);
2707 +int capi_detect_dtmf(struct ast_channel *c, int flag) {
2708 + struct ast_capi_pvt *i = c->tech_pvt;
2709 +#ifndef CAPI_FORCE_SOFTWARE_DTMF
2710 + MESSAGE_EXCHANGE_ERROR error;
2712 + unsigned char buf[9];
2713 + // does the controller support dtmf? and do we want to use it?
2714 + ast_mutex_lock(&contrlock);
2715 + if ((capi_controllers[i->controller]->dtmf == 1) && (i->doDTMF == 0)) {
2716 + ast_mutex_unlock(&contrlock);
2717 + FACILITY_REQ_HEADER(&CMSG, ast_capi_ApplID, ast_capi_MessageNumber++, 0);
2718 + FACILITY_REQ_PLCI(&CMSG) = i->PLCI;
2719 + FACILITY_REQ_FACILITYSELECTOR(&CMSG) = 1;
2727 + buf[3] = AST_CAPI_DTMF_DURATION;
2729 + buf[5] = AST_CAPI_DTMF_DURATION;
2733 + FACILITY_REQ_FACILITYREQUESTPARAMETER(&CMSG) = buf;
2735 + if ((error = _capi_put_cmsg(&CMSG)) != 0) {
2736 + ast_log(LOG_ERROR,"error sending FACILITY_REQ (error=%#x)\n",error);
2739 + if (option_verbose > 5) {
2740 + ast_verbose(VERBOSE_PREFIX_4 "sent FACILITY_REQ (PLCI=%#x)\n",i->PLCI);
2744 + ast_mutex_unlock(&contrlock);
2747 + // do software dtmf detection
2748 + i->doDTMF = 1; // just being paranoid again...
2749 +#ifndef CAPI_FORCE_SOFTWARE_DTMF
2754 +static int capi_send_digit(struct ast_channel *c,char digit) {
2755 + struct ast_capi_pvt *i = c->tech_pvt;
2756 + MESSAGE_EXCHANGE_ERROR error;
2758 + unsigned char buf[10];
2760 + if (i->state != CAPI_STATE_BCONNECTED) {
2765 +#ifndef CAPI_NEVER_EVER_EARLY_B3_CONNECTS
2766 + if(i->earlyB3 == 1)
2767 + /* we should really test for the network saying the number is incomplete
2768 + since i'm only doing a test and this is true at the right time
2769 + i'm going with this */
2772 + INFO_REQ_HEADER(&CMSG, ast_capi_ApplID, ast_capi_MessageNumber++, 0);
2773 + INFO_REQ_PLCI(&CMSG) = i->PLCI;
2777 + INFO_REQ_CALLEDPARTYNUMBER(&CMSG) = buf;
2780 + if ((error = _capi_put_cmsg(&CMSG)) != 0) {
2781 + ast_log(LOG_ERROR,"error sending CALLEDPARTYNUMBER INFO (error=%#x)\n",error);
2784 + if (option_verbose > 5) {
2785 + ast_verbose(VERBOSE_PREFIX_4 "sent CALLEDPARTYNUMBER INFO digit = %c (PLCI=%#x)\n", digit, i->PLCI);
2791 +#ifndef CAPI_FORCE_SOFTWARE_DTMF
2792 + ast_mutex_lock(&contrlock);
2793 + if ((capi_controllers[i->controller]->dtmf == 0) || (i->doDTMF == 1)) {
2796 +#ifndef CAPI_FORCE_SOFTWARE_DTMF
2797 + ast_mutex_unlock(&contrlock);
2800 +#ifndef CAPI_FORCE_SOFTWARE_DTMF
2802 + ast_mutex_unlock(&contrlock);
2804 + FACILITY_REQ_HEADER(&CMSG, ast_capi_ApplID, ast_capi_MessageNumber++, 0);
2805 + FACILITY_REQ_PLCI(&CMSG) = i->NCCI;
2806 + FACILITY_REQ_FACILITYSELECTOR(&CMSG) = 1;
2812 + buf[3] = AST_CAPI_DTMF_DURATION;
2815 + buf[5] = AST_CAPI_DTMF_DURATION;
2821 + FACILITY_REQ_FACILITYREQUESTPARAMETER(&CMSG) = buf;
2823 + if ((error = _capi_put_cmsg(&CMSG)) != 0) {
2824 + ast_log(LOG_ERROR,"error sending FACILITY_REQ (error=%#x)\n",error);
2827 + if (option_verbose > 4) {
2828 + ast_verbose(VERBOSE_PREFIX_3 "sent dtmf '%c'\n",digit);
2832 +#ifndef CAPI_NEVER_EVER_EARLY_B3_CONNECTS
2838 +static int capi_alert(struct ast_channel *c) {
2839 + struct ast_capi_pvt *i = c->tech_pvt;
2840 + MESSAGE_EXCHANGE_ERROR error;
2843 + ALERT_REQ_HEADER(&CMSG, ast_capi_ApplID, i->MessageNumber, 0);
2844 + ALERT_REQ_PLCI(&CMSG) = i->PLCI;
2846 + if ((error = _capi_put_cmsg(&CMSG)) != 0) {
2847 + ast_log(LOG_ERROR,"error sending ALERT_REQ PLCI = %#x\n",i->PLCI);
2850 + if (option_verbose > 5) {
2851 + ast_verbose(VERBOSE_PREFIX_4 "sent ALERT_REQ PLCI = %#x\n",i->PLCI);
2855 + i->state = CAPI_STATE_ALERTING;
2859 +#ifdef CAPI_DEFLECT_ON_CIRCUITBUSY
2860 +static int capi_deflect(struct ast_channel *chan, void *data)
2862 + struct ast_capi_pvt *i = chan->tech_pvt;
2863 + MESSAGE_EXCHANGE_ERROR Info;
2865 + char bchaninfo[1];
2871 + ast_log(LOG_WARNING, "cd requires an argument (destination phone number)\n");
2875 + if ((i->state == CAPI_STATE_CONNECTED) || (i->state == CAPI_STATE_BCONNECTED)) {
2876 + ast_log(LOG_ERROR, "call deflection does not work with calls that are already connected!\n");
2879 + // wait until the channel is alerting, so we dont drop the call and interfer with msgs
2880 + while ((ms > 0) && (i->state != CAPI_STATE_ALERTING)) {
2885 + // make sure we hang up correctly
2886 + i->state = CAPI_STATE_CONNECTPENDING;
2890 + fac[2]=0x01; // Use D-Chan
2891 + fac[3]=0; // Keypad len
2892 + fac[4]=31; // user user data? len = 31 = 29 + 2
2893 + fac[5]=0x1c; // magic?
2894 + fac[6]=0x1d; // strlen destination + 18 = 29
2895 + fac[7]=0x91; // ..
2897 + fac[9]=0x1A; // strlen destination + 15 = 26
2905 + fac[17]=0x12; // strlen destination + 7 = 18
2906 + fac[18]=0x30; // ...hm 0x30
2907 + fac[19]=0x0d; // strlen destination + 2
2908 + fac[20]=0x80; // CLIP
2909 + fac[21]=0x0b; // strlen destination
2910 + fac[22]=0x01; // destination start
2921 + fac[33]=0x01; // 0x1 = sending complete
2925 + memcpy((unsigned char *)fac+22,data,strlen(data));
2926 + fac[22+strlen(data)]=0x01; // fill with 0x01 if number is only 6 numbers (local call)
2927 + fac[23+strlen(data)]=0x01;
2928 + fac[24+strlen(data)]=0x01;
2929 + fac[25+strlen(data)]=0x01;
2930 + fac[26+strlen(data)]=0x01;
2932 + fac[6]=18+strlen(data);
2933 + fac[9]=15+strlen(data);
2934 + fac[17]=7+strlen(data);
2935 + fac[19]=2+strlen(data);
2936 + fac[21]=strlen(data);
2938 + bchaninfo[0] = 0x1;
2939 + INFO_REQ_HEADER(&CMSG,ast_capi_ApplID,ast_capi_MessageNumber++,0);
2940 + INFO_REQ_CONTROLLER(&CMSG) = i->controller;
2941 + INFO_REQ_PLCI(&CMSG) = i->PLCI;
2942 + INFO_REQ_BCHANNELINFORMATION(&CMSG) = (unsigned char*)bchaninfo; // use D-Channel
2943 + INFO_REQ_KEYPADFACILITY(&CMSG) = 0;
2944 + INFO_REQ_USERUSERDATA(&CMSG) = 0;
2945 + INFO_REQ_FACILITYDATAARRAY(&CMSG) = (unsigned char*) fac + 4;
2947 + if ((Info = _capi_put_cmsg(&CMSG)) != 0) {
2948 + ast_log(LOG_ERROR,"Error sending INFO_REQ\n");
2952 + // ast_log(LOG_NOTICE,"%s\n",capi_cmsg2str(&CMSG));
2953 + ast_log(LOG_NOTICE,"sent INFO_REQ PLCI = %#x\n",i->PLCI);
2961 +void remove_pipe(int PLCI) {
2962 + struct capi_pipe *p,*ptmp;
2964 + ast_mutex_lock(&pipelock);
2968 + if (p->PLCI == PLCI) {
2969 + if (ptmp == NULL) {
2970 + // mypipe == head of pipelist
2971 + pipelist = p->next;
2972 + if(p->fd > -1) close(p->fd);
2973 + if(p->i != NULL && p->i->fd > -1) close(p->i->fd);
2975 + if (option_verbose > 4) {
2976 + ast_verbose(VERBOSE_PREFIX_3 "removed pipe for PLCI = %#x\n",PLCI);
2980 + // somehwere inbetween or at the end
2981 + ptmp->next = p->next;
2982 + if (p->next == NULL) {
2983 + capi_last_plci = p->PLCI;
2985 + if(p->fd > -1) close(p->fd);
2986 + if(p->i != NULL && p->i->fd > -1) close(p->i->fd);
2988 + if (option_verbose > 4) {
2989 + ast_verbose(VERBOSE_PREFIX_3 "removed pipe for PLCI = %#x\n",PLCI);
2997 + ast_mutex_unlock(&pipelock);
3000 +static int capi_activehangup(struct ast_channel *c) {
3001 + struct ast_capi_pvt *i = c->tech_pvt;
3002 + MESSAGE_EXCHANGE_ERROR error;
3005 + if (option_verbose > 2) {
3007 + ast_verbose(VERBOSE_PREFIX_4 "activehangingup\n");
3014 + if (c->_state == AST_STATE_RING) {
3015 + CONNECT_RESP_HEADER(&CMSG, ast_capi_ApplID, i->MessageNumber, 0);
3016 + CONNECT_RESP_PLCI(&CMSG) = i->PLCI;
3017 + CONNECT_RESP_REJECT(&CMSG) = 2;
3018 + if ((error = _capi_put_cmsg(&CMSG)) != 0) {
3019 + ast_log(LOG_ERROR,"error sending CONNECT_RESP for PLCI = %#x\n",i->PLCI);
3021 + if (option_verbose > 5) {
3022 + ast_verbose(VERBOSE_PREFIX_4 "sent CONNECT_RESP for PLCI = %#x\n",i->PLCI);
3028 + // active disconnect
3029 + if (i->state == CAPI_STATE_BCONNECTED) {
3030 + DISCONNECT_B3_REQ_HEADER(&CMSG, ast_capi_ApplID, ast_capi_MessageNumber++, 0);
3031 + DISCONNECT_B3_REQ_NCCI(&CMSG) = i->NCCI;
3033 + if ((error = _capi_put_cmsg(&CMSG)) != 0) {
3034 + ast_log(LOG_ERROR, "error sending DISCONNECT_B3_REQ NCCI=%#x\n",i->NCCI);
3036 + if (option_verbose > 5) {
3037 + ast_verbose(VERBOSE_PREFIX_4 "sent DISCONNECT_B3_REQ NCCI=%#x\n",i->NCCI);
3040 + // wait for the B3 layer to go down
3041 + while (i->state != CAPI_STATE_CONNECTED) {
3045 + if ((i->state == CAPI_STATE_CONNECTED) || (i->state == CAPI_STATE_CONNECTPENDING)){
3046 + DISCONNECT_REQ_HEADER(&CMSG, ast_capi_ApplID, ast_capi_MessageNumber++, 0);
3047 + DISCONNECT_REQ_PLCI(&CMSG) = i->PLCI;
3049 + if ((error = _capi_put_cmsg(&CMSG)) != 0) {
3050 + ast_log(LOG_ERROR, "error sending DISCONNECT_REQ PLCI=%#x\n",i->PLCI);
3052 + if (option_verbose > 5) {
3053 + ast_verbose(VERBOSE_PREFIX_4 "sent DISCONNECT_REQ PLCI=%#x\n",i->PLCI);
3056 + // wait for the B1 layer to go down
3057 + while (i->state != CAPI_STATE_DISCONNECTED) {
3064 +static int capi_hangup(struct ast_channel *c) {
3065 + struct ast_capi_pvt *i = c->tech_pvt;
3067 + // hmm....ok...this is called to free the capi interface (passive disconnect)
3068 + // or to bring down the channel (active disconnect)
3070 + if (option_verbose > 3)
3071 + ast_verbose(VERBOSE_PREFIX_3 "CAPI Hangingup\n");
3074 + ast_log(LOG_ERROR,"channel has no interface!\n");
3078 + // are we down, yet?
3079 + if (i->state != CAPI_STATE_DISCONNECTED) {
3081 + capi_activehangup(c);
3084 + remove_pipe(i->PLCI);
3087 + if ((i->doDTMF == 1) && (i->vad != NULL)) {
3088 + ast_dsp_free(i->vad);
3090 + ast_smoother_free(i->smoother); // discard any frames left hanging
3091 + i->smoother=ast_smoother_new(AST_CAPI_MAX_B3_BLOCK_SIZE * 2);
3092 + memset(i->cid,0,sizeof(i->cid));
3094 + ast_mutex_lock(&usecnt_lock);
3096 + ast_mutex_unlock(&usecnt_lock);
3097 + ast_update_use_count();
3100 + c->tech_pvt = NULL;
3101 + ast_setstate(c,AST_STATE_DOWN);
3105 +static char *capi_number(char *data,int strip) {
3106 + unsigned len = *data;
3108 + // convert a capi struct to a \0 terminated string
3109 + if (!len || len < (unsigned int) strip) return NULL;
3110 + len = len - strip;
3111 + data = (char *)(data + 1 + strip);
3112 + return strndup((char *)data,len);
3115 +int capi_call(struct ast_channel *c, char *idest, int timeout)
3117 + struct ast_capi_pvt *i;
3118 + struct capi_pipe *p = NULL;
3120 + char *dest,*interface;
3121 + char buffer[AST_MAX_EXTENSION];
3122 + char called[AST_MAX_EXTENSION],calling[AST_MAX_EXTENSION];
3123 + char bchaninfo[3];
3127 + MESSAGE_EXCHANGE_ERROR error;
3129 + strncpy(buffer,idest,sizeof(buffer)-1);
3130 + interface = strtok(buffer, "/");
3131 + dest = strtok(NULL, "/");
3135 + ast_log(LOG_WARNING, "Destination %s requires a real destination\n", idest);
3139 + i->doB3 = AST_CAPI_B3_DONT; // <homer>DOH</homer>
3142 + if (((char *)dest)[0] == 'b') {
3143 + i->doB3 = AST_CAPI_B3_ALWAYS;
3145 + // only do B3 on successfull calls
3146 + if (((char *)dest)[0] == 'B') {
3147 + i->doB3 = AST_CAPI_B3_ON_SUCCESS;
3150 + if (i->doB3 != AST_CAPI_B3_DONT) {
3154 + if (option_verbose > 1) {
3156 + ast_verbose(VERBOSE_PREFIX_2 "CAPI Call %s %s", c->name, i->doB3?"with B3":"");
3158 + switch (c->cid.cid_pres) {
3159 + case PRES_ALLOWED_USER_NUMBER_NOT_SCREENED:
3160 + case PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN:
3161 + case PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN:
3162 + case PRES_ALLOWED_NETWORK_NUMBER:
3163 + case PRES_NUMBER_NOT_AVAILABLE:
3166 + case PRES_PROHIB_USER_NUMBER_NOT_SCREENED:
3167 + case PRES_PROHIB_USER_NUMBER_PASSED_SCREEN:
3168 + case PRES_PROHIB_USER_NUMBER_FAILED_SCREEN:
3169 + case PRES_PROHIB_NETWORK_NUMBER:
3176 + if (pipe(fds) == 0) {
3177 + ast_mutex_lock(&pipelock);
3179 + flags = fcntl(i->fd,F_GETFL);
3180 + fcntl(i->fd,F_SETFL,flags | O_SYNC | O_DIRECT);
3181 + p = malloc(sizeof(struct capi_pipe));
3182 + memset(p, 0, sizeof(struct capi_pipe));
3184 + flags = fcntl(i->fd,F_GETFL);
3185 + fcntl(p->fd,F_SETFL,flags | O_SYNC | O_DIRECT);
3186 + c->fds[0] = i->fd;
3191 + p->next = pipelist;
3193 + if (option_verbose > 4) {
3194 + ast_verbose(VERBOSE_PREFIX_3 "creating pipe for PLCI=-1\n");
3196 + ast_mutex_unlock(&pipelock);
3200 + i->MessageNumber = ast_capi_MessageNumber++;
3201 + CONNECT_REQ_HEADER(&CMSG, ast_capi_ApplID, i->MessageNumber, i->controller);
3202 + CONNECT_REQ_CONTROLLER(&CMSG) = i->controller;
3203 + CONNECT_REQ_CIPVALUE(&CMSG) = 0x10; // Telephony, could also use 0x04 (3.1Khz audio)
3204 + called[0] = strlen(dest)+1;
3206 + strncpy(&called[2],dest,sizeof(called)-2);
3207 + CONNECT_REQ_CALLEDPARTYNUMBER(&CMSG) = (unsigned char *)called;
3208 + CONNECT_REQ_CALLEDPARTYSUBADDRESS(&CMSG) = NULL;
3210 + if (c->cid.cid_num) {
3211 + calling[0] = strlen(c->cid.cid_num)+2;
3218 + if (i->CLIR == 1) {
3219 + calling[2] = 0xA0; // CLIR
3221 + calling[2] = 0x80; // CLIP
3224 + if (c->cid.cid_num) {
3225 + strncpy(&calling[3],c->cid.cid_num,sizeof(calling)-3);
3227 + CONNECT_REQ_CALLINGPARTYNUMBER(&CMSG) = (unsigned char *)calling;
3228 + CONNECT_REQ_CALLINGPARTYSUBADDRESS(&CMSG) = NULL;
3230 + CONNECT_REQ_B1PROTOCOL(&CMSG) = 1;
3231 + CONNECT_REQ_B2PROTOCOL(&CMSG) = 1; // 1
3232 + CONNECT_REQ_B3PROTOCOL(&CMSG) = 0;
3235 + bchaninfo[1] = 0x0;
3236 + bchaninfo[2] = 0x0;
3237 + CONNECT_REQ_BCHANNELINFORMATION(&CMSG) = (unsigned char *)bchaninfo; // 0
3239 + if ((error = _capi_put_cmsg(&CMSG))) {
3240 + ast_log(LOG_ERROR,"error sending CONNECT_REQ (error=%#x)\n",error);
3243 + if (option_verbose > 5) {
3244 + ast_verbose(VERBOSE_PREFIX_4 "sent CONNECT_REQ MN =%#x\n",CMSG.Messagenumber);
3248 + i->state = CAPI_STATE_CONNECTPENDING;
3250 + ast_setstate(c, AST_STATE_DIALING);
3252 + // XXX fixme, not nice:
3253 +/* if (i->controller > 0) {
3254 + capi_controllers[i->controller]->nfreebchannels--;
3257 + // now we shall return .... the rest has to be done by handle_msg
3262 +static int capi_answer(struct ast_channel *c) {
3263 + struct ast_capi_pvt *i = c->tech_pvt;
3264 + MESSAGE_EXCHANGE_ERROR error;
3266 + char buf[AST_MAX_EXTENSION];
3269 + if (i->isdnmode && (strlen(i->incomingmsn)<strlen(i->dnid)))
3270 + dnid = i->dnid + strlen(i->incomingmsn);
3274 + CONNECT_RESP_HEADER(&CMSG, ast_capi_ApplID, i->MessageNumber, 0);
3275 + CONNECT_RESP_PLCI(&CMSG) = i->PLCI;
3276 + CONNECT_RESP_REJECT(&CMSG) = 0;
3277 + buf[0] = strlen(dnid)+2;
3280 + strncpy(&buf[3],dnid,sizeof(buf)-4);
3281 + CONNECT_RESP_CONNECTEDNUMBER(&CMSG) = (unsigned char *)buf;
3282 + CONNECT_RESP_CONNECTEDSUBADDRESS(&CMSG) = NULL;
3283 + CONNECT_RESP_LLC(&CMSG) = NULL;
3284 + CONNECT_RESP_B1PROTOCOL(&CMSG) = 1;
3285 + CONNECT_RESP_B2PROTOCOL(&CMSG) = 1;
3286 + CONNECT_RESP_B3PROTOCOL(&CMSG) = 0;
3288 + if (option_verbose > 3)
3289 + ast_verbose(VERBOSE_PREFIX_3 "CAPI Answering for MSN %s\n", dnid);
3290 + if ((error = _capi_put_cmsg(&CMSG)) != 0) {
3293 + if (option_verbose > 5) {
3295 + ast_verbose(VERBOSE_PREFIX_4 "sent CONNECT_RESP PLCI = %#x DNID = %s\n",i->PLCI,i->dnid);
3299 + i->state = CAPI_STATE_ANSWERING;
3300 + i->doB3 = AST_CAPI_B3_DONT;
3307 +struct ast_frame *capi_read(struct ast_channel *c) {
3308 + struct ast_capi_pvt *i = c->tech_pvt;
3311 + if ((i->state == CAPI_STATE_REMOTE_HANGUP)) {
3312 + ast_log(LOG_ERROR,"this channel is not connected\n");
3315 + if (i->state == CAPI_STATE_ONHOLD) {
3316 + i->fr.frametype = AST_FRAME_NULL;
3321 + ast_log(LOG_ERROR,"channel has no interface\n");
3324 + i->fr.frametype = AST_FRAME_NULL;
3325 + i->fr.subclass = 0;
3326 + i->fr.delivery.tv_sec = 0;
3327 + i->fr.delivery.tv_usec = 0;
3328 + readsize = read(i->fd,&i->fr,sizeof(struct ast_frame));
3329 + if (readsize != sizeof(struct ast_frame)) {
3330 + ast_log(LOG_ERROR,"did not read a whole frame\n");
3332 + if (i->fr.frametype == AST_FRAME_VOICE) {
3333 + readsize = read(i->fd,i->fr.data,i->fr.datalen);
3334 + if (readsize != i->fr.datalen) {
3335 + ast_log(LOG_ERROR,"did not read whole frame data\n");
3338 + i->fr.mallocd = 0;
3339 + if (i->fr.frametype == AST_FRAME_NULL) {
3342 + if ((i->fr.frametype == AST_FRAME_DTMF) && (i->fr.subclass == 'f')) {
3343 + if (strcmp(c->exten, "fax")) {
3344 + if (ast_exists_extension(c, ast_strlen_zero(c->macrocontext) ? c->context : c->macrocontext, "fax", 1, c->cid.cid_num)) {
3345 + if (option_verbose > 2)
3346 + ast_verbose(VERBOSE_PREFIX_3 "Redirecting %s to fax extension\n", c->name);
3347 + /* Save the DID/DNIS when we transfer the fax call to a "fax" extension */
3348 + pbx_builtin_setvar_helper(c,"FAXEXTEN",c->exten);
3349 + if (ast_async_goto(c, c->context, "fax", 1))
3350 + ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", c->name, c->context);
3352 + ast_log(LOG_NOTICE, "Fax detected, but no fax extension\n");
3355 + ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n");
3361 +int capi_write(struct ast_channel *c, struct ast_frame *f) {
3362 + struct ast_capi_pvt *i = c->tech_pvt;
3364 + MESSAGE_EXCHANGE_ERROR error;
3367 + struct ast_frame *fsmooth;
3372 +#ifndef CAPI_NEVER_EVER_EARLY_B3_CONNECTS
3373 + // dont send audio to the local exchange!
3374 + if (i->earlyB3 == 1 || !i->NCCI) {
3380 + ast_log(LOG_ERROR,"channel has no interface\n");
3384 + if (f->frametype == AST_FRAME_NULL) {
3387 + if (f->frametype == AST_FRAME_DTMF) {
3388 + ast_log(LOG_ERROR,"dtmf frame should be written\n");
3391 + if (f->frametype != AST_FRAME_VOICE) {
3392 + ast_log(LOG_ERROR,"not a voice frame\n");
3395 + if (f->subclass != capi_capability) {
3396 + ast_log(LOG_ERROR,"dont know how to write subclass %d\n",f->subclass);
3399 +// ast_log(LOG_NOTICE,"writing frame %d %d\n",f->frametype,f->subclass);
3401 + if (ast_smoother_feed(i->smoother, f)!=0) {
3402 + ast_log(LOG_ERROR,"failed to fill smoother\n");
3406 + fsmooth=ast_smoother_read(i->smoother);
3407 + while(fsmooth != NULL) {
3408 + DATA_B3_REQ_HEADER(&CMSG, ast_capi_ApplID, ast_capi_MessageNumber++, 0);
3409 + DATA_B3_REQ_NCCI(&CMSG) = i->NCCI;
3410 + DATA_B3_REQ_DATALENGTH(&CMSG) = fsmooth->datalen;
3411 + DATA_B3_REQ_FLAGS(&CMSG) = 0;
3413 + if (ast_mutex_lock(&capi_send_buffer_lock)) {
3414 + ast_log(LOG_WARNING,"Unable to lock B3 send buffer!\n");
3419 + for (j=0;j<fsmooth->datalen;j++) {
3420 + buf[j] = i->g.txgains[reversebits[((unsigned char *)fsmooth->data)[j]]];
3423 + for (j=0;j<fsmooth->datalen;j++) {
3424 + buf[j] = reversebits[ ((unsigned char *)fsmooth->data)[j] ];
3428 + if ((i->doES == 1)) {
3429 + for (j=0;j<fsmooth->datalen;j++) {
3430 + buf[j] = reversebits[ ((unsigned char *)fsmooth->data)[j] ];
3431 + txavg += abs( capiXLAW2INT(reversebits[ ((unsigned char*)fsmooth->data)[j]]) );
3434 + for(j=0;j<ECHO_TX_COUNT-1;j++) {
3435 + i->txavg[j] = i->txavg[j+1];
3437 + i->txavg[ECHO_TX_COUNT-1] = txavg;
3439 +// ast_log(LOG_NOTICE,"txavg = %d\n",txavg);
3442 + for (j=0;j<fsmooth->datalen;j++) {
3443 + buf[j] = i->g.txgains[reversebits[((unsigned char *)fsmooth->data)[j]]];
3446 + for (j=0;j<fsmooth->datalen;j++) {
3447 + buf[j] = reversebits[ ((unsigned char *)fsmooth->data)[j] ];
3453 + DATA_B3_REQ_DATAHANDLE(&CMSG) = capi_send_buffer_handle;
3454 + memcpy((char *)&capi_send_buffer[(capi_send_buffer_handle % AST_CAPI_MAX_B3_BLOCKS) * AST_CAPI_MAX_B3_BLOCK_SIZE],&buf,fsmooth->datalen);
3455 + DATA_B3_REQ_DATA(&CMSG) = (unsigned char *)&capi_send_buffer[(capi_send_buffer_handle % AST_CAPI_MAX_B3_BLOCKS) * AST_CAPI_MAX_B3_BLOCK_SIZE];
3456 + capi_send_buffer_handle++;
3458 + if (ast_mutex_unlock(&capi_send_buffer_lock)) {
3459 + ast_log(LOG_WARNING,"Unable to unlock B3 send buffer!\n");
3465 + ast_mutex_lock(&i->lockB3in);
3466 + if ((i->B3in >= 1) && (i->B3in <= AST_CAPI_MAX_B3_BLOCKS)) {
3468 + ast_mutex_unlock(&i->lockB3in);
3469 + if ((error = _capi_put_cmsg(&CMSG)) != 0) {
3470 + ast_log(LOG_ERROR,"error sending DATA_B3_REQ (error=%#x, datalen=%d) B3in=%d\n",error,fsmooth->datalen,i->B3in);
3471 +// ast_log(LOG_NOTICE,"f: timelen %d b = %d MN = %d \n",fsmooth->timelen,b,CMSG.Messagenumber);
3473 + if (option_verbose > 5) {
3475 + ast_verbose(VERBOSE_PREFIX_4 "sent DATA_B3_REQ (NCCI=%#x) (%d bytes)\n",i->NCCI,fsmooth->datalen);
3479 + if (i->B3in > 0) i->B3in--;
3480 + ast_mutex_unlock(&i->lockB3in);
3483 + if ((error = _capi_put_cmsg(&CMSG)) != 0) {
3484 + ast_log(LOG_ERROR,"error sending DATA_B3_REQ (error=%#x, datalen=%d)\n",error,fsmooth->datalen);
3485 +// ast_log(LOG_NOTICE,"f: timelen %d b = %d MN = %d \n",fsmooth->timelen,b,CMSG.Messagenumber);
3487 + if (option_verbose > 5) {
3489 + ast_verbose(VERBOSE_PREFIX_4 "sent DATA_B3_REQ (NCCI=%#x) (%d bytes)\n",i->NCCI,fsmooth->datalen);
3494 +// ast_frfree(fsmooth);
3496 + fsmooth=ast_smoother_read(i->smoother);
3501 +static int capi_fixup(struct ast_channel *oldchan, struct ast_channel *newchan) {
3502 + struct ast_capi_pvt *p = newchan->tech_pvt;
3503 + p->owner = newchan;
3507 +int capi_indicate(struct ast_channel *c,int condition) {
3511 +int capi_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc) {
3516 +struct ast_channel *capi_new(struct ast_capi_pvt *i,int state) {
3517 + struct ast_channel *tmp;
3520 + tmp = ast_channel_alloc(1);
3521 + if (tmp != NULL) {
3522 + snprintf(tmp->name,sizeof(tmp->name),"CAPI/contr%d/%s-%d",i->controller,i->dnid,capi_counter++);
3524 + tmp->tech = &capi_tech;
3525 + tmp->nativeformats = capi_capability;
3526 + ast_setstate(tmp,state);
3527 + tmp->fds[0] = i->fd;
3528 + i->smoother = ast_smoother_new(AST_CAPI_MAX_B3_BLOCK_SIZE);
3529 + if (i->smoother == NULL) {
3530 + ast_log(LOG_ERROR, "smoother NULL!\n");
3532 + i->fr.frametype = 0;
3533 + i->fr.subclass = 0;
3534 + i->fr.delivery.tv_sec = 0;
3535 + i->fr.delivery.tv_usec = 0;
3536 + i->state = CAPI_STATE_DISCONNECTED;
3538 + i->calledPartyIsISDN = 0; // let's be pessimistic
3540 + i->doB3 = AST_CAPI_B3_DONT;
3542 + i->onholdPLCI = 0;
3545 + ast_mutex_init(&i->lockB3in);
3548 + memset(i->txavg,0,ECHO_TX_COUNT);
3551 +#ifndef CAPI_FORCE_SOFTWARE_DTMF
3552 + if (i->doDTMF == 1) {
3554 + i->vad = ast_dsp_new();
3555 + ast_dsp_set_features(i->vad, DSP_FEATURE_DTMF_DETECT);
3556 +#ifndef CAPI_FORCE_SOFTWARE_DTMF
3560 + tmp->tech_pvt = i;
3561 + tmp->callgroup = i->callgroup;
3562 + tmp->nativeformats = capi_capability;
3563 + fmt = ast_best_codec(tmp->nativeformats);
3564 +// fmt = capi_capability;
3565 + tmp->readformat = fmt;
3566 + tmp->writeformat = fmt;
3567 + tmp->rawreadformat = fmt;
3568 + tmp->rawwriteformat = fmt;
3569 + strncpy(tmp->context,i->context,sizeof(tmp->context)-1);
3570 + tmp->cid.cid_num = strdup(i->cid);
3571 + tmp->cid.cid_dnid = strdup(i->dnid);
3572 + strncpy(tmp->exten,i->dnid,sizeof(tmp->exten)-1);
3573 + strncpy(tmp->accountcode,i->accountcode,sizeof(tmp->accountcode)-1);
3575 + ast_mutex_lock(&usecnt_lock);
3577 + ast_mutex_unlock(&usecnt_lock);
3578 + ast_update_use_count();
3579 + if (state != AST_STATE_DOWN) {
3580 + // we are alerting (phones ringing)
3581 + if (state == AST_STATE_RING)
3583 + if (ast_pbx_start(tmp)) {
3584 + ast_log(LOG_ERROR,"Unable to start pbx on channel!\n");
3588 + if (option_verbose > 2) {
3589 + ast_verbose(VERBOSE_PREFIX_3 "started pbx on channel (callgroup=%d)!\n",tmp->callgroup);
3594 + ast_log(LOG_ERROR,"Unable to allocate channel!\n");
3600 +struct ast_channel *capi_request(const char *type, int format, void *data, int *cause)
3602 + struct ast_capi_pvt *i;
3603 + struct ast_channel *tmp = NULL;
3604 + char *dest,*interface;
3605 + char buffer[AST_MAX_EXTENSION];
3606 + unsigned int capigroup=0, controller=0;
3609 + if (option_verbose > 1) {
3611 + ast_verbose(VERBOSE_PREFIX_3 "data = %s\n",(char *)data);
3613 + strncpy(buffer,(char *)data,sizeof(buffer)-1);
3615 + interface = strtok(buffer, "/");
3616 + dest = strtok(NULL, "/");
3619 + if (((char *)interface)[0] == 'g') {
3621 + capigroup = atoi(interface);
3622 + if (option_verbose > 1) {
3624 + ast_verbose(VERBOSE_PREFIX_3 "capi request group = %d\n",capigroup);
3626 + } else if (!strncmp(interface,"contr",5)) {
3628 + controller = atoi(interface);
3629 + if (option_verbose > 1) {
3631 + ast_verbose(VERBOSE_PREFIX_3 "capi request controller = %d\n",controller);
3634 + ast_log(LOG_ERROR,"Syntax error in dialstring. read the docs!\n");
3637 + ast_mutex_lock(&iflock);
3639 + while (i && notfound) {
3642 + if (controller && (i->controllers & (1 << controller))) {
3643 + // DIAL(CAPI/contrX/...)
3644 + ast_mutex_lock(&contrlock);
3645 + if (capi_controllers[controller]->nfreebchannels > 0) {
3646 + strncpy(i->dnid,dest,sizeof(i->dnid)-1);
3647 + i->controller = controller;
3648 + tmp = capi_new(i, AST_STATE_DOWN);
3650 + i->datahandle = 0;
3651 + i->outgoing = 1; // this is an outgoing line
3653 + // capi_detect_dtmf(tmp,1);
3654 + ast_mutex_unlock(&contrlock);
3655 + ast_mutex_unlock(&iflock);
3658 + // keep on running!
3659 + ast_mutex_unlock(&contrlock);
3661 + } else if (capigroup && (i->group & (1 << capigroup))) {
3663 + // DIAL(CAPI/gX/...)
3664 + ast_mutex_lock(&contrlock);
3665 + for (c=1;c<=capi_num_controllers;c++) {
3666 + if (i->controllers & (1 << c)) {
3667 + if (capi_controllers[c]->nfreebchannels > 0) {
3668 + strncpy(i->dnid,dest,sizeof(i->dnid)-1);
3669 + i->controller = c;
3670 + tmp = capi_new(i, AST_STATE_DOWN);
3672 + i->datahandle = 0;
3673 + i->outgoing = 1; // this is an outgoing line
3675 + // capi_detect_dtmf(tmp,1);
3676 + ast_mutex_unlock(&contrlock);
3677 + ast_mutex_unlock(&iflock);
3680 + // keep on running!
3684 + ast_mutex_unlock(&contrlock);
3687 +// ast_log(LOG_NOTICE,"not contr %d group %d\n",i->controllers, i->group);
3690 + ast_mutex_unlock(&iflock);
3691 + ast_log(LOG_NOTICE,"didn't find capi device with controller = %d or group = %d.\n",controller, capigroup);
3696 +struct capi_pipe *find_pipe(int PLCI,int MN) {
3697 + struct capi_pipe *p;
3698 + // find a pipe by PLCI or by MessageNumber (in case this is a CONNECT_CONF)
3699 + ast_mutex_lock(&pipelock);
3701 + if ((p == NULL) && (capi_last_plci != PLCI)){
3703 + ast_log(LOG_NOTICE,"PLCI doesnt match last pipe (PLCI = %#x)\n",PLCI);
3705 + ast_mutex_unlock(&pipelock);
3708 + while(p != NULL) {
3709 + if ((p->PLCI == PLCI) || ( (p->PLCI == -1) && (p->i->MessageNumber == MN) ) ){
3710 + ast_mutex_unlock(&pipelock);
3716 + ast_log(LOG_ERROR,"unable to find a pipe for PLCI = %#x MN = %#x\n",PLCI,MN);
3718 + ast_mutex_unlock(&pipelock);
3722 +int pipe_frame(struct capi_pipe *p,struct ast_frame *f) {
3725 + struct timeval tv;
3727 + FD_SET(p->fd,&wfds);
3730 + if ((f->frametype == AST_FRAME_VOICE) && (p->i->doDTMF == 1) && (p->i->vad != NULL)) {
3731 + f = ast_dsp_process(p->c,p->i->vad,f);
3732 + if (f->frametype == AST_FRAME_NULL) {
3736 + // we dont want the monitor thread to block
3737 + if (select(p->fd + 1,NULL,&wfds,NULL,&tv) == 1) {
3738 + written = write(p->fd,f,sizeof(struct ast_frame));
3739 + if (written < (signed int) sizeof(struct ast_frame)) {
3740 + ast_log(LOG_ERROR,"wrote %d bytes instead of %d\n", written, (int)sizeof(struct ast_frame));
3743 + if (f->frametype == AST_FRAME_VOICE) {
3744 + written = write(p->fd,f->data,f->datalen);
3745 + if (written < f->datalen) {
3746 + ast_log(LOG_ERROR,"wrote %d bytes instead of %d\n",written,f->datalen);
3756 +static int search_did(struct ast_channel *c)
3761 + // 1 = possible match
3762 + struct ast_capi_pvt *i = c->tech_pvt;
3765 + if (strlen(i->dnid)<strlen(i->incomingmsn))
3768 +// exten = i->dnid + strlen(i->incomingmsn);
3771 + if (ast_exists_extension(NULL, c->context, exten, 1, NULL)) {
3773 + strncpy(c->exten, exten, sizeof(c->exten) - 1);
3777 + if (ast_canmatch_extension(NULL, c->context, exten, 1, NULL)) {
3785 +int pipe_msg(int PLCI,_cmsg *CMSG) {
3786 + struct capi_pipe *p;
3788 + MESSAGE_EXCHANGE_ERROR error;
3789 + struct ast_frame fr;
3800 + p = find_pipe(PLCI,CMSG->Messagenumber);
3802 + if (IS_DISCONNECT_IND(CMSG)) {
3803 + DISCONNECT_RESP_HEADER(&CMSG2, ast_capi_ApplID, CMSG->Messagenumber , 0);
3804 + DISCONNECT_RESP_PLCI(&CMSG2) = PLCI;
3805 + if ((error = _capi_put_cmsg(&CMSG2)) != 0) {
3806 + ast_log(LOG_NOTICE, "error sending DISCONNECT_RESP PLCI=%#x\n",PLCI);
3808 + if (option_verbose > 5) {
3810 + ast_verbose(VERBOSE_PREFIX_4 "sent DISCONNECT_RESP PLCI=%#x\n",PLCI);
3816 + ast_log(LOG_NOTICE,"%s",capi_cmsg2str(CMSG));
3821 + if (CMSG != NULL) {
3822 + switch (CMSG->Subcommand) {
3824 + switch (CMSG->Command) {
3825 + case CAPI_DISCONNECT_B3:
3826 +// ast_log(LOG_NOTICE,"DISCONNECT_B3_IND\n");
3828 + DISCONNECT_B3_RESP_HEADER(&CMSG2, ast_capi_ApplID, CMSG->Messagenumber, 0);
3829 + DISCONNECT_B3_RESP_NCCI(&CMSG2) = DISCONNECT_B3_IND_NCCI(CMSG);
3831 + if ((error = _capi_put_cmsg(&CMSG2)) != 0) {
3832 + ast_log(LOG_NOTICE, "error sending DISCONNECT_B3_RESP NCCI=%#x\n",(int)DISCONNECT_B3_IND_NCCI(CMSG));
3834 + if (option_verbose > 5) {
3836 + ast_verbose(VERBOSE_PREFIX_4 "sent DISCONNECT_B3_RESP NCCI=%#x\n",(int)DISCONNECT_B3_IND_NCCI(CMSG));
3839 + if (p->i->state == CAPI_STATE_BCONNECTED) {
3840 + // passive disconnect
3841 + p->i->state = CAPI_STATE_CONNECTED;
3843 + if (p->i->state == CAPI_STATE_DISCONNECTING) {
3844 + // active disconnect
3845 + memset(&CMSG2,0,sizeof(_cmsg));
3846 + DISCONNECT_REQ_HEADER(&CMSG2, ast_capi_ApplID, ast_capi_MessageNumber++, 0);
3847 + DISCONNECT_REQ_PLCI(&CMSG2) = PLCI;
3849 + if ((error = _capi_put_cmsg(&CMSG2)) != 0) {
3850 + ast_log(LOG_NOTICE, "error sending DISCONNECT_REQ PLCI=%#x\n",PLCI);
3852 + if (option_verbose > 5) {
3854 + ast_verbose(VERBOSE_PREFIX_4 "sent DISCONNECT_REQ PLCI=%#x\n",PLCI);
3858 + if (p->i->state == CAPI_STATE_ONHOLD) {
3861 + ast_mutex_lock(&contrlock);
3862 + if (p->i->controller > 0) {
3863 + capi_controllers[p->i->controller]->nfreebchannels++;
3865 + ast_mutex_unlock(&contrlock);
3867 + case CAPI_DISCONNECT:
3868 +// ast_log(LOG_NOTICE,"DISCONNECT_IND\n");
3869 + DISCONNECT_RESP_HEADER(&CMSG2, ast_capi_ApplID, CMSG->Messagenumber , 0);
3870 + DISCONNECT_RESP_PLCI(&CMSG2) = PLCI;
3871 +/* if (p->i->controller > 0) {
3872 + capi_controllers[p->i->controller]->nfreebchannels++;
3875 + if ((error = _capi_put_cmsg(&CMSG2)) != 0) {
3876 + ast_log(LOG_NOTICE, "error sending DISCONNECT_RESP PLCI=%#x\n",PLCI);
3878 + if (option_verbose > 5) {
3880 + ast_verbose(VERBOSE_PREFIX_4 "sent DISCONNECT_RESP PLCI=%#x\n",PLCI);
3884 + p->c->hangupcause = DISCONNECT_IND_REASON(CMSG) - 0x3480;
3887 + if (PLCI == p->i->onholdPLCI) {
3888 + // the caller onhold hung up (or ECTed away)
3889 + p->i->onholdPLCI = 0;
3890 + remove_pipe(PLCI);
3894 + if (p->i->state == CAPI_STATE_DID) {
3895 + if ((p->c) != NULL) {
3898 + ast_log(LOG_WARNING, "unable to hangup channel on DID. Channel is NULL.\n");
3903 + p->i->state = CAPI_STATE_DISCONNECTED;
3905 + fr.frametype = AST_FRAME_CONTROL;
3906 + if (DISCONNECT_IND_REASON(CMSG) == 0x34a2) {
3907 + fr.subclass = AST_CONTROL_BUSY;
3909 + fr.frametype = AST_FRAME_NULL;
3912 + if (pipe_frame(p,(struct ast_frame *)&fr) == -1) {
3913 + // printf("STATE = %#x\n",p->i->state);
3914 + // in this case * did not read our hangup control frame
3915 + // so we must hangup the channel!
3916 + if ( (p->i->state != CAPI_STATE_DISCONNECTED) && (ast_check_hangup(p->c) == 0)) {
3917 + if (option_verbose > 1) {
3918 + ast_verbose(VERBOSE_PREFIX_3 "soft hangup by capi\n");
3920 + ast_softhangup(p->c,AST_SOFTHANGUP_DEV);
3922 + // dont ever hangup while hanging up!
3923 +// ast_log(LOG_NOTICE,"no soft hangup by capi\n");
3930 +/* fr.frametype = AST_FRAME_NULL;
3932 + pipe_frame(p,(struct ast_frame *)&fr); */
3934 + case CAPI_DATA_B3:
3936 + memcpy(&b3buf[AST_FRIENDLY_OFFSET],(char *)DATA_B3_IND_DATA(CMSG),DATA_B3_IND_DATALENGTH(CMSG));
3937 + b3len = DATA_B3_IND_DATALENGTH(CMSG);
3939 + // send a DATA_B3_RESP very quickly to free the buffer in capi
3940 + DATA_B3_RESP_HEADER(&CMSG2, ast_capi_ApplID, CMSG->Messagenumber,0);
3941 + DATA_B3_RESP_NCCI(&CMSG2) = DATA_B3_IND_NCCI(CMSG);
3942 + DATA_B3_RESP_DATAHANDLE(&CMSG2) = DATA_B3_IND_DATAHANDLE(CMSG);
3943 + if ((error = _capi_put_cmsg(&CMSG2)) != 0) {
3944 + ast_log(LOG_ERROR,"error sending DATA_B3_RESP (error=%#x)\n",error);
3946 + if (option_verbose > 6) {
3948 + ast_verbose(VERBOSE_PREFIX_4 "sent DATA_B3_RESP (NCCI=%#x)\n",(int)DATA_B3_IND_NCCI(CMSG));
3952 + ast_mutex_lock(&p->i->lockB3in);
3954 + if (p->i->B3in > AST_CAPI_MAX_B3_BLOCKS) p->i->B3in = AST_CAPI_MAX_B3_BLOCKS;
3955 + ast_mutex_unlock(&p->i->lockB3in);
3958 + if ((p->i->doES == 1)) {
3959 + for (j=0;j<b3len;j++) {
3960 + b3buf[AST_FRIENDLY_OFFSET + j] = reversebits[(unsigned char)b3buf[AST_FRIENDLY_OFFSET + j]];
3961 + rxavg += abs(capiXLAW2INT( reversebits[(unsigned char)b3buf[AST_FRIENDLY_OFFSET + j]]));
3964 + for(j=0;j<ECHO_EFFECTIVE_TX_COUNT;j++) {
3965 + txavg += p->i->txavg[j];
3969 + if( (txavg/ECHO_TXRX_RATIO) > rxavg) {
3971 + memset(&b3buf[AST_FRIENDLY_OFFSET],255,b3len);
3973 + memset(&b3buf[AST_FRIENDLY_OFFSET],84,b3len);
3976 + ast_log(LOG_NOTICE,"SUPPRESSING ECHOrx=%d, tx=%d\n",rxavg,txavg);
3981 + for (j=0;j<b3len;j++) {
3982 + b3buf[AST_FRIENDLY_OFFSET + j] = reversebits[p->i->g.rxgains[(unsigned char)b3buf[AST_FRIENDLY_OFFSET + j]]];
3985 + for (j=0;j<b3len;j++) {
3986 + b3buf[AST_FRIENDLY_OFFSET + j] = reversebits[(unsigned char)b3buf[AST_FRIENDLY_OFFSET + j]];
3993 + for (j=0;j<b3len;j++) {
3994 + b3buf[AST_FRIENDLY_OFFSET + j] = reversebits[p->i->g.rxgains[(unsigned char)b3buf[AST_FRIENDLY_OFFSET + j]]];
3997 + for (j=0;j<b3len;j++) {
3998 + b3buf[AST_FRIENDLY_OFFSET + j] = reversebits[(unsigned char)b3buf[AST_FRIENDLY_OFFSET + j]];
4003 + // just being paranoid ...
4004 + /* if (p->c->_state != AST_STATE_UP) {
4005 + ast_setstate(p->c,AST_STATE_UP);
4008 + fr.frametype = AST_FRAME_VOICE;
4009 + fr.subclass = capi_capability;
4010 + fr.data = (char *)&b3buf[AST_FRIENDLY_OFFSET];
4011 + fr.datalen = b3len;
4012 + fr.samples = b3len;
4013 + fr.offset = AST_FRIENDLY_OFFSET;
4015 + fr.delivery.tv_sec = 0;
4016 + fr.delivery.tv_usec = 0;
4018 + // ast_verbose(VERBOSE_PREFIX_3 "DATA_B3_IND (len=%d) fr.datalen=%d fr.subclass=%d\n",(int)DATA_B3_IND_DATALENGTH(CMSG),fr.datalen,fr.subclass);
4019 + return pipe_frame(p,(struct ast_frame *)&fr);
4021 + case CAPI_FACILITY:
4022 + if (FACILITY_IND_FACILITYSELECTOR(CMSG) == 0x0001) {
4024 + if (FACILITY_IND_FACILITYINDICATIONPARAMETER(CMSG)[0] != (0xff)) {
4025 + dtmflen = FACILITY_IND_FACILITYINDICATIONPARAMETER(CMSG)[0];
4026 + FACILITY_IND_FACILITYINDICATIONPARAMETER(CMSG) += 1;
4028 + dtmflen = ((__u16 *) (FACILITY_IND_FACILITYINDICATIONPARAMETER(CMSG) + 1))[0];
4029 + FACILITY_IND_FACILITYINDICATIONPARAMETER(CMSG) += 3;
4031 + if (dtmflen == 1) {
4032 + dtmf = (FACILITY_IND_FACILITYINDICATIONPARAMETER(CMSG))[0];
4033 + fr.frametype = AST_FRAME_DTMF;
4034 + fr.subclass = dtmf;
4035 + if (option_verbose > 1) {
4037 + ast_verbose(VERBOSE_PREFIX_3 "c_dtmf = %c\n",dtmf);
4039 + pipe_frame(p,(struct ast_frame *)&fr);
4042 + if (FACILITY_IND_FACILITYSELECTOR(CMSG) == 0x0003) {
4044 + /* ast_log(LOG_NOTICE,"FACILITY_IND PLCI = %#x\n",(int)FACILITY_IND_PLCI(CMSG));
4045 + ast_log(LOG_NOTICE,"%#x\n",FACILITY_IND_FACILITYINDICATIONPARAMETER(CMSG)[0]);
4046 + ast_log(LOG_NOTICE,"%#x\n",FACILITY_IND_FACILITYINDICATIONPARAMETER(CMSG)[1]);
4047 + ast_log(LOG_NOTICE,"%#x\n",FACILITY_IND_FACILITYINDICATIONPARAMETER(CMSG)[2]);
4048 + ast_log(LOG_NOTICE,"%#x\n",FACILITY_IND_FACILITYINDICATIONPARAMETER(CMSG)[3]);
4049 + ast_log(LOG_NOTICE,"%#x\n",FACILITY_IND_FACILITYINDICATIONPARAMETER(CMSG)[4]);
4050 + ast_log(LOG_NOTICE,"%#x\n",FACILITY_IND_FACILITYINDICATIONPARAMETER(CMSG)[5]); */
4052 + if ( (FACILITY_IND_FACILITYINDICATIONPARAMETER(CMSG)[1] == 0x3) && (FACILITY_IND_FACILITYINDICATIONPARAMETER(CMSG)[3] == 0x2)) {
4053 + p->i->state = CAPI_STATE_CONNECTED;
4054 + p->i->PLCI = p->i->onholdPLCI;
4055 + p->i->onholdPLCI = 0;
4057 + if ( (FACILITY_IND_FACILITYINDICATIONPARAMETER(CMSG)[1] == 0x2) && (FACILITY_IND_FACILITYINDICATIONPARAMETER(CMSG)[3] == 0x2)) {
4058 + if ((FACILITY_IND_FACILITYINDICATIONPARAMETER(CMSG)[5] != 0) && (FACILITY_IND_FACILITYINDICATIONPARAMETER(CMSG)[4] != 0)) {
4059 + // reason != 0x0000 == problem
4060 + p->i->onholdPLCI = 0;
4061 + p->i->state = CAPI_STATE_ONHOLD;
4062 + ast_log(LOG_WARNING, "unable to put PLCI=%#x onhold, REASON = %#x%#x, maybe you need to subscribe for this...\n",(int)FACILITY_IND_PLCI(CMSG),FACILITY_IND_FACILITYINDICATIONPARAMETER(CMSG)[5],FACILITY_IND_FACILITYINDICATIONPARAMETER(CMSG)[4]);
4064 + // reason = 0x0000 == call on hold
4065 + p->i->state = CAPI_STATE_ONHOLD;
4067 + ast_log(LOG_NOTICE, "PLCI=%#x put onhold\n",(int)FACILITY_IND_PLCI(CMSG));
4072 + error = FACILITY_RESP(&CMSG2, ast_capi_ApplID, CMSG->Messagenumber,FACILITY_IND_PLCI(CMSG),FACILITY_IND_FACILITYSELECTOR(CMSG),FACILITY_IND_FACILITYINDICATIONPARAMETER(CMSG));
4075 + ast_log(LOG_ERROR,"error sending FACILITY_RESP (error=%#x)\n",error);
4077 + if (option_verbose > 5) {
4079 + ast_verbose(VERBOSE_PREFIX_4 "sent FACILITY_RESP (PLCI=%#x)\n",(int)FACILITY_IND_PLCI(CMSG));
4084 + // ast_log(LOG_ERROR,"INFO_IND PLCI=%#x INFO# = %#x\n",PLCI,INFO_IND_INFONUMBER(CMSG));
4086 + memset(&CMSG2,0,sizeof(_cmsg));
4087 + error = INFO_RESP(&CMSG2,ast_capi_ApplID,CMSG->Messagenumber,PLCI);
4089 + ast_log(LOG_ERROR,"error sending INFO_RESP (error=%#x)\n",error);
4092 + if (option_verbose > 5) {
4094 + ast_verbose(VERBOSE_PREFIX_4 "sent INFO_RESP (PLCI=%#x)\n",PLCI);
4097 +/* if ((INFO_IND_INFONUMBER(CMSG) >> 8) == 0x00) {
4098 + ast_log(LOG_ERROR,"%#x\n",INFO_IND_INFOELEMENT(CMSG)[0]);
4099 + ast_log(LOG_ERROR,"%#x\n",INFO_IND_INFOELEMENT(CMSG)[1]);
4100 + ast_log(LOG_ERROR,"%#x\n",INFO_IND_INFOELEMENT(CMSG)[2]);
4101 + ast_log(LOG_ERROR,"%#x\n",INFO_IND_INFOELEMENT(CMSG)[3]);
4103 +#ifndef CAPI_NEVER_EVER_EARLY_B3_CONNECTS
4104 + if ((INFO_IND_INFONUMBER(CMSG) == 0x001e) && (p->i->doB3 != AST_CAPI_B3_DONT) && (p->i->earlyB3 == -1) && (p->i->state != CAPI_STATE_BCONNECTED)){
4105 + // ETSI 300 102-1 Progress Indicator
4106 + // we do early B3 Connect
4107 + if(INFO_IND_INFOELEMENT(CMSG)[0] >= 2) {
4108 + if(INFO_IND_INFOELEMENT(CMSG)[2] & 0x2) {
4109 + p->i->calledPartyIsISDN = 0;
4110 + // ast_log(LOG_NOTICE,"A N A L O G \n");
4112 + p->i->calledPartyIsISDN = 1;
4113 + // ast_log(LOG_NOTICE,"I S D N\n");
4115 + if(INFO_IND_INFOELEMENT(CMSG)[2] & 0x88) {
4116 + // in-band info available
4117 + p->i->earlyB3 = 1;
4118 + memset(&CMSG2,0,sizeof(_cmsg));
4119 + CONNECT_B3_REQ_HEADER(&CMSG2, ast_capi_ApplID, ast_capi_MessageNumber++,0);
4120 + CONNECT_B3_REQ_PLCI(&CMSG2) = PLCI;
4121 + if ((error = _capi_put_cmsg(&CMSG2)) != 0) {
4122 + ast_log(LOG_ERROR,"error sending early CONNECT_B3_REQ (error=%#x)\n",error);
4125 + if (option_verbose > 1) {
4127 + ast_verbose(VERBOSE_PREFIX_4 "sent early CONNECT_B3_REQ (PLCI=%#x)\n",PLCI);
4134 + if ((INFO_IND_INFONUMBER(CMSG) == 0x8045) && (PLCI == p->i->onholdPLCI)) {
4135 + // the caller onhold hung up (or ECTed away)
4136 + // send a disconnect_req , we cannot hangup the channel here!!!
4137 + memset(&CMSG2,0,sizeof(_cmsg));
4138 + DISCONNECT_REQ_HEADER(&CMSG2, ast_capi_ApplID, ast_capi_MessageNumber++, 0);
4139 + DISCONNECT_REQ_PLCI(&CMSG2) = p->i->onholdPLCI;
4141 + if ((error = _capi_put_cmsg(&CMSG2)) != 0) {
4142 + ast_log(LOG_NOTICE, "error sending DISCONNECT_REQ PLCI=%#x\n",PLCI);
4144 + if (option_verbose > 1) {
4146 + ast_verbose(VERBOSE_PREFIX_4 "sent DISCONNECT_REQ for onholdPLCI=%#x\n",PLCI);
4152 + // case 1: B3 on success or no B3 at all
4153 + if ((INFO_IND_INFONUMBER(CMSG) == 0x8045) && (p->i->doB3 != AST_CAPI_B3_ALWAYS) && (p->i->outgoing == 1)) {
4154 + p->i->earlyB3 = 0; // !!!
4155 + fr.frametype = AST_FRAME_NULL;
4157 + return pipe_frame(p,(struct ast_frame *)&fr);
4159 + // case 2: we are doing B3, and receive the 0x8045 after a successful call
4160 + if ((INFO_IND_INFONUMBER(CMSG) == 0x8045) && (p->i->doB3 != AST_CAPI_B3_DONT) && (p->i->earlyB3 == 0) && (p->i->outgoing == 1)) {
4161 + fr.frametype = AST_FRAME_NULL;
4163 + return pipe_frame(p,(struct ast_frame *)&fr);
4165 + // case 3: this channel is an incoming channel! the user hung up!
4166 + // it is much better to hangup now instead of waiting for a timeout and
4167 + // network caused DISCONNECT_IND!
4168 + if ((INFO_IND_INFONUMBER(CMSG) == 0x8045) && (p->i->outgoing == 0)) {
4169 + // ast_log(LOG_NOTICE,"case 3\n");
4170 + fr.frametype = AST_FRAME_NULL;
4172 + return pipe_frame(p,(struct ast_frame *)&fr);
4174 + // case 4 (a.k.a. the italian case): B3 always. call is unsuccessful
4175 + if ((INFO_IND_INFONUMBER(CMSG) == 0x8045) && (p->i->doB3 == AST_CAPI_B3_ALWAYS) && (p->i->earlyB3 == -1) && (p->i->outgoing == 1)) {
4176 + // wait for the 0x001e (PROGRESS), play audio and wait for a timeout from the network
4180 + // Handle DID digits
4181 + if ((INFO_IND_INFONUMBER(CMSG) == 0x0070) && p->i->isdnmode && (p->c != NULL)) {
4183 + char name[AST_CHANNEL_NAME] = "";
4186 + did = capi_number((char *)INFO_IND_INFOELEMENT(CMSG),1);
4187 + if (strcasecmp(p->i->dnid, did)) {
4188 + strncat(p->i->dnid, did, sizeof(p->i->dnid)-1);
4191 + snprintf(name,sizeof(name),"CAPI/contr%d/%s/-%d",p->i->controller,p->i->dnid,capi_counter++);
4192 + ast_change_name(p->c, name);
4194 + search = search_did(p->c);
4195 + if (search != -1) {
4197 + ast_setstate(p->c, AST_STATE_RING);
4198 + // we are alerting (phones ringing)
4199 + capi_alert(p->c); // Do this here after pbx_start the Channel can be destroyed
4200 + if (ast_pbx_start(p->c)) {
4201 + ast_log(LOG_ERROR,"Unable to start pbx on channel!\n");
4204 + if (option_verbose > 2) {
4206 + ast_verbose(VERBOSE_PREFIX_3 "started pbx on channel!\n");
4211 + ast_log(LOG_ERROR,"did not find device for msn = %s\n",p->i->dnid);
4212 + CONNECT_RESP_HEADER(&CMSG2, ast_capi_ApplID, CMSG->Messagenumber, 0);
4213 + CONNECT_RESP_PLCI(&CMSG2) = PLCI;
4214 + CONNECT_RESP_REJECT(&CMSG2) = 1; // ignore
4215 + if ((error = _capi_put_cmsg(&CMSG2)) != 0) {
4216 + ast_log(LOG_ERROR,"error sending CONNECT_RESP for PLCI = %#x\n",(int)CONNECT_IND_PLCI(CMSG));
4218 + if (option_verbose > 5) {
4220 + ast_verbose(VERBOSE_PREFIX_4 "sent CONNECT_RESP for PLCI = %#x\n",(int)CONNECT_IND_PLCI(CMSG));
4227 + if (INFO_IND_INFONUMBER(CMSG) == 0x8001) {
4228 + fr.frametype = AST_FRAME_CONTROL;
4229 + fr.subclass = AST_CONTROL_RINGING;
4230 + return pipe_frame(p,(struct ast_frame *)&fr);
4232 + if (INFO_IND_INFONUMBER(CMSG) == 0x800d) {
4233 + fr.frametype = AST_FRAME_CONTROL;
4234 + fr.subclass = AST_CONTROL_PROGRESS;
4235 + return pipe_frame(p,(struct ast_frame *)&fr);
4237 + if (INFO_IND_INFONUMBER(CMSG) == 0x74) {
4238 + strncpy(p->i->owner->exten,capi_number((char *)INFO_IND_INFOELEMENT(CMSG),3),sizeof(p->i->owner->exten)-1);
4239 + ast_log(LOG_NOTICE,"%s\n",capi_cmsg2str(CMSG));
4241 + if (INFO_IND_INFONUMBER(CMSG) == 0x28) {
4242 + // ast_sendtext(p->i->owner,capi_number(INFO_IND_INFOELEMENT(CMSG),0));
4243 + // struct ast_frame ft = { AST_FRAME_TEXT, capi_number(INFO_IND_INFOELEMENT(CMSG),0), };
4244 + // ast_queue_frame(p->i->owner, &ft);
4245 + // ast_log(LOG_NOTICE,"%s\n",capi_number(INFO_IND_INFOELEMENT(CMSG),0));
4248 + case CAPI_CONNECT_ACTIVE:
4249 +// ast_log(LOG_NOTICE,"CONNECT_ACTIVE_IND PLCI=%#x\n",(int)CONNECT_ACTIVE_IND_PLCI(CMSG));
4250 + CONNECT_ACTIVE_RESP_HEADER(&CMSG2, ast_capi_ApplID, CMSG->Messagenumber,0);
4251 + CONNECT_ACTIVE_RESP_PLCI(&CMSG2) = PLCI;
4252 + if ((error = _capi_put_cmsg(&CMSG2)) != 0) {
4253 + ast_log(LOG_ERROR,"error sending CONNECT_ACTIVE_RESP (error=%#x)\n",error);
4256 + if (option_verbose > 5) {
4258 + ast_verbose(VERBOSE_PREFIX_4 "sent CONNECT_ACTIVE_RESP (PLCI=%#x)\n",PLCI);
4261 + // normal processing
4262 + if (p->i->earlyB3 != 1) {
4263 + p->i->state = CAPI_STATE_CONNECTED;
4265 + // send a CONNECT_B3_REQ
4266 + if (p->i->outgoing == 1) {
4268 + memset(&CMSG2,0,sizeof(_cmsg));
4269 + CONNECT_B3_REQ_HEADER(&CMSG2, ast_capi_ApplID, ast_capi_MessageNumber++,0);
4270 + CONNECT_B3_REQ_PLCI(&CMSG2) = PLCI;
4271 + if ((error = _capi_put_cmsg(&CMSG2)) != 0) {
4272 + ast_log(LOG_ERROR,"error sending CONNECT_B3_REQ (error=%#x)\n",error);
4275 + if (option_verbose > 1) {
4277 + ast_verbose(VERBOSE_PREFIX_3 "sent CONNECT_B3_REQ (PLCI=%#x)\n",PLCI);
4282 + // RESP already sent ... wait for CONNECT_B3_IND
4283 +// ast_log(LOG_NOTICE,"waiting for CONNECT_B3_IND\n");
4286 + // special treatment for early B3 connects
4287 + p->i->state = CAPI_STATE_BCONNECTED;
4288 + if (p->c->_state != AST_STATE_UP) {
4289 + ast_setstate(p->c,AST_STATE_UP);
4291 + p->i->earlyB3 = 0; // not early anymore
4292 + fr.frametype = AST_FRAME_CONTROL;
4293 + fr.subclass = AST_CONTROL_ANSWER;
4295 + return pipe_frame(p,(struct ast_frame *)&fr);
4299 + case CAPI_CONNECT_B3:
4300 + // then send a CONNECT_B3_RESP
4301 + memset(&CMSG2,0,sizeof(_cmsg));
4302 + CONNECT_B3_RESP_HEADER(&CMSG2, ast_capi_ApplID, CMSG->Messagenumber, 0);
4303 + CONNECT_B3_RESP_NCCI(&CMSG2) = CONNECT_B3_IND_NCCI(CMSG);
4304 + p->NCCI = CONNECT_B3_IND_NCCI(CMSG);
4305 + p->i->NCCI = p->NCCI;
4306 + CONNECT_B3_RESP_REJECT(&CMSG2) = 0;
4308 + if ((error = _capi_put_cmsg(&CMSG2)) != 0) {
4309 + ast_log(LOG_ERROR,"error sending CONNECT_B3_RESP (error=%#x)\n",error);
4312 + if (option_verbose > 5) {
4314 + ast_verbose(VERBOSE_PREFIX_4 "sent CONNECT_B3_RESP (NCCI=%#x)\n",p->i->NCCI);
4317 + /* if (p->i->controller > 0) {
4318 + capi_controllers[p->i->controller]->nfreebchannels--;
4321 + case CAPI_CONNECT_B3_ACTIVE:
4322 +// ast_log(LOG_NOTICE,"CONNECT_B3_ACTIVE_IND NCCI=%#x\n",p->i->NCCI);
4323 + // then send a CONNECT_B3__ACTIVERESP
4325 + CONNECT_B3_ACTIVE_RESP_HEADER(&CMSG2, ast_capi_ApplID, CMSG->Messagenumber, 0);
4326 + CONNECT_B3_ACTIVE_RESP_NCCI(&CMSG2) = p->i->NCCI;
4328 + if ((error = _capi_put_cmsg(&CMSG2)) != 0) {
4329 + ast_log(LOG_ERROR,"error sending CONNECT_B3_ACTIVE_RESP (error=%#x)\n",error);
4332 + if (option_verbose > 5) {
4334 + ast_verbose(VERBOSE_PREFIX_4 "sent CONNECT_B3_ACTIVE_RESP (NCCI=%#x)\n",p->i->NCCI);
4338 + ast_mutex_lock(&contrlock);
4339 + if (p->i->controller > 0) {
4340 + capi_controllers[p->i->controller]->nfreebchannels--;
4342 + ast_mutex_unlock(&contrlock);
4344 + p->i->state = CAPI_STATE_BCONNECTED;
4345 + capi_echo_canceller(p->c,EC_FUNCTION_ENABLE);
4346 + capi_detect_dtmf(p->c,1);
4348 + if (p->i->earlyB3 != 1) {
4349 + ast_setstate(p->c,AST_STATE_UP);
4350 + fr.frametype = AST_FRAME_CONTROL;
4351 + fr.subclass = AST_CONTROL_ANSWER;
4353 + return pipe_frame(p,(struct ast_frame *)&fr);
4361 + switch (CMSG->Command) {
4362 + case CAPI_FACILITY:
4363 + if (FACILITY_CONF_FACILITYSELECTOR(CMSG) == 0x3) {
4364 + if ((FACILITY_CONF_FACILITYCONFIRMATIONPARAMETER(CMSG)[1] == 0x2) && (FACILITY_CONF_FACILITYCONFIRMATIONPARAMETER(CMSG)[2] == 0x0)) {
4365 + if ((FACILITY_CONF_FACILITYCONFIRMATIONPARAMETER(CMSG)[4] == 0x0) && (FACILITY_CONF_FACILITYCONFIRMATIONPARAMETER(CMSG)[5] == 0x0)) {
4367 + p->i->state = CAPI_STATE_BCONNECTED;
4369 + ast_log(LOG_NOTICE,"%s\n",capi_cmsg2str(CMSG));
4374 + case CAPI_DATA_B3:
4375 +// ast_log(LOG_NOTICE,"DATA_B3_CONF (NCCI %#x) for DATAHANDLE %#x\n",DATA_B3_CONF_NCCI(CMSG),DATA_B3_CONF_DATAHANDLE(CMSG));
4378 +// ast_log(LOG_NOTICE,"ALERT_CONF (PLCI=%#x)\n",(int)ALERT_CONF_PLCI(CMSG));
4379 + p->i->state = CAPI_STATE_ALERTING;
4380 + if (p->c->_state == AST_STATE_RING) {
4384 + case CAPI_CONNECT:
4385 + if (option_verbose > 1) {
4387 + ast_verbose(VERBOSE_PREFIX_2 "received CONNECT_CONF PLCI = %#x INFO = %#x\n",(int)CONNECT_CONF_PLCI(CMSG),CONNECT_CONF_INFO(CMSG));
4389 + if (CONNECT_CONF_INFO(CMSG) == 0) {
4390 + p->i->PLCI = CONNECT_CONF_PLCI(CMSG);
4391 + p->PLCI = p->i->PLCI;
4392 + ast_setstate(p->c,AST_STATE_DIALING);
4394 + // here, something has to be done -->
4395 + fr.frametype = AST_FRAME_CONTROL;
4396 + fr.subclass = AST_CONTROL_BUSY;
4398 + return pipe_frame(p,(struct ast_frame *)&fr);
4401 + case CAPI_CONNECT_B3:
4402 +// ast_log(LOG_NOTICE,"received CONNECT_B3_CONF NCCI = %#x INFO = %#x\n",(int)CONNECT_B3_CONF_NCCI(CMSG),CONNECT_B3_CONF_INFO(CMSG));
4403 + if (CONNECT_B3_CONF_INFO(CMSG) == 0) {
4404 + p->i->NCCI = CONNECT_B3_CONF_NCCI(CMSG);
4406 + p->i->earlyB3 = -1;
4407 + p->i->doB3 = AST_CAPI_B3_DONT;
4414 +// ast_log(LOG_NOTICE,"returning\n");
4418 +static void capi_handle_msg(_cmsg *CMSG) {
4419 + struct ast_capi_pvt *i;
4424 + MESSAGE_EXCHANGE_ERROR error;
4429 + char buffer[AST_MAX_EXTENSION];
4430 + struct capi_pipe *p;
4431 + char *magicmsn = "*\0";
4432 + char *emptyid = "\0";
4433 + char *emptydnid = "s\0";
4435 +#ifdef CAPI_DEFLECT_ON_CIRCUITBUSY
4439 + switch (CMSG->Subcommand) {
4440 + // indication msgs
4443 + switch (CMSG->Command) {
4444 + case CAPI_CONNECT: // only connect_ind are global (not channel specific)
4446 + ast_log(LOG_NOTICE,"%s\n",capi_cmsg2str(CMSG));
4447 + DNID = capi_number((char *)CONNECT_IND_CALLEDPARTYNUMBER(CMSG),1);
4448 + if ((DNID && *DNID == 0) || !DNID) {
4451 + NPLAN = (CONNECT_IND_CALLINGPARTYNUMBER(CMSG)[1] & 0x70);
4452 + CID = capi_number((char *)CONNECT_IND_CALLINGPARTYNUMBER(CMSG),2);
4453 + PLCI = CONNECT_IND_PLCI(CMSG);
4454 + controller = PLCI & 0xff;
4455 + if (option_verbose > 1) {
4457 + ast_verbose(VERBOSE_PREFIX_2 "CONNECT_IND (PLCI=%#x,DID=%s,CID=%s,CIP=%#x,CONTROLLER=%#x)\n",PLCI,DNID,CID,CONNECT_IND_CIPVALUE(CMSG),controller);
4459 + if(CONNECT_IND_BCHANNELINFORMATION(CMSG))
4460 + if ((CONNECT_IND_BCHANNELINFORMATION(CMSG)[1] == 0x02) && (!capi_controllers[controller]->isdnmode)) {
4461 + // this is a call waiting CONNECT_IND with BChannelinformation[1] == 0x02
4462 + // meaning "no B or D channel for this call", since we can't do anything with call waiting now
4463 + // just reject it with "user busy"
4464 + // however...if we are a p2p BRI then the telco switch will allow us to choose the b channel
4465 + // so it will look like a callwaiting connect_ind to us
4467 + ast_log(LOG_ERROR,"received a call waiting CONNECT_IND\n");
4468 +#ifndef CAPI_DEFLECT_ON_CIRCUITBUSY
4469 + CONNECT_RESP_HEADER(&CMSG2, ast_capi_ApplID, CMSG->Messagenumber, 0);
4470 + CONNECT_RESP_PLCI(&CMSG2) = CONNECT_IND_PLCI(CMSG);
4471 + CONNECT_RESP_REJECT(&CMSG2) = 3; // user is busy
4472 + if ((error = _capi_put_cmsg(&CMSG2)) != 0) {
4473 + ast_log(LOG_ERROR,"error sending CONNECT_RESP for PLCI = %#x\n",(int)CONNECT_IND_PLCI(CMSG));
4475 + if (option_verbose > 5) {
4477 + ast_verbose(VERBOSE_PREFIX_4 "sent CONNECT_RESP for PLCI = %#x\n",(int)CONNECT_IND_PLCI(CMSG));
4480 + // no need to pipe this
4487 + // well...somebody is calling us. let's set up a channel
4488 + ast_mutex_lock(&iflock);
4493 + if ((!i->owner) && (i->incomingmsn != NULL)){
4494 + strncpy(buffer,i->incomingmsn,sizeof(buffer)-1);
4495 + msn = strtok(buffer,",");
4496 + while (msn != NULL) {
4497 +// ast_log(LOG_NOTICE,"msn=%s\n",msn);
4498 + if (DNID && ((!strcasecmp(msn,DNID)) ||
4499 + (i->isdnmode && (strlen(msn)<strlen(DNID)) && !strncasecmp(msn, DNID, strlen(msn))) || (!strncasecmp(msn,magicmsn,strlen(msn)))) &&
4500 + (i->controllers & (1 << controller))) {
4501 + if (CID != NULL) {
4502 + if(NPLAN == CAPI_ETSI_NPLAN_NATIONAL)
4503 + snprintf(i->cid, (sizeof(i->cid)-1), "%s%s%s", i->prefix, capi_national_prefix, CID);
4504 + else if(NPLAN == CAPI_ETSI_NPLAN_INTERNAT)
4505 + snprintf(i->cid, (sizeof(i->cid)-1), "%s%s%s", i->prefix, capi_international_prefix, CID);
4507 + snprintf(i->cid, (sizeof(i->cid)-1), "%s%s", i->prefix, CID);
4509 + strncpy(i->cid,emptyid,sizeof(i->cid)-1);
4512 + strncpy(i->dnid,DNID,sizeof(i->dnid)-1);
4514 + strncpy(i->dnid,emptydnid,sizeof(i->dnid)-1);
4516 + i->controller=controller;
4518 + i->MessageNumber = CMSG->Messagenumber;
4519 + if (pipe(fds) == 0) {
4520 + if (option_verbose > 4) {
4521 + ast_verbose(VERBOSE_PREFIX_3 "creating pipe for PLCI=%#x msn = %s\n",PLCI,msn);
4524 + flags = fcntl(i->fd,F_GETFL);
4525 + fcntl(i->fd,F_SETFL,flags | O_SYNC | O_DIRECT);
4526 +// ast_log(LOG_NOTICE,"i->fd = %d\n",i->fd);
4527 + p = malloc(sizeof(struct capi_pipe));
4528 + memset(p, 0, sizeof(struct capi_pipe));
4530 + flags = fcntl(i->fd,F_GETFL);
4531 + fcntl(p->fd,F_SETFL,flags | O_SYNC | O_DIRECT);
4532 +// ast_log(LOG_NOTICE,"p->fd = %d\n",p->fd);
4535 + ast_mutex_init(&(p->lock));
4537 + if (i->isdnmode) {
4538 + p->c = capi_new(i,AST_STATE_DOWN);
4539 + i->state = CAPI_STATE_DID;
4541 + p->c = capi_new(i,AST_STATE_RING);
4543 + p->next = pipelist;
4546 + ast_mutex_unlock(&iflock);
4547 +#ifdef CAPI_DEFLECT_ON_CIRCUITBUSY
4548 + if ((deflect == 1) && (i->deflect2)) {
4549 + capi_deflect(p->c,i->deflect2);
4554 + ast_log(LOG_ERROR,"creating pipe for PLCI=%#x failed\n",PLCI);
4557 + } // if strcasecmp
4558 + msn = strtok(NULL,",");
4562 + } // while interface list
4563 + ast_mutex_unlock(&iflock); // obviously we are not called...so tell capi to ignore this call
4565 + ast_log(LOG_ERROR,"did not find device for msn = %s\n",DNID);
4567 + CONNECT_RESP_HEADER(&CMSG2, ast_capi_ApplID, CMSG->Messagenumber, 0);
4568 + CONNECT_RESP_PLCI(&CMSG2) = CONNECT_IND_PLCI(CMSG);
4569 + CONNECT_RESP_REJECT(&CMSG2) = 1; // ignore
4570 + if ((error = _capi_put_cmsg(&CMSG2)) != 0) {
4571 + ast_log(LOG_ERROR,"error sending CONNECT_RESP for PLCI = %#x\n",(int)CONNECT_IND_PLCI(CMSG));
4573 + if (option_verbose > 5) {
4575 + ast_verbose(VERBOSE_PREFIX_4 "sent CONNECT_RESP for PLCI = %#x\n",(int)CONNECT_IND_PLCI(CMSG));
4578 + ast_mutex_lock(&pipelock);
4579 + if (pipelist == NULL) {
4580 + capi_last_plci = PLCI;
4582 + ast_mutex_unlock(&pipelock);
4583 + // no need to pipe this
4585 +// ast_mutex_unlock(&iflock);
4588 + case CAPI_FACILITY:
4589 + PLCI = FACILITY_IND_PLCI(CMSG) & 0xffff; // this is for you eicon
4590 + if (option_verbose > 3) {
4592 + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(CMSG));
4594 +// ast_log(LOG_ERROR,"FACILITY_IND PLCI=%#x\n",PLCI);
4597 + PLCI = INFO_IND_PLCI(CMSG);
4598 + if (option_verbose > 3) {
4600 + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(CMSG));
4602 +// ast_log(LOG_ERROR,"INFO_IND PLCI=%#x INFO# = %#x\n",PLCI,INFO_IND_INFONUMBER(CMSG));
4604 + case CAPI_CONNECT_ACTIVE:
4605 + PLCI = CONNECT_ACTIVE_IND_PLCI(CMSG);
4606 + if (option_verbose > 3) {
4608 + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(CMSG));
4610 +// ast_log(LOG_ERROR,"CONNECT_ACTIVE_IND PLCI=%#x\n",PLCI);
4612 + case CAPI_CONNECT_B3:
4613 + NCCI = CONNECT_B3_IND_NCCI(CMSG);
4614 + PLCI = (NCCI << 16) >> 16;
4615 + if (option_verbose > 3) {
4617 + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(CMSG));
4619 +// ast_log(LOG_ERROR,"CONNECT_B3_IND NCCI=%#x PLCI=%#x\n",NCCI,PLCI);
4621 + case CAPI_CONNECT_B3_ACTIVE:
4622 + NCCI = CONNECT_B3_IND_NCCI(CMSG);
4623 + PLCI = (NCCI << 16) >> 16;
4624 + if (option_verbose > 3) {
4626 + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(CMSG));
4628 +// ast_log(LOG_ERROR,"CONNECT_B3_ACTIVE_IND NCCI=%#x PLCI=%#x\n",NCCI,PLCI);
4630 + case CAPI_DATA_B3:
4631 + NCCI = DATA_B3_IND_NCCI(CMSG);
4632 + PLCI = (NCCI << 16) >> 16;
4633 +// ast_log(LOG_ERROR,"DATA_B3_IND NCCI=%#x PLCI=%#x\n",NCCI,PLCI);
4635 + case CAPI_DISCONNECT_B3:
4636 + NCCI = DISCONNECT_B3_IND_NCCI(CMSG);
4637 + PLCI = (NCCI << 16) >> 16;
4638 + if (option_verbose > 1) {
4640 + ast_verbose(VERBOSE_PREFIX_2 "DISCONNECT_B3_IND NCCI=%#x\n",NCCI);
4643 + case CAPI_DISCONNECT:
4644 + PLCI = DISCONNECT_IND_PLCI(CMSG);
4645 + if (option_verbose > 1) {
4647 + ast_verbose(VERBOSE_PREFIX_2 "DISCONNECT_IND PLCI=%#x REASON=%#x\n",PLCI,DISCONNECT_IND_REASON(CMSG));
4651 + ast_log(LOG_ERROR,"Command.Subcommand = %#x.%#x\n",CMSG->Command,CMSG->Subcommand);
4654 + // confirmation msgs
4656 + switch (CMSG->Command) {
4657 + case CAPI_FACILITY:
4658 + NCCI = FACILITY_CONF_NCCI(CMSG);
4659 + PLCI = (NCCI << 16) >> 16;
4660 + if (option_verbose > 2) {
4661 + if (FACILITY_CONF_FACILITYSELECTOR(CMSG) == 6) {
4662 + if (FACILITY_CONF_INFO(CMSG))
4663 + ast_verbose (VERBOSE_PREFIX_3 "Error setting up echo canceller (PLCI=%#x, Info=%#04x)\n", PLCI, FACILITY_CONF_INFO(CMSG));
4665 + ast_verbose (VERBOSE_PREFIX_3 "Echo canceller successfully set up (PLCI=%#x)\n",PLCI);
4668 + if (option_verbose > 3) {
4670 + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(CMSG));
4672 +// ast_log(LOG_ERROR,"FACILITY_CONF NCCI=%#x INFO=%#x\n",(int)FACILITY_CONF_NCCI(CMSG),FACILITY_CONF_INFO(CMSG));
4675 + PLCI = INFO_CONF_PLCI(CMSG);
4676 +// ast_log(LOG_ERROR,"INFO_CONF PLCI=%#x INFO=%#x\n",PLCI,INFO_CONF_INFO(CMSG));
4678 + case CAPI_CONNECT:
4679 + PLCI = CONNECT_CONF_PLCI(CMSG);
4680 + if (option_verbose > 3) {
4682 + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(CMSG));
4684 +// ast_log(LOG_ERROR,"CONNECT_CONF PLCI=%#x INFO=%#x MN=%#x\n",PLCI,CONNECT_CONF_INFO(CMSG),CMSG->Messagenumber);
4686 + case CAPI_DISCONNECT:
4687 + PLCI = DISCONNECT_CONF_PLCI(CMSG);
4688 + if (option_verbose > 3) {
4690 + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(CMSG));
4692 +// ast_log(LOG_ERROR,"DISCONNECT_CONF PLCI=%#x INFO=%#x MN=%#x\n",PLCI,DISCONNECT_CONF_INFO(CMSG),CMSG->Messagenumber);
4694 + case CAPI_DISCONNECT_B3:
4695 + NCCI = DISCONNECT_B3_CONF_NCCI(CMSG);
4696 + PLCI = (NCCI << 16) >> 16;
4697 + if (option_verbose > 3) {
4699 + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(CMSG));
4701 +// ast_log(LOG_ERROR,"DISCONNECT_B3_CONF NCCI=%#x INFO=%#x MN=%#x\n",NCCI,DISCONNECT_B3_CONF_INFO(CMSG),CMSG->Messagenumber);
4703 + case CAPI_CONNECT_B3:
4704 + NCCI = CONNECT_B3_CONF_NCCI(CMSG);
4705 + PLCI = (NCCI << 16) >> 16;
4706 + if (option_verbose > 3) {
4708 + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(CMSG));
4710 +// ast_log(LOG_ERROR,"CONNECT_B3_CONF PLCI=%#x INFO=%#x MN=%#x\n",PLCI,CONNECT_B3_CONF_INFO(CMSG),CMSG->Messagenumber);
4713 + PLCI = ALERT_CONF_PLCI(CMSG);
4714 + if (option_verbose > 3) {
4716 + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(CMSG));
4718 +// ast_log(LOG_ERROR,"ALERT_CONF PLCI=%#x\n",PLCI);
4720 + case CAPI_DATA_B3:
4721 + NCCI = DATA_B3_CONF_NCCI(CMSG);
4722 + PLCI = (NCCI << 16) >> 16;
4723 + if (option_verbose > 5) {
4725 + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(CMSG));
4727 +// ast_log(LOG_ERROR,"DATA_B3_CONF NCCI=%#x PLCI=%#x\n",NCCI,PLCI);
4730 + ast_log(LOG_ERROR,"Command.Subcommand = %#x.%#x\n",CMSG->Command,CMSG->Subcommand);
4735 + pipe_msg(PLCI,CMSG);
4740 +// module stuff, monitor...
4742 +static void *do_monitor(void *data) {
4743 + unsigned int Info;
4747 + if (ast_mutex_lock(&monlock)) {
4748 + ast_log(LOG_ERROR,"Unable to get monitor lock!\n");
4751 + // do some nifty stuff
4752 + ast_mutex_unlock(&monlock);
4754 + monCMSG = malloc(sizeof(_cmsg));
4755 + memset(monCMSG,0,sizeof(_cmsg));
4756 + switch(Info = check_wait_get_cmsg(monCMSG)) {
4758 + if (option_verbose > 8) {
4760 + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(monCMSG));
4762 + capi_handle_msg(monCMSG);
4765 + // CAPI queue is empty
4768 + // something is wrong!
4778 +static void capi_gains(struct ast_capi_gains *g,float rxgain,float txgain) {
4781 + if (rxgain != 1.0) {
4782 + for (i=0;i<256;i++) {
4783 + x = (int)(((float)capiXLAW2INT(i)) * rxgain);
4784 + if (x > 32767) x = 32767;
4785 + if (x < -32767) x = -32767;
4786 + g->rxgains[i] = capiINT2XLAW(x);
4789 + for (i=0;i<256;i++) {
4790 + g->rxgains[i] = i;
4793 + if (txgain != 1.0) {
4794 + for (i=0;i<256;i++) {
4795 + x = (int)(((float)capiXLAW2INT(i)) * txgain);
4796 + if (x > 32767) x = 32767;
4797 + if (x < -32767) x = -32767;
4798 + g->txgains[i] = capiINT2XLAW(x);
4801 + for (i=0;i<256;i++) {
4802 + g->txgains[i] = i;
4808 +#ifdef CAPI_DEFLECT_ON_CIRCUITBUSY
4809 +int mkif(char *incomingmsn,char *context,char *controllerstr,int devices,int softdtmf,int echocancel,int ecoption,int ectail, char *prefix, int isdnmode, int es,float rxgain,float txgain, char *deflect2, char *accountcode, unsigned int callgroup, unsigned int group) {
4811 +int mkif(char *incomingmsn,char *context,char *controllerstr,int devices,int softdtmf,int echocancel,int ecoption,int ectail, char *prefix, int isdnmode, int es,float rxgain,float txgain, char *accountcode, unsigned int callgroup, unsigned int group) {
4813 + struct ast_capi_pvt *tmp;
4817 + unsigned long contrmap=0;
4819 + for (i=0;i<devices;i++) {
4820 + tmp = malloc(sizeof(struct ast_capi_pvt));
4821 + memset(tmp, 0, sizeof(struct ast_capi_pvt));
4823 + ast_mutex_init(&(tmp->lock));
4824 + strncpy(tmp->context, context, sizeof(tmp->context)-1);
4825 + strncpy(tmp->incomingmsn, incomingmsn, sizeof(tmp->incomingmsn)-1);
4826 + strncpy(tmp->prefix, prefix, sizeof(tmp->prefix)-1);
4827 + strncpy(tmp->accountcode, accountcode, sizeof(tmp->accountcode)-1);
4829 + strncpy(buffer,controllerstr,sizeof(buffer)-1);
4830 + contr = strtok(buffer,",");
4831 + while (contr != NULL) {
4832 + contrmap |= (1 << atoi(contr));
4833 + if (capi_controllers[atoi(contr)]) {
4834 + capi_controllers[atoi(contr)]->isdnmode = isdnmode;
4835 + // ast_log(LOG_NOTICE, "contr %d isdnmode %d\n",atoi(contr),isdnmode);
4837 + contr = strtok(NULL,",");
4839 + tmp->controllers = contrmap;
4840 + capi_used_controllers |= contrmap;
4841 + tmp->controller = 0;
4843 + tmp->earlyB3 = -1;
4844 + tmp->onholdPLCI = 0;
4845 + tmp->doEC = echocancel;
4846 + tmp->ecOption = ecoption;
4847 + tmp->ecTail = ectail;
4848 + tmp->isdnmode = isdnmode;
4850 + tmp->callgroup = callgroup;
4851 + tmp->group = group;
4855 + tmp->rxgain = rxgain;
4856 + tmp->txgain = txgain;
4857 + capi_gains(&tmp->g,rxgain,txgain);
4859 +#ifdef CAPI_DEFLECT_ON_CIRCUITBUSY
4860 + strncpy(tmp->deflect2, deflect2, sizeof(tmp->deflect2)-1);
4862 +#ifndef CAPI_FORCE_SOFTWARE_DTMF
4863 + if (softdtmf == 1) {
4866 +#ifndef CAPI_FORCE_SOFTWARE_DTMF
4871 + tmp->next = iflist; // prepend
4873 + // ast_log(LOG_NOTICE, "ast_capi_pvt(%s,%s,%#x,%d) (%d,%d,%d) (%d)(%f/%f) %d\n",tmp->incomingmsn,tmp->context,(int)tmp->controllers,devices,tmp->doEC,tmp->ecOption,tmp->ecTail,tmp->doES,tmp->rxgain,tmp->txgain,callgroup);
4874 + if (option_verbose > 2) {
4875 + ast_verbose(VERBOSE_PREFIX_2 "ast_capi_pvt(%s,%s,%d,%d) (%d,%d,%d)\n",tmp->incomingmsn,tmp->context,tmp->controller,devices,tmp->doEC,tmp->ecOption,tmp->ecTail);
4885 +void supported_sservices(struct ast_capi_controller *cp) {
4886 + MESSAGE_EXCHANGE_ERROR error;
4888 + struct timeval tv;
4891 + FACILITY_REQ_HEADER(&CMSG, ast_capi_ApplID, ast_capi_MessageNumber++, 0);
4892 + FACILITY_REQ_CONTROLLER(&CMSG) = cp->controller;
4893 + FACILITY_REQ_FACILITYSELECTOR(&CMSG) = 0x0003; // sservices
4898 + FACILITY_REQ_FACILITYREQUESTPARAMETER(&CMSG) = (unsigned char *)&fac;
4899 + if ((error= _capi_put_cmsg(&CMSG)) != 0) {
4900 + ast_log(LOG_ERROR,"error sending FACILITY_REQ (error=%#x)\n",error);
4902 + if (option_verbose > 5) {
4903 + ast_verbose(VERBOSE_PREFIX_4 "sent FACILITY_REQ (CONTROLLER=%#x)\n",cp->controller);
4910 + error = capi20_waitformessage(ast_capi_ApplID,&tv);
4911 + error = capi_get_cmsg(&CMSG2,ast_capi_ApplID);
4912 +// error = check_wait_get_cmsg(&CMSG2);
4914 + if (IS_FACILITY_CONF(&CMSG2)) {
4915 + if (option_verbose > 5) {
4916 + ast_verbose(VERBOSE_PREFIX_4 "FACILITY_CONF INFO = %#x\n",FACILITY_CONF_INFO(&CMSG2));
4922 + // parse supported sservices
4923 + if (FACILITY_CONF_FACILITYSELECTOR(&CMSG2) == 0x0003) {
4925 + if (FACILITY_CONF_FACILITYCONFIRMATIONPARAMETER(&CMSG2)[4] == 0) {
4926 + if ((FACILITY_CONF_FACILITYCONFIRMATIONPARAMETER(&CMSG2)[6] & 1) == 1) {
4927 + cp->holdretrieve = 1;
4928 + if (option_verbose > 3)
4929 + ast_verbose(VERBOSE_PREFIX_4 "HOLD/RETRIEVE\n");
4931 + cp->holdretrieve = 0;
4933 + if (((FACILITY_CONF_FACILITYCONFIRMATIONPARAMETER(&CMSG2)[6] & 2) >> 1) == 1) {
4934 + cp->terminalportability = 1;
4935 + if (option_verbose > 3)
4936 + ast_verbose(VERBOSE_PREFIX_4 "TERMINAL PORTABILITY\n");
4938 + cp->terminalportability = 0;
4940 + if (((FACILITY_CONF_FACILITYCONFIRMATIONPARAMETER(&CMSG2)[6] & 4) >> 2) == 1) {
4942 + if (option_verbose > 3)
4943 + ast_verbose(VERBOSE_PREFIX_4 "ECT\n");
4947 + if (((FACILITY_CONF_FACILITYCONFIRMATIONPARAMETER(&CMSG2)[6] & 8) >> 3) == 1) {
4949 + if (option_verbose > 3)
4950 + ast_verbose(VERBOSE_PREFIX_4 "3PTY\n");
4954 + if (((FACILITY_CONF_FACILITYCONFIRMATIONPARAMETER(&CMSG2)[6] & 16) >> 4) == 1) {
4956 + if (option_verbose > 3)
4957 + ast_verbose(VERBOSE_PREFIX_4 "CF\n");
4961 + if (((FACILITY_CONF_FACILITYCONFIRMATIONPARAMETER(&CMSG2)[6] & 32) >> 5) == 1) {
4963 + if (option_verbose > 3)
4964 + ast_verbose(VERBOSE_PREFIX_4 "CD\n");
4968 + if (((FACILITY_CONF_FACILITYCONFIRMATIONPARAMETER(&CMSG2)[6] & 64) >> 6) == 1) {
4970 + if (option_verbose > 3)
4971 + ast_verbose(VERBOSE_PREFIX_4 "MCID\n");
4975 + if (((FACILITY_CONF_FACILITYCONFIRMATIONPARAMETER(&CMSG2)[6] & 128) >> 7) == 1) {
4977 + if (option_verbose > 3)
4978 + ast_verbose(VERBOSE_PREFIX_4 "CCBS\n");
4982 + if ((FACILITY_CONF_FACILITYCONFIRMATIONPARAMETER(&CMSG2)[7] & 1) == 1) {
4984 + if (option_verbose > 3)
4985 + ast_verbose(VERBOSE_PREFIX_4 "MWI\n");
4989 + if (((FACILITY_CONF_FACILITYCONFIRMATIONPARAMETER(&CMSG2)[7] & 2) >> 1) == 1) {
4991 + if (option_verbose > 3)
4992 + ast_verbose(VERBOSE_PREFIX_4 "CCNR\n");
4996 + if (((FACILITY_CONF_FACILITYCONFIRMATIONPARAMETER(&CMSG2)[7] & 4) >> 2) == 1) {
4998 + if (option_verbose > 3)
4999 + ast_verbose(VERBOSE_PREFIX_4 "CONF\n");
5004 + ast_log(LOG_NOTICE,"supplementary services info = %#x\n",(short)FACILITY_CONF_FACILITYCONFIRMATIONPARAMETER(&CMSG2)[1]);
5007 + ast_log(LOG_NOTICE,"unexpected FACILITY_SELECTOR = %#x\n",FACILITY_CONF_FACILITYSELECTOR(&CMSG2));
5011 +static int capi_info(int fd, int argc, char *argv[])
5015 + return RESULT_SHOWUSAGE;
5016 + for (i=1;i<=capi_num_controllers;i++) {
5017 + ast_mutex_lock(&contrlock);
5018 + if (capi_controllers[i] != NULL) {
5019 + ast_cli(fd,"Contr%d: %d B channels total, %d B channels free.\n",i,capi_controllers[i]->nbchannels,capi_controllers[i]->nfreebchannels);
5021 + ast_mutex_unlock(&contrlock);
5023 + return RESULT_SUCCESS;
5026 +static int capi_do_debug(int fd, int argc, char *argv[])
5029 + return RESULT_SHOWUSAGE;
5031 + ast_cli(fd, "CAPI Debugging Enabled\n");
5032 + return RESULT_SUCCESS;
5035 +static int capi_no_debug(int fd, int argc, char *argv[])
5038 + return RESULT_SHOWUSAGE;
5040 + ast_cli(fd, "CAPI Debugging Disabled\n");
5041 + return RESULT_SUCCESS;
5044 +static char info_usage[] =
5045 +"Usage: capi info\n"
5046 +" Show info about B channels.\n";
5048 +static char debug_usage[] =
5049 +"Usage: capi debug\n"
5050 +" Enables dumping of CAPI packets for debugging purposes\n";
5052 +static char no_debug_usage[] =
5053 +"Usage: capi no debug\n"
5054 +" Disables dumping of CAPI packets for debugging purposes\n";
5056 +static struct ast_cli_entry cli_info =
5057 + { { "capi", "info", NULL }, capi_info, "Show CAPI info", info_usage };
5058 +static struct ast_cli_entry cli_debug =
5059 + { { "capi", "debug", NULL }, capi_do_debug, "Enable CAPI debugging", debug_usage };
5060 +static struct ast_cli_entry cli_no_debug =
5061 + { { "capi", "no", "debug", NULL }, capi_no_debug, "Disable CAPI debugging", no_debug_usage };
5063 +static const struct ast_channel_tech capi_tech = {
5065 + .description = tdesc,
5067 + .capabilities = AST_FORMAT_ULAW,
5069 + .capabilities = AST_FORMAT_ALAW,
5071 + .requester = capi_request,
5072 + .send_digit = capi_send_digit,
5073 + .send_text = NULL,
5074 + .call = capi_call,
5075 + .hangup = capi_hangup,
5076 + .answer = capi_answer,
5077 + .read = capi_read,
5078 + .write = capi_write,
5080 + .exception = NULL,
5081 + .indicate = capi_indicate,
5082 + .fixup = capi_fixup,
5083 + .setoption = NULL,
5086 +int load_module(void)
5088 + struct ast_config *cfg;
5089 + struct ast_variable *v;
5090 + char *config = "capi.conf";
5091 + char incomingmsn[AST_MAX_EXTENSION]="";
5092 + char context[AST_MAX_EXTENSION]="";
5093 + char prefix[AST_MAX_EXTENSION]="";
5094 + char accountcode[20]="";
5095 + char *empty = "\0";
5096 + char deflect2[AST_MAX_EXTENSION]="";
5097 + char controllerstr[AST_MAX_EXTENSION]="";
5102 + int ecoption=EC_OPTION_DISABLE_G165;
5103 + int ectail=EC_DEFAULT_TAIL;
5105 + float rxgain = 1.0;
5106 + float txgain = 1.0;
5108 + unsigned int callgroup=0;
5109 + unsigned int group=0;
5110 + struct ast_capi_controller *cp;
5112 + cfg = ast_config_load(config);
5114 + /* We *must* have a config file otherwise stop immediately, well no... */
5116 + ast_log(LOG_ERROR, "Unable to load config %s, CAPI disabled\n", config);
5119 + if (ast_mutex_lock(&iflock)) {
5120 + ast_log(LOG_ERROR, "Unable to lock interface list???\n");
5124 + strncpy(capi_national_prefix, AST_CAPI_NATIONAL_PREF, sizeof(capi_national_prefix)-1);
5125 + strncpy(capi_international_prefix, AST_CAPI_NATIONAL_PREF, sizeof(capi_national_prefix)-1);
5126 + v = ast_variable_browse(cfg, "general");
5128 + if (!strcasecmp(v->name, "nationalprefix")) {
5129 + strncpy(capi_national_prefix, v->value, sizeof(capi_national_prefix)-1);
5130 + } else if (!strcasecmp(v->name, "internationalprefix")) {
5131 + strncpy(capi_international_prefix, v->value, sizeof(capi_international_prefix)-1);
5132 + } else if (!strcasecmp(v->name, "rxgain")) {
5133 + if (sscanf(v->value,"%f",&rxgain) != 1) {
5134 + ast_log(LOG_ERROR,"invalid rxgain\n");
5136 + } else if (!strcasecmp(v->name, "txgain")) {
5137 + if (sscanf(v->value,"%f",&txgain) != 1) {
5138 + ast_log(LOG_ERROR,"invalid txgain\n");
5147 + if (capi20_isinstalled() != 0) {
5148 + ast_log(LOG_WARNING,"CAPI not installed, CAPI disabled!\n");
5152 + if (capi20_register(AST_CAPI_BCHANS,AST_CAPI_MAX_B3_BLOCKS,AST_CAPI_MAX_B3_BLOCK_SIZE,&ast_capi_ApplID) != 0) {
5153 + ast_log(LOG_NOTICE,"unable to register application at CAPI!\n");
5157 +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__)
5158 + if (capi20_get_profile(0,&profile) != 0) {
5160 + if (capi20_get_profile(0,(unsigned char *)&profile) != 0) {
5162 + ast_log(LOG_NOTICE,"unable to get CAPI profile!\n");
5165 +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__)
5166 + capi_num_controllers = profile.wCtlr;
5168 + capi_num_controllers = profile.ncontrollers;
5170 + if (option_verbose > 3)
5171 + ast_verbose(VERBOSE_PREFIX_3 "This box has %d capi controller(s).\n",capi_num_controllers);
5172 + for (controller=1;controller<=capi_num_controllers;controller++) {
5174 + memset(&profile,0,sizeof(profile));
5175 +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__)
5176 + capi20_get_profile(controller,&profile);
5178 + capi20_get_profile(controller,(unsigned char *)&profile);
5180 + cp = malloc(sizeof(struct ast_capi_controller));
5181 + cp->controller = controller;
5182 +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__)
5183 + cp->nbchannels = profile.wNumBChannels;
5184 + cp->nfreebchannels = profile.wNumBChannels;
5185 + if (profile.dwGlobalOptions & CAPI_PROFILE_DTMF_SUPPORT) {
5187 + cp->nbchannels = profile.nbchannels;
5188 + cp->nfreebchannels = profile.nbchannels;
5189 + if ((profile.globaloptions & 8) >> 3 == 1) {
5191 + if (option_verbose > 3)
5192 + ast_verbose(VERBOSE_PREFIX_3 "CAPI/contr%d supports DTMF\n",controller);
5197 +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__)
5198 + if (profile.dwGlobalOptions & CAPI_PROFILE_ECHO_CANCELLATION) {
5200 + if (profile.globaloptions2 & 1) {
5202 + if (option_verbose > 3)
5203 + ast_verbose(VERBOSE_PREFIX_3 "CAPI/contr%d supports echo cancellation\n",controller);
5204 + cp->echocancel = 1;
5206 + cp->echocancel = 0;
5208 +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__)
5209 + if (profile.dwGlobalOptions & CAPI_PROFILE_SUPPLEMENTARY_SERVICES) {
5211 + if ((profile.globaloptions & 16) >> 4 == 1) {
5213 + cp->sservices = 1;
5215 + cp->sservices = 0;
5217 + capi_controllers[controller] = cp;
5218 + if (cp->sservices == 1) {
5219 + if (option_verbose > 3)
5220 + ast_verbose(VERBOSE_PREFIX_3 "CAPI/contr%d supports supplementary services\n",controller);
5221 + supported_sservices(cp);
5226 + v = ast_variable_browse(cfg, "interfaces");
5228 + /* Create the interface list */
5229 + if (!strcasecmp(v->name, "devices")) {
5230 +#ifdef CAPI_DEFLECT_ON_CIRCUITBUSY
5231 + if (mkif(incomingmsn,context,controllerstr,atoi(v->value),softdtmf,echocancel,ecoption,ectail, prefix, isdnmode, es,rxgain,txgain,deflect2,accountcode,callgroup, group)) {
5233 + if (mkif(incomingmsn,context,controllerstr,atoi(v->value),softdtmf,echocancel,ecoption,ectail, prefix, isdnmode, es,rxgain,txgain,accountcode,callgroup, group)) {
5235 + ast_log(LOG_ERROR,"Error creating interface list\n");
5239 + strncpy(deflect2, empty, sizeof(deflect2)-1);
5240 + } else if (!strcasecmp(v->name, "context")) {
5241 + strncpy(context, v->value, sizeof(context)-1);
5242 + } else if (!strcasecmp(v->name, "incomingmsn")) {
5243 + strncpy(incomingmsn, v->value, sizeof(incomingmsn)-1);
5244 + } else if (!strcasecmp(v->name, "controller")) {
5245 + strncpy(controllerstr, v->value, sizeof(controllerstr)-1);
5246 + } else if (!strcasecmp(v->name, "softdtmf")) {
5247 + softdtmf = atoi(v->value);
5248 + } else if (!strcasecmp(v->name, "echosquelch")) {
5249 + es = atoi(v->value);
5250 + } else if (!strcasecmp(v->name, "callgroup")) {
5251 + callgroup = ast_get_group(v->value);
5252 + } else if (!strcasecmp(v->name, "group")) {
5253 + group = ast_get_group(v->value);
5254 + } else if (!strcasecmp(v->name, "deflect")) {
5255 + strncpy(deflect2, v->value, sizeof(deflect2)-1);
5256 + } else if (!strcasecmp(v->name, "rxgain")) {
5257 + if (sscanf(v->value,"%f",&rxgain) != 1) {
5258 + ast_log(LOG_ERROR,"invalid rxgain\n");
5260 + } else if (!strcasecmp(v->name, "txgain")) {
5261 + if (sscanf(v->value,"%f",&txgain) != 1) {
5262 + ast_log(LOG_ERROR,"invalid txgain\n");
5264 + } else if (!strcasecmp(v->name, "echocancel")) {
5265 + if (!strcasecmp(v->value, "yes") || !strcasecmp(v->value, "1") || !strcasecmp(v->value, "on")) {
5267 + ecoption=EC_OPTION_DISABLE_G165;
5269 + else if (!strcasecmp(v->value, "no") || !strcasecmp(v->value, "0") || !strcasecmp(v->value, "off")) {
5273 + else if (!strcasecmp(v->value, "g165") || !strcasecmp(v->value, "g.165")) {
5275 + ecoption=EC_OPTION_DISABLE_G165;
5277 + else if (!strcasecmp(v->value, "g164") || !strcasecmp(v->value, "g.164")) {
5279 + ecoption=EC_OPTION_DISABLE_G164_OR_G165;
5281 + else if (!strcasecmp(v->value, "force")) {
5283 + ecoption=EC_OPTION_DISABLE_NEVER;
5286 + ast_log(LOG_ERROR,"Unknown echocancel parameter \"%s\" -- ignoring\n",v->value);
5288 + } else if (!strcasecmp(v->name, "echotail")) {
5289 + ectail = atoi(v->value);
5292 + } else if (!strcasecmp(v->name, "prefix")) {
5293 + strncpy(prefix, v->value, sizeof(prefix)-1);
5294 + } else if (!strcasecmp(v->name, "accountcode")) {
5295 + strncpy(accountcode, v->value, sizeof(accountcode)-1);
5296 + } else if (!strcasecmp(v->name, "isdnmode")) {
5297 + if (!strcasecmp(v->value, "ptp") || !strcasecmp(v->value, "1"))
5299 + else if (!strcasecmp(v->value, "ptm") || !strcasecmp(v->value, "0") || !strcasecmp(v->value, "ptmp"))
5302 + ast_log(LOG_ERROR,"Unknown isdnmode parameter \"%s\" -- ignoring\n",v->value);
5308 + ast_config_destroy(cfg);
5310 + for (controller=1;controller<=capi_num_controllers;controller++) {
5311 + if (capi_used_controllers & (1 << controller)) {
5312 + if (ListenOnController(ALL_SERVICES,controller) != 0) {
5313 + ast_log(LOG_ERROR,"Unable to listen on contr%d\n",controller);
5315 + if (option_verbose > 2)
5316 + ast_verbose(VERBOSE_PREFIX_3 "listening on contr%d CIPmask = %#x\n",controller,ALL_SERVICES);
5319 + ast_log(LOG_WARNING,"Unused contr%d\n",controller);
5324 + ast_mutex_unlock(&iflock);
5326 + if (ast_channel_register(&capi_tech)) {
5327 + ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
5332 + ast_cli_register(&cli_info);
5333 + ast_cli_register(&cli_debug);
5334 + ast_cli_register(&cli_no_debug);
5336 + if (ast_mutex_lock(&monlock)) {
5337 + ast_log(LOG_WARNING,"Unable to get monitor lock!\n");
5340 + if (monitor_thread == pthread_self()) {
5341 + ast_mutex_unlock(&monlock);
5342 + ast_log(LOG_WARNING,"Unable to kill myself!\n");
5346 + if (ast_pthread_create(&monitor_thread,NULL,do_monitor,NULL) < 0) {
5347 + ast_mutex_unlock(&monlock);
5348 + ast_log(LOG_ERROR,"Unable to start monitor thread!\n");
5356 +int unload_module()
5358 + if (capi20_release(ast_capi_ApplID) != 0)
5359 + ast_log(LOG_WARNING,"Unable to unregister from CAPI!\n");
5360 + ast_channel_unregister(&capi_tech);
5367 + ast_mutex_lock(&usecnt_lock);
5369 + ast_mutex_unlock(&usecnt_lock);
5373 +char *description()
5381 + return ASTERISK_GPL_KEY;
5383 diff -urN asterisk-1.2.7.1.orig/channels/chan_features.c asterisk-1.2.7.1/channels/chan_features.c
5384 --- asterisk-1.2.7.1.orig/channels/chan_features.c 2006-01-25 19:39:44.000000000 +0100
5385 +++ asterisk-1.2.7.1/channels/chan_features.c 2006-04-18 14:39:28.000000000 +0200
5388 ast_mutex_unlock(&featurelock);
5390 - chan = ast_request(tech, format, dest, &status);
5391 + chan = ast_request(tech, format, dest, &status, NULL);
5393 ast_log(LOG_NOTICE, "Unable to allocate subchannel '%s/%s'\n", tech, dest);
5395 diff -urN asterisk-1.2.7.1.orig/channels/chan_iax2.c asterisk-1.2.7.1/channels/chan_iax2.c
5396 --- asterisk-1.2.7.1.orig/channels/chan_iax2.c 2006-03-31 21:11:26.000000000 +0200
5397 +++ asterisk-1.2.7.1/channels/chan_iax2.c 2006-04-18 14:39:28.000000000 +0200
5399 * the project provides a web site, mailing lists and IRC
5400 * channels for your use.
5402 + * Hangup cause signalling implementation by
5403 + * Levent Guendogdu <levon@feature-it.com>
5405 * This program is free software, distributed under the terms of
5406 * the GNU General Public License Version 2. See the LICENSE file
5407 * at the top of the source tree.
5408 @@ -3065,7 +3068,7 @@
5409 memset(&ied, 0, sizeof(ied));
5410 ast_mutex_lock(&iaxsl[callno]);
5411 if (callno && iaxs[callno]) {
5412 - ast_log(LOG_DEBUG, "We're hanging up %s now...\n", c->name);
5413 + ast_log(LOG_DEBUG, "We're hanging up %s with cause %i now...\n", c->name, c->hangupcause);
5414 alreadygone = ast_test_flag(iaxs[callno], IAX_ALREADYGONE);
5415 /* Send the hangup unless we have had a transmission error or are already gone */
5416 iax_ie_append_byte(&ied, IAX_IE_CAUSECODE, (unsigned char)c->hangupcause);
5417 @@ -3117,7 +3120,8 @@
5418 static struct ast_frame *iax2_read(struct ast_channel *c)
5420 static struct ast_frame f = { AST_FRAME_NULL, };
5421 - ast_log(LOG_NOTICE, "I should never be called!\n");
5422 + if (option_verbose > 3)
5423 + ast_log(LOG_NOTICE, "I should never be called!\n");
5427 @@ -6702,7 +6706,7 @@
5429 if (f.frametype == AST_FRAME_IAX) {
5430 if (iaxs[fr.callno]->initid > -1) {
5431 - /* Don't auto congest anymore since we've gotten something usefulb ack */
5432 + /* Don't auto congest anymore since we've gotten something useful back */
5433 ast_sched_del(sched, iaxs[fr.callno]->initid);
5434 iaxs[fr.callno]->initid = -1;
5436 diff -urN asterisk-1.2.7.1.orig/channels/chan_sip.c asterisk-1.2.7.1/channels/chan_sip.c
5437 --- asterisk-1.2.7.1.orig/channels/chan_sip.c 2006-04-07 16:16:41.000000000 +0200
5438 +++ asterisk-1.2.7.1/channels/chan_sip.c 2006-04-25 13:23:13.000000000 +0200
5440 unsigned int flags; /*!< SIP_ flags */
5441 int timer_t1; /*!< SIP timer T1, ms rtt */
5442 unsigned int sipoptions; /*!< Supported SIP sipoptions on the other end */
5443 + int dialog_established; /*!< SIP dialog established */
5444 int capability; /*!< Special capability (codec) */
5445 int jointcapability; /*!< Supported capability at both ends (codecs ) */
5446 int peercapability; /*!< Supported peer capability */
5448 char refer_to[AST_MAX_EXTENSION]; /*!< Place to store REFER-TO extension */
5449 char referred_by[AST_MAX_EXTENSION]; /*!< Place to store REFERRED-BY extension */
5450 char refer_contact[AST_MAX_EXTENSION]; /*!< Place to store Contact info from a REFER extension */
5451 + char refer_replaces[AST_MAX_EXTENSION]; /*!< Place to store Replaces header of REFER-TO header */
5452 struct sip_pvt *refer_call; /*!< Call we are referring */
5453 struct sip_route *route; /*!< Head of linked list of routing steps (fm Record-Route) */
5454 int route_persistant; /*!< Is this the "real" route? */
5456 char peername[256]; /*!< [peer] name, not set if [user] */
5457 char authname[256]; /*!< Who we use for authentication */
5458 char uri[256]; /*!< Original requested URI */
5459 + char origuri[256]; /*!< REAL! Original requested URI */
5460 char okcontacturi[256]; /*!< URI from the 200 OK on INVITE */
5461 char peersecret[256]; /*!< Password */
5462 char peermd5secret[256];
5464 static int determine_firstline_parts(struct sip_request *req);
5465 static void sip_dump_history(struct sip_pvt *dialog); /* Dump history to LOG_DEBUG at end of dialog, before destroying data */
5466 static const struct cfsubscription_types *find_subscription_type(enum subscriptiontype subtype);
5467 -static int transmit_state_notify(struct sip_pvt *p, int state, int full, int substate);
5468 +static int transmit_state_notify(struct sip_pvt *p, int state, int full, int substate, char *cid_num, char *cid_name);
5469 static char *gettag(struct sip_request *req, char *header, char *tagbuf, int tagbufsize);
5471 /*! \brief Definition of this channel for PBX channel registration */
5472 @@ -1304,7 +1307,7 @@
5473 /* If this is a subscription, tell the phone that we got a timeout */
5474 if (p->subscribed) {
5475 p->subscribed = TIMEOUT;
5476 - transmit_state_notify(p, AST_EXTENSION_DEACTIVATED, 1, 1); /* Send first notification */
5477 + transmit_state_notify(p, AST_EXTENSION_DEACTIVATED, 1, 1, NULL, NULL); /* Send first notification */
5478 p->subscribed = NONE;
5479 append_history(p, "Subscribestatus", "timeout");
5480 return 10000; /* Reschedule this destruction so that we know that it's gone */
5481 @@ -3124,16 +3127,30 @@
5483 /*! \brief find_call: Connect incoming SIP message to current dialog or create new dialog structure */
5484 /* Called by handle_request, sipsock_read */
5485 -static struct sip_pvt *find_call(struct sip_request *req, struct sockaddr_in *sin, const int intended_method)
5486 +static struct sip_pvt *find_call(struct sip_request *req, struct sockaddr_in *sin, const int intended_method, const int replaces_callid)
5496 callid = get_header(req, "Call-ID");
5498 + if (replaces_callid) {
5499 + replaces = get_header(req, "Replaces");
5500 + c = strchr(replaces, ';');
5503 + if (!ast_strlen_zero(replaces)) {
5504 + callid = replaces;
5510 if (pedanticsipchecking) {
5511 /* In principle Call-ID's uniquely identify a call, but with a forking SIP proxy
5512 we need more to identify a branch - so we have to check branch, from
5513 @@ -4058,6 +4075,7 @@
5514 if (sipmethod == SIP_CANCEL) {
5515 c = p->initreq.rlPart2; /* Use original URI */
5516 } else if (sipmethod == SIP_ACK) {
5517 +// XXX+ } else if (!strcasecmp(msg, "ACK") && !p->dialog_established) {
5518 /* Use URI from Contact: in 200 OK (if INVITE)
5519 (we only have the contacturi on INVITEs) */
5520 if (!ast_strlen_zero(p->okcontacturi))
5521 @@ -4824,13 +4842,15 @@
5522 ast_build_string(&invite, &invite_max, ";%s", p->options->uri_options);
5524 ast_copy_string(p->uri, invite_buf, sizeof(p->uri));
5525 + ast_copy_string(p->origuri, invite, sizeof(p->origuri));
5527 if (sipmethod == SIP_NOTIFY && !ast_strlen_zero(p->theirtag)) {
5528 /* If this is a NOTIFY, use the From: tag in the subscribe (RFC 3265) */
5529 snprintf(to, sizeof(to), "<sip:%s>;tag=%s", p->uri, p->theirtag);
5530 } else if (p->options && p->options->vxml_url) {
5531 /* If there is a VXML URL append it to the SIP URL */
5532 - snprintf(to, sizeof(to), "<%s>;%s", p->uri, p->options->vxml_url);
5533 +// snprintf(to, sizeof(to), "<%s>;%s", p->uri, p->options->vxml_url);
5534 + snprintf(to, sizeof(to), "<%s;%s>", p->uri, p->options->vxml_url);
5536 snprintf(to, sizeof(to), "<%s>", p->uri);
5538 @@ -4887,6 +4907,11 @@
5539 if (!ast_strlen_zero(p->referred_by))
5540 add_header(&req, "Referred-By", p->referred_by);
5542 + if (sipmethod == SIP_INVITE) {
5543 + if (!ast_strlen_zero(p->refer_replaces)) {
5544 + add_header(&req, "Replaces", p->refer_replaces);
5548 if ((req.method != SIP_OPTIONS) && p->options && !ast_strlen_zero(p->options->osptoken)) {
5549 ast_log(LOG_DEBUG,"Adding OSP Token: %s\n", p->options->osptoken);
5550 @@ -4961,8 +4986,7 @@
5553 /*! \brief transmit_state_notify: Used in the SUBSCRIBE notification subsystem ----*/
5554 -static int transmit_state_notify(struct sip_pvt *p, int state, int full, int substate)
5556 +static int transmit_state_notify(struct sip_pvt *p, int state, int full, int substate, char *cid_num, char *cid_name) {
5557 char tmp[4000], from[256], to[256];
5558 char *t = tmp, *c, *a, *mfrom, *mto;
5559 size_t maxbytes = sizeof(tmp);
5560 @@ -5106,10 +5130,19 @@
5561 case DIALOG_INFO_XML: /* SNOM subscribes in this format */
5562 ast_build_string(&t, &maxbytes, "<?xml version=\"1.0\"?>\n");
5563 ast_build_string(&t, &maxbytes, "<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" version=\"%d\" state=\"%s\" entity=\"%s\">\n", p->dialogver++, full ? "full":"partial", mto);
5564 - if ((state & AST_EXTENSION_RINGING) && global_notifyringing)
5565 - ast_build_string(&t, &maxbytes, "<dialog id=\"%s\" direction=\"recipient\">\n", p->exten);
5567 + if ((state & AST_EXTENSION_RINGING) && global_notifyringing) {
5568 + ast_build_string(&t, &maxbytes, "<dialog id=\"%s\" direction=\"recipient\">\n", p->exten);
5570 + ast_build_string(&t, &maxbytes, "<local><identity display=\"%s\">%s</identity><target uri=\"%s\"/></local>\n", p->exten, p->exten, mfrom);
5571 + if (cid_name && !ast_strlen_zero(cid_name)) {
5572 + ast_build_string(&t, &maxbytes, "<remote><identity display=\"%s\">sip:%s@%s</identity><target uri=\"sip:%s%s@%s\"/></remote>\n", cid_name, cid_num, p->fromdomain, ast_pickup_ext(), p->exten, p->fromdomain);
5574 + ast_build_string(&t, &maxbytes, "<remote><identity display=\"%s\">sip:%s@%s</identity><target uri=\"sip:%s%s@%s\"/></remote>\n", cid_num, cid_num, p->fromdomain, ast_pickup_ext(), p->exten, p->fromdomain);
5578 ast_build_string(&t, &maxbytes, "<dialog id=\"%s\">\n", p->exten);
5580 ast_build_string(&t, &maxbytes, "<state>%s</state>\n", statestring);
5581 ast_build_string(&t, &maxbytes, "</dialog>\n</dialog-info>\n");
5583 @@ -6321,7 +6354,7 @@
5584 /*! \brief cb_extensionstate: Callback for the devicestate notification (SUBSCRIBE) support subsystem ---*/
5585 /* If you add an "hint" priority to the extension in the dial plan,
5586 you will get notifications on device state changes */
5587 -static int cb_extensionstate(char *context, char* exten, int state, void *data)
5588 +static int cb_extensionstate(char *context, char* exten, int state, void *data, char *cid_num, char *cid_name)
5590 struct sip_pvt *p = data;
5592 @@ -6340,7 +6373,7 @@
5593 p->laststate = state;
5596 - transmit_state_notify(p, state, 1, 1);
5597 + transmit_state_notify(p, state, 1, 1, cid_num, cid_name);
5599 if (option_debug > 1)
5600 ast_verbose(VERBOSE_PREFIX_1 "Extension Changed %s new state %s for Notify User %s\n", exten, ast_extension_state2str(state), p->username);
5601 @@ -8607,6 +8640,7 @@
5605 + struct ast_call_feature *feature;
5607 /* Need to check the media/type */
5608 if (!strcasecmp(get_header(req, "Content-Type"), "application/dtmf-relay") ||
5609 @@ -8670,6 +8704,19 @@
5610 ast_queue_control(p->owner, AST_CONTROL_VIDUPDATE);
5611 transmit_response(p, "200 OK", req);
5613 + } else if ((c = get_header(req, "Record"))) {
5614 + feature = ast_find_builtin_feature("automon");
5615 + if (feature && (!ast_strlen_zero(feature->exten))) {
5617 +// ast_log(LOG_NOTICE, "feature exten %s\n", feature->exten);
5618 + for (i=0; i<strlen(feature->exten); i++) {
5619 + struct ast_frame f = { AST_FRAME_DTMF, feature->exten[i] };
5620 + ast_queue_frame(p->owner, &f);
5623 + ast_log(LOG_NOTICE, "Feature \"One Touch Monitor\" not configured in features.conf.\n");
5626 } else if ((c = get_header(req, "X-ClientCode"))) {
5627 /* Client code (from SNOM phone) */
5628 if (ast_test_flag(p, SIP_USECLIENTCODE)) {
5629 @@ -8769,12 +8816,63 @@
5630 return RESULT_SUCCESS;
5634 +/*! \brief sip_notify: Send SIP notify to peer */
5635 +static int sip_send_notify(int fd, char *notify_type, char *peer)
5637 + struct ast_variable *varlist;
5638 + struct sip_pvt *p;
5639 + struct sip_request req;
5640 + struct ast_variable *var;
5642 + varlist = ast_variable_browse(notify_types, notify_type);
5646 + ast_cli(fd, "Unable to find notify type '%s'\n", notify_type);
5647 + return RESULT_FAILURE;
5650 + p = sip_alloc(NULL, NULL, 0, SIP_NOTIFY);
5652 + ast_log(LOG_WARNING, "Unable to build sip pvt data for notify\n");
5653 + return RESULT_FAILURE;
5656 + if (create_addr(p, peer)) {
5657 + /* Maybe they're not registered, etc. */
5660 + ast_cli(fd, "Could not create address for '%s'\n", peer);
5661 + return RESULT_FAILURE;
5664 + initreqprep(&req, p, SIP_NOTIFY);
5666 + for (var = varlist; var; var = var->next)
5667 + add_header(&req, var->name, var->value);
5669 + add_blank_header(&req);
5670 + /* Recalculate our side, and recalculate Call ID */
5671 + if (ast_sip_ouraddrfor(&p->sa.sin_addr, &p->ourip))
5672 + memcpy(&p->ourip, &__ourip, sizeof(p->ourip));
5673 + build_via(p, p->via, sizeof(p->via));
5674 + build_callid(p->callid, sizeof(p->callid), p->ourip, p->fromdomain);
5676 + ast_cli(fd, "Sending NOTIFY of type '%s' to '%s'\n", notify_type, peer);
5677 + transmit_sip_request(p, &req);
5678 + sip_scheddestroy(p, 15000);
5680 + return RESULT_SUCCESS;
5683 /*! \brief sip_notify: Send SIP notify to peer */
5684 static int sip_notify(int fd, int argc, char *argv[])
5686 struct ast_variable *varlist;
5689 + int res = RESULT_SUCCESS;
5692 return RESULT_SHOWUSAGE;
5694 @@ -8791,41 +8889,13 @@
5697 for (i = 3; i < argc; i++) {
5698 - struct sip_pvt *p;
5699 - struct sip_request req;
5700 - struct ast_variable *var;
5702 - p = sip_alloc(NULL, NULL, 0, SIP_NOTIFY);
5704 - ast_log(LOG_WARNING, "Unable to build sip pvt data for notify\n");
5705 - return RESULT_FAILURE;
5708 - if (create_addr(p, argv[i])) {
5709 - /* Maybe they're not registered, etc. */
5711 - ast_cli(fd, "Could not create address for '%s'\n", argv[i]);
5715 - initreqprep(&req, p, SIP_NOTIFY);
5717 - for (var = varlist; var; var = var->next)
5718 - add_header(&req, var->name, var->value);
5719 + if (sip_send_notify(fd, argv[2], argv[i]) == RESULT_FAILURE)
5720 + res = RESULT_FAILURE;
5725 - add_blank_header(&req);
5726 - /* Recalculate our side, and recalculate Call ID */
5727 - if (ast_sip_ouraddrfor(&p->sa.sin_addr, &p->ourip))
5728 - memcpy(&p->ourip, &__ourip, sizeof(p->ourip));
5729 - build_via(p, p->via, sizeof(p->via));
5730 - build_callid(p->callid, sizeof(p->callid), p->ourip, p->fromdomain);
5731 - ast_cli(fd, "Sending NOTIFY of type '%s' to '%s'\n", argv[2], argv[i]);
5732 - transmit_sip_request(p, &req);
5733 - sip_scheddestroy(p, 15000);
5736 - return RESULT_SUCCESS;
5738 /*! \brief sip_do_history: Enable SIP History logging (CLI) ---*/
5739 static int sip_do_history(int fd, int argc, char *argv[])
5741 @@ -9468,12 +9538,13 @@
5742 case 100: /* Trying */
5743 sip_cancel_destroy(p);
5746 case 180: /* 180 Ringing */
5747 sip_cancel_destroy(p);
5748 if (!ignore && p->owner) {
5749 ast_queue_control(p->owner, AST_CONTROL_RINGING);
5750 if (p->owner->_state != AST_STATE_UP)
5751 - ast_setstate(p->owner, AST_STATE_RINGING);
5752 + ast_setstate_and_cid(p->owner, AST_STATE_RINGING, p->owner->cid.cid_num, p->owner->cid.cid_name);
5754 if (!strcasecmp(get_header(req, "Content-Type"), "application/sdp")) {
5755 process_sdp(p, req);
5756 @@ -9483,17 +9554,17 @@
5760 - case 183: /* Session progress */
5761 +/* case 183: // Session progress
5762 sip_cancel_destroy(p);
5763 - /* Ignore 183 Session progress without SDP */
5764 + // Ignore 183 Session progress without SDP
5765 if (!strcasecmp(get_header(req, "Content-Type"), "application/sdp")) {
5766 process_sdp(p, req);
5767 if (!ignore && p->owner) {
5768 - /* Queue a progress frame */
5769 + // Queue a progress frame
5770 ast_queue_control(p->owner, AST_CONTROL_PROGRESS);
5775 case 200: /* 200 OK on invite - someone's answering our call */
5776 sip_cancel_destroy(p);
5778 @@ -10287,6 +10358,7 @@
5779 /* This is a call to ourself. Send ourselves an error code and stop
5780 processing immediately, as SIP really has no good mechanism for
5781 being able to call yourself */
5782 +ast_log(LOG_NOTICE, "to: %s uri: %s\n", get_header(req, "To"), p->origuri);
5783 transmit_response(p, "482 Loop Detected", req);
5784 /* We do NOT destroy p here, so that our response will be accepted */
5786 @@ -10836,7 +10908,7 @@
5787 struct sip_pvt *p_old;
5789 transmit_response(p, "200 OK", req);
5790 - transmit_state_notify(p, firststate, 1, 1); /* Send first notification */
5791 + transmit_state_notify(p, firststate, 1, 1, NULL, NULL); /* Send first notification */
5792 append_history(p, "Subscribestatus", ast_extension_state2str(firststate));
5794 /* remove any old subscription from this peer for the same exten/context,
5795 @@ -11148,7 +11220,7 @@
5796 /* Process request, with netlock held */
5798 ast_mutex_lock(&netlock);
5799 - p = find_call(&req, &sin, req.method);
5800 + p = find_call(&req, &sin, req.method, 0);
5802 /* Go ahead and lock the owner if it has one -- we may need it */
5803 if (p->owner && ast_mutex_trylock(&p->owner->lock)) {
5804 @@ -11468,6 +11540,52 @@
5808 +static char mandescr_sip_notify[] =
5809 +"Description: Send a NOTIFY message to one or more SIP peers.\n"
5811 +" Peer: <name> The peer name you want to send a NOTIFY to.\n"
5812 +" Type: <name> The notify type (see sip_notify.conf).\n"
5813 +" ActionID: <id> Optional action ID for this AMI transaction.\n";
5815 +/*! \brief manager_sip_notify: Send a notify (see sip_notify.conf) to a peer ---*/
5816 +static int manager_sip_notify(struct mansession *s, struct message *m)
5818 + char *id = astman_get_header(m,"ActionID");
5820 + char *notify_type;
5823 + peer = astman_get_header(m,"Peer");
5824 + if (ast_strlen_zero(peer)) {
5825 + astman_send_error(s, m, "Peer: <name> missing.\n");
5828 + notify_type = astman_get_header(m,"Type");
5829 + if (ast_strlen_zero(notify_type)) {
5830 + astman_send_error(s, m, "Type: <name> missing.\n");
5834 + res = sip_send_notify(-1, notify_type, peer);
5835 + if (res != RESULT_SUCCESS) {
5836 + ast_cli(s->fd, "Response: SIPNotify Failure\r\n"
5839 + "ActionID: %s\r\n"
5841 + peer, notify_type, id);
5843 + ast_cli(s->fd, "Response: SIPNotify Success\r\n"
5846 + "ActionID: %s\r\n"
5848 + peer, notify_type, id);
5854 /*! \brief sip_devicestate: Part of PBX channel interface ---*/
5856 /* Return values:---
5857 @@ -13167,6 +13285,8 @@
5858 "List SIP peers (text format)", mandescr_show_peers);
5859 ast_manager_register2("SIPshowpeer", EVENT_FLAG_SYSTEM, manager_sip_show_peer,
5860 "Show SIP peer (text format)", mandescr_show_peer);
5861 + ast_manager_register2("SIPNotify", EVENT_FLAG_SYSTEM, manager_sip_notify,
5862 + "Send NOTIFY to peer", mandescr_sip_notify);
5864 sip_poke_all_peers();
5865 sip_send_all_registers();
5866 @@ -13197,6 +13317,7 @@
5868 ast_rtp_proto_unregister(&sip_rtp);
5870 + ast_manager_unregister("SIPNotify");
5871 ast_manager_unregister("SIPpeers");
5872 ast_manager_unregister("SIPshowpeer");
5874 diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/chan_zap.c
5875 --- asterisk-1.2.7.1.orig/channels/chan_zap.c 2006-04-04 20:28:14.000000000 +0200
5876 +++ asterisk-1.2.7.1/channels/chan_zap.c 2006-04-25 14:21:48.000000000 +0200
5878 * the project provides a web site, mailing lists and IRC
5879 * channels for your use.
5881 + * Copyright (C) 2003-2006 Junghanns.NET GmbH
5882 + * Klaus-Peter Junghanns <kpj@junghanns.net>
5885 * This program is free software, distributed under the terms of
5886 * the GNU General Public License Version 2. See the LICENSE file
5887 * at the top of the source tree.
5890 #include <libmfcr2.h>
5893 +#include <libgsmat.h>
5896 #include "asterisk.h"
5899 #include "asterisk/term.h"
5900 #include "asterisk/utils.h"
5901 #include "asterisk/transcap.h"
5902 +#include "asterisk/devicestate.h"
5904 #ifndef ZT_SIG_EM_E1
5905 #error "Your zaptel is too old. please cvs update"
5907 #define SIG_FXOGS ZT_SIG_FXOGS
5908 #define SIG_FXOKS ZT_SIG_FXOKS
5909 #define SIG_PRI ZT_SIG_CLEAR
5910 +#define SIG_GSM (0x100000 | ZT_SIG_CLEAR)
5911 #define SIG_R2 ZT_SIG_CAS
5912 #define SIG_SF ZT_SIG_SF
5913 #define SIG_SFWINK (0x0100000 | ZT_SIG_SF)
5915 #define SIG_GR303FXOKS (0x0100000 | ZT_SIG_FXOKS)
5916 #define SIG_GR303FXSKS (0x0100000 | ZT_SIG_FXSKS)
5918 -#define NUM_SPANS 32
5919 +#define NUM_SPANS 128 /*!<"32 spans", muahahaha, us alaws like to have some more... */
5920 #define NUM_DCHANS 4 /*!< No more than 4 d-channels */
5921 #define MAX_CHANNELS 672 /*!< No more than a DS3 per trunk group */
5923 @@ -201,6 +210,11 @@
5924 static char defaultcic[64] = "";
5925 static char defaultozz[64] = "";
5927 +static char nocid[256] = "No CID available";
5928 +static char withheldcid[256] = "CID withheld";
5929 +static char gsm_modem_pin[20];
5930 +static char gsm_modem_exten[AST_MAX_EXTENSION];
5932 static char language[MAX_LANGUAGE] = "";
5933 static char musicclass[MAX_MUSICCLASS] = "";
5934 static char progzone[10]= "";
5936 static int cur_priexclusive = 0;
5938 static int priindication_oob = 0;
5939 +static int pritransfer = 0;
5942 static int minunused = 2;
5944 static char idleext[AST_MAX_EXTENSION];
5945 static char idledial[AST_MAX_EXTENSION];
5946 static int overlapdial = 0;
5947 +static int usercid = 0;
5948 static int facilityenable = 0;
5949 static char internationalprefix[10] = "";
5950 static char nationalprefix[10] = "";
5952 #ifdef PRI_GETSET_TIMERS
5953 static int pritimers[PRI_MAX_TIMERS];
5955 -static int pridebugfd = -1;
5956 -static char pridebugfilename[1024]="";
5959 /*! \brief Wait up to 16 seconds for first digit (FXO logic) */
5960 @@ -327,10 +341,6 @@
5962 static int ifcount = 0;
5965 -AST_MUTEX_DEFINE_STATIC(pridebugfdlock);
5968 /*! \brief Whether we answer on a Polarity Switch event */
5969 static int answeronpolarityswitch = 0;
5971 @@ -389,6 +399,18 @@
5978 + ast_mutex_t lock; /* Mutex */
5981 + struct gsm_modul *modul;
5983 + char exten[AST_MAX_EXTENSION]; /* Where to idle extra calls */
5984 + struct zt_pvt *pvt;
5989 static int r2prot = -1;
5990 @@ -403,6 +425,28 @@
5991 #define PRI_SPAN(p) (((p) >> 8) & 0xff)
5992 #define PRI_EXPLICIT(p) (((p) >> 16) & 0x01)
5994 +struct zt_suspended_call {
5995 + ast_mutex_t lock; /* Mutex */
5996 + char msn[AST_MAX_EXTENSION]; /* the MSN to which this parked call belongs */
5997 + char callid[10]; /* the callID provided by the user */
5998 + int parked_at; /* extension in the call parking context */
5999 + struct zt_suspended_call *next;
6002 +struct zt_holded_call {
6003 + ast_mutex_t lock; /* Mutex */
6004 + char msn[AST_MAX_EXTENSION]; /* the MSN to which this parked call belongs */
6005 + char uniqueid[AST_MAX_EXTENSION]; /* unique id of the onhold channel */
6008 + int alreadyhungup;
6009 + struct ast_channel *channel;
6010 + struct ast_channel *bridge;
6011 + q931_call *call; /* this also covers tei mumbojumbo */
6012 + struct zt_holded_call *next;
6017 pthread_t master; /*!< Thread of master */
6018 ast_mutex_t lock; /*!< Mutex */
6020 int nsf; /*!< Network-Specific Facilities */
6021 int dialplan; /*!< Dialing plan */
6022 int localdialplan; /*!< Local dialing plan */
6024 + char withheldcid[256];
6025 char internationalprefix[10]; /*!< country access code ('00' for european dialplans) */
6026 char nationalprefix[10]; /*!< area access code ('0' for european dialplans) */
6027 char localprefix[20]; /*!< area access code + area code ('0'+area code for european dialplans) */
6029 int fds[NUM_DCHANS]; /*!< FD's for d-channels */
6032 + int usercid; /* trust user provided callerid (callerani) ?? */
6035 time_t lastreset; /*!< time when unused channels were last reset */
6037 struct zt_pvt *pvts[MAX_CHANNELS]; /*!< Member channel pvt structs */
6038 struct zt_pvt *crvs; /*!< Member CRV structs */
6039 struct zt_pvt *crvend; /*!< Pointer to end of CRV structs */
6040 + struct zt_suspended_call *suspended_calls; /* Calls parked with SUSPEND messages */
6041 + struct zt_holded_call *holded_calls; /* Calls on hold */
6047 unsigned int echocanbridged:1;
6048 unsigned int echocanon:1;
6049 unsigned int faxhandled:1; /*!< Has a fax tone already been handled? */
6050 + /*!< KPJ: i will abuse this flag to implement a zapata option for dialing out
6051 + on a zap channel with EC to be off no matter what happens. */
6052 unsigned int firstradio:1;
6053 unsigned int hanguponpolarityswitch:1;
6054 unsigned int hardwaredtmf:1;
6056 unsigned int overlapdial:1;
6057 unsigned int permcallwaiting:1;
6058 unsigned int permhidecallerid:1; /*!< Whether to hide our outgoing caller ID or not */
6059 - unsigned int priindication_oob:1;
6060 + unsigned int priindication_oob:2;
6061 + unsigned int pritransfer:2;
6062 unsigned int priexclusive:1;
6063 unsigned int pulse:1;
6064 unsigned int pulsedial:1; /*!< whether a pulse dial phone is detected */
6067 char cid_num[AST_MAX_EXTENSION];
6068 int cid_ton; /*!< Type Of Number (TON) */
6069 + int cid_pres; /*!< Calling Presentation */
6070 char cid_name[AST_MAX_EXTENSION];
6071 char lastcid_num[AST_MAX_EXTENSION];
6072 char lastcid_name[AST_MAX_EXTENSION];
6073 @@ -672,10 +726,15 @@
6074 int polarityonanswerdelay;
6075 struct timeval polaritydelaytv;
6076 int sendcalleridafter;
6078 + struct zt_gsm gsm;
6082 struct zt_pvt *bearer;
6083 struct zt_pvt *realcall;
6084 + int tei; /* channel in use by this tei */
6085 + q931_call *holdedcall;
6089 @@ -701,11 +760,14 @@
6090 static int zt_indicate(struct ast_channel *chan, int condition);
6091 static int zt_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
6092 static int zt_setoption(struct ast_channel *chan, int option, void *data, int datalen);
6093 +static int zt_devicestate(void *data);
6094 +static void disable_dtmf_detect(struct zt_pvt *p);
6095 +static void enable_dtmf_detect(struct zt_pvt *p);
6097 static const struct ast_channel_tech zap_tech = {
6099 .description = tdesc,
6100 - .capabilities = AST_FORMAT_SLINEAR | AST_FORMAT_ULAW,
6101 + .capabilities = AST_FORMAT_SLINEAR | AST_FORMAT_ULAW | AST_FORMAT_ALAW,
6102 .requester = zt_request,
6103 .send_digit = zt_digit,
6104 .send_text = zt_sendtext,
6106 .indicate = zt_indicate,
6108 .setoption = zt_setoption,
6109 + .devicestate = zt_devicestate
6113 @@ -730,6 +793,13 @@
6114 struct zt_pvt *round_robin[32];
6120 + struct ast_channel *chan;
6124 static inline int pri_grab(struct zt_pvt *pvt, struct zt_pri *pri)
6127 @@ -779,6 +849,112 @@
6128 #define CANBUSYDETECT(p) (ISTRUNK(p) || (p->sig & (SIG_EM | SIG_EM_E1 | SIG_SF)) /* || (p->sig & __ZT_SIG_FXO) */)
6129 #define CANPROGRESSDETECT(p) (ISTRUNK(p) || (p->sig & (SIG_EM | SIG_EM_E1 | SIG_SF)) /* || (p->sig & __ZT_SIG_FXO) */)
6131 +static int zt_devicestate(void *data)
6133 + int groupmatch = 0;
6134 + int channelmatch = 0;
6141 + struct zt_pvt *exit, *start, *end;
6142 + ast_mutex_t *lock;
6144 +// ast_log(LOG_NOTICE, "data = %s\n", (char *)data);
6145 + return AST_DEVICE_UNKNOWN;
6147 + /* Assume we're locking the iflock */
6153 + dest = ast_strdupa((char *)data);
6155 + ast_log(LOG_WARNING, "Channel requested with no data\n");
6156 + return AST_DEVICE_INVALID;
6158 + if (toupper(dest[0]) == 'G' || toupper(dest[0])=='R') {
6159 + /* Retrieve the group number */
6160 + char *stringp=NULL;
6162 + s = strsep(&stringp, "/");
6163 + if ((res = sscanf(s, "%d%c%d", &x, &opt, &y)) < 1) {
6164 + ast_log(LOG_WARNING, "Unable to determine group for data %s\n", (char *)data);
6165 + return AST_DEVICE_INVALID;
6167 + groupmatch = 1 << x;
6169 + char *stringp=NULL;
6171 + s = strsep(&stringp, "/");
6173 + if (!strcasecmp(s, "pseudo")) {
6174 + /* Special case for pseudo */
6178 + return AST_DEVICE_INVALID;
6181 + else if ((res = sscanf(s, "%d%c%d", &x, &opt, &y)) < 1) {
6182 + ast_log(LOG_WARNING, "Unable to determine channel for data %s\n", (char *)data);
6183 + return AST_DEVICE_INVALID;
6186 + ast_log(LOG_NOTICE, "channelmatch = %d\n", channelmatch);
6189 + /* Search for an unowned channel */
6190 + if (ast_mutex_lock(lock)) {
6191 + ast_log(LOG_ERROR, "Unable to lock interface list???\n");
6192 + return AST_DEVICE_INVALID;
6196 + res = AST_DEVICE_INVALID; /* start pessimistic */
6199 + ast_mutex_lock(&p->lock);
6200 + if ((groupmatch && ((p->group & groupmatch) != 0)) || (channelmatch && (p->channel == channelmatch))) {
6203 + for(d=0;d<NUM_DCHANS;d++) {
6204 + if (p->pri->dchanavail[d] & DCHAN_UP) {
6205 + res = AST_DEVICE_UNKNOWN;
6210 + if ((!ast_strlen_zero(p->cid_num) && (strncasecmp(p->cid_num, dest, strlen(p->cid_num)))) || (!ast_strlen_zero(p->dnid) && (strncasecmp(p->dnid, dest, strlen(p->dnid))))) {
6211 + res = AST_DEVICE_UNKNOWN;
6213 + if ((p->owner->_state == AST_STATE_RINGING) && (p->outgoing)) {
6214 + res = AST_DEVICE_RINGING;
6216 + if (((p->owner->_state == AST_STATE_RINGING) && (!p->outgoing)) || (p->owner->_state == AST_STATE_UP) || (p->owner->_state == AST_STATE_DIALING) || (p->owner->_state == AST_STATE_RESERVED) || (p->owner->_state == AST_STATE_RING)){
6217 + res = AST_DEVICE_INUSE;
6220 + if ((res == AST_DEVICE_INUSE) || (res == AST_DEVICE_RINGING)) {
6221 + /* stop searching now, one non-idle channel is sufficient */
6222 + ast_mutex_unlock(&p->lock);
6227 + ast_mutex_unlock(&p->lock);
6231 + ast_mutex_unlock(lock);
6237 static int zt_get_index(struct ast_channel *ast, struct zt_pvt *p, int nullok)
6240 @@ -1181,6 +1357,8 @@
6241 return "GR-303 Signalling with FXOKS";
6242 case SIG_GR303FXSKS:
6243 return "GR-303 Signalling with FXSKS";
6245 + return "GSM Signalling";
6247 return "Pseudo Signalling";
6249 @@ -1381,12 +1559,16 @@
6253 + if (p->faxhandled) {
6254 + ast_log(LOG_DEBUG, "Not enabling echo cancellation on a fax/modem call\n");
6258 ast_log(LOG_DEBUG, "Echo cancellation already on\n");
6262 - ast_log(LOG_DEBUG, "Echo cancellation isn't required on digital connection\n");
6263 + ast_log(LOG_DEBUG, "Echo cancellation does not make any sense on digital connections!\n");
6266 if (p->echocancel) {
6267 @@ -1412,7 +1594,7 @@
6271 - if (p && p->echocancel && p->echotraining) {
6272 + if (p && p->echocancel && p->echotraining && (!p->digital) && (!p->faxhandled)) {
6273 x = p->echotraining;
6274 res = ioctl(p->subs[SUB_REAL].zfd, ZT_ECHOTRAIN, &x);
6276 @@ -1592,7 +1774,7 @@
6280 - if (p->sig == SIG_PRI) {
6281 + if ((p->sig == SIG_PRI) || (p->sig == SIG_GSM)) {
6283 res = ioctl(p->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &y);
6285 @@ -1774,7 +1956,12 @@
6286 ast_log(LOG_WARNING, "Unable to flush input on channel %d\n", p->channel);
6289 - set_actual_gain(p->subs[SUB_REAL].zfd, 0, p->rxgain, p->txgain, p->law);
6290 + if (IS_DIGITAL(ast->transfercapability)) {
6291 + set_actual_gain(p->subs[SUB_REAL].zfd, 0, 0, 0, p->law);
6293 + set_actual_gain(p->subs[SUB_REAL].zfd, 0, p->rxgain, p->txgain, p->law);
6299 @@ -1998,6 +2185,26 @@
6301 /* We'll get it in a moment -- but use dialdest to store pre-setup_ack digits */
6302 p->dialdest[0] = '\0';
6303 + disable_dtmf_detect(p);
6307 + if (p->gsm.modul) {
6308 + c = strchr(dest, '/');
6313 + ast_mutex_lock(&p->gsm.lock);
6314 + if (gsm_dial(p->gsm.modul, 0, c)) {
6315 + ast_log(LOG_WARNING, "dialing failed on channel %d\n", p->channel);
6316 + ast_mutex_unlock(&p->gsm.lock);
6317 + ast_mutex_unlock(&p->lock);
6320 + ast_mutex_unlock(&p->gsm.lock);
6325 ast_log(LOG_DEBUG, "not yet implemented\n");
6326 @@ -2016,6 +2223,12 @@
6330 + if ((p->pri->nodetype == BRI_NETWORK_PTMP) || (p->pri->nodetype == BRI_NETWORK)) {
6331 + // pass NO audio when ringing an isdn phone
6333 + // maybe we could allow passing audio when calling a p2p PBX, but well... ;-)
6336 c = strchr(dest, '/');
6339 @@ -2033,6 +2246,7 @@
6340 ast_mutex_unlock(&p->lock);
6343 + strncpy(p->dnid, (c + p->stripmsd), sizeof(p->dnid)-1);
6344 if (p->sig != SIG_FXSKS) {
6345 p->dop.op = ZT_DIAL_OP_REPLACE;
6346 s = strchr(c + p->stripmsd, 'w');
6347 @@ -2056,6 +2270,8 @@
6349 ast_mutex_unlock(&p->lock);
6352 + // ast_log(LOG_NOTICE, "call %d\n", p->call);
6354 if (!(sr = pri_sr_new())) {
6355 ast_log(LOG_WARNING, "Failed to allocate setup request channel %d\n", p->channel);
6356 @@ -2085,7 +2301,7 @@
6357 pri_sr_set_channel(sr, p->bearer ? PVT_TO_CHANNEL(p->bearer) : PVT_TO_CHANNEL(p), exclusive, 1);
6358 pri_sr_set_bearer(sr, p->digital ? PRI_TRANS_CAP_DIGITAL : ast->transfercapability,
6360 - ((p->law == ZT_LAW_ALAW) ? PRI_LAYER_1_ALAW : PRI_LAYER_1_ULAW)));
6361 + ((p->law == ZT_LAW_ALAW) ? PRI_LAYER_1_ALAW : PRI_LAYER_1_ULAW)), ast->lowlayercompat);
6362 if (p->pri->facilityenable)
6363 pri_facility_enable(p->pri->pri);
6365 @@ -2287,8 +2503,10 @@
6369 - ast_log(LOG_WARNING, "No D-channels available! Using Primary channel %d as D-channel anyway!\n",
6370 + if (pri->nodetype != BRI_CPE_PTMP) {
6371 + ast_log(LOG_WARNING, "No D-channels available! Using Primary channel %d as D-channel anyway!\n",
6372 pri->dchannels[newslot]);
6375 if (old && (oldslot != newslot))
6376 ast_log(LOG_NOTICE, "Switching from from d-channel %d to channel %d!\n",
6377 @@ -2344,8 +2562,7 @@
6379 ast_log(LOG_DEBUG, "Hangup: channel: %d index = %d, normal = %d, callwait = %d, thirdcall = %d\n",
6380 p->channel, index, p->subs[SUB_REAL].zfd, p->subs[SUB_CALLWAIT].zfd, p->subs[SUB_THREEWAY].zfd);
6381 - p->ignoredtmf = 0;
6385 /* Real channel, do some fixup */
6386 p->subs[index].owner = NULL;
6387 @@ -2442,6 +2659,7 @@
6390 if (!p->subs[SUB_REAL].owner && !p->subs[SUB_CALLWAIT].owner && !p->subs[SUB_THREEWAY].owner) {
6391 + int outgoing = p->outgoing;
6394 p->distinctivering = 0;
6395 @@ -2478,19 +2696,61 @@
6396 if (p->call && (!p->bearer || (p->bearer->call == p->call))) {
6397 if (!pri_grab(p, p->pri)) {
6398 if (p->alreadyhungup) {
6399 +/* char *aoc = pbx_builtin_getvar_helper(ast,"AOCEUNITS");
6400 + int iaoc = aoc ? atoi(aoc) : -1;
6401 + char *aocpm = pbx_builtin_getvar_helper(ast,"AOCEUNITSPERMIN");
6402 + int iaocpm = aocpm ? atoi(aocpm) : -1;
6404 + if (iaocpm > -1) {
6406 + long bill_sec = ast->cdr->billsec;
6407 + long bill_min = 0;
6408 + if (bill_sec > 0) {
6409 + bill_min = bill_sec / 60;
6410 + if (bill_min < 1) bill_min = 1;
6412 + iaoc = bill_min * iaocpm;
6414 + ast_log(LOG_NOTICE, "no cdr \n");
6417 + ast_log(LOG_NOTICE, "iaocpm %d \n", iaocpm);
6420 ast_log(LOG_DEBUG, "Already hungup... Calling hangup once, and clearing call\n");
6422 #ifdef SUPPORT_USERUSER
6423 pri_call_set_useruser(p->call, useruser);
6426 - pri_hangup(p->pri->pri, p->call, -1);
6427 + pri_hangup(p->pri->pri, p->call, -1, -1);
6430 p->bearer->call = NULL;
6432 char *cause = pbx_builtin_getvar_helper(ast,"PRI_CAUSE");
6433 int icause = ast->hangupcause ? ast->hangupcause : -1;
6434 +/* char *aoc = pbx_builtin_getvar_helper(ast,"AOCEUNITS");
6435 + int iaoc = aoc ? atoi(aoc) : -1;
6436 + char *aocpm = pbx_builtin_getvar_helper(ast,"AOCEUNITSPERMIN");
6437 + int iaocpm = aocpm ? atoi(aocpm) : -1;
6439 + if (iaocpm > -1) {
6441 + long bill_sec = ast->cdr->billsec;
6442 + long bill_min = 0;
6443 + if (bill_sec > 0) {
6444 + bill_min = bill_sec / 60;
6445 + if (bill_min < 1) bill_min = 1;
6447 + iaoc = bill_min * iaocpm;
6449 + ast_log(LOG_NOTICE, "no cdr \n");
6452 + ast_log(LOG_NOTICE, "iaocpm %d \n", iaocpm);
6455 ast_log(LOG_DEBUG, "Not yet hungup... Calling hangup once with icause, and clearing call\n");
6457 #ifdef SUPPORT_USERUSER
6458 @@ -2504,7 +2764,28 @@
6460 icause = atoi(cause);
6462 - pri_hangup(p->pri->pri, p->call, icause);
6464 + pri_hangup(p->pri->pri, p->call, icause, -1);
6466 + /* if we send a release complete we wont ge no hangup event, so clear the call here */
6467 + if (icause == 34 || icause == 44 || icause == 82 || icause == 1 || icause == 81 || icause == 17) {
6468 + if ((ast->_state == AST_STATE_RING) || (ast->_state == AST_STATE_RINGING) || (ast->_state == AST_STATE_DIALING)) {
6471 + ast_log(LOG_ERROR, "What is wrong with you? You cannot use cause %d number when in state %d!\n", icause, ast->_state);
6472 + icause = 16; /* Note, in pri_hangup() libpri will already override the cause */
6476 + if (p->pri->nodetype == BRI_NETWORK_PTMP) {
6477 + if ((icause == 16 || icause == -1) && (ast->_state != AST_STATE_UP)) {
6487 ast_log(LOG_WARNING, "pri_disconnect failed\n");
6488 @@ -2532,7 +2813,13 @@
6492 - if (p->sig && (p->sig != SIG_PRI) && (p->sig != SIG_R2))
6494 + if (p->gsm.modul) {
6495 + if (!p->alreadyhungup)
6496 + gsm_hangup(p->gsm.modul);
6499 + if (p->sig && (p->sig != SIG_PRI) && (p->sig != SIG_R2) && (p->sig != SIG_GSM))
6500 res = zt_set_hook(p->subs[SUB_REAL].zfd, ZT_ONHOOK);
6502 ast_log(LOG_WARNING, "Unable to hangup line %s\n", ast->name);
6503 @@ -2701,10 +2988,14 @@
6505 res = pri_answer(p->pri->pri, p->call, 0, !p->digital);
6507 + /* stop ignoring inband dtmf */
6508 + enable_dtmf_detect(p);
6510 ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->span);
6513 + /* the audio path is complete now, train the echo canceler */
6518 @@ -2714,6 +3005,13 @@
6519 ast_log(LOG_WARNING, "R2 Answer call failed :( on %s\n", ast->name);
6524 + if (p->gsm.modul) {
6525 + gsm_answer(p->gsm.modul);
6530 ast_mutex_unlock(&p->lock);
6532 @@ -3274,6 +3572,15 @@
6534 struct zt_pvt *p = newchan->tech_pvt;
6536 + if (newchan && newchan->tech_pvt) {
6537 + p = newchan->tech_pvt;
6541 + ast_log(LOG_ERROR, "channel %s has no tech_pvt structure\n", newchan->name);
6545 ast_mutex_lock(&p->lock);
6546 ast_log(LOG_DEBUG, "New owner for channel %d is %s\n", p->channel, newchan->name);
6547 if (p->owner == oldchan) {
6548 @@ -3637,7 +3944,7 @@
6550 if (p->pri && p->pri->pri) {
6551 if (!pri_grab(p, p->pri)) {
6552 - pri_hangup(p->pri->pri, p->call, -1);
6553 + pri_hangup(p->pri->pri, p->call, -1, -1);
6554 pri_destroycall(p->pri->pri, p->call);
6557 @@ -4600,7 +4907,7 @@
6558 p->subs[index].f.data = NULL;
6559 p->subs[index].f.datalen= 0;
6561 - if (p->dsp && (!p->ignoredtmf || p->callwaitcas || p->busydetect || p->callprogress) && !index) {
6562 + if (p->dsp && (!p->ignoredtmf || p->callwaitcas || p->busydetect || p->callprogress) && !index) {
6563 /* Perform busy detection. etc on the zap line */
6564 f = ast_dsp_process(ast, p->dsp, &p->subs[index].f);
6566 @@ -4612,8 +4919,9 @@
6568 } else if (f->frametype == AST_FRAME_DTMF) {
6570 - if (!p->proceeding && p->sig==SIG_PRI && p->pri && p->pri->overlapdial) {
6571 - /* Don't accept in-band DTMF when in overlap dial mode */
6572 + if (p->sig==SIG_PRI && p->pri && p->pri->overlapdial && p->ignoredtmf) {
6573 + /* Don't accept in-band DTMF when in overlap dial mode
6574 + or when in non-overlap overlapdialing mode ... */
6575 f->frametype = AST_FRAME_NULL;
6578 @@ -4661,8 +4969,10 @@
6579 pbx_builtin_setvar_helper(ast, "FAXEXTEN", ast->exten);
6580 if (ast_async_goto(ast, target_context, "fax", 1))
6581 ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", ast->name, target_context);
6583 - ast_log(LOG_NOTICE, "Fax detected, but no fax extension\n");
6585 + if (option_verbose > 2)
6586 + ast_verbose(VERBOSE_PREFIX_3 "Fax detected, but no fax extension\n");
6589 ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n");
6591 @@ -4748,7 +5058,9 @@
6593 /* Write a frame of (presumably voice) data */
6594 if (frame->frametype != AST_FRAME_VOICE) {
6595 - if (frame->frametype != AST_FRAME_IMAGE)
6596 + if (frame->frametype == AST_FRAME_TEXT) {
6597 + ast_log(LOG_NOTICE, "text\n");
6598 + } else if (frame->frametype != AST_FRAME_IMAGE)
6599 ast_log(LOG_WARNING, "Don't know what to do with frame type '%d'\n", frame->frametype);
6602 @@ -4819,7 +5131,7 @@
6604 case AST_CONTROL_BUSY:
6606 - if (p->priindication_oob && p->sig == SIG_PRI) {
6607 + if ((p->priindication_oob == 1) && p->sig == SIG_PRI) {
6608 chan->hangupcause = AST_CAUSE_USER_BUSY;
6609 chan->_softhangup |= AST_SOFTHANGUP_DEV;
6611 @@ -4901,7 +5213,7 @@
6612 case AST_CONTROL_CONGESTION:
6613 chan->hangupcause = AST_CAUSE_CONGESTION;
6615 - if (p->priindication_oob && p->sig == SIG_PRI) {
6616 + if ((p->priindication_oob == 1) && p->sig == SIG_PRI) {
6617 chan->hangupcause = AST_CAUSE_SWITCH_CONGESTION;
6618 chan->_softhangup |= AST_SOFTHANGUP_DEV;
6620 @@ -5086,8 +5398,12 @@
6621 if (state == AST_STATE_RING)
6624 - if ((i->sig == SIG_FXOKS) || (i->sig == SIG_FXOGS) || (i->sig == SIG_FXOLS)) {
6625 - /* Only FXO signalled stuff can be picked up */
6627 + if ((i->sig == SIG_FXOKS) || (i->sig == SIG_FXOGS) || (i->sig == SIG_FXOLS) || (i->sig == SIG_PRI)) {
6629 + if ((i->sig == SIG_FXOKS) || (i->sig == SIG_FXOGS) || (i->sig == SIG_FXOLS)) {
6631 + /* Only FXO signalled stuff can be picked up */ /* i dont think so, mr. ulaw! we alaws like to pick up BRIs/PRIs */
6632 tmp->callgroup = i->callgroup;
6633 tmp->pickupgroup = i->pickupgroup;
6635 @@ -5217,6 +5533,7 @@
6640 if (option_verbose > 2)
6641 ast_verbose( VERBOSE_PREFIX_3 "Starting simple switch on '%s'\n", chan->name);
6642 index = zt_get_index(chan, p, 1);
6643 @@ -5235,10 +5552,17 @@
6644 len = strlen(exten);
6646 while((len < AST_MAX_EXTENSION-1) && ast_matchmore_extension(chan, chan->context, exten, 1, p->cid_num)) {
6647 - if (len && !ast_ignore_pattern(chan->context, exten))
6648 + if (len && !ast_ignore_pattern(chan->context, exten)) {
6649 tone_zone_play_tone(p->subs[index].zfd, -1);
6651 - tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALTONE);
6653 + network = p->pri->nodetype == PRI_NETWORK || p->pri->nodetype == BRI_NETWORK || p->pri->nodetype == BRI_NETWORK_PTMP;
6655 + tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALTONE);
6657 + /* cpe be quiet */
6658 + tone_zone_play_tone(p->subs[index].zfd, -1);
6661 if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num))
6662 timeout = matchdigittimeout;
6664 @@ -6719,6 +7043,8 @@
6666 if (si->totalchans == 31) { /* if it's an E1 */
6667 pris[*span].dchannels[0] = 16 + offset;
6668 + } else if (si->totalchans == 3) { /* if it's an S0 ZAPBRI */
6669 + pris[*span].dchannels[0] = 3 + offset;
6671 pris[*span].dchannels[0] = 24 + offset;
6673 @@ -6806,6 +7132,10 @@
6678 +static void *gsm_dchannel(void *vgsm);
6681 static struct zt_pvt *mkintf(int channel, int signalling, int radio, struct zt_pri *pri, int reloading)
6683 /* Make a zt_pvt structure for this interface (or CRV if "pri" is specified) */
6684 @@ -6964,6 +7294,11 @@
6685 destroy_zt_pvt(&tmp);
6688 + if ((pris[span].localdialplan) && (pris[span].localdialplan != localdialplan)) {
6689 + ast_log(LOG_ERROR, "Span %d is already a %s local dialing plan\n", span + 1, dialplan2str(pris[span].localdialplan));
6690 + destroy_zt_pvt(&tmp);
6693 if (!ast_strlen_zero(pris[span].idledial) && strcmp(pris[span].idledial, idledial)) {
6694 ast_log(LOG_ERROR, "Span %d already has idledial '%s'.\n", span + 1, idledial);
6695 destroy_zt_pvt(&tmp);
6696 @@ -6991,6 +7326,17 @@
6699 pris[span].nodetype = pritype;
6701 + if (pritype == BRI_NETWORK_PTMP) {
6702 + pris[span].dchanavail[0] = DCHAN_AVAILABLE;
6703 + pri_find_dchan(&pris[span]);
6707 + if ((pritype == BRI_CPE) || (pritype == BRI_CPE_PTMP)) {
6708 + pris[span].dchanavail[0] = DCHAN_AVAILABLE;
6709 + pri_find_dchan(&pris[span]);
6711 pris[span].switchtype = myswitchtype;
6712 pris[span].nsf = nsf;
6713 pris[span].dialplan = dialplan;
6714 @@ -6999,9 +7345,14 @@
6715 pris[span].minunused = minunused;
6716 pris[span].minidle = minidle;
6717 pris[span].overlapdial = overlapdial;
6718 + pris[span].usercid = usercid;
6719 + pris[span].suspended_calls = NULL;
6720 + pris[span].holded_calls = NULL;
6721 pris[span].facilityenable = facilityenable;
6722 ast_copy_string(pris[span].idledial, idledial, sizeof(pris[span].idledial));
6723 ast_copy_string(pris[span].idleext, idleext, sizeof(pris[span].idleext));
6724 + ast_copy_string(pris[span].nocid, nocid, sizeof(pris[span].nocid) - 1);
6725 + ast_copy_string(pris[span].withheldcid, withheldcid, sizeof(pris[span].withheldcid) - 1);
6726 ast_copy_string(pris[span].internationalprefix, internationalprefix, sizeof(pris[span].internationalprefix));
6727 ast_copy_string(pris[span].nationalprefix, nationalprefix, sizeof(pris[span].nationalprefix));
6728 ast_copy_string(pris[span].localprefix, localprefix, sizeof(pris[span].localprefix));
6729 @@ -7022,6 +7373,36 @@
6734 + if (signalling == SIG_GSM) {
6735 + struct zt_bufferinfo bi;
6736 + ast_mutex_init(&tmp->gsm.lock);
6737 + strncpy(tmp->gsm.pin, gsm_modem_pin, sizeof(tmp->gsm.pin) - 1);
6738 + strncpy(tmp->gsm.exten, gsm_modem_exten, sizeof(tmp->gsm.exten) - 1);
6739 + snprintf(fn, sizeof(fn), "%d", channel + 1);
6740 + /* Open non-blocking */
6741 + tmp->gsm.fd = zt_open(fn);
6742 + bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
6743 + bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
6745 + bi.bufsize = 1024;
6746 + if (ioctl(tmp->gsm.fd, ZT_SET_BUFINFO, &bi)) {
6747 + ast_log(LOG_ERROR, "Unable to set buffer info on channel '%s': %s\n", fn, strerror(errno));
6750 + tmp->gsm.pvt = tmp;
6751 + tmp->gsm.span = tmp->span;
6752 + tmp->gsm.modul = gsm_new(tmp->gsm.fd, 0, tmp->gsm.pin, tmp->span);
6753 + if (ioctl(tmp->subs[SUB_REAL].zfd, ZT_AUDIOMODE, tmp->channel)) {
6754 + ast_log(LOG_ERROR, "Unable to set clear mode on clear channel %d: %s\n", tmp->channel, strerror(errno));
6755 + destroy_zt_pvt(&tmp);
6758 + if (ast_pthread_create(&tmp->gsm.master, NULL, gsm_dchannel, &tmp->gsm)) {
6759 + zt_close(tmp->gsm.fd);
6764 if (signalling == SIG_R2) {
6766 @@ -7155,6 +7536,7 @@
6767 tmp->restrictcid = restrictcid;
6768 tmp->use_callingpres = use_callingpres;
6769 tmp->priindication_oob = priindication_oob;
6770 + tmp->pritransfer = pritransfer;
6771 tmp->priexclusive = cur_priexclusive;
6772 if (tmp->usedistinctiveringdetection) {
6773 if (!tmp->use_callerid) {
6774 @@ -7428,7 +7810,7 @@
6776 if (!backwards && (x >= pri->numchans))
6778 - if (pri->pvts[x] && !pri->pvts[x]->inalarm && !pri->pvts[x]->owner) {
6779 + if (pri->pvts[x] && !pri->pvts[x]->inalarm && !pri->pvts[x]->owner && !pri->pvts[x]->call) {
6780 ast_log(LOG_DEBUG, "Found empty available channel %d/%d\n",
6781 pri->pvts[x]->logicalspan, pri->pvts[x]->prioffset);
6783 @@ -7475,7 +7857,7 @@
6785 /* We do signed linear */
6787 - format &= (AST_FORMAT_SLINEAR | AST_FORMAT_ULAW);
6788 + format &= (AST_FORMAT_SLINEAR | AST_FORMAT_ULAW | AST_FORMAT_ALAW);
6790 ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", oldformat);
6792 @@ -7635,6 +8017,11 @@
6795 tmp->transfercapability = AST_TRANS_CAP_DIGITAL;
6796 + } else if (opt == 'm') {
6797 + /* If this is a modem/fax call, pretend to have the fax handled and dont do EC */
6798 + p->faxhandled = 1;
6800 + tmp->transfercapability = AST_TRANS_CAP_3_1K_AUDIO;
6802 ast_log(LOG_WARNING, "Unknown option '%c' in '%s'\n", opt, (char *)data);
6804 @@ -7674,6 +8061,164 @@
6809 +static void handle_gsm_event(struct zt_gsm *gsm, gsm_event *e)
6811 + struct ast_channel *c = NULL;
6812 + int law = ZT_LAW_ALAW;
6816 + case GSM_EVENT_DCHAN_UP:
6817 + if (option_verbose > 2)
6818 + ast_verbose(VERBOSE_PREFIX_3 "GSM Span %d registered to network!\n", gsm->span);
6820 + case GSM_EVENT_DCHAN_DOWN:
6821 + if (option_verbose > 2)
6822 + ast_verbose(VERBOSE_PREFIX_3 "GSM Span %d unregistered from network!\n", gsm->span);
6824 + case GSM_EVENT_RING:
6825 + ast_mutex_lock(&gsm->pvt->lock);
6826 + if (!ast_strlen_zero(e->ring.callingnum)) {
6827 + strncpy(gsm->pvt->cid_num, e->ring.callingnum, sizeof(gsm->pvt->cid_num) - 1);
6829 + if (!ast_strlen_zero(gsm->exten)) {
6830 + strncpy(gsm->pvt->exten, gsm->exten, sizeof(gsm->pvt->exten) - 1);
6832 + gsm->pvt->exten[0] = 's';
6833 + gsm->pvt->exten[1] = '\0';
6835 + c = zt_new(gsm->pvt, AST_STATE_RING, 1, SUB_REAL, ZT_LAW_ALAW, AST_TRANS_CAP_SPEECH);
6837 + if (option_verbose > 2)
6838 + ast_verbose(VERBOSE_PREFIX_3 "Ring on channel %d (from %s to %s)\n", e->ring.channel, e->ring.callingnum, gsm->exten);
6839 + gsm->pvt->owner = c;
6840 + if (ioctl(gsm->pvt->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &law) == -1)
6841 + ast_log(LOG_WARNING, "Unable to set audio mode on channel %d to %d\n", gsm->pvt->channel, law);
6842 + res = zt_setlaw(gsm->pvt->subs[SUB_REAL].zfd, law);
6843 + res = set_actual_gain(gsm->pvt->subs[SUB_REAL].zfd, 0, gsm->pvt->rxgain, gsm->pvt->txgain, law);
6845 + ast_log(LOG_WARNING, "Unable to set gains on channel %d\n", gsm->pvt->channel);
6847 +// ast_log(LOG_NOTICE, "tx gain %f rx gain %f law %d pvt->law %d\n", gsm->pvt->txgain, gsm->pvt->rxgain, law, gsm->pvt->law);
6850 + ast_mutex_unlock(&gsm->pvt->lock);
6852 + case GSM_EVENT_HANGUP:
6853 + ast_verbose(VERBOSE_PREFIX_3 "Got hang up on channel %d\n", e->hangup.channel);
6854 + ast_mutex_lock(&gsm->pvt->lock);
6855 + gsm->pvt->alreadyhungup = 1;
6856 + if (gsm->pvt->owner) {
6857 + gsm->pvt->owner->_softhangup |= AST_SOFTHANGUP_DEV;
6859 + ast_mutex_unlock(&gsm->pvt->lock);
6861 + case GSM_EVENT_ALERTING:
6862 + ast_mutex_lock(&gsm->pvt->lock);
6863 + gsm->pvt->subs[SUB_REAL].needringing =1;
6864 + ast_mutex_unlock(&gsm->pvt->lock);
6866 + case GSM_EVENT_ANSWER:
6867 + ast_mutex_lock(&gsm->pvt->lock);
6868 + gsm->pvt->dialing = 0;
6869 + gsm->pvt->subs[SUB_REAL].needanswer =1;
6870 + gsm->pvt->ignoredtmf = 0;
6871 + ast_mutex_unlock(&gsm->pvt->lock);
6873 + case GSM_EVENT_PIN_REQUIRED:
6874 + gsm_send_pin(gsm->modul, gsm->pin);
6876 + case GSM_EVENT_SM_RECEIVED:
6877 + ast_verbose(VERBOSE_PREFIX_3 "SMS received on span %d. PDU: %s\n", gsm->span, e->sm_received.pdu);
6880 + ast_log(LOG_WARNING,"!! Unknown GSM event %d !!\n", e->e);
6884 +static void *gsm_dchannel(void *vgsm)
6886 + struct zt_gsm *gsm = vgsm;
6888 + struct timeval tv = {0,0}, *next;
6889 + fd_set rfds, efds;
6892 + if (!gsm) return NULL;
6894 + if (!gsm->modul) {
6895 + fprintf(stderr, "No gsm_mod\n");
6898 + gsm_set_debug(gsm->modul, 1);
6901 + /* Run the D-Channel */
6904 + FD_SET(gsm->fd, &rfds);
6905 + FD_SET(gsm->fd, &efds);
6907 + if ((next = gsm_schedule_next(gsm->modul))) {
6908 + gettimeofday(&tv, NULL);
6909 + tv.tv_sec = next->tv_sec - tv.tv_sec;
6910 + tv.tv_usec = next->tv_usec - tv.tv_usec;
6911 + if (tv.tv_usec < 0) {
6912 + tv.tv_usec += 1000000;
6915 + if (tv.tv_sec < 0) {
6920 + res = select(gsm->fd + 1, &rfds, NULL, &efds, next ? &tv : NULL);
6923 + ast_mutex_lock(&gsm->lock);
6925 + e = gsm_schedule_run(gsm->modul);
6926 + } else if (res > 0) {
6927 + e = gsm_check_event(gsm->modul, 1);
6928 + } else if (errno == ELAST) {
6929 + res = ioctl(gsm->fd, ZT_GETEVENT, &x);
6930 + printf("Got Zaptel event: %d\n", x);
6931 + } else if (errno != EINTR)
6932 + fprintf(stderr, "Error (%d) on select: %s\n", ELAST, strerror(errno));
6935 + e = gsm_check_event(gsm->modul, 0);
6939 + handle_gsm_event(gsm, e);
6941 + ast_mutex_unlock(&gsm->lock);
6943 + res = ioctl(gsm->fd, ZT_GETEVENT, &x);
6947 + case ZT_EVENT_NOALARM:
6948 + ast_log(LOG_NOTICE, "Alarm cleared on span %d\n", gsm->span);
6950 + gsm_restart(gsm->modul);
6952 + case ZT_EVENT_ALARM:
6953 + ast_log(LOG_NOTICE, "Alarm detected on span %d\n", gsm->span);
6956 + fprintf(stderr, "Got event on GSM interface: %d\n", x);
6968 static struct zt_pvt *pri_find_crv(struct zt_pri *pri, int crv)
6969 @@ -7688,6 +8233,57 @@
6973 +static int pri_find_tei(struct zt_pri *pri, q931_call *c, int tei)
6976 + for (x=0;x<pri->numchans;x++) {
6977 + if (!pri->pvts[x]) continue;
6978 + if ((pri->pvts[x]->tei == tei) && (pri->pvts[x]-> call != c)) {
6985 +static struct zt_holded_call *pri_get_callonhold(struct zt_pri *pri, int cref, int tei) {
6986 + struct zt_holded_call *zhc = pri->holded_calls;
6987 + struct zt_holded_call *zhctemp = NULL;
6990 + if ((zhc->tei == tei) && ((zhc->cref == cref) || (cref == -1))) {
6994 + if (zhc) zhc = zhc->next;
6999 +static int pri_destroy_callonhold(struct zt_pri *pri, struct zt_holded_call *onhold) {
7000 + struct zt_holded_call *zhc = pri->holded_calls;
7001 + struct zt_holded_call *zhctemp = NULL;
7004 + if (zhc == onhold) {
7006 + zhctemp->next = zhc->next;
7009 + pri->holded_calls = zhc->next;
7010 + zhc = pri->holded_calls;
7015 + if (zhc) zhc = zhc->next;
7025 static int pri_find_principle(struct zt_pri *pri, int channel)
7027 @@ -7720,7 +8316,9 @@
7028 static int pri_fixup_principle(struct zt_pri *pri, int principle, q931_call *c)
7033 + char tmpname[256];
7037 @@ -7734,6 +8332,7 @@
7038 /* First, check for other bearers */
7039 for (x=0;x<pri->numchans;x++) {
7040 if (!pri->pvts[x]) continue;
7041 +// ast_log(LOG_NOTICE, "principle %d channel %d call %d channel[x]->call %d\n",principle, x, c, pri->pvts[x]->call);
7042 if (pri->pvts[x]->call == c) {
7043 /* Found our call */
7044 if (principle != x) {
7045 @@ -7747,19 +8346,56 @@
7047 /* Fix it all up now */
7048 pri->pvts[principle]->owner = pri->pvts[x]->owner;
7049 + pri->pvts[principle]->outgoing = pri->pvts[x]->outgoing;
7050 if (pri->pvts[principle]->owner) {
7051 snprintf(pri->pvts[principle]->owner->name, sizeof(pri->pvts[principle]->owner->name),
7052 "Zap/%d:%d-%d", pri->trunkgroup, pri->pvts[principle]->channel, 1);
7053 pri->pvts[principle]->owner->tech_pvt = pri->pvts[principle];
7054 pri->pvts[principle]->owner->fds[0] = pri->pvts[principle]->subs[SUB_REAL].zfd;
7055 pri->pvts[principle]->subs[SUB_REAL].owner = pri->pvts[x]->subs[SUB_REAL].owner;
7058 ast_log(LOG_WARNING, "Whoa, there's no owner, and we're having to fix up channel %d to channel %d\n", pri->pvts[x]->channel, pri->pvts[principle]->channel);
7060 pri->pvts[principle]->call = pri->pvts[x]->call;
7061 + pri->pvts[principle]->dsp = pri->pvts[x]->dsp;
7062 + pri->pvts[principle]->alreadyhungup = pri->pvts[x]->alreadyhungup;
7063 + pri->pvts[principle]->digital = pri->pvts[x]->digital;
7064 + pri->pvts[principle]->faxhandled = pri->pvts[x]->faxhandled;
7066 + if ((pri->nodetype == BRI_CPE_PTMP) || (pri->nodetype == BRI_CPE)) {
7067 + /* this might also apply for other pri types! */
7068 + pri->pvts[principle]->law = pri->pvts[x]->law;
7069 + if (ioctl(pri->pvts[principle]->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &pri->pvts[principle]->law) == -1)
7070 + ast_log(LOG_WARNING, "Unable to set audio mode on channel %d to %d\n", pri->pvts[principle]->channel, pri->pvts[principle]->law);
7071 + res = zt_setlaw(pri->pvts[principle]->subs[SUB_REAL].zfd, pri->pvts[principle]->law);
7073 + ast_log(LOG_WARNING, "Unable to set law on channel %d\n", pri->pvts[principle]->channel);
7074 + if (!pri->pvts[principle]->digital) {
7075 + res = set_actual_gain(pri->pvts[principle]->subs[SUB_REAL].zfd, 0, pri->pvts[principle]->rxgain, pri->pvts[principle]->txgain, pri->pvts[principle]->law);
7077 + res = set_actual_gain(pri->pvts[principle]->subs[SUB_REAL].zfd, 0, 0, 0, pri->pvts[principle]->law);
7080 + ast_log(LOG_WARNING, "Unable to set gains on channel %d\n", pri->pvts[principle]->channel);
7081 + zt_confmute(pri->pvts[x], 0);
7082 + update_conf(pri->pvts[x]);
7083 + reset_conf(pri->pvts[x]);
7084 + restore_gains(pri->pvts[x]);
7085 + zt_disable_ec(pri->pvts[x]);
7086 + zt_setlinear(pri->pvts[x]->subs[SUB_REAL].zfd, 0);
7089 + if (pri->pvts[principle]->owner) {
7090 + snprintf(tmpname, sizeof(tmpname), "Zap/%d-1", pri->pvts[principle]->channel);
7091 + ast_change_name(pri->pvts[principle]->owner, tmpname);
7095 /* Free up the old channel, now not in use */
7096 pri->pvts[x]->subs[SUB_REAL].owner = NULL;
7097 pri->pvts[x]->owner = NULL;
7098 pri->pvts[x]->call = NULL;
7099 + pri->pvts[x]->dsp = NULL;
7103 @@ -7788,7 +8424,9 @@
7107 - ast_log(LOG_WARNING, "Call specified, but not found?\n");
7108 + if ((pri->nodetype != BRI_NETWORK_PTMP) && (pri->nodetype != BRI_NETWORK)) {
7109 + ast_log(LOG_WARNING, "Call specified, but not found?\n");
7114 @@ -7850,86 +8488,33 @@
7116 #error "Upgrade your libpri"
7118 -static void zt_pri_message(struct pri *pri, char *s)
7119 +static void zt_pri_message(char *s, int span)
7122 - int dchan = -1, span = -1;
7123 - int dchancount = 0;
7126 - for (x = 0; x < NUM_SPANS; x++) {
7127 - for (y = 0; y < NUM_DCHANS; y++) {
7128 - if (pris[x].dchans[y])
7131 - if (pris[x].dchans[y] == pri)
7140 - if ((dchan >= 0) && (span >= 0)) {
7141 - if (dchancount > 1)
7142 - ast_verbose("[Span %d D-Channel %d]%s", span, dchan, s);
7144 - ast_verbose("%s", s);
7146 - ast_verbose("PRI debug error: could not find pri associated it with debug message output\n");
7148 - ast_verbose("%s", s);
7150 - ast_mutex_lock(&pridebugfdlock);
7152 - if (pridebugfd >= 0)
7153 - write(pridebugfd, s, strlen(s));
7155 - ast_mutex_unlock(&pridebugfdlock);
7156 + ast_verbose("%d %s", span, s);
7159 -static void zt_pri_error(struct pri *pri, char *s)
7160 +static void zt_pri_error(char *s, int span)
7163 - int dchan = -1, span = -1;
7164 - int dchancount = 0;
7167 - for (x = 0; x < NUM_SPANS; x++) {
7168 - for (y = 0; y < NUM_DCHANS; y++) {
7169 - if (pris[x].dchans[y])
7172 - if (pris[x].dchans[y] == pri)
7181 - if ((dchan >= 0) && (span >= 0)) {
7182 - if (dchancount > 1)
7183 - ast_log(LOG_WARNING, "[Span %d D-Channel %d] PRI: %s", span, dchan, s);
7185 - ast_verbose("%s", s);
7187 - ast_verbose("PRI debug error: could not find pri associated it with debug message output\n");
7189 - ast_log(LOG_WARNING, "%s", s);
7191 - ast_mutex_lock(&pridebugfdlock);
7192 + ast_log(LOG_WARNING, "%d %s", span, s);
7195 - if (pridebugfd >= 0)
7196 - write(pridebugfd, s, strlen(s));
7198 +static void zt_gsm_message(char *s, int span)
7200 +// ast_verbose("%d %s", span, s);
7203 - ast_mutex_unlock(&pridebugfdlock);
7204 +static void zt_gsm_error(char *s, int span)
7206 + ast_log(LOG_WARNING, "GSM: %d %s", span, s);
7210 static int pri_check_restart(struct zt_pri *pri)
7212 + if ((pri->nodetype != PRI_NETWORK) || (pri->nodetype != PRI_CPE)) {
7217 } while((pri->resetpos < pri->numchans) &&
7218 @@ -8012,6 +8597,32 @@
7222 +static void pri_make_callerid(struct zt_pri *pri, char *callerid, int callerid_len, char *callingnum, int callingnum_len, int callingplan, int callingpres, int stripmsd) {
7223 + if (callingnum && (callingnum_len > stripmsd)) {
7224 + callingnum += stripmsd;
7226 + switch (callingplan) {
7227 + case PRI_INTERNATIONAL_ISDN:
7228 + snprintf(callerid, callerid_len, "%s%s", pri->internationalprefix, callingnum);
7230 + case PRI_NATIONAL_ISDN:
7231 + snprintf(callerid, callerid_len, "%s%s", pri->nationalprefix, callingnum);
7233 + case PRI_LOCAL_ISDN:
7234 + snprintf(callerid, callerid_len, "%s%s", pri->localprefix, callingnum);
7237 + snprintf(callerid, callerid_len, "%s%s", pri->privateprefix, callingnum);
7240 + snprintf(callerid, callerid_len, "%s%s", pri->unknownprefix, callingnum);
7243 + snprintf(callerid, callerid_len, "%s", callingnum);
7248 static void *pri_dchannel(void *vpri)
7250 struct zt_pri *pri = vpri;
7251 @@ -8103,6 +8714,8 @@
7252 } else if (pri->pvts[x] && pri->pvts[x]->owner && pri->pvts[x]->isidlecall)
7255 + // ast_log(LOG_NOTICE, "name = %s condition = %d index = %d (%d) zfd = %d res = %d\n",chan->name, condition, index, SUB_REAL, p->subs[index].zfd, res);
7258 printf("nextidle: %d, haveidles: %d, minunsed: %d\n",
7259 nextidle, haveidles, minunused);
7260 @@ -8204,9 +8817,36 @@
7261 if (x == ZT_EVENT_ALARM) {
7262 pri->dchanavail[which] &= ~(DCHAN_NOTINALARM | DCHAN_UP);
7263 pri_find_dchan(pri);
7264 + if ((pri->nodetype == BRI_CPE) || (pri->nodetype == BRI_CPE_PTMP)) {
7266 + ast_log(LOG_NOTICE, "pri_shutdown\n");
7267 + for (i=0; i<pri->numchans; i++) {
7268 + struct zt_pvt *p = pri->pvts[i];
7271 + if (p->pri && p->pri->pri) {
7272 + pri_destroycall(p->pri->pri, p->call);
7276 + ast_log(LOG_WARNING, "The PRI Call have not been destroyed\n");
7279 + p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
7283 + pri_shutdown(pri->pri);
7286 } else if (x == ZT_EVENT_NOALARM) {
7287 - pri->dchanavail[which] |= DCHAN_NOTINALARM;
7288 - pri_restart(pri->dchans[which]);
7289 + if ((pri->nodetype == BRI_CPE) || (pri->nodetype == BRI_CPE_PTMP)) {
7290 + pri->dchanavail[which] |= DCHAN_NOTINALARM;
7291 + pri->dchanavail[which] |= DCHAN_UP;
7293 + pri->dchanavail[which] |= DCHAN_NOTINALARM;
7294 + pri_restart(pri->dchans[which]);
7299 @@ -8218,8 +8858,7 @@
7302 } else if (errno != EINTR)
7303 - ast_log(LOG_WARNING, "pri_event returned error %d (%s)\n", errno, strerror(errno));
7305 + ast_log(LOG_WARNING, "pri_event returned error %d (%s) on span %d\n", errno, strerror(errno), pri->span);
7308 pri_dump_event(pri->dchans[which], e);
7309 @@ -8227,32 +8866,102 @@
7310 pri->dchanavail[which] |= DCHAN_UP;
7312 case PRI_EVENT_DCHAN_UP:
7313 - if (option_verbose > 1)
7314 - ast_verbose(VERBOSE_PREFIX_2 "%s D-Channel on span %d up\n", pri_order(which), pri->span);
7315 - pri->dchanavail[which] |= DCHAN_UP;
7316 - if (!pri->pri) pri_find_dchan(pri);
7318 - /* Note presense of D-channel */
7319 - time(&pri->lastreset);
7321 - /* Restart in 5 seconds */
7322 - if (pri->resetinterval > -1) {
7323 - pri->lastreset -= pri->resetinterval;
7324 - pri->lastreset += 5;
7326 - pri->resetting = 0;
7327 - /* Take the channels from inalarm condition */
7328 - for (i=0; i<pri->numchans; i++)
7329 - if (pri->pvts[i]) {
7330 - pri->pvts[i]->inalarm = 0;
7332 + if (pri->nodetype == BRI_NETWORK_PTMP) {
7333 + if (option_verbose > 3)
7334 + ast_verbose(VERBOSE_PREFIX_2 "%s D-Channel on span %d up for TEI %d\n", pri_order(which), pri->span, e->gen.tei);
7335 + pri->dchanavail[which] |= (DCHAN_PROVISIONED | DCHAN_NOTINALARM | DCHAN_UP);
7336 + pri_find_dchan(pri);
7338 + /* Note presense of D-channel */
7339 + time(&pri->lastreset);
7341 + pri->resetting = 0;
7342 + /* Take the channels from inalarm condition */
7343 + for (i=0; i<pri->numchans; i++)
7344 + if (pri->pvts[i]) {
7345 + pri->pvts[i]->inalarm = 0;
7348 + if (pri->nodetype == BRI_CPE_PTMP) {
7349 + if (option_verbose > 3)
7350 + ast_verbose(VERBOSE_PREFIX_2 "%s D-Channel on span %d up\n", pri_order(which), pri->span);
7352 + if (option_verbose > 1)
7353 + ast_verbose(VERBOSE_PREFIX_2 "%s D-Channel on span %d up\n", pri_order(which), pri->span);
7355 + pri->dchanavail[which] |= (DCHAN_PROVISIONED | DCHAN_NOTINALARM | DCHAN_UP);
7356 + pri_find_dchan(pri);
7358 + /* Note presense of D-channel */
7359 + time(&pri->lastreset);
7361 + /* Restart in 5 seconds */
7362 + pri->lastreset -= pri->resetinterval;
7363 + pri->lastreset += 5;
7364 + pri->resetting = 0;
7365 + /* Take the channels from inalarm condition */
7366 + for (i=0; i<pri->numchans; i++) {
7367 + struct zt_pvt *p = pri->pvts[i];
7370 + /* hang up calls that are not bridged yet, dont touch bridged calls */
7372 + if (p->pri && p->pri->pri) {
7374 + if (p->owner->_state != AST_STATE_UP) {
7375 + p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
7376 + pri_destroycall(p->pri->pri, p->call);
7380 + pri_destroycall(p->pri->pri, p->call);
7389 case PRI_EVENT_DCHAN_DOWN:
7390 - if (option_verbose > 1)
7391 - ast_verbose(VERBOSE_PREFIX_2 "%s D-Channel on span %d down\n", pri_order(which), pri->span);
7392 - pri->dchanavail[which] &= ~DCHAN_UP;
7393 - pri_find_dchan(pri);
7394 - if (!pri_is_up(pri)) {
7395 + if (pri->nodetype == BRI_NETWORK_PTMP) {
7396 + if (option_verbose > 3)
7397 + ast_verbose(VERBOSE_PREFIX_2 "%s D-Channel on span %d down for TEI %d\n", pri_order(which), pri->span, e->gen.tei);
7398 + // PTMP BRIs have N dchans, handled by libpri
7399 + if (e->gen.tei == 0) break;
7400 + /* Hangup active channels */
7401 + for (i=0; i<pri->numchans; i++) {
7402 + struct zt_pvt *p = pri->pvts[i];
7404 + // ast_log(LOG_NOTICE, "chan %d tei %d\n",i,p->tei);
7405 + if (p->tei == e->gen.tei) {
7407 + if (p->pri && p->pri->pri) {
7408 + // pri_hangup(p->pri->pri, p->call, -1);
7409 + pri_destroycall(p->pri->pri, p->call);
7413 + ast_log(LOG_WARNING, "The PRI Call have not been destroyed\n");
7416 + p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
7423 + if (pri->nodetype == BRI_CPE_PTMP) {
7424 + if (option_verbose > 3)
7425 + ast_verbose(VERBOSE_PREFIX_2 "%s D-Channel on span %d down\n", pri_order(which), pri->span);
7427 + if (option_verbose > 1)
7428 + ast_verbose(VERBOSE_PREFIX_2 "%s D-Channel on span %d down\n", pri_order(which), pri->span);
7430 + pri->dchanavail[which] &= ~DCHAN_UP;
7431 + pri_find_dchan(pri);
7432 + if (!pri_is_up(pri)) {
7434 /* Hangup active channels and put them in alarm mode */
7435 for (i=0; i<pri->numchans; i++) {
7436 @@ -8260,19 +8969,29 @@
7439 if (p->pri && p->pri->pri) {
7440 - pri_hangup(p->pri->pri, p->call, -1);
7441 - pri_destroycall(p->pri->pri, p->call);
7444 + if (p->owner->_state != AST_STATE_UP) {
7445 + // pri_hangup(p->pri->pri, p->call, -1);
7446 + pri_destroycall(p->pri->pri, p->call);
7448 + p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
7452 + pri_destroycall(p->pri->pri, p->call);
7457 ast_log(LOG_WARNING, "The PRI Call have not been destroyed\n");
7460 - pri_hangup_all(p->realcall, pri);
7461 - } else if (p->owner)
7462 - p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
7464 + pri_hangup_all(p->realcall, pri);
7472 case PRI_EVENT_RESTART:
7473 @@ -8307,8 +9026,8 @@
7474 pri_destroycall(pri->pri, pri->pvts[x]->call);
7475 pri->pvts[x]->call = NULL;
7477 - if (pri->pvts[chanpos]->realcall)
7478 - pri_hangup_all(pri->pvts[chanpos]->realcall, pri);
7479 + if (pri->pvts[x]->realcall)
7480 + pri_hangup_all(pri->pvts[x]->realcall, pri);
7481 else if (pri->pvts[x]->owner)
7482 pri->pvts[x]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
7483 ast_mutex_unlock(&pri->pvts[x]->lock);
7484 @@ -8342,7 +9061,6 @@
7489 case PRI_EVENT_INFO_RECEIVED:
7490 chanpos = pri_find_principle(pri, e->ring.channel);
7492 @@ -8351,9 +9069,11 @@
7494 chanpos = pri_fixup_principle(pri, chanpos, e->ring.call);
7496 +// ast_log(LOG_NOTICE, "INFO received on channel %d/%d span %d\n",
7497 +// PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), pri->span);
7498 ast_mutex_lock(&pri->pvts[chanpos]->lock);
7499 /* queue DTMF frame if the PBX for this call was already started (we're forwarding INFORMATION further on */
7500 - if (pri->overlapdial && pri->pvts[chanpos]->call==e->ring.call && pri->pvts[chanpos]->owner) {
7501 + if (pri->pvts[chanpos]->call==e->ring.call && pri->pvts[chanpos]->owner) {
7502 /* how to do that */
7503 int digitlen = strlen(e->ring.callednum);
7505 @@ -8365,6 +9085,14 @@
7506 zap_queue_frame(pri->pvts[chanpos], &f, pri);
7509 + if (!pri->overlapdial) {
7510 + strncat(pri->pvts[chanpos]->exten, e->ring.callednum, sizeof(pri->pvts[chanpos]->exten));
7511 + if (!ast_ignore_pattern(pri->pvts[chanpos]->context, pri->pvts[chanpos]->exten + 1)) {
7512 + tone_zone_play_tone(pri->pvts[chanpos]->subs[SUB_REAL].zfd, -1);
7514 + tone_zone_play_tone(pri->pvts[chanpos]->subs[SUB_REAL].zfd, ZT_TONE_DIALTONE);
7518 ast_mutex_unlock(&pri->pvts[chanpos]->lock);
7520 @@ -8372,39 +9100,55 @@
7522 case PRI_EVENT_RING:
7524 - if (e->ring.channel == -1)
7525 + if (e->ring.channel == -1) {
7526 + /* if no channel specified find one empty */
7527 chanpos = pri_find_empty_chan(pri, 1);
7530 chanpos = pri_find_principle(pri, e->ring.channel);
7531 - /* if no channel specified find one empty */
7534 - ast_log(LOG_WARNING, "Ring requested on unconfigured channel %d/%d span %d\n",
7535 - PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), pri->span);
7536 + /* no channel specified and no free channel. this is a callwating SETUP */
7537 + if (e->ring.channel == -1) {
7538 + if (option_verbose > 2)
7539 + ast_verbose(VERBOSE_PREFIX_3 "Ignoring callwaiting SETUP on channel %d/%d span %d %d\n", PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), pri->span, e->ring.channel);
7540 + pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_USER_BUSY, -1);
7544 + /* ok, we got a b channel for this call, lock it */
7545 ast_mutex_lock(&pri->pvts[chanpos]->lock);
7546 if (pri->pvts[chanpos]->owner) {
7547 - if (pri->pvts[chanpos]->call == e->ring.call) {
7548 - ast_log(LOG_WARNING, "Duplicate setup requested on channel %d/%d already in use on span %d\n",
7549 - PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), pri->span);
7552 - ast_log(LOG_WARNING, "Ring requested on channel %d/%d already in use on span %d. Hanging up owner.\n",
7553 + /* safety check, for messed up retransmissions? */
7554 + if (pri->pvts[chanpos]->call == e->ring.call) {
7555 + ast_log(LOG_WARNING, "Duplicate setup requested on channel %d/%d already in use on span %d\n",
7556 PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), pri->span);
7557 - if (pri->pvts[chanpos]->realcall)
7558 - pri_hangup_all(pri->pvts[chanpos]->realcall, pri);
7560 - pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
7561 - ast_mutex_unlock(&pri->pvts[chanpos]->lock);
7566 ast_mutex_unlock(&pri->pvts[chanpos]->lock);
7570 + ast_log(LOG_WARNING, "Ring requested on channel %d/%d already in use on span %d. Hanging up owner.\n",
7571 + PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), pri->span);
7572 + if (pri->pvts[chanpos]->realcall)
7573 + pri_hangup_all(pri->pvts[chanpos]->realcall, pri);
7575 + pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
7576 + ast_mutex_unlock(&pri->pvts[chanpos]->lock);
7581 + if (chanpos > -1) {
7582 + /* everything is ok with the b channel */
7583 + ast_mutex_unlock(&pri->pvts[chanpos]->lock);
7586 - if ((chanpos < 0) && (e->ring.flexible))
7587 - chanpos = pri_find_empty_chan(pri, 1);
7588 + /* actually, we already got a valid channel by now */
7590 ast_mutex_lock(&pri->pvts[chanpos]->lock);
7591 + /* dont detect dtmfs before the signalling is done */
7592 + disable_dtmf_detect(pri->pvts[chanpos]);
7593 + /* this channel is owned by this TEI */
7594 + pri->pvts[chanpos]->tei = e->ring.tei;
7595 if (pri->switchtype == PRI_SWITCH_GR303_TMC) {
7596 /* Should be safe to lock CRV AFAIK while bearer is still locked */
7597 crv = pri_find_crv(pri, pri_get_crv(pri->pri, e->ring.call, NULL));
7598 @@ -8418,13 +9162,14 @@
7599 ast_log(LOG_WARNING, "Call received for busy CRV %d on span %d\n", pri_get_crv(pri->pri, e->ring.call, NULL), pri->span);
7601 ast_log(LOG_NOTICE, "Call received for unconfigured CRV %d on span %d\n", pri_get_crv(pri->pri, e->ring.call, NULL), pri->span);
7602 - pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_INVALID_CALL_REFERENCE);
7603 + pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_INVALID_CALL_REFERENCE, -1);
7605 ast_mutex_unlock(&crv->lock);
7606 ast_mutex_unlock(&pri->pvts[chanpos]->lock);
7610 + /* assign call to b channel */
7611 pri->pvts[chanpos]->call = e->ring.call;
7612 apply_plan_to_number(plancallingnum, sizeof(plancallingnum), pri, e->ring.callingnum, e->ring.callingplan);
7613 if (pri->pvts[chanpos]->use_callerid) {
7614 @@ -8449,29 +9194,78 @@
7616 apply_plan_to_number(pri->pvts[chanpos]->rdnis, sizeof(pri->pvts[chanpos]->rdnis), pri,
7617 e->ring.redirectingnum, e->ring.callingplanrdnis);
7618 + /* get callingpres */
7619 + pri->pvts[chanpos]->cid_pres = e->ring.callingpres;
7620 + switch (e->ring.callingpres) {
7621 + case PRES_PROHIB_USER_NUMBER_NOT_SCREENED:
7622 + case PRES_PROHIB_USER_NUMBER_PASSED_SCREEN:
7623 + case PRES_PROHIB_USER_NUMBER_FAILED_SCREEN:
7624 + case PRES_PROHIB_NETWORK_NUMBER:
7625 + strncpy(pri->pvts[chanpos]->cid_name, pri->withheldcid, sizeof(pri->pvts[chanpos]->cid_name));
7627 + case PRES_NUMBER_NOT_AVAILABLE:
7628 + strncpy(pri->pvts[chanpos]->cid_name, pri->nocid, sizeof(pri->pvts[chanpos]->cid_name));
7631 /* If immediate=yes go to s|1 */
7632 if (pri->pvts[chanpos]->immediate) {
7633 if (option_verbose > 2)
7634 ast_verbose(VERBOSE_PREFIX_3 "Going to extension s|1 because of immediate=yes\n");
7635 pri->pvts[chanpos]->exten[0] = 's';
7636 pri->pvts[chanpos]->exten[1] = '\0';
7638 - /* Get called number */
7639 - else if (!ast_strlen_zero(e->ring.callednum)) {
7640 - ast_copy_string(pri->pvts[chanpos]->exten, e->ring.callednum, sizeof(pri->pvts[chanpos]->exten));
7641 - ast_copy_string(pri->pvts[chanpos]->dnid, e->ring.callednum, sizeof(pri->pvts[chanpos]->dnid));
7643 - pri->pvts[chanpos]->exten[0] = '\0';
7644 - /* Set DNID on all incoming calls -- even immediate */
7645 - if (!ast_strlen_zero(e->ring.callednum))
7646 - ast_copy_string(pri->pvts[chanpos]->dnid, e->ring.callednum, sizeof(pri->pvts[chanpos]->dnid));
7647 - /* No number yet, but received "sending complete"? */
7648 - if (e->ring.complete && (ast_strlen_zero(e->ring.callednum))) {
7649 + } else if (ast_strlen_zero(e->ring.callednum)) {
7650 + /* called party number is empty */
7651 + if ((pri->nodetype == BRI_NETWORK_PTMP) || (pri->nodetype == BRI_NETWORK)) {
7652 + if (!pri->overlapdial) {
7653 + // be able to set digittimeout for BRI phones
7654 + pri->pvts[chanpos]->exten[0] = 's';
7655 + pri->pvts[chanpos]->exten[1] = '\0';
7656 + tone_zone_play_tone(pri->pvts[chanpos]->subs[SUB_REAL].zfd, ZT_TONE_DIALTONE);
7658 + pri->pvts[chanpos]->exten[0] = '\0';
7661 + if (pri->nodetype == BRI_CPE) {
7662 + /* fix for .at p2p bri lines */
7663 + pri->pvts[chanpos]->exten[0] = 's';
7664 + pri->pvts[chanpos]->exten[1] = '\0';
7666 + pri->pvts[chanpos]->exten[0] = '\0';
7669 + /* No number yet, but received "sending complete"? */
7670 + if (e->ring.complete) {
7671 if (option_verbose > 2)
7672 ast_verbose(VERBOSE_PREFIX_3 "Going to extension s|1 because of Complete received\n");
7673 pri->pvts[chanpos]->exten[0] = 's';
7674 pri->pvts[chanpos]->exten[1] = '\0';
7678 + /* Get called number */
7679 + pri_make_callerid(pri, pri->pvts[chanpos]->dnid, sizeof(pri->pvts[chanpos]->dnid), e->ring.callednum, sizeof(e->ring.callednum), e->ring.calledplan, 0, pri->pvts[chanpos]->stripmsd);
7680 + pri_make_callerid(pri, pri->pvts[chanpos]->exten, sizeof(pri->pvts[chanpos]->exten), e->ring.callednum, sizeof(e->ring.callednum), e->ring.calledplan, 0, pri->pvts[chanpos]->stripmsd);
7681 + if ((pri->nodetype == BRI_NETWORK_PTMP) || (pri->nodetype == BRI_NETWORK)) {
7682 + /* if we get the next digit we should stop the dialtone */
7683 + if (!pri->overlapdial) {
7684 + // with overlapdial=no the exten is always prefixed by "s"
7685 + if (!ast_ignore_pattern(pri->pvts[chanpos]->context, pri->pvts[chanpos]->exten + 1)) {
7686 + tone_zone_play_tone(pri->pvts[chanpos]->subs[SUB_REAL].zfd, -1);
7688 + tone_zone_play_tone(pri->pvts[chanpos]->subs[SUB_REAL].zfd, ZT_TONE_DIALTONE);
7691 + if (!ast_ignore_pattern(pri->pvts[chanpos]->context, pri->pvts[chanpos]->exten)) {
7692 + tone_zone_play_tone(pri->pvts[chanpos]->subs[SUB_REAL].zfd, -1);
7694 + tone_zone_play_tone(pri->pvts[chanpos]->subs[SUB_REAL].zfd, ZT_TONE_DIALTONE);
7699 + /* Part 3: create channel, setup audio... */
7700 + /* Set DNID on all incoming calls -- even immediate */
7701 + if (!ast_strlen_zero(e->ring.callednum))
7702 + strncpy(pri->pvts[chanpos]->dnid, e->ring.callednum, sizeof(pri->pvts[chanpos]->dnid) - 1);
7703 /* Make sure extension exists (or in overlap dial mode, can exist) */
7704 if ((pri->overlapdial && ast_canmatch_extension(NULL, pri->pvts[chanpos]->context, pri->pvts[chanpos]->exten, 1, pri->pvts[chanpos]->cid_num)) ||
7705 ast_exists_extension(NULL, pri->pvts[chanpos]->context, pri->pvts[chanpos]->exten, 1, pri->pvts[chanpos]->cid_num)) {
7706 @@ -8490,22 +9284,38 @@
7707 res = zt_setlaw(pri->pvts[chanpos]->subs[SUB_REAL].zfd, law);
7709 ast_log(LOG_WARNING, "Unable to set law on channel %d\n", pri->pvts[chanpos]->channel);
7710 - res = set_actual_gain(pri->pvts[chanpos]->subs[SUB_REAL].zfd, 0, pri->pvts[chanpos]->rxgain, pri->pvts[chanpos]->txgain, law);
7711 + if (IS_DIGITAL(e->ring.ctype)) {
7712 + res = set_actual_gain(pri->pvts[chanpos]->subs[SUB_REAL].zfd, 0, 0, 0, pri->pvts[chanpos]->law);
7714 + res = set_actual_gain(pri->pvts[chanpos]->subs[SUB_REAL].zfd, 0, pri->pvts[chanpos]->rxgain, pri->pvts[chanpos]->txgain, law);
7717 ast_log(LOG_WARNING, "Unable to set gains on channel %d\n", pri->pvts[chanpos]->channel);
7718 - if (e->ring.complete || !pri->overlapdial)
7719 + if ((pri->nodetype != BRI_NETWORK_PTMP) && (pri->nodetype != BRI_NETWORK)) {
7720 + if (e->ring.complete || !pri->overlapdial) {
7721 /* Just announce proceeding */
7722 pri_proceeding(pri->pri, e->ring.call, PVT_TO_CHANNEL(pri->pvts[chanpos]), 0);
7724 + // pri->pvts[chanpos]->ignoredtmf = 0;
7726 if (pri->switchtype != PRI_SWITCH_GR303_TMC)
7727 pri_need_more_info(pri->pri, e->ring.call, PVT_TO_CHANNEL(pri->pvts[chanpos]), 1);
7729 pri_answer(pri->pri, e->ring.call, PVT_TO_CHANNEL(pri->pvts[chanpos]), 1);
7732 + /* BRI_NETWORK | BRI_NETWORK_PTMP */
7733 + if (pri->overlapdial || (!strcasecmp(pri->pvts[chanpos]->exten, "s"))) {
7734 + /* send a SETUP_ACKNOWLEDGE */
7735 + pri_need_more_info(pri->pri, e->ring.call, PVT_TO_CHANNEL(pri->pvts[chanpos]), 1);
7737 + /* send an ALERTING ??? wtf */
7738 + // pri_acknowledge(pri->pri, e->ring.call, PVT_TO_CHANNEL(pri->pvts[chanpos]), 1);
7739 + pri_proceeding(pri->pri, e->ring.call, PVT_TO_CHANNEL(pri->pvts[chanpos]), 0);
7742 - /* Get the use_callingpres state */
7743 - pri->pvts[chanpos]->callingpres = e->ring.callingpres;
7747 + /* overlapdial = yes and the extension can be valid */
7749 if (pri->overlapdial && ast_matchmore_extension(NULL, pri->pvts[chanpos]->context, pri->pvts[chanpos]->exten, 1, pri->pvts[chanpos]->cid_num)) {
7750 /* Release the PRI lock while we create the channel */
7751 ast_mutex_unlock(&pri->lock);
7752 @@ -8513,14 +9323,31 @@
7753 /* Set bearer and such */
7754 pri_assign_bearer(crv, pri, pri->pvts[chanpos]);
7755 c = zt_new(crv, AST_STATE_RESERVED, 0, SUB_REAL, law, e->ring.ctype);
7756 + if (c && (e->ring.lowlayercompat[0] > 0)) {
7757 + memcpy(c->lowlayercompat, e->ring.lowlayercompat, sizeof(c->lowlayercompat));
7759 pri->pvts[chanpos]->owner = &inuse;
7760 ast_log(LOG_DEBUG, "Started up crv %d:%d on bearer channel %d\n", pri->trunkgroup, crv->channel, crv->bearer->channel);
7762 c = zt_new(pri->pvts[chanpos], AST_STATE_RESERVED, 0, SUB_REAL, law, e->ring.ctype);
7763 + if (c && (e->ring.lowlayercompat[0] > 0)) {
7764 + memcpy(c->lowlayercompat, e->ring.lowlayercompat, sizeof(c->lowlayercompat));
7766 + zt_enable_ec(pri->pvts[chanpos]);
7768 if (!ast_strlen_zero(e->ring.callingsubaddr)) {
7769 pbx_builtin_setvar_helper(c, "CALLINGSUBADDR", e->ring.callingsubaddr);
7771 + if (!ast_strlen_zero(e->ring.callingnum)) {
7773 + pri_make_callerid(pri, tmpstr, sizeof(tmpstr), e->ring.callingnum, sizeof(e->ring.callingnum), e->ring.callingplan, e->ring.callingpres, 0);
7774 + pbx_builtin_setvar_helper(c, "PRI_NETWORK_CID", tmpstr);
7776 + if (!ast_strlen_zero(e->ring.callingani)) {
7778 + pri_make_callerid(pri, tmpstr, sizeof(tmpstr), e->ring.callingani, sizeof(e->ring.callingani), e->ring.callingplanuser, e->ring.callingpresuser, 0);
7779 + pbx_builtin_setvar_helper(c, "PRI_USER_CID", tmpstr);
7781 if(e->ring.ani2 >= 0) {
7782 snprintf(ani2str, 5, "%.2d", e->ring.ani2);
7783 pbx_builtin_setvar_helper(c, "ANI2", ani2str);
7784 @@ -8540,8 +9367,8 @@
7785 ast_mutex_lock(&pri->lock);
7786 if (c && !ast_pthread_create(&threadid, &attr, ss_thread, c)) {
7787 if (option_verbose > 2)
7788 - ast_verbose(VERBOSE_PREFIX_3 "Accepting overlap call from '%s' to '%s' on channel %d/%d, span %d\n",
7789 - plancallingnum, !ast_strlen_zero(pri->pvts[chanpos]->exten) ? pri->pvts[chanpos]->exten : "<unspecified>",
7790 + ast_verbose(VERBOSE_PREFIX_3 "Accepting overlap %s call from '%s' to '%s' on channel %d/%d, span %d\n",
7791 + pri->pvts[chanpos]->digital ? "data" : "voice", plancallingnum, !ast_strlen_zero(pri->pvts[chanpos]->exten) ? pri->pvts[chanpos]->exten : "<unspecified>",
7792 pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span);
7794 ast_log(LOG_WARNING, "Unable to start PBX on channel %d/%d, span %d\n",
7795 @@ -8549,14 +9376,18 @@
7799 - pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_SWITCH_CONGESTION);
7800 + pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_SWITCH_CONGESTION, -1);
7801 pri->pvts[chanpos]->call = NULL;
7805 + /* overlapdial = no */
7806 ast_mutex_unlock(&pri->lock);
7807 /* Release PRI lock while we create the channel */
7808 c = zt_new(pri->pvts[chanpos], AST_STATE_RING, 1, SUB_REAL, law, e->ring.ctype);
7809 + if (c && (e->ring.lowlayercompat[0] > 0)) {
7810 + memcpy(c->lowlayercompat, e->ring.lowlayercompat, sizeof(c->lowlayercompat));
7812 ast_mutex_lock(&pri->lock);
7814 char calledtonstr[10];
7815 @@ -8577,23 +9408,40 @@
7816 snprintf(calledtonstr, sizeof(calledtonstr)-1, "%d", e->ring.calledplan);
7817 pbx_builtin_setvar_helper(c, "CALLEDTON", calledtonstr);
7818 if (option_verbose > 2)
7819 - ast_verbose(VERBOSE_PREFIX_3 "Accepting call from '%s' to '%s' on channel %d/%d, span %d\n",
7820 - plancallingnum, pri->pvts[chanpos]->exten,
7821 + ast_verbose(VERBOSE_PREFIX_3 "Accepting %s call from '%s' to '%s' on channel %d/%d, span %d\n",
7822 + pri->pvts[chanpos]->digital ? "data" : "voice", e->ring.callingnum, pri->pvts[chanpos]->exten,
7823 pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span);
7824 zt_enable_ec(pri->pvts[chanpos]);
7825 + if(!ast_strlen_zero(e->ring.callingsubaddr)) {
7826 + pbx_builtin_setvar_helper(c, "CALLINGSUBADDR", e->ring.callingsubaddr);
7828 + if (!ast_strlen_zero(e->ring.callingnum)) {
7830 + pri_make_callerid(pri, tmpstr, sizeof(tmpstr), e->ring.callingnum, sizeof(e->ring.callingnum), e->ring.callingplan, e->ring.callingpres, 0);
7831 + pbx_builtin_setvar_helper(c, "PRI_NETWORK_CID", tmpstr);
7833 + if (!ast_strlen_zero(e->ring.callingani)) {
7835 + pri_make_callerid(pri, tmpstr,sizeof(tmpstr), e->ring.callingani, sizeof(e->ring.callingani), e->ring.callingplanuser, e->ring.callingpresuser, 0);
7836 + pbx_builtin_setvar_helper(c, "PRI_USER_CID", e->ring.callednum);
7838 + if (!ast_strlen_zero(e->ring.useruserinfo)) {
7839 + pbx_builtin_setvar_helper(c, "UUI", e->ring.useruserinfo);
7842 ast_log(LOG_WARNING, "Unable to start PBX on channel %d/%d, span %d\n",
7843 pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span);
7844 - pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_SWITCH_CONGESTION);
7845 + pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_SWITCH_CONGESTION, -1);
7846 pri->pvts[chanpos]->call = NULL;
7850 + /* invalid extension */
7851 if (option_verbose > 2)
7852 ast_verbose(VERBOSE_PREFIX_3 "Extension '%s' in context '%s' from '%s' does not exist. Rejecting call on channel %d/%d, span %d\n",
7853 pri->pvts[chanpos]->exten, pri->pvts[chanpos]->context, pri->pvts[chanpos]->cid_num, pri->pvts[chanpos]->logicalspan,
7854 pri->pvts[chanpos]->prioffset, pri->span);
7855 - pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_UNALLOCATED);
7856 + pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_UNALLOCATED, -1);
7857 pri->pvts[chanpos]->call = NULL;
7858 pri->pvts[chanpos]->exten[0] = '\0';
7860 @@ -8601,7 +9449,7 @@
7861 ast_mutex_unlock(&crv->lock);
7862 ast_mutex_unlock(&pri->pvts[chanpos]->lock);
7864 - pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_REQUESTED_CHAN_UNAVAIL);
7865 + pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_REQUESTED_CHAN_UNAVAIL, -1);
7867 case PRI_EVENT_RINGING:
7868 chanpos = pri_find_principle(pri, e->ringing.channel);
7869 @@ -8619,7 +9467,7 @@
7871 ast_mutex_lock(&pri->pvts[chanpos]->lock);
7872 if (ast_strlen_zero(pri->pvts[chanpos]->dop.dialstr)) {
7873 - zt_enable_ec(pri->pvts[chanpos]);
7874 + // XXX zt_enable_ec(pri->pvts[chanpos]);
7875 pri->pvts[chanpos]->subs[SUB_REAL].needringing = 1;
7876 pri->pvts[chanpos]->alerting = 1;
7878 @@ -8648,9 +9496,15 @@
7881 case PRI_EVENT_PROGRESS:
7882 - /* Get chan value if e->e is not PRI_EVNT_RINGING */
7883 + /* Get chan value if e->e is not PRI_EVENT_RINGING */
7884 chanpos = pri_find_principle(pri, e->proceeding.channel);
7886 + if ((pri->pvts[chanpos]->priindication_oob == 2) && (e->proceeding.cause == PRI_CAUSE_USER_BUSY)) {
7887 + /* received PROGRESS with cause BUSY, no inband callprogress wanted => hang up! */
7888 + if (pri->pvts[chanpos]->owner) {
7889 + pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
7892 #ifdef PRI_PROGRESS_MASK
7893 if ((!pri->pvts[chanpos]->progress) || (e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE)) {
7895 @@ -8697,6 +9551,12 @@
7896 case PRI_EVENT_PROCEEDING:
7897 chanpos = pri_find_principle(pri, e->proceeding.channel);
7899 + chanpos = pri_fixup_principle(pri, chanpos, e->proceeding.call);
7900 + if (chanpos < 0) {
7901 + ast_log(LOG_WARNING, "Received PROCEEDING on channel %d/%d not in use on span %d\n",
7902 + PRI_SPAN(e->proceeding.channel), PRI_CHANNEL(e->proceeding.channel), pri->span);
7905 if (!pri->pvts[chanpos]->proceeding) {
7906 struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_PROCEEDING, };
7908 @@ -8747,6 +9607,295 @@
7912 + case PRI_EVENT_SUSPEND_REQ:
7913 + if ((pri->nodetype != BRI_NETWORK_PTMP) && (pri->nodetype != BRI_NETWORK)) {
7914 + pri_suspend_reject(pri->pri, e->suspend_req.call, "");
7917 + chanpos = pri_find_principle(pri, e->suspend_req.channel);
7918 + if (chanpos < 0) {
7919 + ast_log(LOG_WARNING, "Suspend requested on unconfigured channel %d span %d\n", chanpos, pri->span);
7923 + if (chanpos > -1) {
7924 + ast_mutex_lock(&pri->pvts[chanpos]->lock);
7925 + if (pri->pvts[chanpos]->owner) {
7926 + if (ast_bridged_channel(pri->pvts[chanpos]->owner)) {
7927 + struct zt_suspended_call *zpc;
7929 + zpc = malloc(sizeof(struct zt_suspended_call));
7931 + ast_log(LOG_ERROR, "unable to malloc zt_suspended_call\n");
7934 + strncpy(zpc->msn, pri->pvts[chanpos]->cid_num, sizeof(zpc->msn));
7935 + strncpy(zpc->callid, e->suspend_req.callid, sizeof(zpc->callid));
7936 + ast_masq_park_call(ast_bridged_channel(pri->pvts[chanpos]->owner), NULL, 0, &zpc->parked_at);
7937 + zpc->next = pri->suspended_calls;
7938 + pri->suspended_calls = zpc;
7939 + snprintf(tmpstr, sizeof(tmpstr), "Parked at %d", zpc->parked_at);
7940 + pri_suspend_acknowledge(pri->pri, e->suspend_req.call,tmpstr);
7941 + pri->pvts[chanpos]->call = NULL;
7942 + pri->pvts[chanpos]->tei = -1;
7943 + pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
7945 + pri_suspend_reject(pri->pri, e->suspend_req.call, "cant park a non-bridge");
7946 + ast_mutex_unlock(&pri->pvts[chanpos]->lock);
7950 + pri_suspend_reject(pri->pri, e->suspend_req.call, "");
7952 + ast_mutex_unlock(&pri->pvts[chanpos]->lock);
7955 + case PRI_EVENT_RESUME_REQ:
7956 + if ((pri->nodetype != BRI_NETWORK_PTMP) && (pri->nodetype != BRI_NETWORK)) {
7959 + chanpos = pri_find_empty_chan(pri, 1);
7960 + if (chanpos < 0) {
7961 + pri_resume_reject(pri->pri, e->resume_req.call,"All channels busy");
7962 + ast_log(LOG_WARNING, "Resume requested on odd channel number %d span %d\n", chanpos, pri->span);
7964 + } else if (!pri->pvts[chanpos]) {
7965 + pri_resume_reject(pri->pri, e->resume_req.call,"General protection fault in module 0x0BRI");
7969 + if (chanpos > -1) {
7970 + ast_mutex_lock(&pri->pvts[chanpos]->lock);
7971 + if (!pri->pvts[chanpos]->owner) {
7972 + struct zt_suspended_call *zpc, *zpcl;
7974 + char extenstr[255], temp[255];
7976 + zpcl = pri->suspended_calls;
7978 + // ast_log(LOG_NOTICE, "zpc->parked_at %d zpcl->callid %s\n",zpcl->parked_at, zpcl->callid);
7979 + if (((strlen(zpcl->callid) == 0) && (strlen(e->resume_req.callid)==0)) || (!strcmp(zpcl->callid,e->resume_req.callid))) {
7981 + // found a parked call
7982 + snprintf(extenstr, sizeof(extenstr), "%d", zpcl->parked_at);
7983 + strncpy(pri->pvts[chanpos]->exten, extenstr, sizeof(pri->pvts[chanpos]->exten));
7984 + // strncpy(pri->pvts[chanpos]->context, ast_parking_con(), sizeof(pri->pvts[chanpos]->context));
7985 + pri->pvts[chanpos]->call = e->resume_req.call;
7987 + if (ioctl(pri->pvts[chanpos]->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &law) == -1)
7988 + ast_log(LOG_WARNING, "Unable to set audio mode on channel %d to %d\n", PVT_TO_CHANNEL(pri->pvts[chanpos]), law);
7989 + // uhh ohh...what shall we do without the bearer cap???
7990 + law = ZT_LAW_ALAW;
7991 + res = zt_setlaw(pri->pvts[chanpos]->subs[SUB_REAL].zfd, law);
7993 + ast_log(LOG_WARNING, "Unable to set law on channel %d\n", PVT_TO_CHANNEL(pri->pvts[chanpos]));
7994 + if (!pri->pvts[chanpos]->digital) {
7995 + res = set_actual_gain(pri->pvts[chanpos]->subs[SUB_REAL].zfd, 0, pri->pvts[chanpos]->rxgain, pri->pvts[chanpos]->txgain, law);
7997 + res = set_actual_gain(pri->pvts[chanpos]->subs[SUB_REAL].zfd, 0, 0, 0, pri->pvts[chanpos]->law);
8000 + ast_log(LOG_WARNING, "Unable to set gains on channel %d\n", PVT_TO_CHANNEL(pri->pvts[chanpos]));
8002 + c = zt_new(pri->pvts[chanpos], AST_STATE_UP, 1, SUB_REAL, law, PRI_TRANS_CAP_SPEECH);
8004 + pri->pvts[chanpos]->owner = c;
8005 + pri->pvts[chanpos]->call = e->resume_req.call;
8006 + zt_enable_ec(pri->pvts[chanpos]);
8007 + zt_train_ec(pri->pvts[chanpos]);
8009 + ast_log(LOG_ERROR, "unable to start pbx\n");
8013 + zpc->next = zpcl->next;
8018 + pri->suspended_calls = zpcl->next;
8020 + zpcl = pri->suspended_calls;
8024 + snprintf(temp, sizeof(temp), "Unparked %s", extenstr);
8025 + pri_resume_acknowledge(pri->pri, e->resume_req.call, chanpos + 1, temp);
8029 + if (zpcl) zpcl = zpcl->next;
8032 + pri_resume_reject(pri->pri, e->resume_req.call,"No suspended call to unpark!");
8034 + pri_resume_reject(pri->pri, e->resume_req.call,"No suspended call to unpark!");
8036 + ast_mutex_unlock(&pri->pvts[chanpos]->lock);
8039 + case PRI_EVENT_HOLD_REQ:
8040 + if ((pri->nodetype != BRI_NETWORK_PTMP) && (pri->nodetype != BRI_NETWORK)) {
8041 + pri_hold_reject(pri->pri, e->hold_req.call);
8044 + chanpos = pri_find_principle(pri, e->hold_req.channel);
8045 + if (chanpos < 0) {
8046 + ast_log(LOG_WARNING, "Hold requested on unconfigured channel %d span %d\n", chanpos, pri->span);
8049 + if (chanpos > -1) {
8050 + // ast_log(LOG_NOTICE, "Hold request for channel number %d span %d\n", chanpos, pri->span);
8051 + ast_mutex_lock(&pri->pvts[chanpos]->lock);
8052 + if (pri->pvts[chanpos]->owner) {
8053 + struct zt_pvt *p = pri->pvts[chanpos];
8054 + struct zt_holded_call *zhc;
8057 +// ast_log(LOG_NOTICE,"HOLD request from channel %s tei %d\n",p->owner->name, e->hold_req.tei);
8058 + if (ast_bridged_channel(p->owner)) {
8059 + zhc = malloc(sizeof(struct zt_holded_call));
8061 + ast_log(LOG_ERROR, "unable to malloc zt_holded_call\n");
8064 + memset(zhc, 0, sizeof(zhc));
8065 + strncpy(zhc->msn, pri->pvts[chanpos]->cid_num, sizeof(zhc->msn));
8066 + strncpy(zhc->uniqueid, ast_bridged_channel(p->owner)->uniqueid, sizeof(zhc->uniqueid));
8067 + zhc->tei = e->hold_req.tei;
8068 + zhc->cref = e->hold_req.cref;
8069 + zhc->call = e->hold_req.call;
8070 + zhc->channel = p->owner;
8071 + zhc->alreadyhungup = 0;
8072 + zhc->bridge = ast_bridged_channel(p->owner);
8073 + zhc->next = pri->holded_calls;
8074 + pri->holded_calls = zhc;
8076 + /* put channel on hold */
8077 + ast_masq_hold_call(ast_bridged_channel(p->owner), p->owner);
8079 + pri_hold_acknowledge(pri->pri, e->hold_req.call);
8081 + p->call = NULL; // free the bchannel withouth destroying the call
8084 + // cant hold a non-bridge,...yet
8086 + // make a fake channel
8091 + pri_hold_reject(pri->pri, e->hold_req.call);
8094 + pri_hold_reject(pri->pri, e->hold_req.call);
8096 + ast_mutex_unlock(&pri->pvts[chanpos]->lock);
8098 + pri_hold_reject(pri->pri, e->hold_req.call);
8101 + case PRI_EVENT_RETRIEVE_REQ:
8102 + if ((pri->nodetype != BRI_NETWORK_PTMP) && (pri->nodetype != BRI_NETWORK)) {
8103 + pri_retrieve_reject(pri->pri, e->retrieve_req.call);
8106 + chanpos = pri_find_empty_chan(pri, 1);
8107 + if (chanpos < 0) {
8108 + pri_retrieve_reject(pri->pri, e->retrieve_req.call);
8109 + ast_log(LOG_WARNING, "Retrieve requested on odd channel number %d span %d\n", chanpos, pri->span);
8112 + } else if (!pri->pvts[chanpos]) {
8113 + ast_log(LOG_WARNING, "Retrieve requested on unconfigured channel number %d span %d\n", chanpos, pri->span);
8114 + pri_retrieve_reject(pri->pri, e->retrieve_req.call);
8118 + if (chanpos > -1) {
8119 + struct zt_holded_call *onhold = NULL;
8120 + int retrieved = 0;
8122 + struct app_tmp *tmp;
8123 + pthread_attr_t attr;
8126 + onhold = pri_get_callonhold(pri, e->retrieve_req.cref, e->retrieve_req.tei);
8129 + pri_retrieve_reject(pri->pri, e->retrieve_req.call);
8132 + ast_mutex_lock(&pri->pvts[chanpos]->lock);
8133 + // found a parked call
8135 + if (ioctl(pri->pvts[chanpos]->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &law) == -1)
8136 + ast_log(LOG_WARNING, "Unable to set audio mode on channel %d to %d\n", PVT_TO_CHANNEL(pri->pvts[chanpos]), law);
8137 + // uhh ohh...what shall we do without the bearer cap???
8138 + law = ZT_LAW_ALAW;
8139 + res = zt_setlaw(pri->pvts[chanpos]->subs[SUB_REAL].zfd, law);
8141 + ast_log(LOG_WARNING, "Unable to set law on channel %d\n", PVT_TO_CHANNEL(pri->pvts[chanpos]));
8142 + res = set_actual_gain(pri->pvts[chanpos]->subs[SUB_REAL].zfd, 0, pri->pvts[chanpos]->rxgain, pri->pvts[chanpos]->txgain, law);
8144 + ast_log(LOG_WARNING, "Unable to set gains on channel %d\n", PVT_TO_CHANNEL(pri->pvts[chanpos]));
8146 + c = zt_new(pri->pvts[chanpos], AST_STATE_UP, 0, SUB_REAL, law, PRI_TRANS_CAP_SPEECH);
8148 + pri->pvts[chanpos]->owner = c;
8149 + pri->pvts[chanpos]->outgoing = 1; /* for not sending proceedings... */
8150 + pri->pvts[chanpos]->call = e->retrieve_req.call;
8151 + pri->pvts[chanpos]->tei = e->retrieve_req.tei;
8152 + zt_enable_ec(pri->pvts[chanpos]);
8153 + zt_train_ec(pri->pvts[chanpos]);
8155 + ast_log(LOG_ERROR, "unable to start pbx\n");
8159 + // ast_log(LOG_NOTICE, "sending RETRIEVE ACK on channel %d, span %d for tei %d cref %d\n",chanpos,pri->span, e->retrieve_req.tei, e->retrieve_req.cref);
8160 + pri_retrieve_acknowledge(pri->pri, e->retrieve_req.call, chanpos + 1);
8162 + // the magic begins here: ....
8163 + tmp = malloc(sizeof(struct app_tmp));
8165 + memset(tmp, 0, sizeof(struct app_tmp));
8166 + strncpy(tmp->app, "holdedcall", sizeof(tmp->app) - 1);
8167 + strncpy(tmp->data, onhold->uniqueid, sizeof(tmp->data) - 1);
8170 + pri_destroy_callonhold(pri, onhold);
8173 + ast_mutex_unlock(&pri->pvts[chanpos]->lock);
8174 + pthread_attr_init(&attr);
8175 + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
8176 + if (ast_pthread_create(&tmp->t, &attr, ast_pbx_run_app, tmp)) {
8177 + ast_log(LOG_WARNING, "Unable to spawn execute thread on %s: %s\n", c->name, strerror(errno));
8184 + pri_retrieve_reject(pri->pri, e->retrieve_req.call);
8188 + case PRI_EVENT_DISPLAY_RECEIVED:
8189 + ast_log(LOG_NOTICE, "DISPLAY IE: [ %s ] received\n",e->display.text);
8190 + chanpos = pri_find_principle(pri, e->display.channel);
8191 + if (chanpos < 0) {
8192 + ast_log(LOG_WARNING, "odd channel number %d span %d\n", chanpos, pri->span);
8195 + if (chanpos > -1) {
8196 + if (pri->pvts[chanpos]->owner) {
8197 + // ast_sendtext(pri->pvt[chanpos]->owner, e->display.text);
8201 case PRI_EVENT_ANSWER:
8202 chanpos = pri_find_principle(pri, e->answer.channel);
8204 @@ -8762,6 +9911,7 @@
8207 ast_mutex_lock(&pri->pvts[chanpos]->lock);
8208 + pri->pvts[chanpos]->tei = e->answer.tei;
8209 /* Now we can do call progress detection */
8211 /* We changed this so it turns on the DSP no matter what... progress or no progress.
8212 @@ -8791,11 +9941,15 @@
8213 ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", pri->pvts[chanpos]->dop.dialstr);
8214 pri->pvts[chanpos]->dop.dialstr[0] = '\0';
8215 } else if (pri->pvts[chanpos]->confirmanswer) {
8216 - ast_log(LOG_DEBUG, "Waiting on answer confirmation on channel %d!\n", pri->pvts[chanpos]->channel);
8217 + ast_log(LOG_DEBUG, "Waiting for answer confirmation on channel %d!\n", pri->pvts[chanpos]->channel);
8219 + pri->pvts[chanpos]->dialing = 0;
8220 pri->pvts[chanpos]->subs[SUB_REAL].needanswer =1;
8221 /* Enable echo cancellation if it's not on already */
8222 zt_enable_ec(pri->pvts[chanpos]);
8223 + zt_train_ec(pri->pvts[chanpos]);
8224 + /* stop ignoring inband dtmf */
8225 + enable_dtmf_detect(pri->pvts[chanpos]);
8228 #ifdef SUPPORT_USERUSER
8229 @@ -8844,23 +9998,32 @@
8232 if (option_verbose > 2)
8233 - ast_verbose(VERBOSE_PREFIX_3 "Channel %d/%d, span %d got hangup\n",
8234 - pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span);
8235 + ast_verbose(VERBOSE_PREFIX_3 "Channel %d/%d, span %d got hangup, cause %d\n",
8236 + pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span, e->hangup.cause);
8238 - pri_hangup(pri->pri, pri->pvts[chanpos]->call, e->hangup.cause);
8239 + pri_hangup(pri->pri, pri->pvts[chanpos]->call, e->hangup.cause, -1);
8240 pri->pvts[chanpos]->call = NULL;
8241 + pri->pvts[chanpos]->tei = -1;
8243 if (e->hangup.cause == PRI_CAUSE_REQUESTED_CHAN_UNAVAIL) {
8244 - if (option_verbose > 2)
8245 + if ((pri->nodetype != BRI_CPE_PTMP) && (pri->nodetype != BRI_NETWORK_PTMP)) {
8246 + if (option_verbose > 2)
8247 ast_verbose(VERBOSE_PREFIX_3 "Forcing restart of channel %d/%d on span %d since channel reported in use\n",
8248 PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span);
8249 - pri_reset(pri->pri, PVT_TO_CHANNEL(pri->pvts[chanpos]));
8250 - pri->pvts[chanpos]->resetting = 1;
8251 + pri_reset(pri->pri, PVT_TO_CHANNEL(pri->pvts[chanpos]));
8252 + pri->pvts[chanpos]->resetting = 1;
8255 - if (e->hangup.aoc_units > -1)
8256 + if (e->hangup.aoc_units > -1) {
8257 + if (pri->pvts[chanpos]->owner) {
8259 + snprintf(tmpstr, sizeof(tmpstr), "%d", (int)e->hangup.aoc_units);
8260 + pbx_builtin_setvar_helper(pri->pvts[chanpos]->owner, "AOCEUNITS", tmpstr);
8262 if (option_verbose > 2)
8263 ast_verbose(VERBOSE_PREFIX_3 "Channel %d/%d, span %d received AOC-E charging %d unit%s\n",
8264 pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span, (int)e->hangup.aoc_units, (e->hangup.aoc_units == 1) ? "" : "s");
8267 #ifdef SUPPORT_USERUSER
8268 if (!ast_strlen_zero(e->hangup.useruserinfo)) {
8269 @@ -8870,8 +10033,20 @@
8271 ast_mutex_unlock(&pri->pvts[chanpos]->lock);
8273 - ast_log(LOG_WARNING, "Hangup on bad channel %d/%d on span %d\n",
8274 - PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span);
8275 + struct zt_holded_call *onhold = NULL;
8276 + /* check calls on hold */
8277 + onhold = pri_get_callonhold(pri, e->hangup.cref, e->hangup.tei);
8280 + // ast_log(LOG_NOTICE, "hangup, found cref %d, tei %d\n",e->hangup.cref, e->hangup.tei);
8281 + pri_hangup(pri->pri, onhold->call, e->hangup.cause, -1);
8282 + pri_destroy_callonhold(pri, onhold);
8285 + ast_log(LOG_NOTICE, "Hangup, did not find cref %d, tei %d\n",e->hangup.cref, e->hangup.tei);
8286 + ast_log(LOG_WARNING, "Hangup on bad channel %d/%d on span %d\n",
8287 + PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span);
8292 @@ -8881,17 +10056,25 @@
8293 case PRI_EVENT_HANGUP_REQ:
8294 chanpos = pri_find_principle(pri, e->hangup.channel);
8296 - ast_log(LOG_WARNING, "Hangup REQ requested on unconfigured channel %d/%d span %d\n",
8297 - PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span);
8298 + if (pri->nodetype == BRI_NETWORK_PTMP) {
8299 + pri_hangup(pri->pri, e->hangup.call, e->hangup.cause, -1);
8301 + ast_log(LOG_WARNING, "Hangup REQ requested on unconfigured channel %d/%d span %d\n",
8302 + PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span);
8306 - if (chanpos > -1) {
8307 + /* dont hang up if we want to hear inband call progress */
8308 + if ((chanpos > -1) && ((pri->pvts[chanpos]->priindication_oob != 2) || (!e->hangup.inband_progress) || (!pri->pvts[chanpos]->outgoing))){
8309 chanpos = pri_fixup_principle(pri, chanpos, e->hangup.call);
8311 ast_mutex_lock(&pri->pvts[chanpos]->lock);
8312 if (pri->pvts[chanpos]->realcall)
8313 pri_hangup_all(pri->pvts[chanpos]->realcall, pri);
8314 else if (pri->pvts[chanpos]->owner) {
8316 + snprintf(tmpstr, sizeof(tmpstr), "%d", e->hangup.cause);
8317 + pbx_builtin_setvar_helper(pri->pvts[chanpos]->owner, "PRI_CAUSE", tmpstr);
8318 pri->pvts[chanpos]->owner->hangupcause = e->hangup.cause;
8319 switch(e->hangup.cause) {
8320 case PRI_CAUSE_USER_BUSY:
8321 @@ -8910,20 +10093,87 @@
8323 if (option_verbose > 2)
8324 ast_verbose(VERBOSE_PREFIX_3 "Channel %d/%d, span %d got hangup request\n", PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span);
8325 - if (e->hangup.aoc_units > -1)
8326 - if (option_verbose > 2)
8327 - ast_verbose(VERBOSE_PREFIX_3 "Channel %d/%d, span %d received AOC-E charging %d unit%s\n",
8328 - pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span, (int)e->hangup.aoc_units, (e->hangup.aoc_units == 1) ? "" : "s");
8329 + if (e->hangup.aoc_units > -1) {
8330 + if (pri->pvts[chanpos]->owner) {
8332 + snprintf(tmpstr, sizeof(tmpstr), "%d", (int)e->hangup.aoc_units);
8333 + pbx_builtin_setvar_helper(pri->pvts[chanpos]->owner, "AOCEUNITS", tmpstr);
8335 + if (option_verbose > 2)
8336 + ast_verbose(VERBOSE_PREFIX_3 "Channel %d/%d, span %d received AOC-E charging %d unit%s\n",
8337 + pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span, (int)e->hangup.aoc_units, (e->hangup.aoc_units == 1) ? "" : "s");
8339 + if (pri->nodetype == BRI_NETWORK_PTMP) {
8340 + // check for bri transfers, not everybody uses ECT...
8341 + if (pri->pvts[chanpos]->owner) {
8342 + // find on hold call
8343 + struct zt_holded_call *onhold = NULL;
8344 + struct ast_channel *transferee = NULL;
8345 + int transfer_ok = 0;
8347 + onhold = pri_get_callonhold(pri, -1, e->hangup.tei);
8350 + if (pri->pvts[chanpos]->pritransfer == 2) {
8351 + if (((pri->pvts[chanpos]->owner->_state != AST_STATE_RING) && (pri->pvts[chanpos]->owner->_state != AST_STATE_RESERVED)) || ((!ast_strlen_zero(pri->pvts[chanpos]->exten)) && (strncasecmp(pri->pvts[chanpos]->exten, "s", sizeof(pri->pvts[chanpos]->exten))))) {
8352 + transferee = ast_get_holded_call(onhold->uniqueid);
8355 + if (pri->pvts[chanpos]->owner->_state == AST_STATE_RINGING) {
8356 + ast_indicate(transferee, AST_CONTROL_RINGING);
8359 + pri->pvts[chanpos]->owner->_softhangup &= ~AST_SOFTHANGUP_DEV;
8361 + ast_mutex_unlock(&transferee->lock);
8362 + if (ast_channel_masquerade(pri->pvts[chanpos]->owner, transferee)) {
8363 + ast_log(LOG_WARNING, "unable to masquerade\n");
8365 + /* beware of zombies!!! */
8366 + ast_set_flag(transferee, AST_FLAG_ZOMBIE);
8367 + pri->pvts[chanpos]->owner = NULL;
8368 + pri->pvts[chanpos]->tei = -1;
8373 + } else if (pri->pvts[chanpos]->pritransfer == 0) {
8374 + ast_log(LOG_NOTICE, "killing channel %s \n", onhold->uniqueid);
8375 + ast_retrieve_call_to_death(onhold->uniqueid);
8377 + } else if (pri->pvts[chanpos]->pritransfer == 1) {
8378 + /* we use ECT transfers, so just ignore this */
8382 + if (transfer_ok) {
8383 + onhold->alreadyhungup = 1;
8384 + pri_hangup(pri->pri, onhold->call, e->hangup.cause, -1);
8387 + ast_mutex_unlock(&pri->pvts[chanpos]->lock);
8390 + pri_hangup(pri->pri, pri->pvts[chanpos]->call, e->hangup.cause, -1);
8391 + pri->pvts[chanpos]->call = NULL;
8392 + pri->pvts[chanpos]->tei = -1;
8397 - pri_hangup(pri->pri, pri->pvts[chanpos]->call, e->hangup.cause);
8398 + pri_hangup(pri->pri, pri->pvts[chanpos]->call, e->hangup.cause, -1);
8399 pri->pvts[chanpos]->call = NULL;
8400 + pri->pvts[chanpos]->tei = -1;
8402 if (e->hangup.cause == PRI_CAUSE_REQUESTED_CHAN_UNAVAIL) {
8403 - if (option_verbose > 2)
8404 - ast_verbose(VERBOSE_PREFIX_3 "Forcing restart of channel %d/%d span %d since channel reported in use\n",
8405 - PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span);
8406 - pri_reset(pri->pri, PVT_TO_CHANNEL(pri->pvts[chanpos]));
8407 - pri->pvts[chanpos]->resetting = 1;
8408 + if ((pri->nodetype != BRI_CPE_PTMP) && (pri->nodetype != BRI_NETWORK_PTMP)) {
8409 + if (option_verbose > 2)
8410 + ast_verbose(VERBOSE_PREFIX_3 "Forcing restart of channel %d/%d span %d since channel reported in use\n",
8411 + PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span);
8412 + pri_reset(pri->pri, PVT_TO_CHANNEL(pri->pvts[chanpos]));
8413 + pri->pvts[chanpos]->resetting = 1;
8418 #ifdef SUPPORT_USERUSER
8419 @@ -8934,9 +10184,36 @@
8421 ast_mutex_unlock(&pri->pvts[chanpos]->lock);
8423 - ast_log(LOG_WARNING, "Hangup REQ on bad channel %d/%d on span %d\n", PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span);
8424 + if (pri->nodetype != BRI_NETWORK_PTMP) {
8425 + ast_log(LOG_WARNING, "Hangup REQ on bad channel %d/%d on span %d\n", PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span);
8427 + // check holded_calls!!!
8428 + struct zt_holded_call *onhold = NULL;
8430 + onhold = pri_get_callonhold(pri, e->hangup.cref, e->hangup.tei);
8433 + pri_hangup(pri->pri, e->hangup.call, e->hangup.cause, -1);
8434 + ast_retrieve_call_to_death(onhold->uniqueid);
8435 + pri_destroy_callonhold(pri, onhold);
8438 + ast_log(LOG_WARNING, "Hangup REQ on bad channel %d/%d on span %d\n", PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span);
8443 + if ((chanpos > -1) && (pri->pvts[chanpos]->owner) && (pri->pvts[chanpos]->priindication_oob == 2) && (e->hangup.inband_progress) && (pri->pvts[chanpos]->outgoing)) {
8444 + if (e->hangup.aoc_units > -1) {
8446 + snprintf(tmpstr, sizeof(tmpstr), "%d", (int)e->hangup.aoc_units);
8447 + pbx_builtin_setvar_helper(pri->pvts[chanpos]->owner, "AOCEUNITS", tmpstr);
8448 + if (option_verbose > 2)
8449 + ast_verbose(VERBOSE_PREFIX_3 "Channel %d/%d, span %d received AOC-E charging %d unit%s\n",
8450 + pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span, (int)e->hangup.aoc_units, (e->hangup.aoc_units == 1) ? "" : "s");
8452 + ast_channel_setwhentohangup(pri->pvts[chanpos]->owner, 5);
8455 case PRI_EVENT_HANGUP_ACK:
8456 chanpos = pri_find_principle(pri, e->hangup.channel);
8457 @@ -8950,6 +10227,7 @@
8459 ast_mutex_lock(&pri->pvts[chanpos]->lock);
8460 pri->pvts[chanpos]->call = NULL;
8461 + pri->pvts[chanpos]->tei = -1;
8462 pri->pvts[chanpos]->resetting = 0;
8463 if (pri->pvts[chanpos]->owner) {
8464 if (option_verbose > 2)
8465 @@ -8963,7 +10241,9 @@
8468 ast_mutex_unlock(&pri->pvts[chanpos]->lock);
8474 case PRI_EVENT_CONFIG_ERR:
8475 @@ -9030,7 +10310,7 @@
8476 ast_log(LOG_WARNING, "Received SETUP_ACKNOWLEDGE on unconfigured channel %d/%d span %d\n",
8477 PRI_SPAN(e->setup_ack.channel), PRI_CHANNEL(e->setup_ack.channel), pri->span);
8479 - chanpos = pri_fixup_principle(pri, chanpos, e->ring.call);
8480 + chanpos = pri_fixup_principle(pri, chanpos, e->setup_ack.call);
8482 ast_mutex_lock(&pri->pvts[chanpos]->lock);
8483 pri->pvts[chanpos]->setup_ack = 1;
8484 @@ -9055,10 +10335,22 @@
8485 ast_mutex_lock(&pri->pvts[chanpos]->lock);
8486 switch(e->notify.info) {
8487 case PRI_NOTIFY_REMOTE_HOLD:
8488 + if ((pri->nodetype == BRI_NETWORK_PTMP) || (pri->nodetype == BRI_NETWORK)) {
8489 + ast_log(LOG_DEBUG, "Received REMOTE_HOLD notification on NETWORK channel. Starting MoH\n");
8490 + ast_moh_start(ast_bridged_channel(pri->pvts[chanpos]->owner), NULL);
8492 + ast_log(LOG_DEBUG, "Received REMOTE_HOLD notification on CPE channel. Not Starting MoH\n");
8494 f.subclass = AST_CONTROL_HOLD;
8495 zap_queue_frame(pri->pvts[chanpos], &f, pri);
8497 case PRI_NOTIFY_REMOTE_RETRIEVAL:
8498 + if ((pri->nodetype == BRI_NETWORK_PTMP) || (pri->nodetype == BRI_NETWORK)) {
8499 + ast_log(LOG_DEBUG, "Received REMOTE_RETRIEVAL notification on NETWORK channel. Stopping MoH\n");
8500 + ast_moh_stop(ast_bridged_channel(pri->pvts[chanpos]->owner));
8502 + ast_log(LOG_DEBUG, "Received REMOTE_RETRIEVAL notification on CPE channel.\n");
8504 f.subclass = AST_CONTROL_UNHOLD;
8505 zap_queue_frame(pri->pvts[chanpos], &f, pri);
8507 @@ -9066,6 +10358,77 @@
8508 ast_mutex_unlock(&pri->pvts[chanpos]->lock);
8511 + case PRI_EVENT_FACILITY:
8512 + if (e->facility.operation == 0x06) {
8513 + struct ast_channel *chan = NULL;
8514 + struct zt_holded_call *onhold = NULL;
8515 + if (option_verbose > 2) {
8516 + ast_verbose(VERBOSE_PREFIX_3 "ECT requested by TEI %d for cref %d\n", e->facility.tei, e->facility.cref);
8518 + /* search for cref/tei in held calls */
8519 + onhold = pri_get_callonhold(pri, e->facility.cref, e->facility.tei);
8521 + chan = ast_get_holded_call(onhold->uniqueid);
8522 + onhold->alreadyhungup = 1;
8526 + pri_hangup(pri->pri, e->facility.call, 16, -1);
8530 + /* unknown cref/tei */
8531 + ast_log(LOG_WARNING, "did not find call on hold for cref %d tei %d\n", e->facility.tei, e->facility.cref);
8533 + pri_hangup(pri->pri, e->facility.call, 16, -1);
8537 + /* find an active call for the same tei */
8538 + chanpos = pri_find_tei(pri, e->facility.call, e->facility.tei);
8539 + if (chanpos < 0) {
8540 + /* did not find active call, hangup call on hold */
8546 + ast_mutex_lock(&pri->pvts[chanpos]->lock);
8548 + if (pri->pvts[chanpos]->owner) {
8549 + if (option_verbose > 3) {
8550 + ast_verbose(VERBOSE_PREFIX_3 "ECT: found %s on channel %d for tei %d\n", pri->pvts[chanpos]->owner->name ,chanpos, e->facility.tei);
8552 + /* pass callprogress if the channel is not up yet */
8553 + if (pri->pvts[chanpos]->owner->_state == AST_STATE_RINGING) {
8554 + ast_indicate(chan, AST_CONTROL_RINGING);
8556 + /* unlock the channel we removed from hold */
8557 + ast_mutex_unlock(&chan->lock);
8558 + if (ast_channel_masquerade(pri->pvts[chanpos]->owner, chan)) {
8559 + ast_log(LOG_WARNING, "unable to masquerade\n");
8561 + /* beware of zombies !!! */
8562 + ast_set_flag(chan, AST_FLAG_ZOMBIE);
8563 + // chan->zombie = 1;
8566 + ast_mutex_unlock(&pri->pvts[chanpos]->lock);
8569 + pri_hangup(pri->pri, e->facility.call, 16, -1);
8570 + } else if (e->facility.operation == 0x0D) {
8571 + ast_log(LOG_NOTICE, "call deflection to %s requested.\n", e->facility.forwardnum);
8572 + ast_mutex_lock(&pri->pvts[chanpos]->lock);
8574 + if (pri->pvts[chanpos]->owner) {
8575 + snprintf(pri->pvts[chanpos]->owner->call_forward, sizeof(pri->pvts[chanpos]->owner->call_forward), "Local/%s@%s", e->facility.forwardnum, pri->pvts[chanpos]->owner->context);
8577 + ast_mutex_unlock(&pri->pvts[chanpos]->lock);
8579 + ast_log(LOG_WARNING, "Unknown facility operation %#x requested.\n", e->facility.operation);
8583 ast_log(LOG_DEBUG, "Event: %d\n", e->e);
8585 @@ -9127,7 +10490,7 @@
8589 - pri->dchans[i] = pri_new(pri->fds[i], pri->nodetype, pri->switchtype);
8590 + pri->dchans[i] = pri_new(pri->fds[i], pri->nodetype, pri->switchtype, pri->span);
8591 /* Force overlap dial if we're doing GR-303! */
8592 if (pri->switchtype == PRI_SWITCH_GR303_TMC)
8593 pri->overlapdial = 1;
8594 @@ -9196,39 +10559,77 @@
8596 static int handle_pri_set_debug_file(int fd, int argc, char **argv)
8603 + return RESULT_SHOWUSAGE;
8605 if (!strncasecmp(argv[1], "set", 3)) {
8608 return RESULT_SHOWUSAGE;
8610 - if (ast_strlen_zero(argv[4]))
8611 + if (!argv[4] || ast_strlen_zero(argv[4]))
8612 return RESULT_SHOWUSAGE;
8615 + return RESULT_SHOWUSAGE;
8617 + if (!argv[6] || ast_strlen_zero(argv[6]))
8618 + return RESULT_SHOWUSAGE;
8620 + span = atoi(argv[6]);
8621 + if ((span < 1) && (span > NUM_SPANS)) {
8622 + return RESULT_SUCCESS;
8626 myfd = open(argv[4], O_CREAT|O_WRONLY);
8628 - ast_cli(fd, "Unable to open '%s' for writing\n", argv[4]);
8629 - return RESULT_SUCCESS;
8630 + ast_cli(fd, "Unable to open '%s' for writing\n", argv[4]);
8631 + return RESULT_SUCCESS;
8634 - ast_mutex_lock(&pridebugfdlock);
8636 - if (pridebugfd >= 0)
8637 - close(pridebugfd);
8639 - pridebugfd = myfd;
8640 - ast_copy_string(pridebugfilename,argv[4],sizeof(pridebugfilename));
8642 - ast_mutex_unlock(&pridebugfdlock);
8644 - ast_cli(fd, "PRI debug output will be sent to '%s'\n", argv[4]);
8645 + for (x=0; x < NUM_SPANS; x++) {
8646 + ast_mutex_lock(&pris[x].lock);
8648 + if (pris[x].span == span) {
8649 + if (pris[x].debugfd >= 0)
8650 + close(pris[x].debugfd);
8651 + pris[x].debugfd = myfd;
8652 + for (d=0; d < NUM_DCHANS; d++) {
8653 + if (pris[x].dchans[d])
8654 + pri_set_debug_fd(pris[x].dchans[d], myfd);
8657 + ast_mutex_unlock(&pris[x].lock);
8660 + ast_cli(fd, "PRI debug output for span %d will be sent to '%s'\n", span, argv[4]);
8662 + if (!argv[5] || ast_strlen_zero(argv[5]))
8663 + return RESULT_SHOWUSAGE;
8664 /* Assume it is unset */
8665 - ast_mutex_lock(&pridebugfdlock);
8666 - close(pridebugfd);
8668 - ast_cli(fd, "PRI debug output to file disabled\n");
8669 - ast_mutex_unlock(&pridebugfdlock);
8670 + span = atoi(argv[5]);
8671 + if ((span < 1) && (span > NUM_SPANS)) {
8672 + return RESULT_SUCCESS;
8675 + for (x=0; x < NUM_SPANS; x++) {
8676 + ast_mutex_lock(&pris[x].lock);
8678 + if (pris[x].span == span) {
8679 + if (pris[x].debugfd >= 0)
8680 + close(pris[x].debugfd);
8681 + pris[x].debugfd = -1;
8682 + for (d=0; d < NUM_DCHANS; d++) {
8683 + if (pris[x].dchans[d])
8684 + pri_set_debug_fd(pris[x].dchans[d], -1);
8687 + ast_mutex_unlock(&pris[x].lock);
8690 + ast_cli(fd, "PRI debug output to file for span %d disabled\n", span);
8693 return RESULT_SUCCESS;
8694 @@ -9260,6 +10661,7 @@
8699 static int handle_pri_no_debug(int fd, int argc, char *argv[])
8702 @@ -9366,36 +10768,6 @@
8703 return RESULT_SUCCESS;
8706 -static int handle_pri_show_debug(int fd, int argc, char *argv[])
8713 - for(span=0;span<NUM_SPANS;span++) {
8714 - if (pris[span].pri) {
8715 - for(x=0;x<NUM_DCHANS;x++) {
8717 - if (pris[span].dchans[x]) {
8718 - debug = pri_get_debug(pris[span].dchans[x]);
8719 - ast_cli(fd, "Span %d: Debug: %s\tIntense: %s\n", span+1, (debug&PRI_DEBUG_Q931_STATE)? "Yes" : "No" ,(debug&PRI_DEBUG_Q921_RAW)? "Yes" : "No" );
8726 - ast_mutex_lock(&pridebugfdlock);
8727 - if (pridebugfd >= 0)
8728 - ast_cli(fd, "Logging PRI debug to file %s\n", pridebugfilename);
8729 - ast_mutex_unlock(&pridebugfdlock);
8732 - ast_cli(fd, "No debug set or no PRI running\n");
8733 - return RESULT_SUCCESS;
8736 static char pri_debug_help[] =
8737 "Usage: pri debug span <span>\n"
8738 " Enables debugging on a given PRI span\n";
8739 @@ -9412,6 +10784,18 @@
8740 "Usage: pri show span <span>\n"
8741 " Displays PRI Information\n";
8743 +static char bri_debug_help[] =
8744 + "Usage: bri debug span <span>\n"
8745 + " Enables debugging on a given BRI span\n";
8747 +static char bri_no_debug_help[] =
8748 + "Usage: bri no debug span <span>\n"
8749 + " Disables debugging on a given BRI span\n";
8751 +static char bri_really_debug_help[] =
8752 + "Usage: bri intensive debug span <span>\n"
8753 + " Enables debugging down to the Q.921 level\n";
8755 static struct ast_cli_entry zap_pri_cli[] = {
8756 { { "pri", "debug", "span", NULL }, handle_pri_debug,
8757 "Enables PRI debugging on a span", pri_debug_help, complete_span_4 },
8758 @@ -9419,19 +10803,207 @@
8759 "Disables PRI debugging on a span", pri_no_debug_help, complete_span_5 },
8760 { { "pri", "intense", "debug", "span", NULL }, handle_pri_really_debug,
8761 "Enables REALLY INTENSE PRI debugging", pri_really_debug_help, complete_span_5 },
8762 + { { "bri", "debug", "span", NULL }, handle_pri_debug,
8763 + "Enables BRI debugging on a span", bri_debug_help, complete_span_4 },
8764 + { { "bri", "no", "debug", "span", NULL }, handle_pri_no_debug,
8765 + "Disables BRI debugging on a span", bri_no_debug_help, complete_span_5 },
8766 + { { "bri", "intense", "debug", "span", NULL }, handle_pri_really_debug,
8767 + "Enables REALLY INTENSE BRI debugging", bri_really_debug_help, complete_span_5 },
8768 { { "pri", "show", "span", NULL }, handle_pri_show_span,
8769 "Displays PRI Information", pri_show_span_help, complete_span_4 },
8770 - { { "pri", "show", "debug", NULL }, handle_pri_show_debug,
8771 - "Displays current PRI debug settings" },
8772 { { "pri", "set", "debug", "file", NULL }, handle_pri_set_debug_file,
8773 "Sends PRI debug output to the specified file" },
8774 - { { "pri", "unset", "debug", "file", NULL }, handle_pri_set_debug_file,
8775 + { { "pri", "unset", "debug", "file", "span", NULL }, handle_pri_set_debug_file,
8776 "Ends PRI debug output to file" },
8779 +static int app_zapCD(struct ast_channel *chan, void *data)
8781 + struct zt_pvt *p = chan->tech_pvt;
8784 + ast_log(LOG_WARNING, "zapCD wants a number to deflect to\n");
8787 + return pri_deflect(p->pri->pri, p->call, data);
8790 +static char *zapCD_tdesc = "Call Deflection";
8791 +static char *zapCD_app = "zapCD";
8792 +static char *zapCD_synopsis = "Call Deflection";
8793 #endif /* ZAPATA_PRI */
8798 +static char gsm_send_pdu_help[] =
8799 + "Usage: gsm send pdu <channel> <length> <pdu>\n"
8800 + " Sends a PDU on a GSM channel\n";
8803 +static int handle_gsm_send_pdu(int fd, int argc, char *argv[])
8805 +/* gsm send sms <channel> <destination> <message> */
8808 + struct zt_pvt *pvt = NULL;
8810 + return RESULT_SHOWUSAGE;
8812 + channel = atoi(argv[3]);
8813 + if (channel < 1) {
8814 + ast_cli(fd, "Invalid channel %s. Should be a number.\n", argv[3]);
8815 + return RESULT_SUCCESS;
8817 + len = atoi(argv[4]);
8819 + ast_cli(fd, "Invalid length %s. Should be a number.\n", argv[4]);
8820 + return RESULT_SUCCESS;
8824 + if (pvt->channel == channel) {
8826 + ast_cli(fd, "Channel in use.\n");
8827 + return RESULT_FAILURE;
8829 + ast_mutex_lock(&pvt->lock);
8830 + gsm_sms_send_pdu(pvt->gsm.modul, argv[5], len);
8831 + ast_mutex_unlock(&pvt->lock);
8832 + return RESULT_SUCCESS;
8838 + return RESULT_SUCCESS;
8841 +static struct ast_cli_entry gsm_send_pdu = {
8842 + { "gsm", "send", "pdu", NULL }, handle_gsm_send_pdu, "Sends a SM on a GSM channel", gsm_send_pdu_help, complete_span_4 };
8845 +static char gsm_send_sms_help[] =
8846 + "Usage: gsm send sms <channel> <destination> <message>\n"
8847 + " Sends a SM on a GSM channel\n";
8850 +static int handle_gsm_send_sms(int fd, int argc, char *argv[])
8852 +/* gsm send sms <channel> <destination> <message> */
8854 + struct zt_pvt *pvt = NULL;
8856 + return RESULT_SHOWUSAGE;
8858 + channel = atoi(argv[3]);
8859 + if (channel < 1) {
8860 + ast_cli(fd, "Invalid channel %s. Should be a number.\n", argv[3]);
8861 + return RESULT_SUCCESS;
8865 + if (pvt->channel == channel) {
8867 + ast_cli(fd, "Channel in use.\n");
8868 + return RESULT_FAILURE;
8870 + ast_mutex_lock(&pvt->lock);
8871 + gsm_sms_send_text(pvt->gsm.modul, argv[4], argv[5]);
8872 + ast_mutex_unlock(&pvt->lock);
8873 + return RESULT_SUCCESS;
8879 + return RESULT_SUCCESS;
8882 +static struct ast_cli_entry gsm_send_sms = {
8883 + { "gsm", "send", "sms", NULL }, handle_gsm_send_sms, "Sends a SM on a GSM channel", gsm_send_sms_help, complete_span_4 };
8885 +static char gsm_show_status_help[] =
8886 + "Usage: gsm show status <channel>>\n"
8887 + " Displays status information about the GSM channel.\n";
8890 +static int handle_gsm_show_status(int fd, int argc, char *argv[])
8893 + struct zt_pvt *pvt = NULL;
8895 + return RESULT_SHOWUSAGE;
8897 + channel = atoi(argv[3]);
8898 + if (channel < 1) {
8899 + ast_cli(fd, "Invalid channel %s. Should be a number.\n", argv[3]);
8900 + return RESULT_SUCCESS;
8904 + if (pvt->channel == channel) {
8906 + ast_cli(fd, "Channel in use.\n");
8907 + return RESULT_FAILURE;
8909 + ast_mutex_lock(&pvt->lock);
8910 + gsm_request_status(pvt->gsm.modul);
8911 + ast_mutex_unlock(&pvt->lock);
8912 + return RESULT_SUCCESS;
8918 + return RESULT_SUCCESS;
8921 +static struct ast_cli_entry gsm_show_status = {
8922 + { "gsm", "show", "status", NULL }, handle_gsm_show_status, "Displays status information about the GSM channel.", gsm_show_status_help, complete_span_4 };
8924 +#endif /* ZAPATA_GSM */
8926 +static int app_zapEC(struct ast_channel *chan, void *data)
8929 + struct zt_pvt *p = NULL;
8932 + ast_log(LOG_WARNING, "zapEC requires one argument (on | off)\n");
8934 + if (chan && !strcasecmp("ZAP",chan->type)) {
8935 + p = chan->tech_pvt;
8936 + if (!p) return res;
8937 + if (!strcasecmp("on",(char *)data)) {
8940 + if (option_verbose > 3) {
8941 + ast_verbose(VERBOSE_PREFIX_3 "Enabled echo cancelation on channel %s.\n", chan->name);
8943 + } else if (!strcasecmp("off",(char *)data)) {
8946 + if (option_verbose > 3) {
8947 + ast_verbose(VERBOSE_PREFIX_3 "Disabled echo cancelation on channel %s.\n", chan->name);
8950 + ast_log(LOG_WARNING, "Unknown argument %s to zapEC\n", (char *)data);
8953 + ast_log(LOG_WARNING, "zapNoEC only works on ZAP channels, check your extensions.conf!\n");
8960 +static char *zapEC_tdesc = "Enable/disable Echo cancelation";
8961 +static char *zapEC_app = "zapEC";
8962 +static char *zapEC_synopsis = "Enable/Disable Echo Cancelation on a Zap channel";
8967 static int handle_r2_no_debug(int fd, int argc, char *argv[])
8969 @@ -10044,6 +11616,11 @@
8971 ast_cli_unregister_multiple(zap_pri_cli, sizeof(zap_pri_cli) / sizeof(zap_pri_cli[0]));
8974 + ast_cli_unregister(&gsm_send_sms);
8975 + ast_cli_unregister(&gsm_send_pdu);
8976 + ast_cli_unregister(&gsm_show_status);
8979 ast_cli_unregister_multiple(zap_r2_cli, sizeof(zap_r2_cli) / sizeof(zap_r2_cli[0]));
8981 @@ -10054,6 +11631,7 @@
8982 ast_manager_unregister( "ZapDNDoff" );
8983 ast_manager_unregister( "ZapDNDon" );
8984 ast_manager_unregister("ZapShowChannels");
8985 + ast_unregister_application(zapEC_app);
8986 ast_channel_unregister(&zap_tech);
8987 if (!ast_mutex_lock(&iflock)) {
8988 /* Hangup all interfaces if they have an owner */
8989 @@ -10412,8 +11990,8 @@
8991 } else if (!strcasecmp(v->name, "echotraining")) {
8992 if (sscanf(v->value, "%d", &y) == 1) {
8993 - if ((y < 10) || (y > 4000)) {
8994 - ast_log(LOG_WARNING, "Echo training time must be within the range of 10 to 2000 ms at line %d\n", v->lineno);
8995 + if ((y < 10) || (y > 1000)) {
8996 + ast_log(LOG_WARNING, "Echo training time must be within the range of 10 to 1000 ms at line %d\n", v->lineno);
9000 @@ -10599,12 +12177,33 @@
9001 cur_signalling = SIG_GR303FXSKS;
9004 + } else if (!strcasecmp(v->value, "bri_net_ptmp")) {
9006 + cur_signalling = SIG_PRI;
9007 + pritype = BRI_NETWORK_PTMP;
9008 + } else if (!strcasecmp(v->value, "bri_cpe_ptmp")) {
9009 + cur_signalling = SIG_PRI;
9011 + pritype = BRI_CPE_PTMP;
9012 + } else if (!strcasecmp(v->value, "bri_net")) {
9014 + cur_signalling = SIG_PRI;
9015 + pritype = BRI_NETWORK;
9016 + } else if (!strcasecmp(v->value, "bri_cpe")) {
9017 + cur_signalling = SIG_PRI;
9019 + pritype = BRI_CPE;
9022 } else if (!strcasecmp(v->value, "r2")) {
9023 cur_signalling = SIG_R2;
9027 + } else if (!strcasecmp(v->value, "gsm")) {
9028 + cur_signalling = SIG_GSM;
9032 ast_log(LOG_ERROR, "Unknown signalling method '%s'\n", v->value);
9034 @@ -10687,8 +12286,20 @@
9035 priindication_oob = 1;
9036 else if (!strcasecmp(v->value, "inband"))
9037 priindication_oob = 0;
9038 + else if (!strcasecmp(v->value, "passthrough"))
9039 + priindication_oob = 2;
9041 - ast_log(LOG_WARNING, "'%s' is not a valid pri indication value, should be 'inband' or 'outofband' at line %d\n",
9042 + ast_log(LOG_WARNING, "'%s' is not a valid pri indication value, should be 'inband' , 'outofband' or 'passthrough' at line %d\n",
9043 + v->value, v->lineno);
9044 + } else if (!strcasecmp(v->name, "pritransfer")) {
9045 + if (!strcasecmp(v->value, "no"))
9047 + else if (!strcasecmp(v->value, "ect"))
9049 + else if (!strcasecmp(v->value, "hangup"))
9052 + ast_log(LOG_WARNING, "'%s' is not a valid pri transfer value, should be 'no' , 'ect' or 'hangup' at line %d\n",
9053 v->value, v->lineno);
9054 } else if (!strcasecmp(v->name, "priexclusive")) {
9055 cur_priexclusive = ast_true(v->value);
9056 @@ -10702,6 +12313,14 @@
9057 ast_copy_string(privateprefix, v->value, sizeof(privateprefix));
9058 } else if (!strcasecmp(v->name, "unknownprefix")) {
9059 ast_copy_string(unknownprefix, v->value, sizeof(unknownprefix));
9060 + } else if (!strcasecmp(v->name, "nocid")) {
9061 + ast_copy_string(nocid, v->value, sizeof(nocid) - 1);
9062 + } else if (!strcasecmp(v->name, "withheldcid")) {
9063 + ast_copy_string(withheldcid, v->value, sizeof(withheldcid) - 1);
9064 + } else if (!strcasecmp(v->name, "pin")) {
9065 + ast_copy_string(gsm_modem_pin, v->value, sizeof(gsm_modem_pin) - 1);
9066 + } else if (!strcasecmp(v->name, "exten")) {
9067 + ast_copy_string(gsm_modem_exten, v->value, sizeof(gsm_modem_exten) - 1);
9068 } else if (!strcasecmp(v->name, "resetinterval")) {
9069 if (!strcasecmp(v->value, "never"))
9071 @@ -10716,6 +12335,8 @@
9072 ast_copy_string(idleext, v->value, sizeof(idleext));
9073 } else if (!strcasecmp(v->name, "idledial")) {
9074 ast_copy_string(idledial, v->value, sizeof(idledial));
9075 + } else if (!strcasecmp(v->name, "pritrustusercid")) {
9076 + usercid = ast_true(v->value);
9077 } else if (!strcasecmp(v->name, "overlapdial")) {
9078 overlapdial = ast_true(v->value);
9079 } else if (!strcasecmp(v->name, "pritimer")) {
9080 @@ -10901,6 +12522,7 @@
9083 for (x=0;x<NUM_SPANS;x++) {
9084 + pris[x].debugfd = -1;
9085 if (pris[x].pvts[0]) {
9086 if (start_pri(pris + x)) {
9087 ast_log(LOG_ERROR, "Unable to start D-channel on span %d\n", x + 1);
9088 @@ -10933,6 +12555,10 @@
9089 pri_set_error(zt_pri_error);
9090 pri_set_message(zt_pri_message);
9093 + gsm_set_error(zt_gsm_error);
9094 + gsm_set_message(zt_gsm_message);
9097 /* Make sure we can register our Zap channel type */
9099 @@ -10950,6 +12576,11 @@
9100 ast_cli_register_multiple(zap_r2_cli, sizeof(zap_r2_cli) / sizeof(zap_r2_cli[0]));
9102 ast_cli_register_multiple(zap_cli, sizeof(zap_cli) / sizeof(zap_cli[0]));
9104 + ast_cli_register(&gsm_send_sms);
9105 + ast_cli_register(&gsm_send_pdu);
9106 + ast_cli_register(&gsm_show_status);
9109 memset(round_robin, 0, sizeof(round_robin));
9110 ast_manager_register( "ZapTransfer", 0, action_transfer, "Transfer Zap Channel" );
9111 @@ -10958,11 +12589,46 @@
9112 ast_manager_register( "ZapDNDon", 0, action_zapdndon, "Toggle Zap channel Do Not Disturb status ON" );
9113 ast_manager_register( "ZapDNDoff", 0, action_zapdndoff, "Toggle Zap channel Do Not Disturb status OFF" );
9114 ast_manager_register("ZapShowChannels", 0, action_zapshowchannels, "Show status zapata channels");
9116 + ast_register_application(zapEC_app, app_zapEC, zapEC_synopsis, zapEC_tdesc);
9118 + ast_register_application(zapCD_app, app_zapCD, zapCD_synopsis, zapCD_tdesc);
9124 +static int zt_tdd_sendtext(struct ast_channel *c, const char *text);
9126 +static int zt_pri_sendtext(struct ast_channel *c, const char *text) {
9127 + struct zt_pvt *p = c->tech_pvt;
9128 + if (!p) return -1;
9129 + if (!p->pri) return -1;
9130 + if (strlen(text)) {
9132 + if (!pri_grab(p, p->pri)) {
9133 + // ast_log(LOG_NOTICE, "Sending Display IE '%s'\n", text);
9134 + pri_information_display(p->pri->pri,p->call,(char *)text);
9136 + } else ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->span);
9142 +static int zt_sendtext(struct ast_channel *c, const char *text) {
9143 + struct zt_pvt *p = c->tech_pvt;
9144 + if (!p) return -1;
9145 + if (p->sig == SIG_PRI) {
9146 + return zt_pri_sendtext(c, text);
9148 + return zt_tdd_sendtext(c, text);
9152 +static int zt_tdd_sendtext(struct ast_channel *c, const char *text)
9154 static int zt_sendtext(struct ast_channel *c, const char *text)
9157 #define END_SILENCE_LEN 400
9158 #define HEADER_MS 50
9159 @@ -10981,6 +12647,7 @@
9164 index = zt_get_index(c, p, 0);
9166 ast_log(LOG_WARNING, "Huh? I don't exist?\n");
9167 diff -urN asterisk-1.2.7.1.orig/codecs/codec_ilbc.c asterisk-1.2.7.1/codecs/codec_ilbc.c
9168 --- asterisk-1.2.7.1.orig/codecs/codec_ilbc.c 2005-11-29 19:24:39.000000000 +0100
9169 +++ asterisk-1.2.7.1/codecs/codec_ilbc.c 2006-04-18 14:39:28.000000000 +0200
9171 #include "slin_ilbc_ex.h"
9172 #include "ilbc_slin_ex.h"
9174 -#define USE_ILBC_ENHANCER 0
9175 +#define USE_ILBC_ENHANCER 1
9177 /* #define ILBC_MS 20 */
9179 diff -urN asterisk-1.2.7.1.orig/configs/capi.conf.sample asterisk-1.2.7.1/configs/capi.conf.sample
9180 --- asterisk-1.2.7.1.orig/configs/capi.conf.sample 1970-01-01 01:00:00.000000000 +0100
9181 +++ asterisk-1.2.7.1/configs/capi.conf.sample 2006-04-18 14:39:28.000000000 +0200
9189 +internationalprefix=00
9195 +; mode: ptmp (point-to-multipoint) or ptp (point-to-point)
9197 +; allow incoming calls to this list of MSNs, * == any
9199 +; capi controller number
9203 +; enable/disable software dtmf detection, recommended for AVM cards
9205 +; accountcode to use in CDRs
9207 +; context for incoming calls
9209 +; _VERY_PRIMITIVE_ echo suppression
9211 +; EICON DIVA SERVER echo cancelation
9216 +; deflect incoming calls to 12345678 if all B channels are busy
9218 +; number of concurrent calls on this controller (2 makes sense for single BRI)
9222 +;PointToPoint (55512-0)
9227 diff -urN asterisk-1.2.7.1.orig/configs/modules.conf.sample asterisk-1.2.7.1/configs/modules.conf.sample
9228 --- asterisk-1.2.7.1.orig/configs/modules.conf.sample 2005-11-29 19:24:39.000000000 +0100
9229 +++ asterisk-1.2.7.1/configs/modules.conf.sample 2006-04-18 14:39:28.000000000 +0200
9231 ; exported to modules loaded after them.
9235 diff -urN asterisk-1.2.7.1.orig/configs/watchdog.conf.sample asterisk-1.2.7.1/configs/watchdog.conf.sample
9236 --- asterisk-1.2.7.1.orig/configs/watchdog.conf.sample 1970-01-01 01:00:00.000000000 +0100
9237 +++ asterisk-1.2.7.1/configs/watchdog.conf.sample 2006-04-18 14:39:28.000000000 +0200
9240 +; Configuration file for res_watchdog
9242 +; type = isdnguard | watchdog
9243 +; device = /dev/...
9244 +; interval = interval to trigger the watchdog in ms
9246 +;[ISDNguard-direct]
9248 +;device = /dev/ttyS0
9251 +;[ISDNguard-with-daemon]
9253 +;device = /var/run/guard.ctl
9258 +;device = /dev/watchdog
9261 diff -urN asterisk-1.2.7.1.orig/configs/zapata.conf.sample asterisk-1.2.7.1/configs/zapata.conf.sample
9262 --- asterisk-1.2.7.1.orig/configs/zapata.conf.sample 2006-03-06 03:32:35.000000000 +0100
9263 +++ asterisk-1.2.7.1/configs/zapata.conf.sample 2006-04-18 14:39:28.000000000 +0200
9264 @@ -121,9 +121,20 @@
9266 ; outofband: Signal Busy/Congestion out of band with RELEASE/DISCONNECT
9267 ; inband: Signal Busy/Congestion using in-band tones
9268 +; passthrough: Listen to the telco
9270 ; priindication = outofband
9272 +; PRI/BRI transfers (HOLD -> SETUP -> ECT/Hangup)
9274 +; Configure how transfers are initiated. ECT should be preferred
9276 +; no: no transfers allowed (results in hangup)
9277 +; ect: use ECT (facility)
9278 +: hangup: transfer on hangup (if your phones dont support ECT)
9280 +; pritransfer = ect
9282 ; If you need to override the existing channels selection routine and force all
9283 ; PRI channels to be marked as exclusively selected, set this to yes.
9284 ; priexclusive = yes
9285 diff -urN asterisk-1.2.7.1.orig/db.c asterisk-1.2.7.1/db.c
9286 --- asterisk-1.2.7.1.orig/db.c 2006-01-09 19:09:53.000000000 +0100
9287 +++ asterisk-1.2.7.1/db.c 2006-04-18 14:39:28.000000000 +0200
9288 @@ -516,11 +516,18 @@
9289 struct ast_cli_entry cli_database_deltree =
9290 { { "database", "deltree", NULL }, database_deltree, "Removes database keytree/values", database_deltree_usage };
9292 +static char mandescr_dbput[] =
9293 +"Description: Put a value into astdb\n"
9299 static int manager_dbput(struct mansession *s, struct message *m)
9301 char *family = astman_get_header(m, "Family");
9302 char *key = astman_get_header(m, "Key");
9303 - char *val = astman_get_header(m, "Val");
9304 + char *val = astman_get_header(m, "Value");
9307 if (!strlen(family)) {
9308 @@ -545,6 +552,12 @@
9312 +static char mandescr_dbget[] =
9313 +"Description: Get a value from astdb\n"
9318 static int manager_dbget(struct mansession *s, struct message *m)
9320 char *id = astman_get_header(m,"ActionID");
9322 ast_cli(s->fd, "Event: DBGetResponse\r\n"
9329 family, key, tmp, idText);
9330 @@ -582,6 +595,39 @@
9334 +static char mandescr_dbdel[] =
9335 +"Description: remove value from astdb\n"
9340 +static int manager_dbdel(struct mansession *s, struct message *m)
9342 + char *family = astman_get_header(m, "Family");
9343 + char *key = astman_get_header(m, "Key");
9344 + char *id = astman_get_header(m,"ActionID");
9346 + if (!strlen(family)) {
9347 + astman_send_error(s, m, "No family specified");
9350 + if (!strlen(key)) {
9351 + astman_send_error(s, m, "No key specified");
9355 + if (ast_db_del(family, key)) {
9356 + ast_cli(s->fd, "Response: Failed\r\n");
9358 + ast_cli(s->fd, "Response: Success\r\n");
9360 + if (id && !ast_strlen_zero(id))
9361 + ast_cli(s->fd, "ActionID: %s\r\n",id);
9362 + ast_cli(s->fd, "\r\n");
9367 int astdb_init(void)
9371 ast_cli_register(&cli_database_put);
9372 ast_cli_register(&cli_database_del);
9373 ast_cli_register(&cli_database_deltree);
9374 - ast_manager_register("DBGet", EVENT_FLAG_SYSTEM, manager_dbget, "Get DB Entry");
9375 - ast_manager_register("DBPut", EVENT_FLAG_SYSTEM, manager_dbput, "Put DB Entry");
9376 + ast_manager_register("DBget", EVENT_FLAG_SYSTEM, manager_dbget, mandescr_dbget);
9377 + ast_manager_register("DBput", EVENT_FLAG_SYSTEM, manager_dbput, mandescr_dbput);
9378 + ast_manager_register("DBdel", EVENT_FLAG_SYSTEM, manager_dbdel, mandescr_dbdel);
9381 diff -urN asterisk-1.2.7.1.orig/devicestate.c asterisk-1.2.7.1/devicestate.c
9382 --- asterisk-1.2.7.1.orig/devicestate.c 2006-02-10 21:38:59.000000000 +0100
9383 +++ asterisk-1.2.7.1/devicestate.c 2006-04-18 14:39:28.000000000 +0200
9386 struct state_change {
9387 AST_LIST_ENTRY(state_change) list;
9388 + char cid_num[AST_MAX_EXTENSION];
9389 + char cid_name[AST_MAX_EXTENSION];
9396 /*--- do_state_change: Notify callback watchers of change, and notify PBX core for hint updates */
9397 -static void do_state_change(const char *device)
9398 +static void do_state_change(const char *device, char *cid_num, char *cid_name)
9401 struct devstate_cb *devcb;
9402 @@ -188,13 +190,13 @@
9404 AST_LIST_LOCK(&devstate_cbs);
9405 AST_LIST_TRAVERSE(&devstate_cbs, devcb, list)
9406 - devcb->callback(device, state, devcb->data);
9407 + devcb->callback(device, state, devcb->data, cid_num, cid_name);
9408 AST_LIST_UNLOCK(&devstate_cbs);
9410 - ast_hint_state_changed(device);
9411 + ast_hint_state_changed(device, cid_num, cid_name);
9414 -static int __ast_device_state_changed_literal(char *buf)
9415 +static int __ast_device_state_changed_literal(char *buf, char *cid_num, char *cid_name)
9418 struct state_change *change = NULL;
9419 @@ -209,10 +211,16 @@
9421 /* we could not allocate a change struct, or */
9422 /* there is no background thread, so process the change now */
9423 - do_state_change(device);
9424 + do_state_change(device, cid_num, cid_name);
9426 /* queue the change */
9427 strcpy(change->device, device);
9428 + if (cid_num && (!ast_strlen_zero(cid_num))) {
9429 + strncpy(change->cid_num, cid_num, sizeof(change->cid_num) - 1);
9431 + if (cid_name && (!ast_strlen_zero(cid_name))) {
9432 + strncpy(change->cid_name, cid_name, sizeof(change->cid_name) - 1);
9434 AST_LIST_LOCK(&state_changes);
9435 AST_LIST_INSERT_TAIL(&state_changes, change, list);
9436 if (AST_LIST_FIRST(&state_changes) == change)
9437 @@ -224,23 +232,49 @@
9441 -int ast_device_state_changed_literal(const char *dev)
9442 +int ast_device_state_changed_literal(const char *dev, const char *cid_num, const char *cid_name)
9445 + char *buf2 = NULL;
9446 + char *buf3 = NULL;
9447 buf = ast_strdupa(dev);
9448 - return __ast_device_state_changed_literal(buf);
9450 + buf2 = ast_strdupa(cid_num);
9452 + buf3 = ast_strdupa(cid_name);
9453 + return __ast_device_state_changed_literal(buf, buf2, buf3);
9456 /*--- ast_device_state_changed: Accept change notification, add it to change queue */
9457 int ast_device_state_changed(const char *fmt, ...)
9459 char buf[AST_MAX_EXTENSION];
9460 + char cid_num[AST_MAX_EXTENSION];
9461 + char cid_name[AST_MAX_EXTENSION];
9466 - vsnprintf(buf, sizeof(buf), fmt, ap);
9467 + if (*fmt == 's') {
9468 + s = va_arg(ap, char *);
9469 + snprintf(buf, sizeof(buf), s);
9471 + if (*fmt == 's') {
9472 + s = va_arg(ap, char *);
9474 + snprintf(cid_num, sizeof(cid_num), s);
9477 + if (*fmt == 's') {
9478 + s = va_arg(ap, char *);
9480 + snprintf(cid_name, sizeof(cid_name), s);
9486 - return __ast_device_state_changed_literal(buf);
9487 + return __ast_device_state_changed_literal(buf, cid_num, cid_name);
9490 /*--- do_devstate_changes: Go through the dev state change queue and update changes in the dev state thread */
9493 /* we got an entry, so unlock the list while we process it */
9494 AST_LIST_UNLOCK(&state_changes);
9495 - do_state_change(cur->device);
9496 + do_state_change(cur->device, cur->cid_num, cur->cid_name);
9498 AST_LIST_LOCK(&state_changes);
9500 diff -urN asterisk-1.2.7.1.orig/doc/README.asterisk.conf asterisk-1.2.7.1/doc/README.asterisk.conf
9501 --- asterisk-1.2.7.1.orig/doc/README.asterisk.conf 2005-11-29 19:24:39.000000000 +0100
9502 +++ asterisk-1.2.7.1/doc/README.asterisk.conf 2006-04-18 14:39:28.000000000 +0200
9504 maxcalls = 255 ; The maximum number of concurrent calls you want to allow
9505 execincludes = yes | no ; Allow #exec entries in configuration files
9506 dontwarn = yes | no ; Don't over-inform the Asterisk sysadm, he's a guru
9507 +uniquename = asterisk ; host name part to be included in the uniqueid
9510 ; Changing the following lines may compromise your security
9511 diff -urN asterisk-1.2.7.1.orig/editline/cygdef.h asterisk-1.2.7.1/editline/cygdef.h
9512 --- asterisk-1.2.7.1.orig/editline/cygdef.h 1970-01-01 01:00:00.000000000 +0100
9513 +++ asterisk-1.2.7.1/editline/cygdef.h 2006-04-18 14:39:28.000000000 +0200
9515 +/* cygdef.h. Generated automatically by configure. */
9517 +#define _CYGDEF_H_ 1
9518 +#include <sys/ioctl.h>
9519 +#define __linux__ 1
9522 +typedef void (*sig_t)(int);
9525 +#endif /* _CYGDEF_H_ */
9526 diff -urN asterisk-1.2.7.1.orig/include/asterisk/agi.h asterisk-1.2.7.1/include/asterisk/agi.h
9527 --- asterisk-1.2.7.1.orig/include/asterisk/agi.h 2005-11-29 19:24:39.000000000 +0100
9528 +++ asterisk-1.2.7.1/include/asterisk/agi.h 2006-04-18 14:39:28.000000000 +0200
9531 typedef struct agi_state {
9532 int fd; /* FD for general output */
9533 - int audio; /* FD for audio output */
9534 + int audio_out; /* FD for audio output */
9535 + int audio_in; /* FD for audio output */
9536 int ctrl; /* FD for input control */
9539 diff -urN asterisk-1.2.7.1.orig/include/asterisk/chan_capi.h asterisk-1.2.7.1/include/asterisk/chan_capi.h
9540 --- asterisk-1.2.7.1.orig/include/asterisk/chan_capi.h 1970-01-01 01:00:00.000000000 +0100
9541 +++ asterisk-1.2.7.1/include/asterisk/chan_capi.h 2006-04-18 14:39:28.000000000 +0200
9546 + * An implementation of Common ISDN API 2.0 for Asterisk
9548 + * Copyright (C) 2002, 2003, 2004, Junghanns.NET GmbH
9550 + * Klaus-Peter Junghanns <kapejod@ns1.jnetdns.de>
9552 + * This program is free software and may be modified and
9553 + * distributed under the terms of the GNU Public License.
9556 +#ifndef _ASTERISK_CAPI_H
9557 +#define _ASTERISK_CAPI_H
9559 +#define AST_CAPI_MAX_CONTROLLERS 16
9560 +#define AST_CAPI_MAX_DEVICES 30
9561 +#define AST_CAPI_MAX_BUF 160
9563 +#define AST_CAPI_MAX_B3_BLOCKS 7
9565 +/* was : 130 bytes Alaw = 16.25 ms audio not suitable for VoIP */
9566 +/* now : 160 bytes Alaw = 20 ms audio */
9567 +/* you can tune this to your need. higher value == more latency */
9568 +#define AST_CAPI_MAX_B3_BLOCK_SIZE 160
9570 +#define AST_CAPI_BCHANS 120
9571 +#define ALL_SERVICES 0x1FFF03FF
9573 +/* duration in ms for sending and detecting dtmfs */
9574 +#define AST_CAPI_DTMF_DURATION 0x40
9576 +#define AST_CAPI_NATIONAL_PREF "0"
9577 +#define AST_CAPI_INTERNAT_PREF "00"
9580 +#define ECHO_TX_COUNT 5 // 5 x 20ms = 100ms
9581 +#define ECHO_EFFECTIVE_TX_COUNT 3 // 2 x 20ms = 40ms == 40-100ms ... ignore first 40ms
9582 +#define ECHO_TXRX_RATIO 2.3 // if( rx < (txavg/ECHO_TXRX_RATIO) ) rx=0;
9586 + * state combination for a normal incoming call:
9587 + * DIS -> ALERT -> CON -> BCON -> CON -> DIS
9590 + * DIS -> CONP -> BCONNECTED -> CON -> DIS
9593 +#define CAPI_STATE_ALERTING 1
9594 +#define CAPI_STATE_CONNECTED 2
9595 +#define CAPI_STATE_BCONNECTED 3
9597 +#define CAPI_STATE_DISCONNECTING 4
9598 +#define CAPI_STATE_DISCONNECTED 5
9599 +#define CAPI_STATE_REMOTE_HANGUP 6
9601 +#define CAPI_STATE_CONNECTPENDING 7
9602 +#define CAPI_STATE_ONHOLD 8
9603 +#define CAPI_STATE_NETWORKHANGUP 9
9604 +#define CAPI_STATE_ANSWERING 10
9605 +#define CAPI_STATE_PUTTINGONHOLD 11
9606 +#define CAPI_STATE_RETRIEVING 12
9608 +#define CAPI_STATE_DID 13
9610 +#define AST_CAPI_B3_DONT 0
9611 +#define AST_CAPI_B3_ALWAYS 1
9612 +#define AST_CAPI_B3_ON_SUCCESS 2
9615 +struct ast_capi_gains {
9616 + unsigned char txgains[256];
9617 + unsigned char rxgains[256];
9621 +#define PRES_ALLOWED_USER_NUMBER_NOT_SCREENED 0x00
9622 +#define PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN 0x01
9623 +#define PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN 0x02
9624 +#define PRES_ALLOWED_NETWORK_NUMBER 0x03
9625 +#define PRES_PROHIB_USER_NUMBER_NOT_SCREENED 0x20
9626 +#define PRES_PROHIB_USER_NUMBER_PASSED_SCREEN 0x21
9627 +#define PRES_PROHIB_USER_NUMBER_FAILED_SCREEN 0x22
9628 +#define PRES_PROHIB_NETWORK_NUMBER 0x23
9629 +#define PRES_NUMBER_NOT_AVAILABLE 0x43
9632 +//! Private data for a capi device
9633 +struct ast_capi_pvt {
9637 + /*! Channel we belong to, possibly NULL */
9638 + struct ast_channel *owner;
9640 + struct ast_frame fr;
9642 + char offset[AST_FRIENDLY_OFFSET];
9644 + // capi message number
9645 + _cword MessageNumber;
9648 + /* on which controller we do live */
9651 + /* we could live on those */
9652 + unsigned long controllers;
9656 + short buf[AST_CAPI_MAX_BUF];
9658 + /*! Immediate, or wait for an answer */
9660 + /*! State of modem in miniature */
9662 + /*! Digits to strip on outgoing numbers */
9664 + /*! ringer timeout */
9666 + /*! actual time of last ring */
9668 + /*! dtmf receive state/data */
9671 + char context[AST_MAX_EXTENSION];
9672 + /*! Multiple Subscriber Number we listen to (, seperated list) */
9673 + char incomingmsn[AST_MAX_EXTENSION];
9674 + /*! Prefix to Build CID */
9675 + char prefix[AST_MAX_EXTENSION];
9676 + /*! Caller ID if available */
9677 + char cid[AST_MAX_EXTENSION];
9678 + /*! Dialed Number if available */
9679 + char dnid[AST_MAX_EXTENSION];
9681 + char accountcode[20];
9683 + unsigned int callgroup;
9684 + unsigned int group;
9686 + /*! default language */
9687 + char language[MAX_LANGUAGE];
9688 + /*! Static response buffer */
9689 + char response[256];
9691 + int calledPartyIsISDN;
9692 + // this is an outgoing channel
9696 + // are we doing early B3 connect on this interface?
9698 + // should we do early B3 on this interface?
9700 + // store plci here for the call that is onhold
9702 + // do software dtmf detection
9704 + // CAPI echo cancellation
9708 + // isdnmode ptp or ptm
9710 +#ifdef CAPI_DEFLECT_ON_CIRCUITBUSY
9711 + // deflect on circuitbusy
9712 + char deflect2[AST_MAX_EXTENSION];
9715 + // not all codecs supply frames in nice 320 byte chunks
9716 + struct ast_smoother *smoother;
9717 + // ok, we stop to be nice and give them the lowest possible latency 130 samples * 2 = 260 bytes */
9720 + ast_mutex_t lockB3in;
9723 + // do ECHO SURPRESSION
9726 + short txavg[ECHO_TX_COUNT];
9731 + struct ast_capi_gains g;
9735 + struct ast_dsp *vad;
9738 + struct capi_pipe *mypipe;
9739 + /*! Next channel in list */
9740 + struct ast_capi_pvt *next;
9744 +struct ast_capi_profile {
9745 + unsigned short ncontrollers;
9746 + unsigned short nbchannels;
9747 + unsigned char globaloptions;
9748 + unsigned char globaloptions2;
9749 + unsigned char globaloptions3;
9750 + unsigned char globaloptions4;
9751 + unsigned int b1protocols;
9752 + unsigned int b2protocols;
9753 + unsigned int b3protocols;
9754 + unsigned int reserved3[6];
9755 + unsigned int manufacturer[5];
9762 + // fd for writing to the channel
9765 + // PLCI and NCCI of the B3 CON
9768 + // pointer to the interface
9769 + struct ast_capi_pvt *i;
9770 + // pointer to the channel
9771 + struct ast_channel *c;
9773 + struct capi_pipe *next;
9776 +struct ast_capi_controller {
9777 + // which controller is this?
9779 + // how many bchans?
9782 + int nfreebchannels;
9788 + int sservices; // supplementray services
9789 + // supported sservices:
9791 + int terminalportability;
9804 +// ETSI 300 102-1 information element identifiers
9805 +#define CAPI_ETSI_IE_CAUSE 0x08;
9806 +#define CAPI_ETSI_IE_PROGRESS_INDICATOR 0x1e;
9807 +#define CAPI_ETSI_IE_CALLED_PARTY_NUMBER 0x70;
9809 +// ETIS 300 102-1 message types
9810 +#define CAPI_ETSI_ALERTING 0x01;
9811 +#define CAPI_ETSI_SETUP_ACKKNOWLEDGE 0x0d;
9812 +#define CAPI_ETSI_DISCONNECT 0x45;
9814 +// ETSI 300 102-1 Numbering Plans
9815 +#define CAPI_ETSI_NPLAN_NATIONAL 0x20
9816 +#define CAPI_ETSI_NPLAN_INTERNAT 0x10
9819 diff -urN asterisk-1.2.7.1.orig/include/asterisk/chan_capi_app.h asterisk-1.2.7.1/include/asterisk/chan_capi_app.h
9820 --- asterisk-1.2.7.1.orig/include/asterisk/chan_capi_app.h 1970-01-01 01:00:00.000000000 +0100
9821 +++ asterisk-1.2.7.1/include/asterisk/chan_capi_app.h 2006-04-18 14:39:28.000000000 +0200
9826 + * An implementation of Common ISDN API 2.0 for Asterisk
9828 + * include file for helper applications
9830 + * Copyright (C) 2002, 2003, 2004, Junghanns.NET GmbH
9832 + * Klaus-Peter Junghanns <kapejod@ns1.jnetdns.de>
9834 + * This program is free software and may be modified and
9835 + * distributed under the terms of the GNU Public License.
9838 +#ifndef _ASTERISK_CAPI_IF_H
9839 +#define _ASTERISK_CAPI_IF_H
9841 +// exported symbols from chan_capi
9843 +// important things we need
9844 +extern unsigned ast_capi_ApplID;
9845 +extern unsigned ast_capi_MessageNumber;
9846 +extern int capidebug;
9848 +extern int capi_call(struct ast_channel *c, char *idest, int timeout);
9849 +extern int capi_detect_dtmf(struct ast_channel *c, int flag);
9850 +extern MESSAGE_EXCHANGE_ERROR _capi_put_cmsg(_cmsg *CMSG);
9853 diff -urN asterisk-1.2.7.1.orig/include/asterisk/channel.h asterisk-1.2.7.1/include/asterisk/channel.h
9854 --- asterisk-1.2.7.1.orig/include/asterisk/channel.h 2006-02-11 19:15:00.000000000 +0100
9855 +++ asterisk-1.2.7.1/include/asterisk/channel.h 2006-04-18 14:39:28.000000000 +0200
9857 #ifndef _ASTERISK_CHANNEL_H
9858 #define _ASTERISK_CHANNEL_H
9860 +/* Max length of the uniqueid */
9861 +#define AST_MAX_UNIQUEID 64
9869 /* Unique Channel Identifier */
9870 - char uniqueid[32];
9871 + char uniqueid[AST_MAX_UNIQUEID];
9873 /* Why is the channel hanged up */
9875 @@ -397,6 +400,12 @@
9876 /*! ISDN Transfer Capbility - AST_FLAG_DIGITAL is not enough */
9877 unsigned short transfercapability;
9879 + /*! ISDN Low Layer Compatibility */
9880 + char lowlayercompat[16];
9882 + /*! ISDN High Layer Compatibility */
9883 + char highlayercompat[4];
9885 struct ast_frame *readq;
9887 /*! Write translation path */
9888 @@ -533,6 +542,11 @@
9889 #define AST_STATE_MUTE (1 << 16)
9892 +extern ast_mutex_t uniquelock;
9894 +/*! \brief Change the state of a channel and the callerid of the calling channel*/
9895 +int ast_setstate_and_cid(struct ast_channel *chan, int state, char *cid_num, char *cid_name);
9897 /*! \brief Change the state of a channel */
9898 int ast_setstate(struct ast_channel *chan, int state);
9901 * by the low level module
9902 * \return Returns an ast_channel on success, NULL on failure.
9904 -struct ast_channel *ast_request(const char *type, int format, void *data, int *status);
9905 +struct ast_channel *ast_request(const char *type, int format, void *data, int *status, char *uniqueid);
9908 * \brief Request a channel of a given type, with data as optional information used
9910 * \return Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state
9911 * to know if the call was answered or not.
9913 -struct ast_channel *ast_request_and_dial(const char *type, int format, void *data, int timeout, int *reason, const char *cidnum, const char *cidname);
9914 +struct ast_channel *ast_request_and_dial(const char *type, int format, void *data, int timeout, int *reason, int callingpres, const char *cidnum, const char *cidname, char *uniqueid);
9916 -struct ast_channel *__ast_request_and_dial(const char *type, int format, void *data, int timeout, int *reason, const char *cidnum, const char *cidname, struct outgoing_helper *oh);
9917 +struct ast_channel *__ast_request_and_dial(const char *type, int format, void *data, int timeout, int *reason, int callingpres, const char *cidnum, const char *cidname, struct outgoing_helper *oh, char *uniqueid);
9919 /*!\brief Register a channel technology (a new channel driver)
9920 * Called by a channel module to register the kind of channels it supports.
9921 @@ -839,6 +853,10 @@
9922 /*--- ast_get_channel_by_exten_locked: Get channel by exten (and optionally context) and lock it */
9923 struct ast_channel *ast_get_channel_by_exten_locked(const char *exten, const char *context);
9925 +/*! Get channel by uniqueid (locks channel) */
9926 +struct ast_channel *ast_get_channel_by_uniqueid_locked(const char *uniqueid);
9929 /*! Waits for a digit */
9931 * \param c channel to wait for a digit on
9933 p->owner pointer) that is affected by the change. The physical layer of the original
9934 channel is hung up. */
9935 int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clone);
9936 +int ast_channel_masquerade_locked(struct ast_channel *original, struct ast_channel *clone);
9938 +char *ast_alloc_uniqueid(void);
9940 /*! Gives the string form of a given cause code */
9942 diff -urN asterisk-1.2.7.1.orig/include/asterisk/devicestate.h asterisk-1.2.7.1/include/asterisk/devicestate.h
9943 --- asterisk-1.2.7.1.orig/include/asterisk/devicestate.h 2005-11-29 19:24:39.000000000 +0100
9944 +++ asterisk-1.2.7.1/include/asterisk/devicestate.h 2006-04-18 14:39:28.000000000 +0200
9946 /*! Device is ringing */
9947 #define AST_DEVICE_RINGING 6
9949 -typedef int (*ast_devstate_cb_type)(const char *dev, int state, void *data);
9950 +typedef int (*ast_devstate_cb_type)(const char *dev, int state, void *data, char *cid_num, char *cid_name);
9952 /*! \brief Convert device state to text string for output
9953 * \param devstate Current device state
9955 * callbacks for the changed extensions
9956 * Returns 0 on success, -1 on failure
9958 -int ast_device_state_changed_literal(const char *device);
9959 +int ast_device_state_changed_literal(const char *device, const char *cid_num, const char *cid_name);
9961 /*! \brief Registers a device state change callback
9962 * \param callback Callback
9963 diff -urN asterisk-1.2.7.1.orig/include/asterisk/features.h asterisk-1.2.7.1/include/asterisk/features.h
9964 --- asterisk-1.2.7.1.orig/include/asterisk/features.h 2005-11-29 19:24:39.000000000 +0100
9965 +++ asterisk-1.2.7.1/include/asterisk/features.h 2006-04-18 14:39:28.000000000 +0200
9970 +extern int ast_autoanswer_login(struct ast_channel *chan, void *data);
9971 +extern int ast_masq_autoanswer_login(struct ast_channel *rchan, void *data);
9973 /*! \brief Park a call and read back parked location
9974 * \param chan the channel to actually be parked
9977 extern int ast_masq_park_call(struct ast_channel *rchan, struct ast_channel *host, int timeout, int *extout);
9979 +extern int ast_hold_call(struct ast_channel *chan, struct ast_channel *host);
9980 +extern int ast_masq_hold_call(struct ast_channel *rchan, struct ast_channel *host);
9981 +extern int ast_retrieve_call(struct ast_channel *chan, char *uniqueid);
9982 +extern int ast_retrieve_call_to_death(char *uniqueid);
9983 +extern struct ast_channel *ast_get_holded_call(char *uniqueid);
9985 /*! \brief Determine system parking extension
9986 * Returns the call parking extension for drivers that provide special
9987 call parking help */
9988 extern char *ast_parking_ext(void);
9990 +extern char *ast_parking_con(void);
9992 /*! \brief Determine system call pickup extension */
9993 extern char *ast_pickup_ext(void);
9996 \param feature the ast_call_feature object which was registered before*/
9997 extern void ast_unregister_feature(struct ast_call_feature *feature);
9999 +/*! \brief find a feature by name
10000 + \param name of the feature to be returned */
10001 +extern struct ast_call_feature *ast_find_feature(char *name);
10003 +/*! \brief find a builtin feature by name
10004 + \param name of the feature to be returned */
10005 +extern struct ast_call_feature *ast_find_builtin_feature(char *name);
10007 #endif /* _AST_FEATURES_H */
10008 diff -urN asterisk-1.2.7.1.orig/include/asterisk/pbx.h asterisk-1.2.7.1/include/asterisk/pbx.h
10009 --- asterisk-1.2.7.1.orig/include/asterisk/pbx.h 2006-03-29 21:11:18.000000000 +0200
10010 +++ asterisk-1.2.7.1/include/asterisk/pbx.h 2006-04-18 14:39:28.000000000 +0200
10012 AST_EXTENSION_BUSY = 1 << 1,
10013 /*! All devices UNAVAILABLE/UNREGISTERED */
10014 AST_EXTENSION_UNAVAILABLE = 1 << 2,
10015 - /*! All devices RINGING */
10016 + /*! One or more devices RINGING */
10017 AST_EXTENSION_RINGING = 1 << 3,
10021 struct ast_ignorepat;
10024 -typedef int (*ast_state_cb_type)(char *context, char* id, enum ast_extension_states state, void *data);
10025 +typedef int (*ast_state_cb_type)(char *context, char* id, enum ast_extension_states state, void *data, char *cid_num, char *cid_name);
10027 /*! Data structure associated with a custom function */
10028 struct ast_custom_function {
10029 @@ -156,6 +156,8 @@
10031 extern struct ast_app *pbx_findapp(const char *app);
10033 +void *ast_pbx_run_app(void *data);
10035 /*! executes an application */
10037 * \param c channel to execute on
10038 @@ -563,11 +565,11 @@
10040 /* Synchronously or asynchronously make an outbound call and send it to a
10041 particular extension */
10042 -int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
10043 +int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, int callingpres, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, char *uniqueid);
10045 /* Synchronously or asynchronously make an outbound call and send it to a
10046 particular application with given extension */
10047 -int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
10048 +int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, int callingpres, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, char *uniqueid);
10050 /* Evaluate a condition for non-falseness and return a boolean */
10051 int pbx_checkcondition(char *condition);
10052 @@ -659,7 +661,7 @@
10054 void ast_func_write(struct ast_channel *chan, const char *in, const char *value);
10056 -void ast_hint_state_changed(const char *device);
10057 +void ast_hint_state_changed(const char *device, char *cid_num, char *cid_name);
10059 #if defined(__cplusplus) || defined(c_plusplus)
10061 diff -urN asterisk-1.2.7.1.orig/include/asterisk/xlaw.h asterisk-1.2.7.1/include/asterisk/xlaw.h
10062 --- asterisk-1.2.7.1.orig/include/asterisk/xlaw.h 1970-01-01 01:00:00.000000000 +0100
10063 +++ asterisk-1.2.7.1/include/asterisk/xlaw.h 2006-04-18 14:39:28.000000000 +0200
10065 +#ifndef _ASTERISK_XLAW_H
10066 +#define _ASTERISK_XLAW_H
10069 +#define capiXLAW2INT(x) capiULAW2INT[x]
10070 +#define capiINT2XLAW(x) capiINT2ULAW[((unsigned short)x) >> 2]
10072 +#define capiXLAW2INT(x) capiALAW2INT[x]
10073 +#define capiINT2XLAW(x) capiINT2ALAW[(x>>4)+4096]
10076 +static unsigned char reversebits[256] =
10078 +0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
10079 +0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
10080 +0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
10081 +0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
10082 +0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
10083 +0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
10084 +0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
10085 +0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
10086 +0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
10087 +0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
10088 +0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
10089 +0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
10090 +0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
10091 +0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
10092 +0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
10093 +0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
10094 +0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
10095 +0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
10096 +0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
10097 +0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
10098 +0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
10099 +0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
10100 +0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
10101 +0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
10102 +0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
10103 +0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
10104 +0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
10105 +0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
10106 +0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
10107 +0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
10108 +0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
10109 +0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
10113 +static short capiULAW2INT[] =
10115 +0x8284, 0x7d7c, 0xf8a4, 0x075c, 0xe104, 0x1efc, 0xfe8c, 0x0174,
10116 +0xc184, 0x3e7c, 0xfc94, 0x036c, 0xf0c4, 0x0f3c, 0xff88, 0x0078,
10117 +0xa284, 0x5d7c, 0xfaa4, 0x055c, 0xe904, 0x16fc, 0xff0c, 0x00f4,
10118 +0xd184, 0x2e7c, 0xfd94, 0x026c, 0xf4c4, 0x0b3c, 0xffc8, 0x0038,
10119 +0x9284, 0x6d7c, 0xf9a4, 0x065c, 0xe504, 0x1afc, 0xfecc, 0x0134,
10120 +0xc984, 0x367c, 0xfd14, 0x02ec, 0xf2c4, 0x0d3c, 0xffa8, 0x0058,
10121 +0xb284, 0x4d7c, 0xfba4, 0x045c, 0xed04, 0x12fc, 0xff4c, 0x00b4,
10122 +0xd984, 0x267c, 0xfe14, 0x01ec, 0xf6c4, 0x093c, 0xffe8, 0x0018,
10123 +0x8a84, 0x757c, 0xf924, 0x06dc, 0xe304, 0x1cfc, 0xfeac, 0x0154,
10124 +0xc584, 0x3a7c, 0xfcd4, 0x032c, 0xf1c4, 0x0e3c, 0xff98, 0x0068,
10125 +0xaa84, 0x557c, 0xfb24, 0x04dc, 0xeb04, 0x14fc, 0xff2c, 0x00d4,
10126 +0xd584, 0x2a7c, 0xfdd4, 0x022c, 0xf5c4, 0x0a3c, 0xffd8, 0x0028,
10127 +0x9a84, 0x657c, 0xfa24, 0x05dc, 0xe704, 0x18fc, 0xfeec, 0x0114,
10128 +0xcd84, 0x327c, 0xfd54, 0x02ac, 0xf3c4, 0x0c3c, 0xffb8, 0x0048,
10129 +0xba84, 0x457c, 0xfc24, 0x03dc, 0xef04, 0x10fc, 0xff6c, 0x0094,
10130 +0xdd84, 0x227c, 0xfe54, 0x01ac, 0xf7c4, 0x083c, 0xfff8, 0x0008,
10131 +0x8684, 0x797c, 0xf8e4, 0x071c, 0xe204, 0x1dfc, 0xfe9c, 0x0164,
10132 +0xc384, 0x3c7c, 0xfcb4, 0x034c, 0xf144, 0x0ebc, 0xff90, 0x0070,
10133 +0xa684, 0x597c, 0xfae4, 0x051c, 0xea04, 0x15fc, 0xff1c, 0x00e4,
10134 +0xd384, 0x2c7c, 0xfdb4, 0x024c, 0xf544, 0x0abc, 0xffd0, 0x0030,
10135 +0x9684, 0x697c, 0xf9e4, 0x061c, 0xe604, 0x19fc, 0xfedc, 0x0124,
10136 +0xcb84, 0x347c, 0xfd34, 0x02cc, 0xf344, 0x0cbc, 0xffb0, 0x0050,
10137 +0xb684, 0x497c, 0xfbe4, 0x041c, 0xee04, 0x11fc, 0xff5c, 0x00a4,
10138 +0xdb84, 0x247c, 0xfe34, 0x01cc, 0xf744, 0x08bc, 0xfff0, 0x0010,
10139 +0x8e84, 0x717c, 0xf964, 0x069c, 0xe404, 0x1bfc, 0xfebc, 0x0144,
10140 +0xc784, 0x387c, 0xfcf4, 0x030c, 0xf244, 0x0dbc, 0xffa0, 0x0060,
10141 +0xae84, 0x517c, 0xfb64, 0x049c, 0xec04, 0x13fc, 0xff3c, 0x00c4,
10142 +0xd784, 0x287c, 0xfdf4, 0x020c, 0xf644, 0x09bc, 0xffe0, 0x0020,
10143 +0x9e84, 0x617c, 0xfa64, 0x059c, 0xe804, 0x17fc, 0xfefc, 0x0104,
10144 +0xcf84, 0x307c, 0xfd74, 0x028c, 0xf444, 0x0bbc, 0xffc0, 0x0040,
10145 +0xbe84, 0x417c, 0xfc64, 0x039c, 0xf004, 0x0ffc, 0xff7c, 0x0084,
10146 +0xdf84, 0x207c, 0xfe74, 0x018c, 0xf844, 0x07bc, 0x0000, 0x0000
10149 +const unsigned char capiINT2ULAW[16384] = {
10150 +255,127,127,191,191,63,63,223,223,95,95,159,159,31,31,239,
10151 +239,111,111,175,175,47,47,207,207,79,79,143,143,15,15,247,
10152 +247,247,247,119,119,119,119,183,183,183,183,55,55,55,55,215,
10153 +215,215,215,87,87,87,87,151,151,151,151,23,23,23,23,231,
10154 +231,231,231,103,103,103,103,167,167,167,167,39,39,39,39,199,
10155 +199,199,199,71,71,71,71,135,135,135,135,7,7,7,7,251,
10156 +251,251,251,251,251,251,251,123,123,123,123,123,123,123,123,187,
10157 +187,187,187,187,187,187,187,59,59,59,59,59,59,59,59,219,
10158 +219,219,219,219,219,219,219,91,91,91,91,91,91,91,91,155,
10159 +155,155,155,155,155,155,155,27,27,27,27,27,27,27,27,235,
10160 +235,235,235,235,235,235,235,107,107,107,107,107,107,107,107,171,
10161 +171,171,171,171,171,171,171,43,43,43,43,43,43,43,43,203,
10162 +203,203,203,203,203,203,203,75,75,75,75,75,75,75,75,139,
10163 +139,139,139,139,139,139,139,11,11,11,11,11,11,11,11,243,
10164 +243,243,243,243,243,243,243,243,243,243,243,243,243,243,243,115,
10165 +115,115,115,115,115,115,115,115,115,115,115,115,115,115,115,179,
10166 +179,179,179,179,179,179,179,179,179,179,179,179,179,179,179,51,
10167 +51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,211,
10168 +211,211,211,211,211,211,211,211,211,211,211,211,211,211,211,83,
10169 +83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,147,
10170 +147,147,147,147,147,147,147,147,147,147,147,147,147,147,147,19,
10171 +19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,227,
10172 +227,227,227,227,227,227,227,227,227,227,227,227,227,227,227,99,
10173 +99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,163,
10174 +163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,35,
10175 +35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,195,
10176 +195,195,195,195,195,195,195,195,195,195,195,195,195,195,195,67,
10177 +67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,131,
10178 +131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,3,
10179 +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,253,
10180 +253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,
10181 +253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,125,
10182 +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,
10183 +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,189,
10184 +189,189,189,189,189,189,189,189,189,189,189,189,189,189,189,189,
10185 +189,189,189,189,189,189,189,189,189,189,189,189,189,189,189,61,
10186 +61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,
10187 +61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,221,
10188 +221,221,221,221,221,221,221,221,221,221,221,221,221,221,221,221,
10189 +221,221,221,221,221,221,221,221,221,221,221,221,221,221,221,93,
10190 +93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,
10191 +93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,157,
10192 +157,157,157,157,157,157,157,157,157,157,157,157,157,157,157,157,
10193 +157,157,157,157,157,157,157,157,157,157,157,157,157,157,157,29,
10194 +29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,
10195 +29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,237,
10196 +237,237,237,237,237,237,237,237,237,237,237,237,237,237,237,237,
10197 +237,237,237,237,237,237,237,237,237,237,237,237,237,237,237,109,
10198 +109,109,109,109,109,109,109,109,109,109,109,109,109,109,109,109,
10199 +109,109,109,109,109,109,109,109,109,109,109,109,109,109,109,173,
10200 +173,173,173,173,173,173,173,173,173,173,173,173,173,173,173,173,
10201 +173,173,173,173,173,173,173,173,173,173,173,173,173,173,173,45,
10202 +45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,
10203 +45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,205,
10204 +205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,
10205 +205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,77,
10206 +77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,
10207 +77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,141,
10208 +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,
10209 +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,13,
10210 +13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
10211 +13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,245,
10212 +245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,
10213 +245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,
10214 +245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,
10215 +245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,117,
10216 +117,117,117,117,117,117,117,117,117,117,117,117,117,117,117,117,
10217 +117,117,117,117,117,117,117,117,117,117,117,117,117,117,117,117,
10218 +117,117,117,117,117,117,117,117,117,117,117,117,117,117,117,117,
10219 +117,117,117,117,117,117,117,117,117,117,117,117,117,117,117,181,
10220 +181,181,181,181,181,181,181,181,181,181,181,181,181,181,181,181,
10221 +181,181,181,181,181,181,181,181,181,181,181,181,181,181,181,181,
10222 +181,181,181,181,181,181,181,181,181,181,181,181,181,181,181,181,
10223 +181,181,181,181,181,181,181,181,181,181,181,181,181,181,181,53,
10224 +53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,
10225 +53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,
10226 +53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,
10227 +53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,213,
10228 +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,
10229 +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,
10230 +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,
10231 +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,85,
10232 +85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
10233 +85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
10234 +85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
10235 +85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,149,
10236 +149,149,149,149,149,149,149,149,149,149,149,149,149,149,149,149,
10237 +149,149,149,149,149,149,149,149,149,149,149,149,149,149,149,149,
10238 +149,149,149,149,149,149,149,149,149,149,149,149,149,149,149,149,
10239 +149,149,149,149,149,149,149,149,149,149,149,149,149,149,149,21,
10240 +21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,
10241 +21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,
10242 +21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,
10243 +21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,229,
10244 +229,229,229,229,229,229,229,229,229,229,229,229,229,229,229,229,
10245 +229,229,229,229,229,229,229,229,229,229,229,229,229,229,229,229,
10246 +229,229,229,229,229,229,229,229,229,229,229,229,229,229,229,229,
10247 +229,229,229,229,229,229,229,229,229,229,229,229,229,229,229,101,
10248 +101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,
10249 +101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,
10250 +101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,
10251 +101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,165,
10252 +165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,
10253 +165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,
10254 +165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,
10255 +165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,37,
10256 +37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,
10257 +37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,
10258 +37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,
10259 +37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,197,
10260 +197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,
10261 +197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,
10262 +197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,
10263 +197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,69,
10264 +69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,
10265 +69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,
10266 +69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,
10267 +69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,133,
10268 +133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,
10269 +133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,
10270 +133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,
10271 +133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,5,
10272 +5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
10273 +5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
10274 +5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
10275 +5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,249,
10276 +249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,
10277 +249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,
10278 +249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,
10279 +249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,
10280 +249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,
10281 +249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,
10282 +249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,
10283 +249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,121,
10284 +121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,
10285 +121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,
10286 +121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,
10287 +121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,
10288 +121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,
10289 +121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,
10290 +121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,
10291 +121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,185,
10292 +185,185,185,185,185,185,185,185,185,185,185,185,185,185,185,185,
10293 +185,185,185,185,185,185,185,185,185,185,185,185,185,185,185,185,
10294 +185,185,185,185,185,185,185,185,185,185,185,185,185,185,185,185,
10295 +185,185,185,185,185,185,185,185,185,185,185,185,185,185,185,185,
10296 +185,185,185,185,185,185,185,185,185,185,185,185,185,185,185,185,
10297 +185,185,185,185,185,185,185,185,185,185,185,185,185,185,185,185,
10298 +185,185,185,185,185,185,185,185,185,185,185,185,185,185,185,185,
10299 +185,185,185,185,185,185,185,185,185,185,185,185,185,185,185,57,
10300 +57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,
10301 +57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,
10302 +57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,
10303 +57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,
10304 +57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,
10305 +57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,
10306 +57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,
10307 +57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,217,
10308 +217,217,217,217,217,217,217,217,217,217,217,217,217,217,217,217,
10309 +217,217,217,217,217,217,217,217,217,217,217,217,217,217,217,217,
10310 +217,217,217,217,217,217,217,217,217,217,217,217,217,217,217,217,
10311 +217,217,217,217,217,217,217,217,217,217,217,217,217,217,217,217,
10312 +217,217,217,217,217,217,217,217,217,217,217,217,217,217,217,217,
10313 +217,217,217,217,217,217,217,217,217,217,217,217,217,217,217,217,
10314 +217,217,217,217,217,217,217,217,217,217,217,217,217,217,217,217,
10315 +217,217,217,217,217,217,217,217,217,217,217,217,217,217,217,89,
10316 +89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,
10317 +89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,
10318 +89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,
10319 +89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,
10320 +89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,
10321 +89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,
10322 +89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,
10323 +89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,153,
10324 +153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,
10325 +153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,
10326 +153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,
10327 +153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,
10328 +153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,
10329 +153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,
10330 +153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,
10331 +153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,25,
10332 +25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
10333 +25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
10334 +25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
10335 +25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
10336 +25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
10337 +25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
10338 +25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
10339 +25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,233,
10340 +233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,
10341 +233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,
10342 +233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,
10343 +233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,
10344 +233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,
10345 +233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,
10346 +233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,
10347 +233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,105,
10348 +105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,
10349 +105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,
10350 +105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,
10351 +105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,
10352 +105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,
10353 +105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,
10354 +105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,
10355 +105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,169,
10356 +169,169,169,169,169,169,169,169,169,169,169,169,169,169,169,169,
10357 +169,169,169,169,169,169,169,169,169,169,169,169,169,169,169,169,
10358 +169,169,169,169,169,169,169,169,169,169,169,169,169,169,169,169,
10359 +169,169,169,169,169,169,169,169,169,169,169,169,169,169,169,169,
10360 +169,169,169,169,169,169,169,169,169,169,169,169,169,169,169,169,
10361 +169,169,169,169,169,169,169,169,169,169,169,169,169,169,169,169,
10362 +169,169,169,169,169,169,169,169,169,169,169,169,169,169,169,169,
10363 +169,169,169,169,169,169,169,169,169,169,169,169,169,169,169,41,
10364 +41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,
10365 +41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,
10366 +41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,
10367 +41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,
10368 +41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,
10369 +41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,
10370 +41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,
10371 +41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,201,
10372 +201,201,201,201,201,201,201,201,201,201,201,201,201,201,201,201,
10373 +201,201,201,201,201,201,201,201,201,201,201,201,201,201,201,201,
10374 +201,201,201,201,201,201,201,201,201,201,201,201,201,201,201,201,
10375 +201,201,201,201,201,201,201,201,201,201,201,201,201,201,201,201,
10376 +201,201,201,201,201,201,201,201,201,201,201,201,201,201,201,201,
10377 +201,201,201,201,201,201,201,201,201,201,201,201,201,201,201,201,
10378 +201,201,201,201,201,201,201,201,201,201,201,201,201,201,201,201,
10379 +201,201,201,201,201,201,201,201,201,201,201,201,201,201,201,73,
10380 +73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,
10381 +73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,
10382 +73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,
10383 +73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,
10384 +73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,
10385 +73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,
10386 +73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,
10387 +73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,137,
10388 +137,137,137,137,137,137,137,137,137,137,137,137,137,137,137,137,
10389 +137,137,137,137,137,137,137,137,137,137,137,137,137,137,137,137,
10390 +137,137,137,137,137,137,137,137,137,137,137,137,137,137,137,137,
10391 +137,137,137,137,137,137,137,137,137,137,137,137,137,137,137,137,
10392 +137,137,137,137,137,137,137,137,137,137,137,137,137,137,137,137,
10393 +137,137,137,137,137,137,137,137,137,137,137,137,137,137,137,137,
10394 +137,137,137,137,137,137,137,137,137,137,137,137,137,137,137,137,
10395 +137,137,137,137,137,137,137,137,137,137,137,137,137,137,137,9,
10396 +9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
10397 +9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
10398 +9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
10399 +9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
10400 +9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
10401 +9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
10402 +9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
10403 +9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,241,
10404 +241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
10405 +241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
10406 +241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
10407 +241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
10408 +241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
10409 +241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
10410 +241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
10411 +241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
10412 +241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
10413 +241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
10414 +241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
10415 +241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
10416 +241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
10417 +241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
10418 +241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
10419 +241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,113,
10420 +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,
10421 +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,
10422 +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,
10423 +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,
10424 +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,
10425 +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,
10426 +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,
10427 +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,
10428 +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,
10429 +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,
10430 +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,
10431 +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,
10432 +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,
10433 +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,
10434 +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,
10435 +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,177,
10436 +177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,
10437 +177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,
10438 +177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,
10439 +177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,
10440 +177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,
10441 +177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,
10442 +177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,
10443 +177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,
10444 +177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,
10445 +177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,
10446 +177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,
10447 +177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,
10448 +177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,
10449 +177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,
10450 +177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,
10451 +177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,49,
10452 +49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,
10453 +49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,
10454 +49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,
10455 +49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,
10456 +49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,
10457 +49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,
10458 +49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,
10459 +49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,
10460 +49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,
10461 +49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,
10462 +49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,
10463 +49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,
10464 +49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,
10465 +49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,
10466 +49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,
10467 +49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,209,
10468 +209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,
10469 +209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,
10470 +209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,
10471 +209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,
10472 +209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,
10473 +209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,
10474 +209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,
10475 +209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,
10476 +209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,
10477 +209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,
10478 +209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,
10479 +209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,
10480 +209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,
10481 +209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,
10482 +209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,
10483 +209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,81,
10484 +81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,
10485 +81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,
10486 +81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,
10487 +81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,
10488 +81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,
10489 +81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,
10490 +81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,
10491 +81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,
10492 +81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,
10493 +81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,
10494 +81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,
10495 +81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,
10496 +81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,
10497 +81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,
10498 +81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,
10499 +81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,145,
10500 +145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
10501 +145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
10502 +145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
10503 +145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
10504 +145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
10505 +145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
10506 +145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
10507 +145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
10508 +145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
10509 +145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
10510 +145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
10511 +145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
10512 +145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
10513 +145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
10514 +145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
10515 +145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,17,
10516 +17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
10517 +17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
10518 +17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
10519 +17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
10520 +17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
10521 +17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
10522 +17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
10523 +17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
10524 +17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
10525 +17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
10526 +17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
10527 +17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
10528 +17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
10529 +17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
10530 +17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
10531 +17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,225,
10532 +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,
10533 +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,
10534 +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,
10535 +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,
10536 +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,
10537 +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,
10538 +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,
10539 +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,
10540 +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,
10541 +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,
10542 +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,
10543 +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,
10544 +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,
10545 +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,
10546 +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,
10547 +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,97,
10548 +97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,
10549 +97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,
10550 +97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,
10551 +97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,
10552 +97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,
10553 +97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,
10554 +97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,
10555 +97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,
10556 +97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,
10557 +97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,
10558 +97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,
10559 +97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,
10560 +97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,
10561 +97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,
10562 +97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,
10563 +97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,161,
10564 +161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,
10565 +161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,
10566 +161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,
10567 +161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,
10568 +161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,
10569 +161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,
10570 +161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,
10571 +161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,
10572 +161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,
10573 +161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,
10574 +161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,
10575 +161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,
10576 +161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,
10577 +161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,
10578 +161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,
10579 +161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,33,
10580 +33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,
10581 +33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,
10582 +33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,
10583 +33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,
10584 +33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,
10585 +33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,
10586 +33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,
10587 +33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,
10588 +33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,
10589 +33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,
10590 +33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,
10591 +33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,
10592 +33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,
10593 +33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,
10594 +33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,
10595 +33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,193,
10596 +193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,
10597 +193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,
10598 +193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,
10599 +193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,
10600 +193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,
10601 +193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,
10602 +193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,
10603 +193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,
10604 +193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,
10605 +193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,
10606 +193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,
10607 +193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,
10608 +193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,
10609 +193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,
10610 +193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,
10611 +193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,65,
10612 +65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,
10613 +65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,
10614 +65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,
10615 +65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,
10616 +65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,
10617 +65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,
10618 +65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,
10619 +65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,
10620 +65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,
10621 +65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,
10622 +65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,
10623 +65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,
10624 +65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,
10625 +65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,
10626 +65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,
10627 +65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,129,
10628 +129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,
10629 +129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,
10630 +129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,
10631 +129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,
10632 +129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,
10633 +129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,
10634 +129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,
10635 +129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,
10636 +129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,
10637 +129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,
10638 +129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,
10639 +129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,
10640 +129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,
10641 +129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,
10642 +129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,
10643 +129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,1,
10644 +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
10645 +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
10646 +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
10647 +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
10648 +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
10649 +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
10650 +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
10651 +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
10652 +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
10653 +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
10654 +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
10655 +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
10656 +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
10657 +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
10658 +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
10659 +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
10660 +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
10661 +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
10662 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10663 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10664 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10665 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10666 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10667 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10668 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10669 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10670 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10671 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10672 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10673 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10674 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10675 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10676 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10677 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10678 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10679 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10680 +64,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,
10681 +128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,
10682 +128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,
10683 +128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,
10684 +128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,
10685 +128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,
10686 +128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,
10687 +128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,
10688 +128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,
10689 +128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,
10690 +128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,
10691 +128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,
10692 +128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,
10693 +128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,
10694 +128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,
10695 +128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,
10696 +128,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10697 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10698 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10699 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10700 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10701 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10702 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10703 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10704 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10705 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10706 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10707 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10708 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10709 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10710 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10711 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
10712 +64,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
10713 +192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
10714 +192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
10715 +192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
10716 +192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
10717 +192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
10718 +192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
10719 +192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
10720 +192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
10721 +192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
10722 +192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
10723 +192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
10724 +192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
10725 +192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
10726 +192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
10727 +192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
10728 +192,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
10729 +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
10730 +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
10731 +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
10732 +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
10733 +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
10734 +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
10735 +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
10736 +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
10737 +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
10738 +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
10739 +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
10740 +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
10741 +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
10742 +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
10743 +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
10744 +32,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,
10745 +160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,
10746 +160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,
10747 +160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,
10748 +160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,
10749 +160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,
10750 +160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,
10751 +160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,
10752 +160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,
10753 +160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,
10754 +160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,
10755 +160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,
10756 +160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,
10757 +160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,
10758 +160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,
10759 +160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,
10760 +160,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,
10761 +96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,
10762 +96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,
10763 +96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,
10764 +96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,
10765 +96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,
10766 +96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,
10767 +96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,
10768 +96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,
10769 +96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,
10770 +96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,
10771 +96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,
10772 +96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,
10773 +96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,
10774 +96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,
10775 +96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,
10776 +96,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,
10777 +224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,
10778 +224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,
10779 +224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,
10780 +224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,
10781 +224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,
10782 +224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,
10783 +224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,
10784 +224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,
10785 +224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,
10786 +224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,
10787 +224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,
10788 +224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,
10789 +224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,
10790 +224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,
10791 +224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,
10792 +224,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
10793 +16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
10794 +16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
10795 +16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
10796 +16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
10797 +16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
10798 +16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
10799 +16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
10800 +16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
10801 +16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
10802 +16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
10803 +16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
10804 +16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
10805 +16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
10806 +16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
10807 +16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
10808 +16,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
10809 +144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
10810 +144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
10811 +144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
10812 +144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
10813 +144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
10814 +144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
10815 +144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
10816 +144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
10817 +144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
10818 +144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
10819 +144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
10820 +144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
10821 +144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
10822 +144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
10823 +144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
10824 +144,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,
10825 +80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,
10826 +80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,
10827 +80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,
10828 +80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,
10829 +80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,
10830 +80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,
10831 +80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,
10832 +80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,
10833 +80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,
10834 +80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,
10835 +80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,
10836 +80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,
10837 +80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,
10838 +80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,
10839 +80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,
10840 +80,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,
10841 +208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,
10842 +208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,
10843 +208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,
10844 +208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,
10845 +208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,
10846 +208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,
10847 +208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,
10848 +208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,
10849 +208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,
10850 +208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,
10851 +208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,
10852 +208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,
10853 +208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,
10854 +208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,
10855 +208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,
10856 +208,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,
10857 +48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,
10858 +48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,
10859 +48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,
10860 +48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,
10861 +48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,
10862 +48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,
10863 +48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,
10864 +48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,
10865 +48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,
10866 +48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,
10867 +48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,
10868 +48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,
10869 +48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,
10870 +48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,
10871 +48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,
10872 +48,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
10873 +176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
10874 +176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
10875 +176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
10876 +176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
10877 +176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
10878 +176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
10879 +176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
10880 +176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
10881 +176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
10882 +176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
10883 +176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
10884 +176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
10885 +176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
10886 +176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
10887 +176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
10888 +176,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
10889 +112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
10890 +112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
10891 +112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
10892 +112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
10893 +112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
10894 +112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
10895 +112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
10896 +112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
10897 +112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
10898 +112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
10899 +112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
10900 +112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
10901 +112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
10902 +112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
10903 +112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
10904 +112,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,
10905 +240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,
10906 +240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,
10907 +240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,
10908 +240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,
10909 +240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,
10910 +240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,
10911 +240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,
10912 +240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,
10913 +240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,
10914 +240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,
10915 +240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,
10916 +240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,
10917 +240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,
10918 +240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,
10919 +240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,
10920 +240,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
10921 +8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
10922 +8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
10923 +8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
10924 +8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
10925 +8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
10926 +8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
10927 +8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
10928 +8,136,136,136,136,136,136,136,136,136,136,136,136,136,136,136,
10929 +136,136,136,136,136,136,136,136,136,136,136,136,136,136,136,136,
10930 +136,136,136,136,136,136,136,136,136,136,136,136,136,136,136,136,
10931 +136,136,136,136,136,136,136,136,136,136,136,136,136,136,136,136,
10932 +136,136,136,136,136,136,136,136,136,136,136,136,136,136,136,136,
10933 +136,136,136,136,136,136,136,136,136,136,136,136,136,136,136,136,
10934 +136,136,136,136,136,136,136,136,136,136,136,136,136,136,136,136,
10935 +136,136,136,136,136,136,136,136,136,136,136,136,136,136,136,136,
10936 +136,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,
10937 +72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,
10938 +72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,
10939 +72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,
10940 +72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,
10941 +72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,
10942 +72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,
10943 +72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,
10944 +72,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,
10945 +200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,
10946 +200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,
10947 +200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,
10948 +200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,
10949 +200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,
10950 +200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,
10951 +200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,
10952 +200,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,
10953 +40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,
10954 +40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,
10955 +40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,
10956 +40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,
10957 +40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,
10958 +40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,
10959 +40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,
10960 +40,168,168,168,168,168,168,168,168,168,168,168,168,168,168,168,
10961 +168,168,168,168,168,168,168,168,168,168,168,168,168,168,168,168,
10962 +168,168,168,168,168,168,168,168,168,168,168,168,168,168,168,168,
10963 +168,168,168,168,168,168,168,168,168,168,168,168,168,168,168,168,
10964 +168,168,168,168,168,168,168,168,168,168,168,168,168,168,168,168,
10965 +168,168,168,168,168,168,168,168,168,168,168,168,168,168,168,168,
10966 +168,168,168,168,168,168,168,168,168,168,168,168,168,168,168,168,
10967 +168,168,168,168,168,168,168,168,168,168,168,168,168,168,168,168,
10968 +168,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,
10969 +104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,
10970 +104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,
10971 +104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,
10972 +104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,
10973 +104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,
10974 +104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,
10975 +104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,
10976 +104,232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,
10977 +232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,
10978 +232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,
10979 +232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,
10980 +232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,
10981 +232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,
10982 +232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,
10983 +232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,
10984 +232,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
10985 +24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
10986 +24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
10987 +24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
10988 +24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
10989 +24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
10990 +24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
10991 +24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
10992 +24,152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,
10993 +152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,
10994 +152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,
10995 +152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,
10996 +152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,
10997 +152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,
10998 +152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,
10999 +152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,
11000 +152,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,
11001 +88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,
11002 +88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,
11003 +88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,
11004 +88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,
11005 +88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,
11006 +88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,
11007 +88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,
11008 +88,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,
11009 +216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,
11010 +216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,
11011 +216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,
11012 +216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,
11013 +216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,
11014 +216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,
11015 +216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,
11016 +216,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,
11017 +56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,
11018 +56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,
11019 +56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,
11020 +56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,
11021 +56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,
11022 +56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,
11023 +56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,
11024 +56,184,184,184,184,184,184,184,184,184,184,184,184,184,184,184,
11025 +184,184,184,184,184,184,184,184,184,184,184,184,184,184,184,184,
11026 +184,184,184,184,184,184,184,184,184,184,184,184,184,184,184,184,
11027 +184,184,184,184,184,184,184,184,184,184,184,184,184,184,184,184,
11028 +184,184,184,184,184,184,184,184,184,184,184,184,184,184,184,184,
11029 +184,184,184,184,184,184,184,184,184,184,184,184,184,184,184,184,
11030 +184,184,184,184,184,184,184,184,184,184,184,184,184,184,184,184,
11031 +184,184,184,184,184,184,184,184,184,184,184,184,184,184,184,184,
11032 +184,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,
11033 +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,
11034 +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,
11035 +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,
11036 +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,
11037 +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,
11038 +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,
11039 +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,
11040 +120,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
11041 +248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
11042 +248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
11043 +248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
11044 +248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
11045 +248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
11046 +248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
11047 +248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
11048 +248,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
11049 +4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
11050 +4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
11051 +4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
11052 +4,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,
11053 +132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,
11054 +132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,
11055 +132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,
11056 +132,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,
11057 +68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,
11058 +68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,
11059 +68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,
11060 +68,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,
11061 +196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,
11062 +196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,
11063 +196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,
11064 +196,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,
11065 +36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,
11066 +36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,
11067 +36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,
11068 +36,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,
11069 +164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,
11070 +164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,
11071 +164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,
11072 +164,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,
11073 +100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,
11074 +100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,
11075 +100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,
11076 +100,228,228,228,228,228,228,228,228,228,228,228,228,228,228,228,
11077 +228,228,228,228,228,228,228,228,228,228,228,228,228,228,228,228,
11078 +228,228,228,228,228,228,228,228,228,228,228,228,228,228,228,228,
11079 +228,228,228,228,228,228,228,228,228,228,228,228,228,228,228,228,
11080 +228,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
11081 +20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
11082 +20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
11083 +20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
11084 +20,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,
11085 +148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,
11086 +148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,
11087 +148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,
11088 +148,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11089 +84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11090 +84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11091 +84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11092 +84,212,212,212,212,212,212,212,212,212,212,212,212,212,212,212,
11093 +212,212,212,212,212,212,212,212,212,212,212,212,212,212,212,212,
11094 +212,212,212,212,212,212,212,212,212,212,212,212,212,212,212,212,
11095 +212,212,212,212,212,212,212,212,212,212,212,212,212,212,212,212,
11096 +212,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,
11097 +52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,
11098 +52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,
11099 +52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,
11100 +52,180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,
11101 +180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,
11102 +180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,
11103 +180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,
11104 +180,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,
11105 +116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,
11106 +116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,
11107 +116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,
11108 +116,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,
11109 +244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,
11110 +244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,
11111 +244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,
11112 +244,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
11113 +12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
11114 +12,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,
11115 +140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,
11116 +140,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,
11117 +76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,
11118 +76,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,
11119 +204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,
11120 +204,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,
11121 +44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,
11122 +44,172,172,172,172,172,172,172,172,172,172,172,172,172,172,172,
11123 +172,172,172,172,172,172,172,172,172,172,172,172,172,172,172,172,
11124 +172,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,
11125 +108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,
11126 +108,236,236,236,236,236,236,236,236,236,236,236,236,236,236,236,
11127 +236,236,236,236,236,236,236,236,236,236,236,236,236,236,236,236,
11128 +236,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,
11129 +28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,
11130 +28,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,
11131 +156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,
11132 +156,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,
11133 +92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,
11134 +92,220,220,220,220,220,220,220,220,220,220,220,220,220,220,220,
11135 +220,220,220,220,220,220,220,220,220,220,220,220,220,220,220,220,
11136 +220,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,
11137 +60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,
11138 +60,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,
11139 +188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,
11140 +188,124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,
11141 +124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,
11142 +124,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,
11143 +252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,
11144 +252,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
11145 +2,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,
11146 +130,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,
11147 +66,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
11148 +194,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,
11149 +34,162,162,162,162,162,162,162,162,162,162,162,162,162,162,162,
11150 +162,98,98,98,98,98,98,98,98,98,98,98,98,98,98,98,
11151 +98,226,226,226,226,226,226,226,226,226,226,226,226,226,226,226,
11152 +226,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,
11153 +18,146,146,146,146,146,146,146,146,146,146,146,146,146,146,146,
11154 +146,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,
11155 +82,210,210,210,210,210,210,210,210,210,210,210,210,210,210,210,
11156 +210,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,
11157 +50,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,
11158 +178,114,114,114,114,114,114,114,114,114,114,114,114,114,114,114,
11159 +114,242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,
11160 +242,10,10,10,10,10,10,10,10,138,138,138,138,138,138,138,
11161 +138,74,74,74,74,74,74,74,74,202,202,202,202,202,202,202,
11162 +202,42,42,42,42,42,42,42,42,170,170,170,170,170,170,170,
11163 +170,106,106,106,106,106,106,106,106,234,234,234,234,234,234,234,
11164 +234,26,26,26,26,26,26,26,26,154,154,154,154,154,154,154,
11165 +154,90,90,90,90,90,90,90,90,218,218,218,218,218,218,218,
11166 +218,58,58,58,58,58,58,58,58,186,186,186,186,186,186,186,
11167 +186,122,122,122,122,122,122,122,122,250,250,250,250,250,250,250,
11168 +250,6,6,6,6,134,134,134,134,70,70,70,70,198,198,198,
11169 +198,38,38,38,38,166,166,166,166,102,102,102,102,230,230,230,
11170 +230,22,22,22,22,150,150,150,150,86,86,86,86,214,214,214,
11171 +214,54,54,54,54,182,182,182,182,118,118,118,118,246,246,246,
11172 +246,14,14,142,142,78,78,206,206,46,46,174,174,110,110,238,
11173 +238,30,30,158,158,94,94,222,222,62,62,190,190,126,126,254,
11176 +static short capiALAW2INT[] =
11178 + 0x13fc, 0xec04, 0x0144, 0xfebc, 0x517c, 0xae84, 0x051c, 0xfae4,
11179 + 0x0a3c, 0xf5c4, 0x0048, 0xffb8, 0x287c, 0xd784, 0x028c, 0xfd74,
11180 + 0x1bfc, 0xe404, 0x01cc, 0xfe34, 0x717c, 0x8e84, 0x071c, 0xf8e4,
11181 + 0x0e3c, 0xf1c4, 0x00c4, 0xff3c, 0x387c, 0xc784, 0x039c, 0xfc64,
11182 + 0x0ffc, 0xf004, 0x0104, 0xfefc, 0x417c, 0xbe84, 0x041c, 0xfbe4,
11183 + 0x083c, 0xf7c4, 0x0008, 0xfff8, 0x207c, 0xdf84, 0x020c, 0xfdf4,
11184 + 0x17fc, 0xe804, 0x018c, 0xfe74, 0x617c, 0x9e84, 0x061c, 0xf9e4,
11185 + 0x0c3c, 0xf3c4, 0x0084, 0xff7c, 0x307c, 0xcf84, 0x030c, 0xfcf4,
11186 + 0x15fc, 0xea04, 0x0164, 0xfe9c, 0x597c, 0xa684, 0x059c, 0xfa64,
11187 + 0x0b3c, 0xf4c4, 0x0068, 0xff98, 0x2c7c, 0xd384, 0x02cc, 0xfd34,
11188 + 0x1dfc, 0xe204, 0x01ec, 0xfe14, 0x797c, 0x8684, 0x07bc, 0xf844,
11189 + 0x0f3c, 0xf0c4, 0x00e4, 0xff1c, 0x3c7c, 0xc384, 0x03dc, 0xfc24,
11190 + 0x11fc, 0xee04, 0x0124, 0xfedc, 0x497c, 0xb684, 0x049c, 0xfb64,
11191 + 0x093c, 0xf6c4, 0x0028, 0xffd8, 0x247c, 0xdb84, 0x024c, 0xfdb4,
11192 + 0x19fc, 0xe604, 0x01ac, 0xfe54, 0x697c, 0x9684, 0x069c, 0xf964,
11193 + 0x0d3c, 0xf2c4, 0x00a4, 0xff5c, 0x347c, 0xcb84, 0x034c, 0xfcb4,
11194 + 0x12fc, 0xed04, 0x0134, 0xfecc, 0x4d7c, 0xb284, 0x04dc, 0xfb24,
11195 + 0x09bc, 0xf644, 0x0038, 0xffc8, 0x267c, 0xd984, 0x026c, 0xfd94,
11196 + 0x1afc, 0xe504, 0x01ac, 0xfe54, 0x6d7c, 0x9284, 0x06dc, 0xf924,
11197 + 0x0dbc, 0xf244, 0x00b4, 0xff4c, 0x367c, 0xc984, 0x036c, 0xfc94,
11198 + 0x0f3c, 0xf0c4, 0x00f4, 0xff0c, 0x3e7c, 0xc184, 0x03dc, 0xfc24,
11199 + 0x07bc, 0xf844, 0x0008, 0xfff8, 0x1efc, 0xe104, 0x01ec, 0xfe14,
11200 + 0x16fc, 0xe904, 0x0174, 0xfe8c, 0x5d7c, 0xa284, 0x05dc, 0xfa24,
11201 + 0x0bbc, 0xf444, 0x0078, 0xff88, 0x2e7c, 0xd184, 0x02ec, 0xfd14,
11202 + 0x14fc, 0xeb04, 0x0154, 0xfeac, 0x557c, 0xaa84, 0x055c, 0xfaa4,
11203 + 0x0abc, 0xf544, 0x0058, 0xffa8, 0x2a7c, 0xd584, 0x02ac, 0xfd54,
11204 + 0x1cfc, 0xe304, 0x01cc, 0xfe34, 0x757c, 0x8a84, 0x075c, 0xf8a4,
11205 + 0x0ebc, 0xf144, 0x00d4, 0xff2c, 0x3a7c, 0xc584, 0x039c, 0xfc64,
11206 + 0x10fc, 0xef04, 0x0114, 0xfeec, 0x457c, 0xba84, 0x045c, 0xfba4,
11207 + 0x08bc, 0xf744, 0x0018, 0xffe8, 0x227c, 0xdd84, 0x022c, 0xfdd4,
11208 + 0x18fc, 0xe704, 0x018c, 0xfe74, 0x657c, 0x9a84, 0x065c, 0xf9a4,
11209 + 0x0cbc, 0xf344, 0x0094, 0xff6c, 0x327c, 0xcd84, 0x032c, 0xfcd4
11212 +const unsigned char capiINT2ALAW[8192] = {
11213 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11214 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11215 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11216 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11217 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11218 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11219 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11220 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11221 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11222 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11223 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11224 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11225 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11226 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11227 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11228 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11229 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11230 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11231 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11232 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11233 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11234 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11235 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11236 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11237 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11238 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11239 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11240 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11241 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11242 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11243 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11244 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11245 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11246 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11247 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11248 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11249 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11250 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11251 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11252 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11253 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11254 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11255 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11256 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11257 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11258 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11259 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11260 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11261 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11262 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11263 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11264 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11265 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11266 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11267 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11268 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11269 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11270 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11271 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11272 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11273 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11274 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11275 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11276 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11277 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11278 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11279 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11280 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11281 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11282 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11283 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11284 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11285 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11286 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11287 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11288 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11289 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11290 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11291 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11292 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11293 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11294 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11295 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11296 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11297 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11298 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11299 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11300 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11301 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11302 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11303 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11304 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11305 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11306 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11307 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11308 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11309 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11310 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11311 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11312 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11313 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11314 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11315 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11316 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11317 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11318 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11319 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11320 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11321 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11322 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11323 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11324 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11325 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11326 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11327 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11328 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11329 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11330 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11331 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11332 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11333 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11334 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11335 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11336 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11337 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11338 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11339 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11340 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11341 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11342 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11343 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11344 + 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
11345 + 212,212,212,212,212,212,212,212,212,212,212,212,212,212,212,212,
11346 + 212,212,212,212,212,212,212,212,212,212,212,212,212,212,212,212,
11347 + 212,212,212,212,212,212,212,212,212,212,212,212,212,212,212,212,
11348 + 212,212,212,212,212,212,212,212,212,212,212,212,212,212,212,212,
11349 + 20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
11350 + 20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
11351 + 20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
11352 + 20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
11353 + 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,
11354 + 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,
11355 + 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,
11356 + 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,
11357 + 116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,
11358 + 116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,
11359 + 116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,
11360 + 116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,
11361 + 244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,
11362 + 244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,
11363 + 244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,
11364 + 244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,
11365 + 52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,
11366 + 52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,
11367 + 52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,
11368 + 52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,
11369 + 180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,
11370 + 180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,
11371 + 180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,
11372 + 180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,
11373 + 68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,
11374 + 68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,
11375 + 68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,
11376 + 68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,
11377 + 196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,
11378 + 196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,
11379 + 196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,
11380 + 196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,
11381 + 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
11382 + 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
11383 + 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
11384 + 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
11385 + 132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,
11386 + 132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,
11387 + 132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,
11388 + 132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,
11389 + 100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,
11390 + 100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,
11391 + 100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,
11392 + 100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,
11393 + 228,228,228,228,228,228,228,228,228,228,228,228,228,228,228,228,
11394 + 228,228,228,228,228,228,228,228,228,228,228,228,228,228,228,228,
11395 + 228,228,228,228,228,228,228,228,228,228,228,228,228,228,228,228,
11396 + 228,228,228,228,228,228,228,228,228,228,228,228,228,228,228,228,
11397 + 36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,
11398 + 36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,
11399 + 36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,
11400 + 36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,
11401 + 164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,
11402 + 164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,
11403 + 164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,
11404 + 164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,
11405 + 92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,
11406 + 92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,
11407 + 220,220,220,220,220,220,220,220,220,220,220,220,220,220,220,220,
11408 + 220,220,220,220,220,220,220,220,220,220,220,220,220,220,220,220,
11409 + 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,
11410 + 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,
11411 + 156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,
11412 + 156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,
11413 + 124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,
11414 + 124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,
11415 + 252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,
11416 + 252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,
11417 + 60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,
11418 + 60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,
11419 + 188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,
11420 + 188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,
11421 + 76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,
11422 + 76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,
11423 + 204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,
11424 + 204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,
11425 + 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
11426 + 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
11427 + 140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,
11428 + 140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,
11429 + 108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,
11430 + 108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,
11431 + 236,236,236,236,236,236,236,236,236,236,236,236,236,236,236,236,
11432 + 236,236,236,236,236,236,236,236,236,236,236,236,236,236,236,236,
11433 + 44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,
11434 + 44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,
11435 + 172,172,172,172,172,172,172,172,172,172,172,172,172,172,172,172,
11436 + 172,172,172,172,172,172,172,172,172,172,172,172,172,172,172,172,
11437 + 80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,
11438 + 208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,
11439 + 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
11440 + 144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
11441 + 112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
11442 + 240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,
11443 + 48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,
11444 + 176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
11445 + 64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
11446 + 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
11447 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
11448 + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,
11449 + 96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,
11450 + 224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,
11451 + 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
11452 + 160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,
11453 + 88,88,88,88,88,88,88,88,216,216,216,216,216,216,216,216,
11454 + 24,24,24,24,24,24,24,24,152,152,152,152,152,152,152,152,
11455 + 120,120,120,120,120,120,120,120,248,248,248,248,248,248,248,248,
11456 + 56,56,56,56,56,56,56,56,184,184,184,184,184,184,184,184,
11457 + 72,72,72,72,72,72,72,72,200,200,200,200,200,200,200,200,
11458 + 8,8,8,8,8,8,8,8,136,136,136,136,136,136,136,136,
11459 + 104,104,104,104,104,104,104,104,232,232,232,232,232,232,232,232,
11460 + 40,40,40,40,40,40,40,40,168,168,168,168,168,168,168,168,
11461 + 86,86,86,86,214,214,214,214,22,22,22,22,150,150,150,150,
11462 + 118,118,118,118,246,246,246,246,54,54,54,54,182,182,182,182,
11463 + 70,70,70,70,198,198,198,198,6,6,6,6,134,134,134,134,
11464 + 102,102,102,102,230,230,230,230,38,38,38,38,166,166,166,166,
11465 + 94,94,222,222,30,30,158,158,126,126,254,254,62,62,190,190,
11466 + 78,78,206,206,14,14,142,142,110,110,238,238,46,46,174,174,
11467 + 82,210,18,146,114,242,50,178,66,194,2,130,98,226,34,162,
11468 + 90,218,26,154,122,250,58,186,74,202,10,138,106,234,42,170,
11469 + 171,43,235,107,139,11,203,75,187,59,251,123,155,27,219,91,
11470 + 163,35,227,99,131,3,195,67,179,51,243,115,147,19,211,83,
11471 + 175,175,47,47,239,239,111,111,143,143,15,15,207,207,79,79,
11472 + 191,191,63,63,255,255,127,127,159,159,31,31,223,223,95,95,
11473 + 167,167,167,167,39,39,39,39,231,231,231,231,103,103,103,103,
11474 + 135,135,135,135,7,7,7,7,199,199,199,199,71,71,71,71,
11475 + 183,183,183,183,55,55,55,55,247,247,247,247,119,119,119,119,
11476 + 151,151,151,151,23,23,23,23,215,215,215,215,87,87,87,87,
11477 + 169,169,169,169,169,169,169,169,41,41,41,41,41,41,41,41,
11478 + 233,233,233,233,233,233,233,233,105,105,105,105,105,105,105,105,
11479 + 137,137,137,137,137,137,137,137,9,9,9,9,9,9,9,9,
11480 + 201,201,201,201,201,201,201,201,73,73,73,73,73,73,73,73,
11481 + 185,185,185,185,185,185,185,185,57,57,57,57,57,57,57,57,
11482 + 249,249,249,249,249,249,249,249,121,121,121,121,121,121,121,121,
11483 + 153,153,153,153,153,153,153,153,25,25,25,25,25,25,25,25,
11484 + 217,217,217,217,217,217,217,217,89,89,89,89,89,89,89,89,
11485 + 161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,
11486 + 33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,
11487 + 225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,
11488 + 97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,
11489 + 129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,
11490 + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
11491 + 193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,
11492 + 65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,
11493 + 177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,
11494 + 49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,
11495 + 241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
11496 + 113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,
11497 + 145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
11498 + 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
11499 + 209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,
11500 + 81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,
11501 + 173,173,173,173,173,173,173,173,173,173,173,173,173,173,173,173,
11502 + 173,173,173,173,173,173,173,173,173,173,173,173,173,173,173,173,
11503 + 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,
11504 + 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,
11505 + 237,237,237,237,237,237,237,237,237,237,237,237,237,237,237,237,
11506 + 237,237,237,237,237,237,237,237,237,237,237,237,237,237,237,237,
11507 + 109,109,109,109,109,109,109,109,109,109,109,109,109,109,109,109,
11508 + 109,109,109,109,109,109,109,109,109,109,109,109,109,109,109,109,
11509 + 141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,
11510 + 141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,
11511 + 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
11512 + 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
11513 + 205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,
11514 + 205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,
11515 + 77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,
11516 + 77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,
11517 + 189,189,189,189,189,189,189,189,189,189,189,189,189,189,189,189,
11518 + 189,189,189,189,189,189,189,189,189,189,189,189,189,189,189,189,
11519 + 61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,
11520 + 61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,
11521 + 253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,
11522 + 253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,
11523 + 125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,
11524 + 125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,
11525 + 157,157,157,157,157,157,157,157,157,157,157,157,157,157,157,157,
11526 + 157,157,157,157,157,157,157,157,157,157,157,157,157,157,157,157,
11527 + 29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,
11528 + 29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,
11529 + 221,221,221,221,221,221,221,221,221,221,221,221,221,221,221,221,
11530 + 221,221,221,221,221,221,221,221,221,221,221,221,221,221,221,221,
11531 + 93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,
11532 + 93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,
11533 + 165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,
11534 + 165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,
11535 + 165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,
11536 + 165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,
11537 + 37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,
11538 + 37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,
11539 + 37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,
11540 + 37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,
11541 + 229,229,229,229,229,229,229,229,229,229,229,229,229,229,229,229,
11542 + 229,229,229,229,229,229,229,229,229,229,229,229,229,229,229,229,
11543 + 229,229,229,229,229,229,229,229,229,229,229,229,229,229,229,229,
11544 + 229,229,229,229,229,229,229,229,229,229,229,229,229,229,229,229,
11545 + 101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,
11546 + 101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,
11547 + 101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,
11548 + 101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,
11549 + 133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,
11550 + 133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,
11551 + 133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,
11552 + 133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,
11553 + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
11554 + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
11555 + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
11556 + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
11557 + 197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,
11558 + 197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,
11559 + 197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,
11560 + 197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,
11561 + 69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,
11562 + 69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,
11563 + 69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,
11564 + 69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,
11565 + 181,181,181,181,181,181,181,181,181,181,181,181,181,181,181,181,
11566 + 181,181,181,181,181,181,181,181,181,181,181,181,181,181,181,181,
11567 + 181,181,181,181,181,181,181,181,181,181,181,181,181,181,181,181,
11568 + 181,181,181,181,181,181,181,181,181,181,181,181,181,181,181,181,
11569 + 53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,
11570 + 53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,
11571 + 53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,
11572 + 53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,
11573 + 245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,
11574 + 245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,
11575 + 245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,
11576 + 245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,
11577 + 117,117,117,117,117,117,117,117,117,117,117,117,117,117,117,117,
11578 + 117,117,117,117,117,117,117,117,117,117,117,117,117,117,117,117,
11579 + 117,117,117,117,117,117,117,117,117,117,117,117,117,117,117,117,
11580 + 117,117,117,117,117,117,117,117,117,117,117,117,117,117,117,117,
11581 + 149,149,149,149,149,149,149,149,149,149,149,149,149,149,149,149,
11582 + 149,149,149,149,149,149,149,149,149,149,149,149,149,149,149,149,
11583 + 149,149,149,149,149,149,149,149,149,149,149,149,149,149,149,149,
11584 + 149,149,149,149,149,149,149,149,149,149,149,149,149,149,149,149,
11585 + 21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,
11586 + 21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,
11587 + 21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,
11588 + 21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,
11589 + 213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,
11590 + 213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,
11591 + 213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,
11592 + 213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,
11593 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11594 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11595 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11596 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11597 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11598 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11599 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11600 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11601 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11602 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11603 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11604 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11605 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11606 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11607 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11608 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11609 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11610 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11611 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11612 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11613 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11614 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11615 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11616 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11617 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11618 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11619 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11620 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11621 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11622 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11623 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11624 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11625 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11626 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11627 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11628 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11629 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11630 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11631 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11632 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11633 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11634 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11635 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11636 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11637 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11638 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11639 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11640 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11641 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11642 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11643 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11644 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11645 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11646 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11647 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11648 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11649 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11650 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11651 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11652 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11653 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11654 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11655 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11656 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11657 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11658 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11659 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11660 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11661 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11662 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11663 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11664 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11665 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11666 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11667 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11668 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11669 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11670 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11671 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11672 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11673 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11674 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11675 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11676 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11677 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11678 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11679 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11680 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11681 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11682 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11683 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11684 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11685 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11686 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11687 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11688 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11689 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11690 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11691 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11692 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11693 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11694 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11695 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11696 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11697 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11698 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11699 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11700 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11701 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11702 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11703 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11704 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11705 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11706 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11707 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11708 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11709 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11710 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11711 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11712 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11713 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11714 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11715 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11716 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11717 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11718 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11719 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11720 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11721 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11722 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11723 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
11724 + 85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85
11727 +#endif // CAPI_ULAW
11730 diff -urN asterisk-1.2.7.1.orig/include/asterisk.h asterisk-1.2.7.1/include/asterisk.h
11731 --- asterisk-1.2.7.1.orig/include/asterisk.h 2005-11-30 04:37:37.000000000 +0100
11732 +++ asterisk-1.2.7.1/include/asterisk.h 2006-04-18 14:39:28.000000000 +0200
11734 extern char ast_config_AST_PID[AST_CONFIG_MAX_PATH];
11735 extern char ast_config_AST_SOCKET[AST_CONFIG_MAX_PATH];
11736 extern char ast_config_AST_RUN_DIR[AST_CONFIG_MAX_PATH];
11737 +extern char ast_config_AST_SYMBOLIC_NAME[20];
11738 extern char ast_config_AST_CTL_PERMISSIONS[AST_CONFIG_MAX_PATH];
11739 extern char ast_config_AST_CTL_OWNER[AST_CONFIG_MAX_PATH];
11740 extern char ast_config_AST_CTL_GROUP[AST_CONFIG_MAX_PATH];
11741 diff -urN asterisk-1.2.7.1.orig/manager.c asterisk-1.2.7.1/manager.c
11742 --- asterisk-1.2.7.1.orig/manager.c 2006-02-11 19:15:00.000000000 +0100
11743 +++ asterisk-1.2.7.1/manager.c 2006-04-18 14:39:28.000000000 +0200
11745 * the project provides a web site, mailing lists and IRC
11746 * channels for your use.
11748 + * Copyright (C) 2003-2004, Junghanns.NET Gmbh
11749 + * Klaus-Peter Junghanns <kpj@junghanns.net>
11751 * This program is free software, distributed under the terms of
11752 * the GNU General Public License Version 2. See the LICENSE file
11753 * at the top of the source tree.
11755 #include "asterisk/md5.h"
11756 #include "asterisk/acl.h"
11757 #include "asterisk/utils.h"
11758 +#include "asterisk/astdb.h"
11760 struct fast_originate_helper {
11761 char tech[AST_MAX_MANHEADER_LEN];
11763 char idtext[AST_MAX_MANHEADER_LEN];
11764 char account[AST_MAX_ACCOUNT_CODE];
11767 + char uniqueid[64];
11768 struct ast_variable *vars;
11771 @@ -657,11 +663,17 @@
11773 struct ast_channel *c = NULL;
11774 char *name = astman_get_header(m, "Channel");
11775 - if (ast_strlen_zero(name)) {
11776 - astman_send_error(s, m, "No channel specified");
11777 + char *uniqueid = astman_get_header(m, "Uniqueid");
11778 + if (ast_strlen_zero(name) && ast_strlen_zero(uniqueid)) {
11779 + astman_send_error(s, m, "No channel or uniqueid specified");
11782 - c = ast_get_channel_by_name_locked(name);
11783 + if (!ast_strlen_zero(uniqueid)) {
11784 + c = ast_get_channel_by_uniqueid_locked(uniqueid);
11786 + if (!ast_strlen_zero(name))
11787 + c = ast_get_channel_by_name_locked(name);
11790 astman_send_error(s, m, "No such channel");
11792 @@ -760,6 +772,7 @@
11797 /*! \brief action_status: Manager "status" command to show channels */
11798 /* Needs documentation... */
11799 static int action_status(struct mansession *s, struct message *m)
11800 @@ -866,32 +879,50 @@
11801 char *exten = astman_get_header(m, "Exten");
11802 char *context = astman_get_header(m, "Context");
11803 char *priority = astman_get_header(m, "Priority");
11804 + char *uniqueid = astman_get_header(m, "Uniqueid");
11805 + char *uniqueid2 = astman_get_header(m, "ExtraUniqueid");
11806 + char *exten2 = astman_get_header(m, "ExtraExten");
11807 + char *context2 = astman_get_header(m, "ExtraContext");
11808 + char *priority2 = astman_get_header(m, "ExtraPriority");
11809 struct ast_channel *chan, *chan2 = NULL;
11814 - if (ast_strlen_zero(name)) {
11815 - astman_send_error(s, m, "Channel not specified");
11816 + if ((!name || ast_strlen_zero(name)) && (!uniqueid || ast_strlen_zero(uniqueid))) {
11817 + astman_send_error(s, m, "Channel or Uniqueid not specified");
11820 if (!ast_strlen_zero(priority) && (sscanf(priority, "%d", &pi) != 1)) {
11821 astman_send_error(s, m, "Invalid priority\n");
11824 - chan = ast_get_channel_by_name_locked(name);
11825 + if (uniqueid && (!ast_strlen_zero(uniqueid))) {
11826 + chan = ast_get_channel_by_uniqueid_locked(uniqueid);
11828 + chan = ast_get_channel_by_name_locked(name);
11832 snprintf(buf, sizeof(buf), "Channel does not exist: %s", name);
11833 astman_send_error(s, m, buf);
11836 - if (!ast_strlen_zero(name2))
11837 + if (!ast_strlen_zero(uniqueid2)) {
11838 + chan2 = ast_get_channel_by_uniqueid_locked(uniqueid2);
11839 + if (!ast_strlen_zero(priority2) && (sscanf(priority, "%d", &pi2) != 1)) {
11840 + astman_send_error(s, m, "Invalid priority2\n");
11844 + if (!ast_strlen_zero(name2))
11845 chan2 = ast_get_channel_by_name_locked(name2);
11847 res = ast_async_goto(chan, context, exten, pi);
11849 - if (!ast_strlen_zero(name2)) {
11850 + if ((!ast_strlen_zero(name2)) || (!ast_strlen_zero(uniqueid2))){
11852 - res = ast_async_goto(chan2, context, exten, pi);
11853 + res = ast_async_goto(chan2, context2, exten2, pi2);
11857 @@ -937,15 +968,15 @@
11858 struct ast_channel *chan = NULL;
11860 if (!ast_strlen_zero(in->app)) {
11861 - res = ast_pbx_outgoing_app(in->tech, AST_FORMAT_SLINEAR, in->data, in->timeout, in->app, in->appdata, &reason, 1,
11862 + res = ast_pbx_outgoing_app(in->tech, AST_FORMAT_SLINEAR, in->data, in->timeout, in->app, in->appdata, &reason, 1, in->callingpres,
11863 !ast_strlen_zero(in->cid_num) ? in->cid_num : NULL,
11864 !ast_strlen_zero(in->cid_name) ? in->cid_name : NULL,
11865 - in->vars, in->account, &chan);
11866 + in->vars, in->account, &chan, in->uniqueid);
11868 - res = ast_pbx_outgoing_exten(in->tech, AST_FORMAT_SLINEAR, in->data, in->timeout, in->context, in->exten, in->priority, &reason, 1,
11869 + res = ast_pbx_outgoing_exten(in->tech, AST_FORMAT_SLINEAR, in->data, in->timeout, in->context, in->exten, in->priority, &reason, 1, in->callingpres,
11870 !ast_strlen_zero(in->cid_num) ? in->cid_num : NULL,
11871 !ast_strlen_zero(in->cid_name) ? in->cid_name : NULL,
11872 - in->vars, in->account, &chan);
11873 + in->vars, in->account, &chan, in->uniqueid);
11876 manager_event(EVENT_FLAG_CALL,
11877 @@ -956,7 +987,7 @@
11880 "Uniqueid: %s\r\n",
11881 - in->idtext, in->tech, in->data, in->context, in->exten, reason, chan ? chan->uniqueid : "<null>");
11882 + in->idtext, in->tech, in->data, in->context, in->exten, reason, in->uniqueid ? in->uniqueid : (chan ? chan->uniqueid : "<null>"));
11884 manager_event(EVENT_FLAG_CALL,
11885 "OriginateFailure",
11886 @@ -966,7 +997,7 @@
11889 "Uniqueid: %s\r\n",
11890 - in->idtext, in->tech, in->data, in->context, in->exten, reason, chan ? chan->uniqueid : "<null>");
11891 + in->idtext, in->tech, in->data, in->context, in->exten, reason, in->uniqueid ? in->uniqueid : (chan ? chan->uniqueid : "<null>"));
11893 /* Locked by ast_pbx_outgoing_exten or ast_pbx_outgoing_app */
11895 @@ -999,6 +1030,7 @@
11896 char *priority = astman_get_header(m, "Priority");
11897 char *timeout = astman_get_header(m, "Timeout");
11898 char *callerid = astman_get_header(m, "CallerID");
11899 + char *callingpres = astman_get_header(m, "CallingPres");
11900 char *account = astman_get_header(m, "Account");
11901 char *app = astman_get_header(m, "Application");
11902 char *appdata = astman_get_header(m, "Data");
11903 @@ -1007,12 +1039,15 @@
11904 struct ast_variable *vars = astman_get_variables(m);
11906 char *l=NULL, *n=NULL;
11915 + char idText[256] = "";
11918 pthread_attr_t attr;
11919 @@ -1028,6 +1063,10 @@
11920 astman_send_error(s, m, "Invalid timeout\n");
11923 + if (!ast_strlen_zero(callingpres) && (sscanf(callingpres, "%d", &cpresi) != 1)) {
11924 + astman_send_error(s, m, "Invalid CallingPres\n");
11927 ast_copy_string(tmp, name, sizeof(tmp));
11929 data = strchr(tmp, '/');
11930 @@ -1048,6 +1087,7 @@
11931 if (ast_strlen_zero(l))
11934 + uniqueid = ast_alloc_uniqueid();
11935 if (ast_true(async)) {
11936 struct fast_originate_helper *fast = malloc(sizeof(struct fast_originate_helper));
11938 @@ -1068,8 +1108,10 @@
11939 ast_copy_string(fast->context, context, sizeof(fast->context));
11940 ast_copy_string(fast->exten, exten, sizeof(fast->exten));
11941 ast_copy_string(fast->account, account, sizeof(fast->account));
11942 + ast_copy_string(fast->uniqueid, uniqueid, sizeof(fast->uniqueid));
11943 fast->timeout = to;
11944 fast->priority = pi;
11945 + fast->callingpres = cpresi;
11946 pthread_attr_init(&attr);
11947 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
11948 if (ast_pthread_create(&th, &attr, fast_originate, fast)) {
11949 @@ -1079,19 +1121,28 @@
11952 } else if (!ast_strlen_zero(app)) {
11953 - res = ast_pbx_outgoing_app(tech, AST_FORMAT_SLINEAR, data, to, app, appdata, &reason, 1, l, n, vars, account, NULL);
11954 + res = ast_pbx_outgoing_app(tech, AST_FORMAT_SLINEAR, data, to, app, appdata, &reason, 1, cpresi, l, n, vars, account, NULL, uniqueid);
11956 if (exten && context && pi)
11957 - res = ast_pbx_outgoing_exten(tech, AST_FORMAT_SLINEAR, data, to, context, exten, pi, &reason, 1, l, n, vars, account, NULL);
11958 + res = ast_pbx_outgoing_exten(tech, AST_FORMAT_SLINEAR, data, to, context, exten, pi, &reason, 1, cpresi, l, n, vars, account, NULL, uniqueid);
11960 astman_send_error(s, m, "Originate with 'Exten' requires 'Context' and 'Priority'");
11965 - astman_send_ack(s, m, "Originate successfully queued");
11968 + if (id && !ast_strlen_zero(id)) {
11969 + snprintf(idText,256,"ActionID: %s\r\n",id);
11971 + ast_cli(s->fd, "Response: Success\r\n"
11973 + "Message: Originate successfully queued\r\n"
11974 + "Uniqueid: %s\r\n"
11976 + idText, uniqueid);
11978 astman_send_error(s, m, "Originate failed");
11983 @@ -1565,10 +1616,10 @@
11987 -static int manager_state_cb(char *context, char *exten, int state, void *data)
11988 +static int manager_state_cb(char *context, char *exten, int state, void *data, char *cid_num, char *cid_name)
11990 /* Notify managers of change */
11991 - manager_event(EVENT_FLAG_CALL, "ExtensionStatus", "Exten: %s\r\nContext: %s\r\nStatus: %d\r\n", exten, context, state);
11992 + manager_event(EVENT_FLAG_CALL, "ExtensionStatus", "Exten: %s\r\nContext: %s\r\nStatus: %d\r\nCallerID: \"%s\" <%s>\r\n", exten, context, state, cid_num, cid_name);
11996 diff -urN asterisk-1.2.7.1.orig/pbx/pbx_spool.c asterisk-1.2.7.1/pbx/pbx_spool.c
11997 --- asterisk-1.2.7.1.orig/pbx/pbx_spool.c 2006-02-11 19:15:00.000000000 +0100
11998 +++ asterisk-1.2.7.1/pbx/pbx_spool.c 2006-04-18 14:39:28.000000000 +0200
11999 @@ -259,11 +259,11 @@
12000 if (!ast_strlen_zero(o->app)) {
12001 if (option_verbose > 2)
12002 ast_verbose(VERBOSE_PREFIX_3 "Attempting call on %s/%s for application %s(%s) (Retry %d)\n", o->tech, o->dest, o->app, o->data, o->retries);
12003 - res = ast_pbx_outgoing_app(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->app, o->data, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, o->account, NULL);
12004 + res = ast_pbx_outgoing_app(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->app, o->data, &reason, 2 /* wait to finish */, 0, o->cid_num, o->cid_name, o->vars, o->account, NULL, NULL);
12006 if (option_verbose > 2)
12007 ast_verbose(VERBOSE_PREFIX_3 "Attempting call on %s/%s for %s@%s:%d (Retry %d)\n", o->tech, o->dest, o->exten, o->context,o->priority, o->retries);
12008 - res = ast_pbx_outgoing_exten(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->context, o->exten, o->priority, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, o->account, NULL);
12009 + res = ast_pbx_outgoing_exten(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->context, o->exten, o->priority, &reason, 2 /* wait to finish */, 0, o->cid_num, o->cid_name, o->vars, o->account, NULL, NULL);
12012 ast_log(LOG_NOTICE, "Call failed to go through, reason %d\n", reason);
12013 diff -urN asterisk-1.2.7.1.orig/pbx.c asterisk-1.2.7.1/pbx.c
12014 --- asterisk-1.2.7.1.orig/pbx.c 2006-04-13 17:56:35.000000000 +0200
12015 +++ asterisk-1.2.7.1/pbx.c 2006-04-18 14:39:28.000000000 +0200
12016 @@ -353,7 +353,8 @@
12018 { "Hangup", pbx_builtin_hangup,
12019 "Hang up the calling channel",
12020 - " Hangup(): This application will hang up the calling channel.\n"
12021 + " Hangup(Cause): Unconditionally hangs up a given channel by returning -1 always.\n"
12022 + " If cause is given, it will set the hangup cause accordingly.\n"
12025 { "NoOp", pbx_builtin_noop,
12026 @@ -1880,7 +1881,7 @@
12027 return ast_extension_state2(e); /* Check all devices in the hint */
12030 -void ast_hint_state_changed(const char *device)
12031 +void ast_hint_state_changed(const char *device, char *cid_num, char *cid_name)
12033 struct ast_hint *hint;
12034 struct ast_state_cb *cblist;
12035 @@ -1908,11 +1909,11 @@
12037 /* For general callbacks */
12038 for (cblist = statecbs; cblist; cblist = cblist->next)
12039 - cblist->callback(hint->exten->parent->name, hint->exten->exten, state, cblist->data);
12040 + cblist->callback(hint->exten->parent->name, hint->exten->exten, state, cblist->data, cid_num, cid_name);
12042 /* For extension callbacks */
12043 for (cblist = hint->callbacks; cblist; cblist = cblist->next)
12044 - cblist->callback(hint->exten->parent->name, hint->exten->exten, state, cblist->data);
12045 + cblist->callback(hint->exten->parent->name, hint->exten->exten, state, cblist->data, cid_num, cid_name);
12047 hint->laststate = state;
12049 @@ -2153,7 +2154,7 @@
12050 /* Notify with -1 and remove all callbacks */
12052 cblist = cblist->next;
12053 - cbprev->callback(list->exten->parent->name, list->exten->exten, AST_EXTENSION_DEACTIVATED, cbprev->data);
12054 + cbprev->callback(list->exten->parent->name, list->exten->exten, AST_EXTENSION_DEACTIVATED, cbprev->data, NULL, NULL);
12057 list->callbacks = NULL;
12058 @@ -3774,7 +3775,7 @@
12061 thiscb = thiscb->next;
12062 - prevcb->callback(this->context, this->exten, AST_EXTENSION_REMOVED, prevcb->data);
12063 + prevcb->callback(this->context, this->exten, AST_EXTENSION_REMOVED, prevcb->data, NULL, NULL);
12067 @@ -4976,7 +4977,7 @@
12068 return 0; /* success */
12071 -int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **channel)
12072 +int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, int callingpres, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **channel, char *uniqueid)
12074 struct ast_channel *chan;
12075 struct async_stat *as;
12076 @@ -4986,7 +4987,7 @@
12080 - chan = __ast_request_and_dial(type, format, data, timeout, reason, cid_num, cid_name, &oh);
12081 + chan = __ast_request_and_dial(type, format, data, timeout, reason, callingpres, cid_num, cid_name, &oh, uniqueid);
12085 @@ -5088,7 +5089,7 @@
12086 goto outgoing_exten_cleanup;
12088 memset(as, 0, sizeof(struct async_stat));
12089 - chan = ast_request_and_dial(type, format, data, timeout, reason, cid_num, cid_name);
12090 + chan = ast_request_and_dial(type, format, data, timeout, reason, callingpres, cid_num, cid_name, uniqueid);
12094 @@ -5134,7 +5135,7 @@
12098 -static void *ast_pbx_run_app(void *data)
12099 +void *ast_pbx_run_app(void *data)
12101 struct app_tmp *tmp = data;
12102 struct ast_app *app;
12103 @@ -5150,7 +5151,7 @@
12107 -int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel)
12108 +int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, int callingpres, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, char *uniqueid)
12110 struct ast_channel *chan;
12111 struct async_stat *as;
12112 @@ -5170,7 +5171,7 @@
12113 goto outgoing_app_cleanup;
12116 - chan = __ast_request_and_dial(type, format, data, timeout, reason, cid_num, cid_name, &oh);
12117 + chan = __ast_request_and_dial(type, format, data, timeout, reason, callingpres, cid_num, cid_name, &oh, uniqueid);
12119 if (chan->cdr) { /* check if the channel already has a cdr record, if not give it one */
12120 ast_log(LOG_WARNING, "%s already has a call record??\n", chan->name);
12121 @@ -5257,7 +5258,8 @@
12122 goto outgoing_app_cleanup;
12124 memset(as, 0, sizeof(struct async_stat));
12125 - chan = __ast_request_and_dial(type, format, data, timeout, reason, cid_num, cid_name, &oh);
12126 + chan = __ast_request_and_dial(type, format, data, timeout, reason, callingpres, cid_num, cid_name, &oh, uniqueid);
12127 +// chan = ast_request_and_dial(type, format, data, timeout, reason, callingpres, cid_num, cid_name, uniqueid);
12131 @@ -5544,6 +5546,9 @@
12133 static int pbx_builtin_hangup(struct ast_channel *chan, void *data)
12135 + /* Copy the hangup cause as specified */
12137 + chan->hangupcause = atoi(data);
12138 /* Just return non-zero and it will hang up */
12139 if (!chan->hangupcause)
12140 chan->hangupcause = AST_CAUSE_NORMAL_CLEARING;
12141 @@ -6200,6 +6205,9 @@
12145 + if (chan->_state != AST_STATE_UP) {
12146 + ast_answer(chan);
12148 return res = ast_say_number(chan, atoi((char *) tmp), "", chan->language, options);
12151 @@ -6207,8 +6215,12 @@
12157 + if (chan->_state != AST_STATE_UP) {
12158 + ast_answer(chan);
12160 res = ast_say_digit_str(chan, (char *)data, "", chan->language);
12165 @@ -6216,8 +6228,12 @@
12171 + if (chan->_state != AST_STATE_UP) {
12172 + ast_answer(chan);
12174 res = ast_say_character_str(chan, (char *)data, "", chan->language);
12179 @@ -6225,8 +6241,12 @@
12185 + if (chan->_state != AST_STATE_UP) {
12186 + ast_answer(chan);
12188 res = ast_say_phonetic_str(chan, (char *)data, "", chan->language);
12193 diff -urN asterisk-1.2.7.1.orig/res/Makefile asterisk-1.2.7.1/res/Makefile
12194 --- asterisk-1.2.7.1.orig/res/Makefile 2005-11-29 19:24:39.000000000 +0100
12195 +++ asterisk-1.2.7.1/res/Makefile 2006-04-18 14:39:28.000000000 +0200
12197 # the GNU General Public License
12200 -MODS=res_indications.so res_monitor.so res_adsi.so res_agi.so res_features.so
12201 +MODS=res_indications.so res_monitor.so res_adsi.so res_agi.so res_features.so res_watchdog.so
12203 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/odbcinst.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/odbcinst.h),)
12204 ifneq (${OSARCH},FreeBSD)
12205 diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
12206 --- asterisk-1.2.7.1.orig/res/res_agi.c 2006-02-28 19:31:04.000000000 +0100
12207 +++ asterisk-1.2.7.1/res/res_agi.c 2006-04-18 14:39:28.000000000 +0200
12209 * the project provides a web site, mailing lists and IRC
12210 * channels for your use.
12212 + * Copyright (C) 2005 Junghanns.NET GmbH
12213 + * Klaus-Peter Junghanns <kpj@junghanns.net>
12215 * This program is free software, distributed under the terms of
12216 * the GNU General Public License Version 2. See the LICENSE file
12217 * at the top of the source tree.
12218 @@ -74,16 +77,19 @@
12220 static char *app = "AGI";
12222 +static char *xapp = "XAGI";
12224 static char *eapp = "EAGI";
12226 static char *deadapp = "DeadAGI";
12228 static char *synopsis = "Executes an AGI compliant application";
12229 +static char *xsynopsis = "Executes an XAGI compliant application";
12230 static char *esynopsis = "Executes an EAGI compliant application";
12231 static char *deadsynopsis = "Executes AGI on a hungup channel";
12233 static char *descrip =
12234 -" [E|Dead]AGI(command|args): Executes an Asterisk Gateway Interface compliant\n"
12235 +" [E|Dead|X]AGI(command|args): Executes an Asterisk Gateway Interface compliant\n"
12236 "program on a channel. AGI allows Asterisk to launch external programs\n"
12237 "written in any language to control a telephony channel, play audio,\n"
12238 "read DTMF digits, etc. by communicating with the AGI protocol on stdin\n"
12240 " hangup, or 0 on non-hangup exit. \n"
12241 "Using 'EAGI' provides enhanced AGI, with incoming audio available out of band\n"
12242 "on file descriptor 3\n\n"
12243 +"Using 'XAGI' provides enhanced AGI, with incoming audio available out of band"
12244 +" on file descriptor 3 and outgoing audio available out of band on file descriptor 4\n\n"
12245 "Use the CLI command 'show agi' to list available agi commands\n";
12247 static int agidebug = 0;
12248 @@ -220,13 +228,14 @@
12252 -static int launch_script(char *script, char *argv[], int *fds, int *efd, int *opid)
12253 +static int launch_script(char *script, char *argv[], int *fds, int *efd, int *efd2, int *opid)
12263 sigset_t signal_set;
12264 @@ -271,6 +280,33 @@
12269 + if (pipe(audio2)) {
12270 + ast_log(LOG_WARNING, "unable to create audio pipe: %s\n", strerror(errno));
12271 + close(fromast[0]);
12272 + close(fromast[1]);
12279 + res = fcntl(audio2[0], F_GETFL);
12281 + res = fcntl(audio2[0], F_SETFL, res | O_NONBLOCK);
12283 + ast_log(LOG_WARNING, "unable to set audio pipe parameters: %s\n", strerror(errno));
12284 + close(fromast[0]);
12285 + close(fromast[1]);
12290 + close(audio2[0]);
12291 + close(audio2[1]);
12297 ast_log(LOG_WARNING, "Failed to fork(): %s\n", strerror(errno));
12298 @@ -285,15 +321,19 @@
12300 close(STDERR_FILENO + 1);
12303 + dup2(audio2[1], STDERR_FILENO + 2);
12305 + close(STDERR_FILENO + 2);
12308 /* unblock important signal handlers */
12309 if (sigfillset(&signal_set) || pthread_sigmask(SIG_UNBLOCK, &signal_set, NULL)) {
12310 ast_log(LOG_WARNING, "unable to unblock signals for AGI script: %s\n", strerror(errno));
12314 /* Close everything but stdin/out/error */
12315 - for (x=STDERR_FILENO + 2;x<1024;x++)
12316 + for (x=STDERR_FILENO + 3;x<1024;x++)
12319 /* Don't run AGI scripts with realtime priority -- it causes audio stutter */
12320 @@ -312,6 +352,9 @@
12325 + *efd2 = audio2[0];
12327 /* close what we're not using in the parent */
12330 @@ -320,6 +363,9 @@
12331 /* [PHM 12/18/03] */
12335 + close(audio2[1]);
12340 @@ -350,7 +396,7 @@
12341 fdprintf(fd, "agi_context: %s\n", chan->context);
12342 fdprintf(fd, "agi_extension: %s\n", chan->exten);
12343 fdprintf(fd, "agi_priority: %d\n", chan->priority);
12344 - fdprintf(fd, "agi_enhanced: %s\n", enhanced ? "1.0" : "0.0");
12345 + fdprintf(fd, "agi_enhanced: %d%s\n", enhanced, ".0");
12347 /* User information */
12348 fdprintf(fd, "agi_accountcode: %s\n", chan->accountcode ? chan->accountcode : "");
12349 @@ -382,7 +428,7 @@
12350 return RESULT_SHOWUSAGE;
12351 if (sscanf(argv[3], "%d", &to) != 1)
12352 return RESULT_SHOWUSAGE;
12353 - res = ast_waitfordigit_full(chan, to, agi->audio, agi->ctrl);
12354 + res = ast_waitfordigit_full(chan, to, agi->audio_out, agi->ctrl);
12355 fdprintf(agi->fd, "200 result=%d\n", res);
12357 return RESULT_SUCCESS;
12358 @@ -558,7 +604,7 @@
12360 return RESULT_FAILURE;
12362 - res = ast_waitstream_full(chan, argv[3], agi->audio, agi->ctrl);
12363 + res = ast_waitstream_full(chan, argv[3], agi->audio_out, agi->ctrl);
12364 /* this is to check for if ast_waitstream closed the stream, we probably are at
12365 * the end of the stream, return that amount, else check for the amount */
12366 sample_offset = (chan->stream) ? ast_tellstream(fs) : max_length;
12367 @@ -618,7 +664,7 @@
12369 return RESULT_FAILURE;
12371 - res = ast_waitstream_full(chan, argv[3], agi->audio, agi->ctrl);
12372 + res = ast_waitstream_full(chan, argv[3], agi->audio_out, agi->ctrl);
12373 /* this is to check for if ast_waitstream closed the stream, we probably are at
12374 * the end of the stream, return that amount, else check for the amount */
12375 sample_offset = (chan->stream)?ast_tellstream(fs):max_length;
12376 @@ -630,7 +676,7 @@
12378 /* If the user didnt press a key, wait for digitTimeout*/
12380 - res = ast_waitfordigit_full(chan, timeout, agi->audio, agi->ctrl);
12381 + res = ast_waitfordigit_full(chan, timeout, agi->audio_out, agi->ctrl);
12382 /* Make sure the new result is in the escape digits of the GET OPTION */
12383 if ( !strchr(edigits,res) )
12385 @@ -657,7 +703,7 @@
12386 return RESULT_SHOWUSAGE;
12387 if (sscanf(argv[2], "%d", &num) != 1)
12388 return RESULT_SHOWUSAGE;
12389 - res = ast_say_number_full(chan, num, argv[3], chan->language, (char *) NULL, agi->audio, agi->ctrl);
12390 + res = ast_say_number_full(chan, num, argv[3], chan->language, (char *) NULL, agi->audio_out, agi->ctrl);
12392 return RESULT_SUCCESS;
12393 fdprintf(agi->fd, "200 result=%d\n", res);
12394 @@ -677,7 +723,7 @@
12395 if (sscanf(argv[2], "%d", &num) != 1)
12396 return RESULT_SHOWUSAGE;
12398 - res = ast_say_digit_str_full(chan, argv[2], argv[3], chan->language, agi->audio, agi->ctrl);
12399 + res = ast_say_digit_str_full(chan, argv[2], argv[3], chan->language, agi->audio_out, agi->ctrl);
12400 if (res == 1) /* New command */
12401 return RESULT_SUCCESS;
12402 fdprintf(agi->fd, "200 result=%d\n", res);
12403 @@ -694,7 +740,7 @@
12405 return RESULT_SHOWUSAGE;
12407 - res = ast_say_character_str_full(chan, argv[2], argv[3], chan->language, agi->audio, agi->ctrl);
12408 + res = ast_say_character_str_full(chan, argv[2], argv[3], chan->language, agi->audio_out, agi->ctrl);
12409 if (res == 1) /* New command */
12410 return RESULT_SUCCESS;
12411 fdprintf(agi->fd, "200 result=%d\n", res);
12412 @@ -784,7 +830,7 @@
12414 return RESULT_SHOWUSAGE;
12416 - res = ast_say_phonetic_str_full(chan, argv[2], argv[3], chan->language, agi->audio, agi->ctrl);
12417 + res = ast_say_phonetic_str_full(chan, argv[2], argv[3], chan->language, agi->audio_out, agi->ctrl);
12418 if (res == 1) /* New command */
12419 return RESULT_SUCCESS;
12420 fdprintf(agi->fd, "200 result=%d\n", res);
12421 @@ -811,7 +857,7 @@
12422 max = atoi(argv[4]);
12425 - res = ast_app_getdata_full(chan, argv[2], data, max, timeout, agi->audio, agi->ctrl);
12426 + res = ast_app_getdata_full(chan, argv[2], data, max, timeout, agi->audio_out, agi->ctrl);
12427 if (res == 2) /* New command */
12428 return RESULT_SUCCESS;
12430 @@ -1849,7 +1895,12 @@
12432 int returnstatus = 0;
12433 struct ast_frame *f;
12434 + struct ast_frame fr;
12436 + char audiobuf[2048];
12439 + int enhanced = 0;
12441 /* how many times we'll retry if ast_waitfor_nandfs will return without either
12442 channel or file descriptor in case select is interrupted by a system call (EINTR) */
12443 @@ -1863,10 +1914,22 @@
12447 - setup_env(chan, request, agi->fd, (agi->audio > -1));
12448 + if (agi->audio_out > -1) {
12451 + if (agi->audio_in > -1) {
12454 + setup_env(chan, request, agi->fd, enhanced);
12455 + fds[0] = agi->ctrl;
12456 + fds[1] = agi->audio_in;
12459 - c = ast_waitfor_nandfds(&chan, dead ? 0 : 1, &agi->ctrl, 1, NULL, &outfd, &ms);
12460 + if (agi->audio_in > -1) {
12461 + c = ast_waitfor_nandfds(&chan, dead ? 0 : 1, fds, 2, NULL, &outfd, &ms);
12463 + c = ast_waitfor_nandfds(&chan, dead ? 0 : 1, &agi->ctrl, 1, NULL, &outfd, &ms);
12467 /* Idle the channel until we get a command */
12468 @@ -1877,13 +1940,24 @@
12471 /* If it's voice, write it to the audio pipe */
12472 - if ((agi->audio > -1) && (f->frametype == AST_FRAME_VOICE)) {
12473 + if ((agi->audio_out > -1) && (f->frametype == AST_FRAME_VOICE)) {
12474 /* Write, ignoring errors */
12475 - write(agi->audio, f->data, f->datalen);
12476 + write(agi->audio_out, f->data, f->datalen);
12480 } else if (outfd > -1) {
12481 + if ((agi->audio_in > -1) && (outfd == agi->audio_in)) {
12482 + audiobytes = read(agi->audio_in, audiobuf, sizeof(audiobuf));
12483 + if (audiobytes > 0) {
12484 + // ast_log(LOG_NOTICE, "read %d bytes of audio\n", audiobytes);
12485 + fr.frametype = AST_FRAME_VOICE;
12486 + fr.subclass = AST_FORMAT_SLINEAR;
12487 + fr.datalen = audiobytes;
12488 + fr.data = audiobuf;
12489 + ast_write(chan, &fr);
12493 if (!fgets(buf, sizeof(buf), readf)) {
12494 /* Program terminated */
12495 @@ -1905,6 +1979,7 @@
12496 if ((returnstatus < 0) || (returnstatus == AST_PBX_KEEPALIVE)) {
12501 if (--retry <= 0) {
12502 ast_log(LOG_WARNING, "No channel, no fd?\n");
12503 @@ -2011,6 +2086,7 @@
12511 @@ -2036,15 +2112,18 @@
12515 - res = launch_script(argv[0], argv, fds, enhanced ? &efd : NULL, &pid);
12516 + res = launch_script(argv[0], argv, fds, enhanced ? &efd : NULL, (enhanced == 2) ? &efd2 : NULL, &pid);
12521 + agi.audio_out = efd;
12522 + agi.audio_in = efd2;
12523 res = run_agi(chan, argv[0], &agi, pid, dead);
12530 LOCAL_USER_REMOVE(u);
12532 @@ -2078,6 +2157,35 @@
12536 +static int xagi_exec(struct ast_channel *chan, void *data)
12538 + int readformat, writeformat;
12541 + if (chan->_softhangup)
12542 + ast_log(LOG_WARNING, "If you want to run AGI on hungup channels you should use DeadAGI!\n");
12543 + readformat = chan->readformat;
12544 + if (ast_set_read_format(chan, AST_FORMAT_SLINEAR)) {
12545 + ast_log(LOG_WARNING, "Unable to set channel '%s' to linear mode\n", chan->name);
12548 + writeformat = chan->writeformat;
12549 + if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) {
12550 + ast_log(LOG_WARNING, "Unable to set channel '%s' to linear mode\n", chan->name);
12553 + res = agi_exec_full(chan, data, 2, 0);
12555 + if (ast_set_read_format(chan, readformat)) {
12556 + ast_log(LOG_WARNING, "Unable to restore channel '%s' to format %s\n", chan->name, ast_getformatname(readformat));
12558 + if (ast_set_write_format(chan, writeformat)) {
12559 + ast_log(LOG_WARNING, "Unable to restore channel '%s' to format %s\n", chan->name, ast_getformatname(writeformat));
12565 static int deadagi_exec(struct ast_channel *chan, void *data)
12567 return agi_exec_full(chan, data, 0, 1);
12568 @@ -2107,6 +2215,7 @@
12569 ast_cli_unregister(&dumpagihtml);
12570 ast_cli_unregister(&cli_debug);
12571 ast_cli_unregister(&cli_no_debug);
12572 + ast_unregister_application(xapp);
12573 ast_unregister_application(eapp);
12574 ast_unregister_application(deadapp);
12575 return ast_unregister_application(app);
12576 @@ -2120,6 +2229,7 @@
12577 ast_cli_register(&cli_no_debug);
12578 ast_register_application(deadapp, deadagi_exec, deadsynopsis, descrip);
12579 ast_register_application(eapp, eagi_exec, esynopsis, descrip);
12580 + ast_register_application(xapp, xagi_exec, xsynopsis, descrip);
12581 return ast_register_application(app, agi_exec, synopsis, descrip);
12584 diff -urN asterisk-1.2.7.1.orig/res/res_features.c asterisk-1.2.7.1/res/res_features.c
12585 --- asterisk-1.2.7.1.orig/res/res_features.c 2006-04-10 19:29:51.000000000 +0200
12586 +++ asterisk-1.2.7.1/res/res_features.c 2006-04-18 14:39:28.000000000 +0200
12588 * the project provides a web site, mailing lists and IRC
12589 * channels for your use.
12591 + * Copyright (C) 2004, Junghanns.NET GmbH
12593 + * Klaus-Peter Junghanns <kpj@junghanns.net>
12595 * This program is free software, distributed under the terms of
12596 * the GNU General Public License Version 2. See the LICENSE file
12597 * at the top of the source tree.
12599 #include "asterisk/utils.h"
12600 #include "asterisk/adsi.h"
12601 #include "asterisk/monitor.h"
12602 +#include "asterisk/indications.h"
12604 #ifdef __AST_DEBUG_MALLOC
12605 static void FREE(void *ptr)
12607 #define AST_MAX_WATCHERS 256
12609 static char *parkedcall = "ParkedCall";
12610 +static char *holdedcall = "HoldedCall";
12612 /* No more than 45 seconds parked before you do something with them */
12613 static int parkingtime = DEFAULT_PARK_TIME;
12614 @@ -132,6 +138,20 @@
12615 "into the dialplan, although you should include the 'parkedcalls'\n"
12618 +static char *autoanswerlogin = "AutoanswerLogin";
12620 +static char *synopsis3 = "Log in for autoanswer";
12622 +static char *descrip3 = "AutoanswerLogin(exten):"
12623 +"Used to login to the autoanswer application for an extension.\n";
12625 +static char *autoanswer = "Autoanswer";
12627 +static char *synopsis4 = "Autoanswer a call";
12629 +static char *descrip4 = "Autoanswer(exten):"
12630 +"Used to autoanswer a call for an extension.\n";
12632 static struct ast_app *monitor_app=NULL;
12633 static int monitor_ok=1;
12635 @@ -150,12 +170,51 @@
12636 struct parkeduser *next;
12639 +struct holdeduser {
12640 + struct ast_channel *chan;
12641 + struct timeval start;
12645 + /* Where to go if our parking time expires */
12646 + char context[AST_MAX_EXTENSION];
12647 + char exten[AST_MAX_EXTENSION];
12650 + char uniqueid[AST_MAX_UNIQUEID];
12651 + char uniqueidpeer[AST_MAX_UNIQUEID];
12652 + struct holdeduser *next;
12655 +/* auto answer user */
12657 + struct ast_channel *chan;
12658 + struct timeval start;
12659 + /* waiting on this extension/context */
12660 + char exten[AST_MAX_EXTENSION];
12661 + char context[AST_MAX_EXTENSION];
12664 + struct aauser *next;
12668 +static struct aauser *aalot;
12669 +AST_MUTEX_DEFINE_STATIC(autoanswer_lock);
12670 +static pthread_t autoanswer_thread;
12672 static struct parkeduser *parkinglot;
12674 +static struct holdeduser *holdlist;
12676 AST_MUTEX_DEFINE_STATIC(parking_lock);
12678 +AST_MUTEX_DEFINE_STATIC(holding_lock);
12680 static pthread_t parking_thread;
12682 +static pthread_t holding_thread;
12684 STANDARD_LOCAL_USER;
12687 @@ -165,6 +224,12 @@
12688 return parking_ext;
12691 +char *ast_parking_con(void)
12693 + return parking_con;
12697 char *ast_pickup_ext(void)
12700 @@ -362,10 +427,11 @@
12703 "CallerIDName: %s\r\n"
12704 + "Unqiueid: %s\r\n\r\n"
12705 ,pu->parkingnum, pu->chan->name, peer ? peer->name : ""
12706 ,(long)pu->start.tv_sec + (long)(pu->parkingtime/1000) - (long)time(NULL)
12707 ,(pu->chan->cid.cid_num ? pu->chan->cid.cid_num : "<unknown>")
12708 - ,(pu->chan->cid.cid_name ? pu->chan->cid.cid_name : "<unknown>")
12709 + ,(pu->chan->cid.cid_name ? pu->chan->cid.cid_name : "<unknown>"), pu->chan->uniqueid
12713 @@ -418,7 +484,8 @@
12714 ast_copy_string(chan->context, rchan->context, sizeof(chan->context));
12715 ast_copy_string(chan->exten, rchan->exten, sizeof(chan->exten));
12716 chan->priority = rchan->priority;
12718 + /* might be dirty but we want trackable channels */
12719 + strncpy(chan->uniqueid, rchan->uniqueid, sizeof(chan->uniqueid) - 1);
12720 /* Make the masq execute */
12721 f = ast_read(chan);
12723 @@ -906,7 +973,7 @@
12726 /* find a feature by name */
12727 -static struct ast_call_feature *find_feature(char *name)
12728 +struct ast_call_feature *ast_find_feature(char *name)
12730 struct ast_call_feature *tmp;
12732 @@ -916,10 +983,21 @@
12735 AST_LIST_UNLOCK(&feature_list);
12740 +struct ast_call_feature *ast_find_builtin_feature(char *name)
12744 + for (x = 0; x < FEATURES_COUNT; x++) {
12745 + if (!strcasecmp(name, builtin_features[x].sname)) {
12746 + return &builtin_features[x];
12752 /* exec an app by feature */
12753 static int feature_exec_app(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, char *code, int sense)
12755 @@ -1014,7 +1092,7 @@
12758 while ((tok = strsep(&tmp, "#")) != NULL) {
12759 - feature = find_feature(tok);
12760 + feature = ast_find_feature(tok);
12763 /* Feature is up for consideration */
12764 @@ -1064,7 +1142,7 @@
12766 /* while we have a feature */
12767 while (NULL != (tok = strsep(&tmp, "#"))) {
12768 - if ((feature = find_feature(tok))) {
12769 + if ((feature = ast_find_feature(tok))) {
12770 if (ast_test_flag(feature, AST_FEATURE_FLAG_NEEDSDTMF)) {
12771 if (ast_test_flag(feature, AST_FEATURE_FLAG_CALLER))
12772 ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_0);
12773 @@ -1089,7 +1167,7 @@
12774 struct ast_frame *f = NULL;
12775 int res = 0, ready = 0;
12777 - if ((chan = ast_request(type, format, data, &cause))) {
12778 + if ((chan = ast_request(type, format, data, &cause, NULL))) {
12779 ast_set_callerid(chan, cid_num, cid_name, cid_num);
12780 ast_channel_inherit_variables(caller, chan);
12781 if (!ast_call(chan, data, timeout)) {
12782 @@ -1541,9 +1619,10 @@
12785 "CallerIDName: %s\r\n"
12786 + "Uniqueid: %s\r\n\r\n"
12787 ,pu->parkingnum, pu->chan->name
12788 ,(pu->chan->cid.cid_num ? pu->chan->cid.cid_num : "<unknown>")
12789 - ,(pu->chan->cid.cid_name ? pu->chan->cid.cid_name : "<unknown>")
12790 + ,(pu->chan->cid.cid_name ? pu->chan->cid.cid_name : "<unknown>"), pu->chan->uniqueid
12793 if (option_verbose > 1)
12794 @@ -1586,9 +1665,10 @@
12797 "CallerIDName: %s\r\n"
12798 + "Uniqueid: %s\r\n\r\n"
12799 ,pu->parkingnum, pu->chan->name
12800 ,(pu->chan->cid.cid_num ? pu->chan->cid.cid_num : "<unknown>")
12801 - ,(pu->chan->cid.cid_name ? pu->chan->cid.cid_name : "<unknown>")
12802 + ,(pu->chan->cid.cid_name ? pu->chan->cid.cid_name : "<unknown>"), pu->chan->uniqueid
12805 /* There's a problem, hang them up*/
12806 @@ -1675,6 +1755,280 @@
12810 +int ast_hold_call(struct ast_channel *chan, struct ast_channel *peer)
12812 + /* We put the user in the parking list, then wake up the parking thread to be sure it looks
12813 + after these channels too */
12814 + struct holdeduser *pu;
12815 + pu = malloc(sizeof(struct holdeduser));
12817 + memset(pu, 0, sizeof(pu));
12818 + ast_mutex_lock(&holding_lock);
12819 + chan->appl = "Holded Call";
12820 + chan->data = NULL;
12823 + strncpy(pu->uniqueid, chan->uniqueid, sizeof(pu->uniqueid));
12824 + strncpy(pu->uniqueidpeer, peer->uniqueid, sizeof(pu->uniqueidpeer));
12825 + /* Start music on hold */
12826 + ast_moh_start(pu->chan, NULL);
12827 + gettimeofday(&pu->start, NULL);
12828 + pu->next = holdlist;
12830 + ast_mutex_unlock(&holding_lock);
12831 + /* Wake up the (presumably select()ing) thread */
12832 + pthread_kill(holding_thread, SIGURG);
12834 + manager_event(EVENT_FLAG_CALL, "HoldedCall",
12835 + "Channel1: %s\r\n"
12836 + "Channel2: %s\r\n"
12837 + "Uniqueid1: %s\r\n"
12838 + "Uniqueid2: %s\r\n"
12839 + ,pu->chan->name, peer->name, pu->chan->uniqueid, peer->uniqueid);
12842 + ast_log(LOG_WARNING, "Out of memory\n");
12848 +int ast_masq_hold_call(struct ast_channel *rchan, struct ast_channel *peer)
12850 + struct ast_channel *chan;
12851 + struct ast_frame *f;
12852 + /* Make a new, fake channel that we'll use to masquerade in the real one */
12853 + chan = ast_channel_alloc(0);
12855 + /* Let us keep track of the channel name */
12856 + snprintf(chan->name, sizeof (chan->name), "Onhold/%s",rchan->name);
12857 + /* Make formats okay */
12858 + chan->readformat = rchan->readformat;
12859 + chan->writeformat = rchan->writeformat;
12860 + ast_channel_masquerade(chan, rchan);
12861 + /* Setup the extensions and such */
12862 + strncpy(chan->context, rchan->context, sizeof(chan->context) - 1);
12863 + strncpy(chan->exten, rchan->exten, sizeof(chan->exten) - 1);
12864 + chan->priority = rchan->priority;
12865 + /* this might be dirty, but we need to preserve the uniqueid */
12866 + strncpy(chan->uniqueid, rchan->uniqueid, sizeof(chan->uniqueid) - 1);
12867 + /* Make the masq execute */
12868 + f = ast_read(chan);
12871 + ast_hold_call(chan, peer);
12874 + ast_log(LOG_WARNING, "Unable to create holded channel\n");
12880 +int ast_retrieve_call(struct ast_channel *chan, char *uniqueid)
12882 + int res=-1, dres=-1;
12883 + struct ast_channel *peer=NULL;
12884 + struct ast_bridge_config config;
12886 + peer = ast_get_holded_call(uniqueid);
12888 + /* JK02: it helps to answer the channel if not already up */
12889 + if (chan->_state != AST_STATE_UP) {
12890 + ast_answer(chan);
12894 + ast_mutex_unlock(&peer->lock);
12895 + ast_moh_stop(peer);
12896 + res = ast_channel_make_compatible(chan, peer);
12898 + ast_log(LOG_WARNING, "Could not make channels %s and %s compatible for bridge\n", chan->name, peer->name);
12899 + ast_hangup(peer);
12902 + /* This runs sorta backwards, since we give the incoming channel control, as if it
12903 + were the person called. */
12904 + if (option_verbose > 2)
12905 + ast_verbose(VERBOSE_PREFIX_3 "Channel %s connected to holded call %s\n", chan->name, peer->name);
12907 + memset(&config,0,sizeof(struct ast_bridge_config));
12908 + ast_set_flag(&(config.features_callee), AST_FEATURE_REDIRECT);
12909 + ast_set_flag(&(config.features_caller), AST_FEATURE_REDIRECT);
12910 + config.timelimit = 0;
12911 + config.play_warning = 0;
12912 + config.warning_freq = 0;
12913 + config.warning_sound=NULL;
12914 + res = ast_bridge_call(chan,peer,&config);
12916 + /* Simulate the PBX hanging up */
12917 + if (res != AST_PBX_NO_HANGUP_PEER)
12918 + ast_hangup(peer);
12921 + /* XXX Play a message XXX */
12922 + dres = ast_streamfile(chan, "pbx-invalidpark", chan->language);
12924 + dres = ast_waitstream(chan, "");
12926 + ast_log(LOG_WARNING, "ast_streamfile of %s failed on %s\n", "pbx-invalidpark", chan->name);
12933 +int ast_retrieve_call_to_death(char *uniqueid)
12936 + struct ast_channel *peer=NULL;
12938 + peer = ast_get_holded_call(uniqueid);
12942 + if (option_verbose > 2)
12943 + ast_verbose(VERBOSE_PREFIX_3 "Channel %s removed from hold.\n", peer->name);
12944 + ast_mutex_unlock(&peer->lock);
12945 + ast_hangup(peer);
12947 + ast_log(LOG_WARNING, "Could not find channel with uniqueid %s to retrieve.\n", uniqueid);
12952 +struct ast_channel *ast_get_holded_call(char *uniqueid)
12955 + struct ast_channel *peer=NULL;
12956 + struct holdeduser *pu, *pl=NULL;
12958 + ast_mutex_lock(&holding_lock);
12961 + if (!strncmp(uniqueid,pu->uniqueid,sizeof(pu->uniqueid))) {
12963 + pl->next = pu->next;
12965 + holdlist = pu->next;
12971 + ast_mutex_unlock(&holding_lock);
12973 + peer = ast_get_channel_by_uniqueid_locked(pu->uniqueid);
12977 + if (option_verbose > 2)
12978 + ast_verbose(VERBOSE_PREFIX_3 "Channel %s removed from hold.\n", peer->name);
12979 + ast_moh_stop(peer);
12982 + if (option_verbose > 2)
12983 + ast_verbose(VERBOSE_PREFIX_3 "Could not find channel with uniqueid %s.\n", uniqueid);
12987 + ast_log(LOG_WARNING, "Could not find held channel with uniqueid %s to retrieve.\n", uniqueid);
12992 +/* this is our autmagically service thread that keeps channels onhold happy */
12993 +static void *do_holding_thread(void *ignore)
12995 + int ms, tms, max;
12996 + struct holdeduser *pu, *pl, *pt = NULL;
12997 + struct timeval tv;
12998 + struct ast_frame *f;
13000 + fd_set rfds, efds;
13001 + fd_set nrfds, nefds;
13007 + ast_mutex_lock(&holding_lock);
13010 + gettimeofday(&tv, NULL);
13014 + tms = (tv.tv_sec - pu->start.tv_sec) * 1000 + (tv.tv_usec - pu->start.tv_usec) / 1000;
13015 + for (x=0;x<AST_MAX_FDS;x++) {
13016 + if ((pu->chan->fds[x] > -1) && (FD_ISSET(pu->chan->fds[x], &rfds) || FD_ISSET(pu->chan->fds[x], &efds))) {
13017 + /* if (FD_ISSET(pu->chan->fds[x], &efds))
13018 + pu->chan->exception = 1; */
13019 + pu->chan->fdno = x;
13020 + /* See if they need servicing */
13021 + f = ast_read(pu->chan);
13022 + if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP))) {
13023 + /* There's a problem, hang them up*/
13024 + if (option_verbose > 1)
13025 + ast_verbose(VERBOSE_PREFIX_2 "%s got tired of being onhold\n", pu->chan->name);
13026 + ast_hangup(pu->chan);
13027 + /* find the corresponding channel and hang them up too! */
13028 + /* but only if it is not bridged yet! */
13029 + /* And take them out of the parking lot */
13031 + pl->next = pu->next;
13033 + holdlist = pu->next;
13039 + /* XXX Maybe we could do something with packets, like dial "0" for operator or something XXX */
13041 + goto std; /* XXX Ick: jumping into an else statement??? XXX */
13045 + if (x >= AST_MAX_FDS) {
13046 +std: for (x=0;x<AST_MAX_FDS;x++) {
13047 + /* Keep this one for next one */
13048 + if (pu->chan->fds[x] > -1) {
13049 + FD_SET(pu->chan->fds[x], &nrfds);
13050 + FD_SET(pu->chan->fds[x], &nefds);
13051 + if (pu->chan->fds[x] > max)
13052 + max = pu->chan->fds[x];
13055 + /* Keep track of our longest wait */
13056 + if ((tms < ms) || (ms < 0))
13062 + ast_mutex_unlock(&holding_lock);
13065 + tv.tv_sec = ms / 1000;
13066 + tv.tv_usec = (ms % 1000) * 1000;
13067 + /* Wait for something to happen */
13068 + ast_select(max + 1, &rfds, NULL, &efds, (ms > -1) ? &tv : NULL);
13069 + pthread_testcancel();
13071 + return NULL; /* Never reached */
13074 +static int retrieve_call_exec(struct ast_channel *chan, void *data) {
13076 + struct localuser *u;
13077 + char *uniqueid = (char *)data;
13078 + LOCAL_USER_ADD(u);
13079 + res = ast_retrieve_call(chan, uniqueid);
13080 + LOCAL_USER_REMOVE(u);
13084 static int park_exec(struct ast_channel *chan, void *data)
13087 @@ -1723,9 +2077,10 @@
13090 "CallerIDName: %s\r\n"
13091 + "Uniqueid: %s\r\n\r\n"
13092 ,pu->parkingnum, pu->chan->name, chan->name
13093 ,(pu->chan->cid.cid_num ? pu->chan->cid.cid_num : "<unknown>")
13094 - ,(pu->chan->cid.cid_name ? pu->chan->cid.cid_name : "<unknown>")
13095 + ,(pu->chan->cid.cid_name ? pu->chan->cid.cid_name : "<unknown>"), pu->chan->uniqueid
13099 @@ -1893,12 +2248,13 @@
13102 "CallerIDName: %s\r\n"
13103 + "Uniqueid: %s\r\n"
13106 ,cur->parkingnum, cur->chan->name
13107 ,(long)cur->start.tv_sec + (long)(cur->parkingtime/1000) - (long)time(NULL)
13108 ,(cur->chan->cid.cid_num ? cur->chan->cid.cid_num : "")
13109 - ,(cur->chan->cid.cid_name ? cur->chan->cid.cid_name : "")
13110 + ,(cur->chan->cid.cid_name ? cur->chan->cid.cid_name : ""), cur->chan->uniqueid
13114 @@ -1914,6 +2270,386 @@
13115 return RESULT_SUCCESS;
13118 +static int handle_autoanswer(int fd, int argc, char *argv[])
13120 + struct aauser *cur;
13122 + ast_cli(fd, "%25s %10s %15s \n", "Channel"
13123 + , "Extension", "Context");
13125 + ast_mutex_lock(&autoanswer_lock);
13129 + ast_cli(fd, "%25s %10s %15s\n",cur->chan->name, cur->exten, cur->context);
13134 + ast_mutex_unlock(&autoanswer_lock);
13136 + return RESULT_SUCCESS;
13138 +static char showautoanswer_help[] =
13139 +"Usage: show autoanswer\n"
13140 +" Lists currently logged in autoanswr channels.\n";
13142 +static struct ast_cli_entry showautoanswer =
13143 +{ { "show", "autoanswer", NULL }, handle_autoanswer, "Lists autoanswer channels", showautoanswer_help };
13145 +int ast_masq_autoanswer_login(struct ast_channel *rchan, void *data)
13147 + struct ast_channel *chan;
13148 + struct ast_frame *f;
13149 + /* Make a new, fake channel that we'll use to masquerade in the real one */
13150 + chan = ast_channel_alloc(0);
13152 + /* Let us keep track of the channel name */
13153 + snprintf(chan->name, sizeof (chan->name), "Autoanswer/%s",rchan->name);
13154 + /* Make formats okay */
13155 + chan->readformat = rchan->readformat;
13156 + chan->writeformat = rchan->writeformat;
13157 + ast_channel_masquerade(chan, rchan);
13158 + /* Setup the extensions and such */
13159 + strncpy(chan->context, rchan->context, sizeof(chan->context) - 1);
13160 + strncpy(chan->exten, rchan->exten, sizeof(chan->exten) - 1);
13161 + chan->priority = rchan->priority;
13162 + /* Make the masq execute */
13163 + f = ast_read(chan);
13166 + ast_autoanswer_login(chan, data);
13168 + ast_log(LOG_WARNING, "Unable to create aa channel\n");
13174 +static int autoanswer_login_exec(struct ast_channel *chan, void *data)
13177 + struct localuser *u;
13178 + LOCAL_USER_ADD(u);
13180 + ast_log(LOG_WARNING, "AutoanswerLogin requires an argument (extension number)\n");
13183 + res = ast_masq_autoanswer_login(chan, data);
13184 + LOCAL_USER_REMOVE(u);
13188 +int ast_autoanswer_login(struct ast_channel *chan, void *data)
13190 + /* We put the user in the parking list, then wake up the parking thread to be sure it looks
13191 + after these channels too */
13192 + struct ast_context *con;
13193 + char exten[AST_MAX_EXTENSION];
13194 + struct aauser *pu,*pl = NULL;
13195 + char *s, *stringp, *aacontext, *aaexten = NULL;
13197 + s = ast_strdupa((void *) data);
13199 + aacontext = strsep(&stringp, "|");
13200 + aaexten = strsep(&stringp, "|");
13202 + aaexten = aacontext;
13203 + aacontext = NULL;
13206 + ast_log(LOG_WARNING, "AutoanswerLogin requires at least an extension!\n");
13209 + if (!aacontext) {
13210 + aacontext = "default";
13214 + ast_mutex_lock(&autoanswer_lock);
13217 + if ((!strncasecmp(pu->exten, aaexten, sizeof(pu->exten)-1)) && (!strncasecmp(pu->context, aacontext, sizeof(pu->context)-1))){
13219 + pl->next = pu->next;
13221 + aalot = pu->next;
13227 + ast_mutex_unlock(&autoanswer_lock);
13229 + ast_log(LOG_NOTICE, "Logout old Channel %s for %s@%s.\n",pu->chan->name, pu->exten, pu->context);
13230 + manager_event(EVENT_FLAG_CALL, "AutoanswerLogout",
13231 + "Channel: %s\r\n"
13232 + "Uniqueid: %s\r\n"
13233 + "Context: %s\r\n"
13235 + ,pu->chan->name, pu->chan->uniqueid, pu->context, pu->exten);
13236 + ast_hangup(pu->chan);
13239 + pu = malloc(sizeof(struct aauser));
13241 + memset(pu, 0, sizeof(pu));
13242 + ast_mutex_lock(&autoanswer_lock);
13243 + chan->appl = "Autoanswer";
13244 + chan->data = NULL;
13247 + if (chan->_state != AST_STATE_UP) {
13248 + ast_answer(chan);
13251 + /* Start music on hold */
13252 + ast_moh_start(pu->chan, NULL);
13253 + gettimeofday(&pu->start, NULL);
13254 + strncpy(pu->exten, aaexten, sizeof(pu->exten)-1);
13255 + strncpy(pu->context, aacontext, sizeof(pu->exten)-1);
13256 + pu->next = aalot;
13258 + con = ast_context_find(aacontext);
13260 + con = ast_context_create(NULL,aacontext, registrar);
13262 + ast_log(LOG_ERROR, "Context '%s' does not exist and unable to create\n", aacontext);
13266 + snprintf(exten, sizeof(exten), "%s", aaexten);
13267 + ast_add_extension2(con, 1, exten, 1, NULL, NULL, autoanswer, strdup((char *)data), free, registrar);
13270 + ast_mutex_unlock(&autoanswer_lock);
13271 + /* Wake up the (presumably select()ing) thread */
13272 + pthread_kill(autoanswer_thread, SIGURG);
13273 + if (option_verbose > 1)
13274 + ast_verbose(VERBOSE_PREFIX_2 "Autoanswer login from %s for %s@%s.\n", pu->chan->name, pu->exten, pu->context);
13275 + manager_event(EVENT_FLAG_CALL, "AutoanswerLogin",
13276 + "Channel: %s\r\n"
13277 + "Uniqueid: %s\r\n"
13278 + "Context: %s\r\n"
13280 + ,pu->chan->name, pu->chan->uniqueid, pu->context, pu->exten);
13284 + ast_log(LOG_WARNING, "Out of memory\n");
13290 +static void *do_autoanswer_thread(void *ignore)
13292 + int ms, tms, max;
13293 + struct ast_context *con;
13294 + char exten[AST_MAX_EXTENSION];
13295 + struct aauser *pu, *pl, *pt = NULL;
13296 + struct timeval tv;
13297 + struct ast_frame *f;
13299 + fd_set rfds, efds;
13300 + fd_set nrfds, nefds;
13306 + ast_mutex_lock(&autoanswer_lock);
13309 + gettimeofday(&tv, NULL);
13313 + tms = (tv.tv_sec - pu->start.tv_sec) * 1000 + (tv.tv_usec - pu->start.tv_usec) / 1000;
13314 + for (x=0;x<AST_MAX_FDS;x++) {
13315 + if ((pu->chan->fds[x] > -1) && (FD_ISSET(pu->chan->fds[x], &rfds) || FD_ISSET(pu->chan->fds[x], &efds))) {
13316 +/* if (FD_ISSET(pu->chan->fds[x], &efds))
13317 + pu->chan->exception = 1; */
13318 + pu->chan->fdno = x;
13319 + /* See if they need servicing */
13320 + f = ast_read(pu->chan);
13321 + if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP))) {
13322 + /* There's a problem, hang them up*/
13323 + if (option_verbose > 1)
13324 + ast_verbose(VERBOSE_PREFIX_2 "%s logged out of autoanswer app\n", pu->chan->name);
13325 + manager_event(EVENT_FLAG_CALL, "AutoanswerLogout",
13326 + "Channel: %s\r\n"
13327 + "Uniqueid: %s\r\n"
13328 + "Context: %s\r\n"
13330 + ,pu->chan->name, pu->chan->uniqueid, pu->context, pu->exten);
13331 + ast_hangup(pu->chan);
13332 + con = ast_context_find(pu->context);
13334 + snprintf(exten, sizeof(exten), "%s", pu->exten);
13335 + if (ast_context_remove_extension2(con, exten, 1, registrar))
13336 + ast_log(LOG_WARNING, "Whoa, failed to remove the extension!\n");
13338 + ast_log(LOG_WARNING, "Whoa, no %s context?\n", pu->exten);
13340 + /* And take them out of the parking lot */
13342 + pl->next = pu->next;
13344 + aalot = pu->next;
13350 + /* XXX Maybe we could do something with packets, like dial "0" for operator or something XXX */
13352 + goto std; /* XXX Ick: jumping into an else statement??? XXX */
13356 + if (x >= AST_MAX_FDS) {
13357 +std: for (x=0;x<AST_MAX_FDS;x++) {
13358 + /* Keep this one for next one */
13359 + if (pu->chan->fds[x] > -1) {
13360 + FD_SET(pu->chan->fds[x], &nrfds);
13361 + FD_SET(pu->chan->fds[x], &nefds);
13362 + if (pu->chan->fds[x] > max)
13363 + max = pu->chan->fds[x];
13366 + /* Keep track of our longest wait */
13367 + if ((tms < ms) || (ms < 0))
13373 + ast_mutex_unlock(&autoanswer_lock);
13376 + tv.tv_sec = ms / 1000;
13377 + tv.tv_usec = (ms % 1000) * 1000;
13378 + /* Wait for something to happen */
13379 + ast_select(max + 1, &rfds, NULL, &efds, (ms > -1) ? &tv : NULL);
13380 + pthread_testcancel();
13382 + return NULL; /* Never reached */
13385 +static int autoanswer_exec(struct ast_channel *chan, void *data)
13388 + struct localuser *u;
13389 + struct ast_channel *peer=NULL;
13390 + struct aauser *pu, *pl=NULL;
13391 + struct ast_bridge_config config;
13392 + char *s, *stringp, *aacontext, *aaexten = NULL;
13393 + char datastring[80];
13396 + ast_log(LOG_WARNING, "Autoanswer requires an argument (extension number)\n");
13399 + s = ast_strdupa((void *) data);
13401 + aacontext = strsep(&stringp, "|");
13402 + aaexten = strsep(&stringp, "|");
13404 + aaexten = aacontext;
13405 + aacontext = NULL;
13408 + ast_log(LOG_WARNING, "AutoanswerLogin requires at least an extension!\n");
13411 + if (!aacontext) {
13412 + aacontext = "default";
13416 + LOCAL_USER_ADD(u);
13417 + ast_mutex_lock(&autoanswer_lock);
13420 + if ((!strncasecmp(pu->exten, aaexten, sizeof(pu->exten)-1)) && (!strncasecmp(pu->context, aacontext, sizeof(pu->context)-1))){
13422 + pl->next = pu->next;
13424 + aalot = pu->next;
13430 + ast_mutex_unlock(&autoanswer_lock);
13436 + /* JK02: it helps to answer the channel if not already up */
13437 + if (chan->_state != AST_STATE_UP) {
13438 + ast_answer(chan);
13442 + ast_moh_stop(peer);
13443 + /* Play a courtesy beep in the callED channel to prefix the bridge connecting */
13444 + if (!ast_strlen_zero(courtesytone)) {
13445 + if (!ast_streamfile(peer, courtesytone, peer->language)) {
13446 + if (ast_waitstream(peer, "") < 0) {
13447 + ast_log(LOG_WARNING, "Failed to play courtesy tone!\n");
13448 + ast_hangup(peer);
13454 + res = ast_channel_make_compatible(chan, peer);
13456 + ast_log(LOG_WARNING, "Could not make channels %s and %s compatible for bridge\n", chan->name, peer->name);
13457 + ast_hangup(peer);
13460 + /* This runs sorta backwards, since we give the incoming channel control, as if it
13461 + were the person called. */
13462 + if (option_verbose > 2)
13463 + ast_verbose(VERBOSE_PREFIX_3 "Channel %s autoanswered %s\n", peer->name, chan->name);
13464 + manager_event(EVENT_FLAG_CALL, "Autoanswer",
13465 + "Channel: %s\r\n"
13466 + "Uniqueid: %s\r\n"
13467 + "Channel2: %s\r\n"
13468 + "Uniqueid2: %s\r\n"
13469 + "Context: %s\r\n"
13471 + ,chan->name, chan->uniqueid, peer->name, peer->uniqueid, aacontext, aaexten);
13474 + memset(&config,0,sizeof(struct ast_bridge_config));
13475 + ast_set_flag(&(config.features_callee), AST_FEATURE_REDIRECT);
13476 + ast_set_flag(&(config.features_caller), AST_FEATURE_REDIRECT);
13477 + config.timelimit = 0;
13478 + config.play_warning = 0;
13479 + config.warning_freq = 0;
13480 + config.warning_sound=NULL;
13481 + res = ast_bridge_call(chan,peer,&config);
13483 + if (option_verbose > 2)
13484 + ast_verbose(VERBOSE_PREFIX_3 "returning from bridge %s\n", peer->name);
13486 + snprintf(datastring, sizeof(datastring) - 1, "%s|%s", aacontext, aaexten);
13487 + ast_autoanswer_login(peer, datastring);
13490 + if (option_verbose > 2)
13491 + ast_verbose(VERBOSE_PREFIX_3 "Nobody logged in for autoanswer %s@%s\n", aaexten, aacontext);
13494 + LOCAL_USER_REMOVE(u);
13499 int ast_pickup_call(struct ast_channel *chan)
13501 @@ -2068,7 +2804,7 @@
13505 - struct ast_call_feature *feature=find_feature(var->name);
13506 + struct ast_call_feature *feature = ast_find_feature(var->name);
13510 @@ -2144,14 +2880,22 @@
13511 if ((res = load_config()))
13513 ast_cli_register(&showparked);
13514 + ast_cli_register(&showautoanswer);
13515 ast_cli_register(&showfeatures);
13516 ast_pthread_create(&parking_thread, NULL, do_parking_thread, NULL);
13517 + ast_pthread_create(&holding_thread, NULL, do_holding_thread, NULL);
13518 res = ast_register_application(parkedcall, park_exec, synopsis, descrip);
13520 res = ast_register_application(parkcall, park_call_exec, synopsis2, descrip2);
13522 ast_manager_register("ParkedCalls", 0, manager_parking_status, "List parked calls" );
13524 + res = ast_register_application(holdedcall, retrieve_call_exec, synopsis, descrip);
13525 + ast_pthread_create(&autoanswer_thread, NULL, do_autoanswer_thread, NULL);
13527 + res = ast_register_application(autoanswerlogin, autoanswer_login_exec, synopsis3, descrip3);
13529 + res = ast_register_application(autoanswer, autoanswer_exec, synopsis4, descrip4);
13533 @@ -2162,7 +2906,11 @@
13535 ast_manager_unregister("ParkedCalls");
13536 ast_cli_unregister(&showfeatures);
13537 + ast_cli_unregister(&showautoanswer);
13538 ast_cli_unregister(&showparked);
13539 + ast_unregister_application(autoanswer);
13540 + ast_unregister_application(autoanswerlogin);
13541 + ast_unregister_application(holdedcall);
13542 ast_unregister_application(parkcall);
13543 return ast_unregister_application(parkedcall);
13545 diff -urN asterisk-1.2.7.1.orig/res/res_watchdog.c asterisk-1.2.7.1/res/res_watchdog.c
13546 --- asterisk-1.2.7.1.orig/res/res_watchdog.c 1970-01-01 01:00:00.000000000 +0100
13547 +++ asterisk-1.2.7.1/res/res_watchdog.c 2006-04-24 09:39:12.000000000 +0200
13550 + * Asterisk -- A telephony toolkit for Linux.
13552 + * Resource to make watchdogs happy
13554 + * Copyright (C) 2005, Junghanns.NET GmbH
13556 + * Klaus-Peter Junghanns <kpj@junghanns.net>
13558 + * This program is free software, distributed under the terms of
13559 + * the GNU General Public License
13562 +#include <stdlib.h>
13563 +#include <errno.h>
13564 +#include <unistd.h>
13565 +#include <string.h>
13566 +#include <stdlib.h>
13567 +#include <stdio.h>
13568 +#include <sys/time.h>
13569 +#include <sys/signal.h>
13570 +#include <netinet/in.h>
13571 +#include <asterisk/lock.h>
13572 +#include <asterisk/file.h>
13573 +#include <asterisk/logger.h>
13574 +#include <asterisk/channel.h>
13575 +#include <asterisk/pbx.h>
13576 +#include <asterisk/options.h>
13577 +#include <asterisk/module.h>
13578 +#include <asterisk/translate.h>
13579 +#include <asterisk/say.h>
13580 +#include <asterisk/features.h>
13581 +#include <asterisk/musiconhold.h>
13582 +#include <asterisk/config.h>
13583 +#include <asterisk/cli.h>
13584 +#include <asterisk/manager.h>
13585 +#include <asterisk/utils.h>
13586 +#include <asterisk/adsi.h>
13588 +static struct watchdog_pvt *watchdogs = NULL;
13590 +STANDARD_LOCAL_USER;
13594 +typedef struct watchdog_pvt {
13599 + pthread_t watchdog_thread;
13600 + struct watchdog_pvt *next;
13603 +static void *do_watchdog_thread(void *data) {
13604 + struct watchdog_pvt *woof = (struct watchdog_pvt *)data;
13607 + write(woof->fd, "PING\n", 1);
13609 + usleep(woof->interval * 1000);
13615 +int load_module(void)
13618 + char *cat, *utype, *udevice, *uinterval;
13619 + struct ast_config *cfg;
13620 + struct watchdog_pvt *woof = NULL;
13622 + cfg = ast_config_load("watchdog.conf");
13624 + cat = ast_category_browse(cfg, NULL);
13626 + cat = ast_category_browse(cfg, cat);
13627 + utype = ast_variable_retrieve(cfg, cat, "type");
13629 + ast_log(LOG_NOTICE, "type = %s\n", utype);
13631 + udevice = ast_variable_retrieve(cfg, cat, "device");
13633 + ast_log(LOG_NOTICE, "device = %s\n", udevice);
13635 + uinterval = ast_variable_retrieve(cfg, cat, "interval");
13637 + ast_log(LOG_NOTICE, "interval = %s\n", uinterval);
13639 + if (uinterval && udevice && utype) {
13640 + woof = malloc(sizeof(struct watchdog_pvt));
13642 + ast_log(LOG_ERROR, "unable to malloc!\n");
13645 + memset(woof, 0x0, sizeof(struct watchdog_pvt));
13646 + strncpy(woof->device, udevice, sizeof(woof->device) - 1);
13648 + woof->interval = atoi(uinterval);;
13649 + woof->next = watchdogs;
13650 + watchdogs = woof;
13651 + woof->fd = open(woof->device, O_WRONLY | O_SYNC);
13653 + if (!strncmp(utype, "isdnguard", sizeof(utype))) {
13655 + write(woof->fd, "START\n", 6);
13657 + ast_pthread_create(&woof->watchdog_thread, NULL, do_watchdog_thread, woof);
13659 + ast_log(LOG_WARNING, "error opening watchdog device %s !\n", woof->device);
13663 + ast_config_destroy(cfg);
13669 +int unload_module(void)
13671 + struct watchdog_pvt *dogs, *woof;
13672 + STANDARD_HANGUP_LOCALUSERS;
13673 + dogs = watchdogs;
13675 + pthread_cancel(dogs->watchdog_thread);
13677 + woof = dogs->next;
13684 +char *description(void)
13686 + return "Watchdog Resource";
13689 +int usecount(void)
13696 + return ASTERISK_GPL_KEY;
13698 diff -urN asterisk-1.2.7.1.orig/rtp.c asterisk-1.2.7.1/rtp.c
13699 --- asterisk-1.2.7.1.orig/rtp.c 2006-03-15 19:07:06.000000000 +0100
13700 +++ asterisk-1.2.7.1/rtp.c 2006-04-18 14:39:28.000000000 +0200
13701 @@ -442,6 +442,11 @@
13702 struct rtpPayloadType rtpPT;
13706 + /* XXX SYMPTON CURE, DIRTY FIX, CHECK, BEGIN */
13708 + return &null_frame;
13709 + /* XXX SYMPTON CURE, DIRTY FIX, CHECK, END */
13711 /* Cache where the header will go */
13712 res = recvfrom(rtp->s, rtp->rawdata + AST_FRIENDLY_OFFSET, sizeof(rtp->rawdata) - AST_FRIENDLY_OFFSET,