[Pkg-voip-commits] r3742 - in asterisk1.2/trunk/debian: . patches

tzafrir-guest at alioth.debian.org tzafrir-guest at alioth.debian.org
Sun Jul 15 16:12:48 UTC 2007


Author: tzafrir-guest
Date: 2007-07-15 16:12:48 +0000 (Sun, 15 Jul 2007)
New Revision: 3742

Added:
   asterisk1.2/trunk/debian/patches/h323_fix_1217.dpatch
Modified:
   asterisk1.2/trunk/debian/changelog
   asterisk1.2/trunk/debian/patches/00list
   asterisk1.2/trunk/debian/patches/bristuff.dpatch
   asterisk1.2/trunk/debian/rules
Log:
Still doesn't build, but closer to working. Commiting what I have done
so far in the current round.

* New upstream release: 1.2.21.1
* Bristuff 0.3.0-1y-h
* h323_fix_1217.dpatch: fix build of h323 that got broken in 1.2.17 .
* Fix target of sample h323.conf file.


Modified: asterisk1.2/trunk/debian/changelog
===================================================================
--- asterisk1.2/trunk/debian/changelog	2007-07-14 20:21:04 UTC (rev 3741)
+++ asterisk1.2/trunk/debian/changelog	2007-07-15 16:12:48 UTC (rev 3742)
@@ -1,7 +1,10 @@
-asterisk1.2 (1:1.2.18~dfsg-1) UNRELEASED; urgency=low
+asterisk1.2 (1:1.2.21.1~dfsg-1) UNRELEASED; urgency=low
 
   * NOT YET RELEASED
   * Moved asterisk 1.2 series into own namespace
+  * Bristuff 0.3.0-1y-h
+  * h323_fix_1217.dpatch: fix build of h323 that got broken in 1.2.17 .
+  * Fix target of sample h323.conf file.
 
  -- Kilian Krause <kilian at debian.org>  Wed, 30 May 2007 19:18:00 +0200
 

Modified: asterisk1.2/trunk/debian/patches/00list
===================================================================
--- asterisk1.2/trunk/debian/patches/00list	2007-07-14 20:21:04 UTC (rev 3741)
+++ asterisk1.2/trunk/debian/patches/00list	2007-07-15 16:12:48 UTC (rev 3742)
@@ -22,3 +22,4 @@
 Makefile_hostcc
 Makefile_clean
 daemon_color
+h323_fix_1217

Modified: asterisk1.2/trunk/debian/patches/bristuff.dpatch
===================================================================
--- asterisk1.2/trunk/debian/patches/bristuff.dpatch	2007-07-14 20:21:04 UTC (rev 3741)
+++ asterisk1.2/trunk/debian/patches/bristuff.dpatch	2007-07-15 16:12:48 UTC (rev 3742)
@@ -2,233 +2,14 @@
 ## bristuff.dpatch by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
 ##
 ## All lines beginning with `## DP:' are a description of the patch.
-## DP: bristuff support in asterisk: asterisk.patch from bristuff-0.3.0-PRE-1x
+## DP: bristuff support: asterisk.patch from bristuff-0.3.0-PRE-1y-h
 ## DP: cygdef.h removed ;-)
-## DP: Updated version: 1.2.16
+## DP: Updated version: 1.2.21.1
 
 @DPATCH@
-diff -urNad asterisk-1.2.15~dfsg~/.version asterisk-1.2.15~dfsg/.version
---- asterisk-1.2.15~dfsg~/.version	2007-02-09 01:35:53.000000000 +0200
-+++ asterisk-1.2.15~dfsg/.version	2007-02-11 06:04:58.000000000 +0200
-@@ -1 +1 @@
--1.2.16
-+1.2.16-BRIstuffed-0.3.0-PRE-1x
-diff -urNad asterisk-1.2.15~dfsg~/HARDWARE asterisk-1.2.15~dfsg/HARDWARE
---- asterisk-1.2.15~dfsg~/HARDWARE	2005-11-29 20:24:39.000000000 +0200
-+++ asterisk-1.2.15~dfsg/HARDWARE	2007-02-11 06:04:58.000000000 +0200
-@@ -37,6 +37,19 @@
-    * Wildcard TE410P - Quad T1/E1 switchable interface.  Supports PRI and 
-      RBS signalling, as well as PPP, FR, and HDLC data modes.
- 
-+-- Junghanns.NET (Primary author of BRIstuff)
-+	http://www.junghanns.net
-+	
-+    * quadBRI PCI ISDN - 4port BRI ISDN interface, supports NT and TE mode
-+    
-+    * octoBRI PCI ISDN - 8port BRI ISDN interface, supports NT and TE mode
-+
-+    * singleE1 PCI ISDN - Single E1 interface
-+
-+    * doubleE1 PCI ISDN - Double E1 interface
-+    
-+    * uno/duo/quad GSM PCI - 1/2/4 channel GSM interface cards
-+
- Non-zaptel compatible hardware
- ==============================
- 
-diff -urNad asterisk-1.2.15~dfsg~/LICENSE asterisk-1.2.15~dfsg/LICENSE
---- asterisk-1.2.15~dfsg~/LICENSE	2006-10-17 19:22:01.000000000 +0200
-+++ asterisk-1.2.15~dfsg/LICENSE	2007-02-11 06:04:58.000000000 +0200
-@@ -1,7 +1,7 @@
--Asterisk is distributed under the GNU General Public License version 2
--and is also available under alternative licenses negotiated directly
--with Digium, Inc. If you obtained Asterisk under the GPL, then the GPL
--applies to all loadable Asterisk modules used on your system as well,
-+BRIstuffed Asterisk is distributed under the GNU General Public License version 2
-+and is not available under any alternative licenses.
-+If you obtained BRIstuffed Asterisk under the GPL, then the GPL
-+applies to all loadable BRIstuffed Asterisk modules used on your system as well,
- except as defined below. The GPL (version 2) is included in this
- source tree in the file COPYING.
- 
-diff -urNad asterisk-1.2.15~dfsg~/Makefile asterisk-1.2.15~dfsg/Makefile
---- asterisk-1.2.15~dfsg~/Makefile	2007-02-11 06:04:48.000000000 +0200
-+++ asterisk-1.2.15~dfsg/Makefile	2007-02-11 06:04:58.000000000 +0200
-@@ -781,6 +781,9 @@
- 		echo ";astctlowner = root" ; \
- 		echo ";astctlgroup = apache" ; \
- 		echo ";astctl = asterisk.ctl" ; \
-+		echo "[options]" ; \
-+		echo "uniquename = `hostname`" ;\
-+		echo "silence_suppression = yes" ;\
- 		) > $(DESTDIR)$(ASTCONFPATH) ; \
- 	else \
- 		echo "Skipping asterisk.conf creation"; \
-diff -urNad asterisk-1.2.15~dfsg~/README asterisk-1.2.15~dfsg/README
---- asterisk-1.2.15~dfsg~/README	2006-03-03 10:12:33.000000000 +0200
-+++ asterisk-1.2.15~dfsg/README	2007-02-11 06:04:58.000000000 +0200
-@@ -4,6 +4,8 @@
- 
- Copyright (C) 2001-2005 Digium, Inc.
- and other copyright holders.
-+Copyright (C) 2002-2005 Junghanns.NET GmbH 
-+and other copyright holders.
- ================================================================
- 
- * SECURITY
-diff -urNad asterisk-1.2.15~dfsg~/README.chan_capi asterisk-1.2.15~dfsg/README.chan_capi
---- asterisk-1.2.15~dfsg~/README.chan_capi	1970-01-01 02:00:00.000000000 +0200
-+++ asterisk-1.2.15~dfsg/README.chan_capi	2007-02-11 06:04:58.000000000 +0200
-@@ -0,0 +1,146 @@
-+(CAPI*) chan_capi a Common ISDN API 2.0 implementation for Asterisk
-+(C) 2002, 2003, 2004, 2005 Junghanns.NET GmbH 
-+Klaus-Peter Junghanns <kpj at junghanns.net>
-+
-+This program is free software and may be modified and distributed under
-+the terms of the GNU Public License. There is _NO_ warranty for this!
-+
-+Thanks go to the debuggers and bugfixers (listed in chronological order) :)
-+===========================================================================
-+Lele Forzani <lele at windmill.it>
-+Florian Overkamp <florian at obsimref.com>
-+Gareth Watts <gareth at omnipotent.net>
-+Jeff Noxon <jeff at planetfall.com>
-+Petr Michalek <petr.michalek at aca.cz>
-+Jan Stocker
-+(...and all the others that i forgot..) :-)
-+
-+chan_capi version 0.4.0-PRE1 includes:
-+======================================
-+
-+- multiple controller support
-+- CID,DNID (callling party, called party)
-+- CLIR/CLIP
-+- supplementary services, CD,HOLD,RETRIEVE,ECT
-+- DTMF (dependend on card) + software DTMF support
-+- early B3 connects (always,success,never)
-+- digital audio (what did you think?)
-+- incoming/outgoing calls
-+- overlap sending (dialtone)
-+- E(xplicit) C(all) T(ransfer) (...although it's done implicit .. but dont tell!)
-+- tuneable latency ;) you can configure the size of B3 blocks at compile time
-+  (in chan_capi_pvt.h, AST_CAPI_MAX_B3_BLOCK_SIZE)
-+  the default is 160 samples, for non-VoIP use you can tune it down to 130
-+- use asterisk's internal dsp functions for dtmf
-+- alaw support 
-+- ulaw support! 
-+- Eicon CAPI echo cancelation (echocancel=1)
-+- reject call waiting (ACO)
-+- DID for Point to Point mode (a.k.a overlap receiving)
-+- experimental echo squelching (echosquelch=1)
-+- call progress, no need to add ||r to your dialstring anymore
-+- rx/tx gains (rxgain=1.0)
-+- call deflection on circuitbusy (makefile option) (deflect=12345678)
-+- (inter)national dialing prefix (for callerid) configurable in capi.conf
-+- CLI command "capi info" shows B channel status
-+- capiECT will announce the callerID since it gets lost on most isdn pbxes
-+  the called party can press # to drop the call
-+- audio syncing (timing outgoing dataB3 on incoming dataB3), supposed to fix
-+  the DATA_B3_REQ (error = 0x1103) problem
-+- catch all MSN (incomingmsn=*)
-+- some configuration enhancements (msn=123,124,125 and controller=1,2,3,4)
-+- accountcode= added.
-+- finally the echo squelching works!
-+- callgroup support
-+- fixed pipe leak
-+- updated to support the new frame->delivery field
-+- compiles with latest cvs with a makefile option (LOOK AT THE MAKEFILE)
-+- fixed channel name bug in p2p mode
-+- added app_capiNoES for disabling the primitive echo suppressor, use this before
-+  you start recording voicemail or your files may get choppy
-+- fixed for latest cvs (AST_MUTEX_DEFINE_STATIC)
-+- fixed for latest cvs (asterisk/parking.h -> asterisk/features.h)
-+- fixed for latest cvs ast_pthread_create
-+
-+- ATTENTION! the dialstring syntax now uses the zaptel dialstring syntax 
-+  it used to be:  Dial(CAPI/[@]<outgoingMSN>:[b|B]<destination>)
-+ 
-+  now it is:      Dial(CAPI/g<group>/[b|B]<destination>)
-+  or:             Dial(CAPI/contr<controller>/[b|B]<destination>)
-+ 
-+  CLIP/CLIR is now uses the calling presentation of the calling channel, this can
-+  be modified using the CallingPres() application. Use CallinPres(32) for CLIR.
-+  That is why the msn= param in capi.conf is now obsolete. The callerID is also
-+  taken from the calling channel.
-+
-+- fixes for BSD (Jan Stocker)
-+
-+Helper applications
-+===================
-+kapejod says: "No No No, dont use those yet....!" (except maybe HOLD,ECT...)
-+
-+app_capiCD.c		forwards an unanswered call to another phone (does not rely on sservice CD)
-+			example:
-+			exten => s,1,Wait,1
-+			exten => s,2,capiCD,12345678
-+			
-+app_capiHOLD.c		puts an answered call on hold, this has nothing to do with asterisk's onhold thingie (music et al)
-+			after putting a call onhold, never use the Wait application!
-+
-+app_capiRETRIEVE.c	gets the holded call back
-+
-+app_capiECT.c		explicit call transfer of the holded call (must put call on hold first!)
-+			example:
-+			exten => s,1,Answer
-+			exten => s,2,capiHOLD
-+			exten => s,3,capiECT,55:50
-+			will ECT the call to 50 using 55 as the callerid/outgoing msn
-+
-+
-+Using CLIR
-+==========
-+Use the CallingPres() application before you dial:
-+exten => _X.,1,CallingPres(32)
-+exten => _X.,2,Dial(CAPI/contr1/${EXTEN})    
-+
-+Enjoying early B3 connects (inband call progress, tones and announcements)
-+==========================================================================
-+early B3 is now configurable in the dialstring :)
-+if you prefix the destination number with a 'b' early B3 will always be used, also if the call fails
-+because the number is unprovisioned, etc ...
-+if you prefix it with a 'B' early B3 will only be used on successful calls, giving you ring indication,etc...
-+
-+dont use indications in the Dial command, your local exchange will do that for you:
-+exten => _X.,1,Dial(CAPI/contr1/B${EXTEN},30)		(early B3 on success)
-+exten => _X.,1,Dial(CAPI/contr1/b${EXTEN},30)		(always early B3)
-+exten => _X.,1,Dial(CAPI/contr1/${EXTEN},30,r)		(no early B3, fake ring indication)
-+
-+exten => _X.,1,Dial(CAPI/contr1/b${EXTEN},30,r)		(always early B3, fake indicatons if the exchange
-+							does not give us indications)
-+exten => _X.,1,Dial(CAPI/contr1/B${EXTEN},30,r)		(early B3 on success, fake indicatons if the exchange
-+							does not give us indications)
-+    
-+you can totally turn B3 off in the Makefile at buildtime (-DNEVER_EVER_EARLY_B3_CONNECTS).
-+
-+For normal PBX usage you would use the "b" option, always early B3.
-+
-+Overlap sending (a.k.a. real dialtone)
-+======================================
-+when you dial an empty number, and have early B3 enabled, with:
-+    Dial(CAPI/g1/b)
-+the channel will come up at once and give you the dialtone it gets from the local exchange.
-+at this point the channel is like a legacy phone, now you can send dtmf digits to dial.    
-+
-+Example context for incoming calls on MSN 12345678:
-+===================================================
-+
-+[capi-in]
-+exten => 12345678,1,Dial(SIP/phone1)
-+exten => 12345678,2,Hangup
-+
-+
-+More information/documentation and commercial support can be found at:
-+	http://www.junghanns.net/asterisk/
-+	
-+
-+
-diff -urNad asterisk-1.2.15~dfsg~/agi/Makefile asterisk-1.2.15~dfsg/agi/Makefile
---- asterisk-1.2.15~dfsg~/agi/Makefile	2006-03-28 22:22:05.000000000 +0200
-+++ asterisk-1.2.15~dfsg/agi/Makefile	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/agi/Makefile asterisk-1.2.19/agi/Makefile
+--- asterisk-1.2.19.orig/agi/Makefile	2006-03-28 22:22:05.000000000 +0200
++++ asterisk-1.2.19/agi/Makefile	2007-06-25 11:13:51.369615860 +0200
 @@ -11,7 +11,7 @@
  # the GNU General Public License
  #
@@ -247,9 +28,9 @@
  
  %.so : %.o
  	$(CC) -shared -Xlinker -x -o $@ $<
-diff -urNad asterisk-1.2.15~dfsg~/agi/xagi-test.c asterisk-1.2.15~dfsg/agi/xagi-test.c
---- asterisk-1.2.15~dfsg~/agi/xagi-test.c	1970-01-01 02:00:00.000000000 +0200
-+++ asterisk-1.2.15~dfsg/agi/xagi-test.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/agi/xagi-test.c asterisk-1.2.19/agi/xagi-test.c
+--- asterisk-1.2.19.orig/agi/xagi-test.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.19/agi/xagi-test.c	2007-06-25 11:13:51.393621529 +0200
 @@ -0,0 +1,175 @@
 +/*
 + * Asterisk -- A telephony toolkit for Linux.
@@ -426,29 +207,9 @@
 +		return -1;
 +	exit(0);
 +}
-diff -urNad asterisk-1.2.15~dfsg~/apps/Makefile asterisk-1.2.15~dfsg/apps/Makefile
---- asterisk-1.2.15~dfsg~/apps/Makefile	2006-04-30 16:38:22.000000000 +0300
-+++ asterisk-1.2.15~dfsg/apps/Makefile	2007-02-11 06:04:58.000000000 +0200
-@@ -28,8 +28,15 @@
-      app_test.so app_forkcdr.so app_math.so app_realtime.so \
-      app_dumpchan.so app_waitforsilence.so app_while.so app_setrdnis.so \
-      app_md5.so app_readfile.so app_chanspy.so app_settransfercapability.so \
-+     app_pickup.so app_segfault.so app_callingpres.so app_devstate.so \
-      app_dictate.so app_externalivr.so app_directed_pickup.so \
--     app_mixmonitor.so app_stack.so
-+     app_mixmonitor.so app_stack.so 
-+
-+
-+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/capi20.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/capi20.h),)
-+  APPS+= app_capiNoES.so app_capiCD.so app_capiECT.so
-+endif
-+    
- 
- #
- # Obsolete things...
-diff -urNad asterisk-1.2.15~dfsg~/apps/app_callingpres.c asterisk-1.2.15~dfsg/apps/app_callingpres.c
---- asterisk-1.2.15~dfsg~/apps/app_callingpres.c	1970-01-01 02:00:00.000000000 +0200
-+++ asterisk-1.2.15~dfsg/apps/app_callingpres.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/apps/app_callingpres.c asterisk-1.2.19/apps/app_callingpres.c
+--- asterisk-1.2.19.orig/apps/app_callingpres.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.19/apps/app_callingpres.c	2007-06-25 11:13:51.397622474 +0200
 @@ -0,0 +1,70 @@
 +/*
 + * An application to change the CallingPresentation for an Asterisk channel.
@@ -520,9 +281,9 @@
 +{
 +    return ASTERISK_GPL_KEY;
 +}
-diff -urNad asterisk-1.2.15~dfsg~/apps/app_capiCD.c asterisk-1.2.15~dfsg/apps/app_capiCD.c
---- asterisk-1.2.15~dfsg~/apps/app_capiCD.c	1970-01-01 02:00:00.000000000 +0200
-+++ asterisk-1.2.15~dfsg/apps/app_capiCD.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/apps/app_capiCD.c asterisk-1.2.19/apps/app_capiCD.c
+--- asterisk-1.2.19.orig/apps/app_capiCD.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.19/apps/app_capiCD.c	2007-06-25 11:13:51.397622474 +0200
 @@ -0,0 +1,172 @@
 +/*
 + * (CAPI*)
@@ -696,9 +457,9 @@
 +{
 +	return ASTERISK_GPL_KEY;
 +}
-diff -urNad asterisk-1.2.15~dfsg~/apps/app_capiECT.c asterisk-1.2.15~dfsg/apps/app_capiECT.c
---- asterisk-1.2.15~dfsg~/apps/app_capiECT.c	1970-01-01 02:00:00.000000000 +0200
-+++ asterisk-1.2.15~dfsg/apps/app_capiECT.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/apps/app_capiECT.c asterisk-1.2.19/apps/app_capiECT.c
+--- asterisk-1.2.19.orig/apps/app_capiECT.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.19/apps/app_capiECT.c	2007-06-25 11:13:51.397622474 +0200
 @@ -0,0 +1,210 @@
 +/*
 + * (CAPI*)
@@ -910,9 +671,9 @@
 +{
 +	return ASTERISK_GPL_KEY;
 +}
-diff -urNad asterisk-1.2.15~dfsg~/apps/app_capiNoES.c asterisk-1.2.15~dfsg/apps/app_capiNoES.c
---- asterisk-1.2.15~dfsg~/apps/app_capiNoES.c	1970-01-01 02:00:00.000000000 +0200
-+++ asterisk-1.2.15~dfsg/apps/app_capiNoES.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/apps/app_capiNoES.c asterisk-1.2.19/apps/app_capiNoES.c
+--- asterisk-1.2.19.orig/apps/app_capiNoES.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.19/apps/app_capiNoES.c	2007-06-25 11:13:51.397622474 +0200
 @@ -0,0 +1,96 @@
 +/*
 + * (CAPI*)
@@ -1010,9 +771,9 @@
 +{
 +	return ASTERISK_GPL_KEY;
 +}
-diff -urNad asterisk-1.2.15~dfsg~/apps/app_chanisavail.c asterisk-1.2.15~dfsg/apps/app_chanisavail.c
---- asterisk-1.2.15~dfsg~/apps/app_chanisavail.c	2005-11-29 20:24:39.000000000 +0200
-+++ asterisk-1.2.15~dfsg/apps/app_chanisavail.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/apps/app_chanisavail.c asterisk-1.2.19/apps/app_chanisavail.c
+--- asterisk-1.2.19.orig/apps/app_chanisavail.c	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.19/apps/app_chanisavail.c	2007-06-25 11:13:51.401623419 +0200
 @@ -118,7 +118,7 @@
  				snprintf(trychan, sizeof(trychan), "%s/%s",cur,number);
  				status = inuse = ast_device_state(trychan);
@@ -1022,9 +783,9 @@
  					pbx_builtin_setvar_helper(chan, "AVAILCHAN", tempchan->name);
  					/* Store the originally used channel too */
  					snprintf(tmp, sizeof(tmp), "%s/%s", tech, number);
-diff -urNad asterisk-1.2.15~dfsg~/apps/app_chanspy.c asterisk-1.2.15~dfsg/apps/app_chanspy.c
---- asterisk-1.2.15~dfsg~/apps/app_chanspy.c	2007-02-02 01:14:09.000000000 +0200
-+++ asterisk-1.2.15~dfsg/apps/app_chanspy.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/apps/app_chanspy.c asterisk-1.2.19/apps/app_chanspy.c
+--- asterisk-1.2.19.orig/apps/app_chanspy.c	2007-02-02 00:14:09.000000000 +0100
++++ asterisk-1.2.19/apps/app_chanspy.c	2007-06-25 11:13:51.401623419 +0200
 @@ -55,6 +55,7 @@
  
  static const char *synopsis = "Listen to the audio of an active channel";
@@ -1152,9 +913,9 @@
  }
  
  char *description(void)
-diff -urNad asterisk-1.2.15~dfsg~/apps/app_devstate.c asterisk-1.2.15~dfsg/apps/app_devstate.c
---- asterisk-1.2.15~dfsg~/apps/app_devstate.c	1970-01-01 02:00:00.000000000 +0200
-+++ asterisk-1.2.15~dfsg/apps/app_devstate.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/apps/app_devstate.c asterisk-1.2.19/apps/app_devstate.c
+--- asterisk-1.2.19.orig/apps/app_devstate.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.19/apps/app_devstate.c	2007-06-25 11:13:51.401623419 +0200
 @@ -0,0 +1,225 @@
 +/*
 + * Devstate application
@@ -1381,9 +1142,9 @@
 +{
 +    return ASTERISK_GPL_KEY;
 +}
-diff -urNad asterisk-1.2.15~dfsg~/apps/app_dial.c asterisk-1.2.15~dfsg/apps/app_dial.c
---- asterisk-1.2.15~dfsg~/apps/app_dial.c	2007-02-11 06:04:48.000000000 +0200
-+++ asterisk-1.2.15~dfsg/apps/app_dial.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/apps/app_dial.c asterisk-1.2.19/apps/app_dial.c
+--- asterisk-1.2.19.orig/apps/app_dial.c	2007-06-07 16:19:40.000000000 +0200
++++ asterisk-1.2.19/apps/app_dial.c	2007-06-25 11:13:51.409625309 +0200
 @@ -11,6 +11,10 @@
   * the project provides a web site, mailing lists and IRC
   * channels for your use.
@@ -1403,7 +1164,7 @@
  
  static char *tdesc = "Dialing Application";
  
-@@ -116,7 +121,8 @@
+@@ -119,7 +124,8 @@
  "           action post answer options in conjunction with this option.\n" 
  "    h    - Allow the called party to hang up by sending the '*' DTMF digit.\n"
  "    H    - Allow the calling party to hang up by hitting the '*' DTMF digit.\n"
@@ -1413,7 +1174,7 @@
  "    L(x[:y][:z]) - Limit the call to 'x' ms. Play a warning when 'y' ms are\n"
  "           left. Repeat the warning every 'z' ms. The following special\n"
  "           variables can be used with this option:\n"
-@@ -163,8 +169,11 @@
+@@ -166,8 +172,11 @@
  "           family/key is not specified.\n"
  "    r    - Indicate ringing to the calling party. Pass no audio to the calling\n"
  "           party until the called channel has answered.\n"
@@ -1426,7 +1187,7 @@
  "    t    - Allow the called party to transfer the calling party by sending the\n"
  "           DTMF sequence defined in features.conf.\n"
  "    T    - Allow the calling party to transfer the called party by sending the\n"
-@@ -215,6 +224,8 @@
+@@ -218,6 +227,8 @@
  	OPT_CALLEE_MONITOR = (1 << 21),
  	OPT_CALLER_MONITOR = (1 << 22),
  	OPT_GOTO = (1 << 23),
@@ -1435,7 +1196,7 @@
  } dial_exec_option_flags;
  
  #define DIAL_STILLGOING			(1 << 30)
-@@ -253,6 +264,8 @@
+@@ -256,6 +267,8 @@
  	AST_APP_OPTION('p', OPT_SCREENING),
  	AST_APP_OPTION_ARG('P', OPT_PRIVACY, OPT_ARG_PRIVACY),
  	AST_APP_OPTION('r', OPT_RINGBACK),
@@ -1444,7 +1205,7 @@
  	AST_APP_OPTION_ARG('S', OPT_DURATION_STOP, OPT_ARG_DURATION_STOP),
  	AST_APP_OPTION('t', OPT_CALLEE_TRANSFER),
  	AST_APP_OPTION('T', OPT_CALLER_TRANSFER),
-@@ -390,7 +403,7 @@
+@@ -393,7 +406,7 @@
  	char *context = NULL;
  	char cidname[AST_MAX_EXTENSION];
  
@@ -1453,16 +1214,16 @@
  	
  	if (single) {
  		/* Turn off hold music, etc */
-@@ -469,7 +482,7 @@
+@@ -472,7 +485,7 @@
  						if (option_verbose > 2)
  							ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", in->name, tech, stuff, o->chan->name);
  						/* Setup parameters */
 -						o->chan = ast_request(tech, in->nativeformats, stuff, &cause);
 +						o->chan = ast_request(tech, in->nativeformats, stuff, &cause, NULL);
- 						if (!o->chan)
- 							ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause);
- 						else
-@@ -587,12 +600,18 @@
+ 						if (o->chan) {
+ 							if (single)
+ 								ast_channel_make_compatible(o->chan, in);
+@@ -592,17 +605,23 @@
  							HANDLE_CAUSE(AST_CAUSE_CONGESTION, in);
  							break;
  						case AST_CONTROL_RINGING:
@@ -1487,7 +1248,31 @@
  							break;
  						case AST_CONTROL_PROGRESS:
  							if (option_verbose > 2)
-@@ -767,6 +786,7 @@
+ 								ast_verbose ( VERBOSE_PREFIX_3 "%s is making progress passing it to %s\n", o->chan->name,in->name);
+-							if (!ast_test_flag(outgoing, OPT_RINGBACK))
++							if (!ast_test_flag(outgoing, OPT_RINGBACK | OPT_NOINBAND))
+ 								ast_indicate(in, AST_CONTROL_PROGRESS);
+ 							break;
+ 						case AST_CONTROL_VIDUPDATE:
+@@ -613,7 +632,7 @@
+ 						case AST_CONTROL_PROCEEDING:
+ 							if (option_verbose > 2)
+ 								ast_verbose ( VERBOSE_PREFIX_3 "%s is proceeding passing it to %s\n", o->chan->name,in->name);
+-							if (!ast_test_flag(outgoing, OPT_RINGBACK))
++							if (!ast_test_flag(outgoing, OPT_RINGBACK | OPT_NOINBAND))
+ 								ast_indicate(in, AST_CONTROL_PROCEEDING);
+ 							break;
+ 						case AST_CONTROL_HOLD:
+@@ -631,7 +650,7 @@
+ 							/* Ignore going off hook and flash */
+ 							break;
+ 						case -1:
+-							if (!ast_test_flag(outgoing, OPT_RINGBACK | OPT_MUSICBACK)) {
++							if (!ast_test_flag(outgoing, OPT_RINGBACK | OPT_MUSICBACK | OPT_NOINBAND)) {
+ 								if (option_verbose > 2)
+ 									ast_verbose( VERBOSE_PREFIX_3 "%s stopped sounds\n", o->chan->name);
+ 								ast_indicate(in, -1);
+@@ -779,6 +798,7 @@
  	int digit = 0, result = 0;
  	time_t start_time, answer_time, end_time;
  	struct ast_app *app = NULL;
@@ -1495,7 +1280,7 @@
  
  	char *parse;
  	AST_DECLARE_APP_ARGS(args,
-@@ -939,13 +959,13 @@
+@@ -951,13 +971,13 @@
  		}
  		
  		if( privdb_val == AST_PRIVACY_DENY ) {
@@ -1511,7 +1296,7 @@
  			if (option_priority_jumping || ast_test_flag(&opts, OPT_PRIORITY_JUMP)) {
  				ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 201);
  			}
-@@ -953,7 +973,7 @@
+@@ -965,7 +985,7 @@
  			goto out; /* Is this right? */
  		}
  		else if( privdb_val == AST_PRIVACY_TORTURE ) {
@@ -1520,16 +1305,25 @@
  			if (option_priority_jumping || ast_test_flag(&opts, OPT_PRIORITY_JUMP)) {
  				ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 301);
  			}
-@@ -1007,7 +1027,7 @@
- 	/* If a channel group has been specified, get it for use when we create peer channels */
- 	outbound_group = pbx_builtin_getvar_helper(chan, "OUTBOUND_GROUP");
- 
+@@ -1028,7 +1048,7 @@
+ 		outbound_group = pbx_builtin_getvar_helper(chan, "OUTBOUND_GROUP");
+ 	}
+ 	    
 -	ast_copy_flags(peerflags, &opts, OPT_DTMF_EXIT | OPT_GO_ON | OPT_ORIGINAL_CLID | OPT_CALLER_HANGUP);
-+	ast_copy_flags(peerflags, &opts, OPT_DTMF_EXIT | OPT_GO_ON | OPT_ORIGINAL_CLID | OPT_CALLER_HANGUP| OPT_CALLBACK_INIT | OPT_NOINBAND);
++	ast_copy_flags(peerflags, &opts, OPT_DTMF_EXIT | OPT_GO_ON | OPT_ORIGINAL_CLID | OPT_CALLER_HANGUP | OPT_CALLBACK_INIT | OPT_NOINBAND);
  	cur = args.peers;
  	do {
  		/* Remember where to start next time */
-@@ -1049,7 +1069,7 @@
+@@ -1057,7 +1077,7 @@
+ 				       OPT_CALLEE_TRANSFER | OPT_CALLER_TRANSFER |
+ 				       OPT_CALLEE_HANGUP | OPT_CALLER_HANGUP |
+ 				       OPT_CALLEE_MONITOR | OPT_CALLER_MONITOR |
+-				       OPT_RINGBACK | OPT_MUSICBACK | OPT_FORCECLID);
++				       OPT_RINGBACK | OPT_MUSICBACK | OPT_FORCECLID | OPT_NOINBAND);
+ 			ast_set2_flag(tmp, args.url, DIAL_NOFORWARDHTML);	
+ 		}
+ 		ast_copy_string(numsubst, number, sizeof(numsubst));
+@@ -1070,7 +1090,7 @@
  				ast_log(LOG_DEBUG, "Dialing by extension %s\n", numsubst);
  		}
  		/* Request the peer */
@@ -1538,7 +1332,7 @@
  		if (!tmp->chan) {
  			/* If we can't, just go on to the next call */
  			ast_log(LOG_NOTICE, "Unable to create channel of type '%s' (cause %d - %s)\n", tech, cause, ast_cause2str(cause));
-@@ -1081,7 +1101,7 @@
+@@ -1102,7 +1122,7 @@
  					ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", chan->name, tech, stuff, tmp->chan->name);
  				ast_hangup(tmp->chan);
  				/* Setup parameters */
@@ -1547,7 +1341,7 @@
  				if (!tmp->chan)
  					ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause);
  				else
-@@ -1196,7 +1216,7 @@
+@@ -1217,7 +1237,7 @@
  
  	if (outgoing) {
  		/* Our status will at least be NOANSWER */
@@ -1556,7 +1350,7 @@
  		if (ast_test_flag(outgoing, OPT_MUSICBACK)) {
  			moh=1;
  			ast_indicate(chan, AST_CONTROL_PROGRESS);
-@@ -1205,8 +1225,11 @@
+@@ -1226,8 +1246,11 @@
  			ast_indicate(chan, AST_CONTROL_RINGING);
  			sentringing++;
  		}
@@ -1570,7 +1364,61 @@
  
  	time(&start_time);
  	peer = wait_for_answer(chan, outgoing, &to, peerflags, &sentringing, status, sizeof(status), numbusy, numnochan, numcongestion, ast_test_flag(&opts, OPT_PRIORITY_JUMP), &result);
-@@ -1571,18 +1594,22 @@
+@@ -1359,7 +1382,7 @@
+ 					strcpy(status,"NOANSWER");
+ 					if (ast_test_flag(&opts, OPT_MUSICBACK)) {
+ 						ast_moh_stop(chan);
+-					} else if (ast_test_flag(&opts, OPT_RINGBACK)) {
++					} else if (ast_test_flag(&opts, OPT_RINGBACK | OPT_NOINBAND)) {
+ 						ast_indicate(chan, -1);
+ 						sentringing=0;
+ 					}
+@@ -1379,7 +1402,7 @@
+ 					res = 0;
+ 					if (ast_test_flag(&opts, OPT_MUSICBACK)) {
+ 						ast_moh_stop(chan);
+-					} else if (ast_test_flag(&opts, OPT_RINGBACK)) {
++					} else if (ast_test_flag(&opts, OPT_RINGBACK | OPT_NOINBAND)) {
+ 						ast_indicate(chan, -1);
+ 						sentringing=0;
+ 					}
+@@ -1398,7 +1421,7 @@
+ 					res = 0;
+ 					if (ast_test_flag(&opts, OPT_MUSICBACK)) {
+ 						ast_moh_stop(chan);
+-					} else if (ast_test_flag(&opts, OPT_RINGBACK)) {
++					} else if (ast_test_flag(&opts, OPT_RINGBACK | OPT_NOINBAND)) {
+ 						ast_indicate(chan, -1);
+ 						sentringing=0;
+ 					}
+@@ -1413,7 +1436,7 @@
+ 						ast_privacy_set(opt_args[OPT_ARG_PRIVACY], privcid, AST_PRIVACY_ALLOW);
+ 						if (ast_test_flag(&opts, OPT_MUSICBACK)) {
+ 							ast_moh_stop(chan);
+-						} else if (ast_test_flag(&opts, OPT_RINGBACK)) {
++						} else if (ast_test_flag(&opts, OPT_RINGBACK | OPT_NOINBAND)) {
+ 							ast_indicate(chan, -1);
+ 							sentringing=0;
+ 						}
+@@ -1431,7 +1454,7 @@
+ 						ast_log(LOG_NOTICE,"privacy: no valid response from the callee. Sending the caller to voicemail, the callee isn't responding\n");
+ 					if (ast_test_flag(&opts, OPT_MUSICBACK)) {
+ 						ast_moh_stop(chan);
+-					} else if (ast_test_flag(&opts, OPT_RINGBACK)) {
++					} else if (ast_test_flag(&opts, OPT_RINGBACK | OPT_NOINBAND)) {
+ 						ast_indicate(chan, -1);
+ 						sentringing=0;
+ 					}
+@@ -1442,7 +1465,7 @@
+ 				}
+ 				if (ast_test_flag(&opts, OPT_MUSICBACK)) {
+ 					ast_moh_stop(chan);
+-				} else if (ast_test_flag(&opts, OPT_RINGBACK)) {
++				} else if (ast_test_flag(&opts, OPT_RINGBACK | OPT_NOINBAND)) {
+ 					ast_indicate(chan, -1);
+ 					sentringing=0;
+ 				}
+@@ -1594,18 +1617,22 @@
  				ast_set_flag(&(config.features_caller), AST_FEATURE_PLAY_WARNING);
  			if (play_to_callee)
  				ast_set_flag(&(config.features_callee), AST_FEATURE_PLAY_WARNING);
@@ -1599,7 +1447,7 @@
  
  			config.timelimit = timelimit;
  			config.play_warning = play_warning;
-@@ -1618,7 +1645,15 @@
+@@ -1641,7 +1668,15 @@
  		}
  		snprintf(toast, sizeof(toast), "%ld", (long)(end_time - start_time));
  		pbx_builtin_setvar_helper(chan, "DIALEDTIME", toast);
@@ -1616,9 +1464,9 @@
  		if (res != AST_PBX_NO_HANGUP_PEER) {
  			if (!chan->_softhangup)
  				chan->hangupcause = peer->hangupcause;
-diff -urNad asterisk-1.2.15~dfsg~/apps/app_directed_pickup.c asterisk-1.2.15~dfsg/apps/app_directed_pickup.c
---- asterisk-1.2.15~dfsg~/apps/app_directed_pickup.c	2006-04-06 20:00:10.000000000 +0300
-+++ asterisk-1.2.15~dfsg/apps/app_directed_pickup.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/apps/app_directed_pickup.c asterisk-1.2.19/apps/app_directed_pickup.c
+--- asterisk-1.2.19.orig/apps/app_directed_pickup.c	2006-04-06 19:00:10.000000000 +0200
++++ asterisk-1.2.19/apps/app_directed_pickup.c	2007-06-25 11:13:51.409625309 +0200
 @@ -41,7 +41,7 @@
  #include "asterisk/app.h"
  
@@ -1628,10 +1476,10 @@
  static const char *synopsis = "Directed Call Pickup";
  static const char *descrip =
  "  Pickup(extension[@context]): This application can pickup any ringing channel\n"
-diff -urNad asterisk-1.2.15~dfsg~/apps/app_meetme.c asterisk-1.2.15~dfsg/apps/app_meetme.c
---- asterisk-1.2.15~dfsg~/apps/app_meetme.c	2007-02-03 22:39:45.000000000 +0200
-+++ asterisk-1.2.15~dfsg/apps/app_meetme.c	2007-02-11 06:04:58.000000000 +0200
-@@ -458,7 +458,7 @@
+diff -urN asterisk-1.2.19.orig/apps/app_meetme.c asterisk-1.2.19/apps/app_meetme.c
+--- asterisk-1.2.19.orig/apps/app_meetme.c	2007-03-29 19:33:58.000000000 +0200
++++ asterisk-1.2.19/apps/app_meetme.c	2007-06-25 11:13:51.413626254 +0200
+@@ -460,7 +460,7 @@
  			ast_copy_string(cnf->pin, pin, sizeof(cnf->pin));
  			ast_copy_string(cnf->pinadmin, pinadmin, sizeof(cnf->pinadmin));
  			cnf->markedusers = 0;
@@ -1640,7 +1488,7 @@
  			if (cnf->chan) {
  				cnf->fd = cnf->chan->fds[0];	/* for use by conf_play() */
  			} else {
-@@ -829,8 +829,9 @@
+@@ -850,8 +850,9 @@
  	char recordingtmp[AST_MAX_EXTENSION] = "";
  	int dtmf, opt_waitmarked_timeout = 0;
  	time_t timeout = 0;
@@ -1651,7 +1499,7 @@
  	char *buf = __buf + AST_FRIENDLY_OFFSET;
  	
  	if (!user) {
-@@ -1008,7 +1009,7 @@
+@@ -1021,7 +1022,7 @@
  		}
  		/* Setup buffering information */
  		memset(&bi, 0, sizeof(bi));
@@ -1660,7 +1508,7 @@
  		bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
  		bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
  		bi.numbufs = audio_buffers;
-@@ -1298,6 +1299,14 @@
+@@ -1311,6 +1312,14 @@
  				f = ast_read(c);
  				if (!f)
  					break;
@@ -1675,7 +1523,7 @@
  				if ((f->frametype == AST_FRAME_VOICE) && (f->subclass == AST_FORMAT_SLINEAR)) {
  					if (user->talk.actual)
  						ast_frame_adjust_volume(f, user->talk.actual);
-@@ -1532,7 +1541,7 @@
+@@ -1545,7 +1554,7 @@
  				}
  				ast_frfree(f);
  			} else if (outfd > -1) {
@@ -1684,9 +1532,9 @@
  				if (res > 0) {
  					memset(&fr, 0, sizeof(fr));
  					fr.frametype = AST_FRAME_VOICE;
-diff -urNad asterisk-1.2.15~dfsg~/apps/app_milliwatt.c asterisk-1.2.15~dfsg/apps/app_milliwatt.c
---- asterisk-1.2.15~dfsg~/apps/app_milliwatt.c	2006-01-19 06:17:45.000000000 +0200
-+++ asterisk-1.2.15~dfsg/apps/app_milliwatt.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/apps/app_milliwatt.c asterisk-1.2.19/apps/app_milliwatt.c
+--- asterisk-1.2.19.orig/apps/app_milliwatt.c	2006-01-19 05:17:45.000000000 +0100
++++ asterisk-1.2.19/apps/app_milliwatt.c	2007-06-25 11:13:51.413626254 +0200
 @@ -74,20 +74,28 @@
  {
  	struct ast_frame wf;
@@ -1722,9 +1570,9 @@
  	wf.src = "app_milliwatt";
  	wf.delivery.tv_sec = 0;
  	wf.delivery.tv_usec = 0;
-diff -urNad asterisk-1.2.15~dfsg~/apps/app_page.c asterisk-1.2.15~dfsg/apps/app_page.c
---- asterisk-1.2.15~dfsg~/apps/app_page.c	2007-01-31 23:25:11.000000000 +0200
-+++ asterisk-1.2.15~dfsg/apps/app_page.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/apps/app_page.c asterisk-1.2.19/apps/app_page.c
+--- asterisk-1.2.19.orig/apps/app_page.c	2007-02-20 20:49:50.000000000 +0100
++++ asterisk-1.2.19/apps/app_page.c	2007-06-25 11:13:51.413626254 +0200
 @@ -85,7 +85,7 @@
  {
  	struct calloutdata *cd = data;
@@ -1734,9 +1582,9 @@
  	free(cd);
  	return NULL;
  }
-diff -urNad asterisk-1.2.15~dfsg~/apps/app_parkandannounce.c asterisk-1.2.15~dfsg/apps/app_parkandannounce.c
---- asterisk-1.2.15~dfsg~/apps/app_parkandannounce.c	2005-11-29 20:24:39.000000000 +0200
-+++ asterisk-1.2.15~dfsg/apps/app_parkandannounce.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/apps/app_parkandannounce.c asterisk-1.2.19/apps/app_parkandannounce.c
+--- asterisk-1.2.19.orig/apps/app_parkandannounce.c	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.19/apps/app_parkandannounce.c	2007-06-25 11:13:51.413626254 +0200
 @@ -183,7 +183,7 @@
  
  	memset(&oh, 0, sizeof(oh));
@@ -1746,9 +1594,9 @@
  
  	if(dchan) {
  		if(dchan->_state == AST_STATE_UP) {
-diff -urNad asterisk-1.2.15~dfsg~/apps/app_pickup.c asterisk-1.2.15~dfsg/apps/app_pickup.c
---- asterisk-1.2.15~dfsg~/apps/app_pickup.c	1970-01-01 02:00:00.000000000 +0200
-+++ asterisk-1.2.15~dfsg/apps/app_pickup.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/apps/app_pickup.c asterisk-1.2.19/apps/app_pickup.c
+--- asterisk-1.2.19.orig/apps/app_pickup.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.19/apps/app_pickup.c	2007-06-25 16:03:48.878931207 +0200
 @@ -0,0 +1,319 @@
 +/*
 + * Asterisk -- A telephony toolkit for Linux.
@@ -2069,10 +1917,10 @@
 +{
 +	return ASTERISK_GPL_KEY;
 +}
-diff -urNad asterisk-1.2.15~dfsg~/apps/app_queue.c asterisk-1.2.15~dfsg/apps/app_queue.c
---- asterisk-1.2.15~dfsg~/apps/app_queue.c	2007-01-31 23:25:11.000000000 +0200
-+++ asterisk-1.2.15~dfsg/apps/app_queue.c	2007-02-11 06:04:58.000000000 +0200
-@@ -543,7 +543,7 @@
+diff -urN asterisk-1.2.19.orig/apps/app_queue.c asterisk-1.2.19/apps/app_queue.c
+--- asterisk-1.2.19.orig/apps/app_queue.c	2007-05-22 15:07:03.000000000 +0200
++++ asterisk-1.2.19/apps/app_queue.c	2007-06-25 11:13:51.421628144 +0200
+@@ -545,7 +545,7 @@
  	return NULL;
  }
  
@@ -2081,7 +1929,7 @@
  {
  	/* Avoid potential for deadlocks by spawning a new thread to handle
  	   the event */
-@@ -1527,7 +1527,7 @@
+@@ -1529,7 +1529,7 @@
  		location = "";
  
  	/* Request the peer */
@@ -2090,7 +1938,7 @@
  	if (!tmp->chan) {			/* If we can't, just go on to the next call */
  #if 0
  		ast_log(LOG_NOTICE, "Unable to create channel of type '%s' for Queue\n", cur->tech);
-@@ -1839,7 +1839,7 @@
+@@ -1841,7 +1841,7 @@
  					if (option_verbose > 2)
  						ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", in->name, tech, stuff, o->chan->name);
  					/* Setup parameters */
@@ -2099,7 +1947,7 @@
  					if (status != o->oldstatus) 
  						update_dial_status(qe->parent, o->member, status);						
  					if (!o->chan) {
-@@ -2383,14 +2383,14 @@
+@@ -2385,14 +2385,14 @@
  			else
  				which = peer;
  			if (monitorfilename)
@@ -2117,9 +1965,9 @@
  			}
  			if (qe->parent->monjoin)
  				ast_monitor_setjoinfiles(which, 1);
-diff -urNad asterisk-1.2.15~dfsg~/apps/app_readfile.c asterisk-1.2.15~dfsg/apps/app_readfile.c
---- asterisk-1.2.15~dfsg~/apps/app_readfile.c	2006-03-23 22:13:48.000000000 +0200
-+++ asterisk-1.2.15~dfsg/apps/app_readfile.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/apps/app_readfile.c asterisk-1.2.19/apps/app_readfile.c
+--- asterisk-1.2.19.orig/apps/app_readfile.c	2006-03-23 21:13:48.000000000 +0100
++++ asterisk-1.2.19/apps/app_readfile.c	2007-06-25 11:13:51.421628144 +0200
 @@ -40,7 +40,7 @@
  #include "asterisk/app.h"
  #include "asterisk/module.h"
@@ -2129,9 +1977,9 @@
  
  static char *app_readfile = "ReadFile";
  
-diff -urNad asterisk-1.2.15~dfsg~/apps/app_segfault.c asterisk-1.2.15~dfsg/apps/app_segfault.c
---- asterisk-1.2.15~dfsg~/apps/app_segfault.c	1970-01-01 02:00:00.000000000 +0200
-+++ asterisk-1.2.15~dfsg/apps/app_segfault.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/apps/app_segfault.c asterisk-1.2.19/apps/app_segfault.c
+--- asterisk-1.2.19.orig/apps/app_segfault.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.19/apps/app_segfault.c	2007-06-25 11:13:51.421628144 +0200
 @@ -0,0 +1,75 @@
 +/*
 + * Segfault application
@@ -2208,9 +2056,9 @@
 +{
 +    return ASTERISK_GPL_KEY;
 +}
-diff -urNad asterisk-1.2.15~dfsg~/apps/app_sendtext.c asterisk-1.2.15~dfsg/apps/app_sendtext.c
---- asterisk-1.2.15~dfsg~/apps/app_sendtext.c	2005-11-29 20:24:39.000000000 +0200
-+++ asterisk-1.2.15~dfsg/apps/app_sendtext.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/apps/app_sendtext.c asterisk-1.2.19/apps/app_sendtext.c
+--- asterisk-1.2.19.orig/apps/app_sendtext.c	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.19/apps/app_sendtext.c	2007-06-25 11:13:51.425629089 +0200
 @@ -112,7 +112,7 @@
  	}
  	status = "FAILURE";
@@ -2220,9 +2068,9 @@
  	if (!res)
  		status = "SUCCESS";
  	pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
-diff -urNad asterisk-1.2.15~dfsg~/apps/app_zapras.c asterisk-1.2.15~dfsg/apps/app_zapras.c
---- asterisk-1.2.15~dfsg~/apps/app_zapras.c	2006-12-11 02:33:59.000000000 +0200
-+++ asterisk-1.2.15~dfsg/apps/app_zapras.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/apps/app_zapras.c asterisk-1.2.19/apps/app_zapras.c
+--- asterisk-1.2.19.orig/apps/app_zapras.c	2006-12-11 01:33:59.000000000 +0100
++++ asterisk-1.2.19/apps/app_zapras.c	2007-06-25 11:13:51.425629089 +0200
 @@ -188,7 +188,7 @@
  				}
  			}
@@ -2232,9 +2080,29 @@
  			ioctl(chan->fds[0], ZT_AUDIOMODE, &x);
  
  			/* Restore saved values */
-diff -urNad asterisk-1.2.15~dfsg~/asterisk.c asterisk-1.2.15~dfsg/asterisk.c
---- asterisk-1.2.15~dfsg~/asterisk.c	2007-02-11 06:04:48.000000000 +0200
-+++ asterisk-1.2.15~dfsg/asterisk.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/apps/Makefile asterisk-1.2.19/apps/Makefile
+--- asterisk-1.2.19.orig/apps/Makefile	2006-04-30 15:38:22.000000000 +0200
++++ asterisk-1.2.19/apps/Makefile	2007-06-25 11:13:51.425629089 +0200
+@@ -28,8 +28,15 @@
+      app_test.so app_forkcdr.so app_math.so app_realtime.so \
+      app_dumpchan.so app_waitforsilence.so app_while.so app_setrdnis.so \
+      app_md5.so app_readfile.so app_chanspy.so app_settransfercapability.so \
++     app_pickup.so app_segfault.so app_callingpres.so app_devstate.so \
+      app_dictate.so app_externalivr.so app_directed_pickup.so \
+-     app_mixmonitor.so app_stack.so
++     app_mixmonitor.so app_stack.so 
++
++
++ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/capi20.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/capi20.h),)
++  APPS+= app_capiNoES.so app_capiCD.so app_capiECT.so
++endif
++    
+ 
+ #
+ # Obsolete things...
+diff -urN asterisk-1.2.19.orig/asterisk.c asterisk-1.2.19/asterisk.c
+--- asterisk-1.2.19.orig/asterisk.c	2007-04-30 16:34:07.000000000 +0200
++++ asterisk-1.2.19/asterisk.c	2007-06-25 11:13:51.429630034 +0200
 @@ -169,7 +169,7 @@
  int option_maxcalls = 0;			/*!< */
  double option_maxload = 0.0;			/*!< Max load avg on system */
@@ -2252,7 +2120,7 @@
  
  static char *_argv[256];
  static int shuttingdown = 0;
-@@ -1885,6 +1886,7 @@
+@@ -1890,6 +1891,7 @@
  	ast_copy_string(ast_config_AST_PID, AST_PID, sizeof(ast_config_AST_PID));
  	ast_copy_string(ast_config_AST_SOCKET, AST_SOCKET, sizeof(ast_config_AST_SOCKET));
  	ast_copy_string(ast_config_AST_RUN_DIR, AST_RUN_DIR, sizeof(ast_config_AST_RUN_DIR));
@@ -2260,7 +2128,7 @@
  
  	/* no asterisk.conf? no problem, use buildtime config! */
  	if (!cfg) {
-@@ -1999,6 +2001,8 @@
+@@ -2004,6 +2006,8 @@
  		/* What group to run as */
  		} else if (!strcasecmp(v->name, "rungroup")) {
  			ast_copy_string(ast_config_AST_RUN_GROUP, v->value, sizeof(ast_config_AST_RUN_GROUP));
@@ -2269,9 +2137,9 @@
  		}
  		v = v->next;
  	}
-diff -urNad asterisk-1.2.15~dfsg~/build_tools/make_defaults_h asterisk-1.2.15~dfsg/build_tools/make_defaults_h
---- asterisk-1.2.15~dfsg~/build_tools/make_defaults_h	2007-02-11 06:04:48.000000000 +0200
-+++ asterisk-1.2.15~dfsg/build_tools/make_defaults_h	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/build_tools/make_defaults_h asterisk-1.2.19/build_tools/make_defaults_h
+--- asterisk-1.2.19.orig/build_tools/make_defaults_h	2005-06-20 19:26:08.000000000 +0200
++++ asterisk-1.2.19/build_tools/make_defaults_h	2007-06-25 11:13:51.429630034 +0200
 @@ -16,6 +16,7 @@
  #define AST_KEY_DIR    "${INSTALL_PATH}${ASTVARLIBDIR}/keys"
  #define AST_DB         "${INSTALL_PATH}${ASTVARLIBDIR}/astdb"
@@ -2280,9 +2148,9 @@
  
  #define AST_CONFIG_FILE "${INSTALL_PATH}${ASTCONFPATH}"
  
-diff -urNad asterisk-1.2.15~dfsg~/channel.c asterisk-1.2.15~dfsg/channel.c
---- asterisk-1.2.15~dfsg~/channel.c	2007-01-30 21:41:52.000000000 +0200
-+++ asterisk-1.2.15~dfsg/channel.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/channel.c asterisk-1.2.19/channel.c
+--- asterisk-1.2.19.orig/channel.c	2007-06-14 22:56:19.000000000 +0200
++++ asterisk-1.2.19/channel.c	2007-06-25 11:13:51.433630978 +0200
 @@ -94,8 +94,8 @@
   */
  static int shutting_down = 0;
@@ -2319,7 +2187,18 @@
  	        
  
  	/* If shutting down, don't allocate any new channels */
-@@ -587,9 +599,12 @@
+@@ -563,6 +575,10 @@
+ 	if (needqueue) {
+ 		if (pipe(tmp->alertpipe)) {
+ 			ast_log(LOG_WARNING, "Channel allocation failed: Can't create alert pipe!\n");
++			if (tmp->sched) {
++			    sched_context_destroy(tmp->sched);	
++			    tmp->sched = NULL;
++			}
+ 			free(tmp);
+ 			return NULL;
+ 		} else {
+@@ -587,9 +603,12 @@
  	tmp->data = NULL;
  	tmp->fin = global_fin;
  	tmp->fout = global_fout;
@@ -2335,7 +2214,7 @@
  	headp = &tmp->varshead;
  	ast_mutex_init(&tmp->lock);
  	AST_LIST_HEAD_INIT_NOLOCK(headp);
-@@ -732,7 +747,7 @@
+@@ -732,7 +751,7 @@
   */
  static struct ast_channel *channel_find_locked(const struct ast_channel *prev,
  					       const char *name, const int namelen,
@@ -2344,9 +2223,9 @@
  {
  	const char *msg = prev ? "deadlock" : "initial deadlock";
  	int retries;
-@@ -749,7 +764,12 @@
- 				/* found, prepare to return c->next */
- 				c = c->next;
+@@ -753,7 +772,12 @@
+ 				 * next section.
+ 				 */
  			}
 -			if (name) { /* want match by name */
 +			if (uniqueid) {
@@ -2358,7 +2237,7 @@
  				if ((!namelen && strcasecmp(c->name, name)) ||
  				    (namelen && strncasecmp(c->name, name, namelen)))
  					continue;	/* name match failed */
-@@ -787,33 +807,39 @@
+@@ -801,33 +825,39 @@
  /*--- ast_channel_walk_locked: Browse channels in use */
  struct ast_channel *ast_channel_walk_locked(const struct ast_channel *prev)
  {
@@ -2392,80 +2271,27 @@
  {
 -	return channel_find_locked(NULL, NULL, 0, context, exten);
 +	return channel_find_locked(NULL, NULL, 0, context, exten, NULL);
-+}
-+
+ }
+ 
 +struct ast_channel *ast_get_channel_by_uniqueid_locked(const char *uniqueid)
 +{
 +	return channel_find_locked(NULL, NULL, 0, NULL, NULL, uniqueid);
- }
- 
++}
 +
++
  /*--- ast_safe_sleep_conditional: Wait, look for hangups and condition arg */
  int ast_safe_sleep_conditional(	struct ast_channel *chan, int ms,
  	int (*cond)(void*), void *data )
-@@ -879,8 +905,9 @@
- 	char name[AST_CHANNEL_NAME];
- 	
- 	headp=&chan->varshead;
-+	ast_mutex_lock(&chan->lock); 	/* aquire channel lock first */
- 	
--	ast_mutex_lock(&chlock);
-+	ast_mutex_lock(&chlock);	/* aquire list lock */
- 	cur = channels;
- 	while(cur) {
- 		if (cur == chan) {
-@@ -893,21 +920,20 @@
- 		last = cur;
- 		cur = cur->next;
- 	}
-+	
-+	ast_mutex_unlock(&chlock);	/* release list lock */
- 	if (!cur)
- 		ast_log(LOG_WARNING, "Unable to find channel in list\n");
--	else {
--		/* Lock and unlock the channel just to be sure nobody
--		   has it locked still */
--		ast_mutex_lock(&cur->lock);
--		ast_mutex_unlock(&cur->lock);
--	}
-+
- 	if (chan->tech_pvt) {
- 		ast_log(LOG_WARNING, "Channel '%s' may not have been hung up properly\n", chan->name);
- 		free(chan->tech_pvt);
- 	}
- 
--	if (chan->sched)
--		sched_context_destroy(chan->sched);
-+	if (chan->sched) {
-+		sched_context_destroy(chan->sched);	
-+		chan->sched = NULL;
-+	}
- 
- 	ast_copy_string(name, chan->name, sizeof(name));
- 
-@@ -928,6 +954,8 @@
- 	if (chan->pbx) 
- 		ast_log(LOG_WARNING, "PBX may not have been terminated properly on '%s'\n", chan->name);
- 	free_cid(&chan->cid);
-+
-+	ast_mutex_unlock(&chan->lock);
- 	ast_mutex_destroy(&chan->lock);
- 	/* Close pipes if appropriate */
- 	if ((fd = chan->alertpipe[0]) > -1)
-@@ -950,10 +978,10 @@
- 	while ((vardata = AST_LIST_REMOVE_HEAD(headp, entries)))
- 		ast_var_delete(vardata);
- 
-+
+@@ -972,7 +1002,7 @@
  	free(chan);
--	ast_mutex_unlock(&chlock);
+ 	ast_mutex_unlock(&chlock);
  
 -	ast_device_state_changed_literal(name);
 +	ast_device_state_changed_literal(name, NULL, NULL);
  }
  
  int ast_channel_spy_add(struct ast_channel *chan, struct ast_channel_spy *spy)
-@@ -2142,7 +2170,7 @@
+@@ -2161,7 +2191,7 @@
  	return buf;
  }
  
@@ -2474,7 +2300,7 @@
  {
  	int res = 0;
  	/* Stop if we're a zombie or need a soft hangup */
-@@ -2150,7 +2178,7 @@
+@@ -2169,7 +2199,7 @@
  		return -1;
  	CHECK_BLOCKING(chan);
  	if (chan->tech->send_text)
@@ -2483,7 +2309,7 @@
  	ast_clear_flag(chan, AST_FLAG_BLOCKING);
  	return res;
  }
-@@ -2280,7 +2308,7 @@
+@@ -2299,7 +2329,7 @@
  		break;
  	case AST_FRAME_TEXT:
  		if (chan->tech->send_text)
@@ -2492,7 +2318,7 @@
  		else
  			res = 0;
  		break;
-@@ -2424,7 +2452,7 @@
+@@ -2443,7 +2473,7 @@
  			  &chan->writetrans, 1);
  }
  
@@ -2501,7 +2327,7 @@
  {
  	int state = 0;
  	int cause = 0;
-@@ -2432,7 +2460,7 @@
+@@ -2451,7 +2481,7 @@
  	struct ast_frame *f;
  	int res = 0;
  	
@@ -2510,7 +2336,7 @@
  	if (chan) {
  		if (oh) {
  			if (oh->vars)	
-@@ -2446,6 +2474,7 @@
+@@ -2465,6 +2495,7 @@
  		}
  		ast_set_callerid(chan, cid_num, cid_name, cid_num);
  
@@ -2518,7 +2344,7 @@
  		if (!ast_call(chan, data, 0)) {
  			res = 1;	/* in case chan->_state is already AST_STATE_UP */
  			while (timeout && (chan->_state != AST_STATE_UP)) {
-@@ -2469,6 +2498,7 @@
+@@ -2488,6 +2519,7 @@
  					if (f->subclass == AST_CONTROL_RINGING)
  						state = AST_CONTROL_RINGING;
  					else if ((f->subclass == AST_CONTROL_BUSY) || (f->subclass == AST_CONTROL_CONGESTION)) {
@@ -2526,7 +2352,7 @@
  						state = f->subclass;
  						ast_frfree(f);
  						break;
-@@ -2538,12 +2568,12 @@
+@@ -2557,12 +2589,12 @@
  	return chan;
  }
  
@@ -2542,7 +2368,7 @@
  {
  	struct chanlist *chan;
  	struct ast_channel *c;
-@@ -2580,6 +2610,7 @@
+@@ -2599,6 +2631,7 @@
  		if (!(c = chan->tech->requester(type, capabilities, data, cause)))
  			return NULL;
  
@@ -2550,7 +2376,7 @@
  		if (c->_state == AST_STATE_DOWN) {
  			manager_event(EVENT_FLAG_CALL, "Newchannel",
  				      "Channel: %s\r\n"
-@@ -2856,6 +2887,29 @@
+@@ -2880,6 +2913,29 @@
  	return res;
  }
  
@@ -2580,7 +2406,7 @@
  void ast_change_name(struct ast_channel *chan, char *newname)
  {
  	char tmp[256];
-@@ -2997,7 +3051,7 @@
+@@ -3005,7 +3061,7 @@
  	ast_copy_string(clone->name, masqn, sizeof(clone->name));
  	
  	/* Notify any managers of the change, first the masq then the other */
@@ -2589,7 +2415,7 @@
  	manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", orig, newn, original->uniqueid);
  
  	/* Swap the technlogies */	
-@@ -3245,15 +3299,14 @@
+@@ -3255,15 +3311,14 @@
  				);
  }
  
@@ -2607,7 +2433,7 @@
  	manager_event(EVENT_FLAG_CALL,
  		      (oldstate == AST_STATE_DOWN && !ast_test_flag(chan, AST_FLAG_NOTNEW)) ? "Newchannel" : "Newstate",
  		      "Channel: %s\r\n"
-@@ -3269,6 +3322,10 @@
+@@ -3279,6 +3334,10 @@
  	return 0;
  }
  
@@ -2618,7 +2444,7 @@
  /*--- Find bridged channel */
  struct ast_channel *ast_bridged_channel(struct ast_channel *chan)
  {
-@@ -3448,6 +3505,7 @@
+@@ -3458,6 +3517,7 @@
  	char caller_warning = 0;
  	char callee_warning = 0;
  
@@ -2626,7 +2452,7 @@
  	if (c0->_bridge) {
  		ast_log(LOG_WARNING, "%s is already in a bridge with %s\n", 
  			c0->name, c0->_bridge->name);
-@@ -3458,6 +3516,10 @@
+@@ -3468,6 +3528,10 @@
  			c1->name, c1->_bridge->name);
  		return -1;
  	}
@@ -2637,7 +2463,7 @@
  	
  	/* Stop if we're a zombie or need a soft hangup */
  	if (ast_test_flag(c0, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) ||
-@@ -4181,3 +4243,22 @@
+@@ -4191,3 +4255,22 @@
  
  	free(state);
  }
@@ -2660,79 +2486,9 @@
 +
 +	return res;
 +}
-diff -urNad asterisk-1.2.15~dfsg~/channels/Makefile asterisk-1.2.15~dfsg/channels/Makefile
---- asterisk-1.2.15~dfsg~/channels/Makefile	2007-02-11 06:04:47.000000000 +0200
-+++ asterisk-1.2.15~dfsg/channels/Makefile	2007-02-11 06:04:58.000000000 +0200
-@@ -102,6 +102,11 @@
-   ZAPR2=-lmfcr2
- endif
- 
-+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/lib/libgsmat.so.1)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/lib/libgsmat.so.1),)
-+  CFLAGS+=-DZAPATA_GSM
-+  ZAPGSM=-lgsmat
-+endif
-+
- ALSA_SRC=chan_alsa.c
- 
- ifneq ($(wildcard alsa-monitor.h),)
-@@ -122,6 +127,35 @@
- endif
- endif # WITHOUT_ZAPTEL
- 
-+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/capi20.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/capi20.h),)
-+  CHANNEL_LIBS+=chan_capi.so
-+# uncomment the following line if you really never ever want early b3 connects,
-+# you can also configure it in the dialstring, this is just for performance
-+# NOTE: this is probably obsolete by using the "R" dial option
-+#CFLAGS+=-DCAPI_NEVER_EVER_EARLY_B3_CONNECTS
-+
-+# uncommnet next line to force dtmf software detection/generation, can also be configured
-+# in capi.conf on a perdevice basis (softdtmf=1)
-+#CFLAGS+=-DCAPI_FORCE_SOFTWARE_DTMF
-+
-+# uncomment the next line if you are in the ulaw world
-+#CFLAGS+=-DCAPI_ULAW
-+
-+# very experimental echo squelching
-+CFLAGS+=-DCAPI_ES
-+
-+#gains
-+CFLAGS+=-DCAPI_GAIN
-+
-+# what do to with call waiting connect indications?
-+# uncomment the next line for call deflection in that case
-+CFLAGS+=-DCAPI_DEFLECT_ON_CIRCUITBUSY
-+
-+# audio sync
-+CFLAGS+=-DCAPI_SYNC
-+
-+endif
-+
- ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/vpbapi.h),)
-   CHANNEL_LIBS+=chan_vpb.so
-   CFLAGS+=-DLINUX
-@@ -204,7 +238,7 @@
- 	$(CC) -c $(CFLAGS) -o chan_zap.o chan_zap.c
- 
- chan_zap.so: chan_zap.o
--	$(CC) $(SOLINK) -o $@ $<  $(ZAPPRI) $(ZAPR2) -ltonezone
-+	$(CC) $(SOLINK) -o $@ $<  $(ZAPPRI) $(ZAPGSM) $(ZAPR2) -ltonezone
- 
- chan_sip.so: chan_sip.o
- 	$(CC) $(SOLINK) -o $@ ${CYGSOLINK} chan_sip.o ${CYGSOLIB}
-@@ -220,6 +254,9 @@
- chan_nbs.so: chan_nbs.o
- 	$(CC) $(SOLINK) -o $@ $< -lnbs
- 
-+chan_capi.so: chan_capi.o
-+	$(CC) $(SOLINK) -o $@ $< -lcapi20
-+
- chan_vpb.o: chan_vpb.c
- 	$(CXX) -c $(CFLAGS) -o $@ chan_vpb.c
- 
-diff -urNad asterisk-1.2.15~dfsg~/channels/chan_agent.c asterisk-1.2.15~dfsg/channels/chan_agent.c
---- asterisk-1.2.15~dfsg~/channels/chan_agent.c	2006-09-06 21:16:41.000000000 +0300
-+++ asterisk-1.2.15~dfsg/channels/chan_agent.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/channels/chan_agent.c asterisk-1.2.19/channels/chan_agent.c
+--- asterisk-1.2.19.orig/channels/chan_agent.c	2007-02-28 19:55:45.000000000 +0100
++++ asterisk-1.2.19/channels/chan_agent.c	2007-06-25 11:13:51.437631923 +0200
 @@ -248,7 +248,7 @@
  static struct ast_frame *agent_read(struct ast_channel *ast);
  static int agent_write(struct ast_channel *ast, struct ast_frame *f);
@@ -2767,7 +2523,7 @@
  	ast_mutex_unlock(&p->lock);
  	return res;
  }
-@@ -1336,7 +1336,7 @@
+@@ -1348,7 +1348,7 @@
  						chan = agent_new(p, AST_STATE_DOWN);
  					} else if (!p->owner && !ast_strlen_zero(p->loginchan)) {
  						/* Adjustable agent */
@@ -2776,9 +2532,9 @@
  						if (p->chan)
  							chan = agent_new(p, AST_STATE_DOWN);
  					}
-diff -urNad asterisk-1.2.15~dfsg~/channels/chan_alsa.c asterisk-1.2.15~dfsg/channels/chan_alsa.c
---- asterisk-1.2.15~dfsg~/channels/chan_alsa.c	2005-12-21 22:01:16.000000000 +0200
-+++ asterisk-1.2.15~dfsg/channels/chan_alsa.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/channels/chan_alsa.c asterisk-1.2.19/channels/chan_alsa.c
+--- asterisk-1.2.19.orig/channels/chan_alsa.c	2005-12-21 21:01:16.000000000 +0100
++++ asterisk-1.2.19/channels/chan_alsa.c	2007-06-25 11:13:51.437631923 +0200
 @@ -172,7 +172,7 @@
  /* ZZ */
  static struct ast_channel *alsa_request(const char *type, int format, void *data, int *cause);
@@ -2797,9 +2553,9 @@
  {
  	ast_mutex_lock(&alsalock);
  	ast_verbose( " << Console Received text %s >> \n", text);
-diff -urNad asterisk-1.2.15~dfsg~/channels/chan_capi.c asterisk-1.2.15~dfsg/channels/chan_capi.c
---- asterisk-1.2.15~dfsg~/channels/chan_capi.c	1970-01-01 02:00:00.000000000 +0200
-+++ asterisk-1.2.15~dfsg/channels/chan_capi.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/channels/chan_capi.c asterisk-1.2.19/channels/chan_capi.c
+--- asterisk-1.2.19.orig/channels/chan_capi.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.19/channels/chan_capi.c	2007-06-25 11:13:51.445633813 +0200
 @@ -0,0 +1,2888 @@
 +/*
 + * (CAPI*)
@@ -5689,9 +5445,9 @@
 +{
 +	return ASTERISK_GPL_KEY;
 +}
-diff -urNad asterisk-1.2.15~dfsg~/channels/chan_features.c asterisk-1.2.15~dfsg/channels/chan_features.c
---- asterisk-1.2.15~dfsg~/channels/chan_features.c	2006-08-30 21:59:44.000000000 +0300
-+++ asterisk-1.2.15~dfsg/channels/chan_features.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/channels/chan_features.c asterisk-1.2.19/channels/chan_features.c
+--- asterisk-1.2.19.orig/channels/chan_features.c	2006-08-30 20:59:44.000000000 +0200
++++ asterisk-1.2.19/channels/chan_features.c	2007-06-25 11:13:51.445633813 +0200
 @@ -427,7 +427,7 @@
  	}
  	ast_mutex_unlock(&featurelock);
@@ -5701,9 +5457,9 @@
  		if (!chan) {
  			ast_log(LOG_NOTICE, "Unable to allocate subchannel '%s/%s'\n", tech, dest);
  			return NULL;
-diff -urNad asterisk-1.2.15~dfsg~/channels/chan_iax2.c asterisk-1.2.15~dfsg/channels/chan_iax2.c
---- asterisk-1.2.15~dfsg~/channels/chan_iax2.c	2007-02-11 06:04:49.000000000 +0200
-+++ asterisk-1.2.15~dfsg/channels/chan_iax2.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/channels/chan_iax2.c asterisk-1.2.19/channels/chan_iax2.c
+--- asterisk-1.2.19.orig/channels/chan_iax2.c	2007-05-23 22:06:13.000000000 +0200
++++ asterisk-1.2.19/channels/chan_iax2.c	2007-06-25 11:13:51.457636648 +0200
 @@ -11,6 +11,9 @@
   * the project provides a web site, mailing lists and IRC
   * channels for your use.
@@ -5714,7 +5470,7 @@
   * This program is free software, distributed under the terms of
   * the GNU General Public License Version 2. See the LICENSE file
   * at the top of the source tree.
-@@ -746,7 +749,7 @@
+@@ -747,7 +750,7 @@
  static struct ast_channel *iax2_request(const char *type, int format, void *data, int *cause);
  static int iax2_devicestate(void *data);
  static int iax2_digit(struct ast_channel *c, char digit);
@@ -5723,7 +5479,7 @@
  static int iax2_sendimage(struct ast_channel *c, struct ast_frame *img);
  static int iax2_sendhtml(struct ast_channel *c, int subclass, const char *data, int datalen);
  static int iax2_call(struct ast_channel *c, char *dest, int timeout);
-@@ -2567,7 +2570,7 @@
+@@ -2575,7 +2578,7 @@
  	return send_command_locked(PTR_TO_CALLNO(c->tech_pvt), AST_FRAME_DTMF, digit, 0, NULL, 0, -1);
  }
  
@@ -5732,7 +5488,7 @@
  {
  	
  	return send_command_locked(PTR_TO_CALLNO(c->tech_pvt), AST_FRAME_TEXT,
-@@ -3106,7 +3109,7 @@
+@@ -3114,7 +3117,7 @@
   	memset(&ied, 0, sizeof(ied));
  	ast_mutex_lock(&iaxsl[callno]);
  	if (callno && iaxs[callno]) {
@@ -5741,19 +5497,9 @@
  		alreadygone = ast_test_flag(iaxs[callno], IAX_ALREADYGONE);
  		/* Send the hangup unless we have had a transmission error or are already gone */
   		iax_ie_append_byte(&ied, IAX_IE_CAUSECODE, (unsigned char)c->hangupcause);
-@@ -3158,7 +3161,8 @@
- static struct ast_frame *iax2_read(struct ast_channel *c) 
- {
- 	static struct ast_frame f = { AST_FRAME_NULL, };
--	ast_log(LOG_NOTICE, "I should never be called!\n");
-+	if (option_verbose > 3)
-+	    ast_log(LOG_NOTICE, "I should never be called!\n");
- 	return &f;
- }
- 
-diff -urNad asterisk-1.2.15~dfsg~/channels/chan_oss.c asterisk-1.2.15~dfsg/channels/chan_oss.c
---- asterisk-1.2.15~dfsg~/channels/chan_oss.c	2006-07-05 18:31:01.000000000 +0300
-+++ asterisk-1.2.15~dfsg/channels/chan_oss.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/channels/chan_oss.c asterisk-1.2.19/channels/chan_oss.c
+--- asterisk-1.2.19.orig/channels/chan_oss.c	2006-07-05 17:31:01.000000000 +0200
++++ asterisk-1.2.19/channels/chan_oss.c	2007-06-25 11:13:51.457636648 +0200
 @@ -318,7 +318,7 @@
  static struct ast_channel *oss_request(const char *type, int format, void *data
  , int *cause);
@@ -5772,9 +5518,9 @@
  {
  	/* print received messages */
  	ast_verbose( " << Console Received text %s >> \n", text);
-diff -urNad asterisk-1.2.15~dfsg~/channels/chan_oss_old.c asterisk-1.2.15~dfsg/channels/chan_oss_old.c
---- asterisk-1.2.15~dfsg~/channels/chan_oss_old.c	2005-11-29 20:24:39.000000000 +0200
-+++ asterisk-1.2.15~dfsg/channels/chan_oss_old.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/channels/chan_oss_old.c asterisk-1.2.19/channels/chan_oss_old.c
+--- asterisk-1.2.19.orig/channels/chan_oss_old.c	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.19/channels/chan_oss_old.c	2007-06-25 11:13:51.461637593 +0200
 @@ -136,7 +136,7 @@
  
  static struct ast_channel *oss_request(const char *type, int format, void *data, int *cause);
@@ -5793,9 +5539,9 @@
  {
  	ast_verbose( " << Console Received text %s >> \n", text);
  	return 0;
-diff -urNad asterisk-1.2.15~dfsg~/channels/chan_phone.c asterisk-1.2.15~dfsg/channels/chan_phone.c
---- asterisk-1.2.15~dfsg~/channels/chan_phone.c	2006-11-28 18:56:01.000000000 +0200
-+++ asterisk-1.2.15~dfsg/channels/chan_phone.c	2007-02-11 06:04:58.000000000 +0200
+diff -urN asterisk-1.2.19.orig/channels/chan_phone.c asterisk-1.2.19/channels/chan_phone.c
+--- asterisk-1.2.19.orig/channels/chan_phone.c	2007-04-24 20:20:31.000000000 +0200
++++ asterisk-1.2.19/channels/chan_phone.c	2007-06-25 11:13:51.461637593 +0200
 @@ -153,7 +153,7 @@
  static struct ast_frame *phone_read(struct ast_channel *ast);
  static int phone_write(struct ast_channel *ast, struct ast_frame *frame);
@@ -5814,10 +5560,10 @@
  {
      int length = strlen(text);
      return phone_write_buf(ast->tech_pvt, text, length, length, 0) == 
-diff -urNad asterisk-1.2.15~dfsg~/channels/chan_sip.c asterisk-1.2.15~dfsg/channels/chan_sip.c
---- asterisk-1.2.15~dfsg~/channels/chan_sip.c	2007-02-02 00:21:56.000000000 +0200
-+++ asterisk-1.2.15~dfsg/channels/chan_sip.c	2007-02-11 06:04:58.000000000 +0200
-@@ -602,6 +602,7 @@
+diff -urN asterisk-1.2.19.orig/channels/chan_sip.c asterisk-1.2.19/channels/chan_sip.c
+--- asterisk-1.2.19.orig/channels/chan_sip.c	2007-06-07 02:09:13.000000000 +0200
++++ asterisk-1.2.19/channels/chan_sip.c	2007-06-25 11:21:49.290502680 +0200
+@@ -604,6 +604,7 @@
  	unsigned int flags;			/*!< SIP_ flags */	
  	int timer_t1;				/*!< SIP timer T1, ms rtt */
  	unsigned int sipoptions;		/*!< Supported SIP sipoptions on the other end */
@@ -5825,7 +5571,13 @@
  	int capability;				/*!< Special capability (codec) */
  	int jointcapability;			/*!< Supported capability at both ends (codecs ) */
  	int peercapability;			/*!< Supported peer capability */
-@@ -626,6 +627,7 @@
+@@ -623,11 +624,13 @@
+ 	int redircodecs;			/*!< Redirect codecs */
+ 	struct sockaddr_in recv;		/*!< Received as */
+ 	struct in_addr ourip;			/*!< Our IP */
++	struct in_addr rtpip;			/*!< Our RTP IP */
+ 	struct ast_channel *owner;		/*!< Who owns us */
+ 	char exten[AST_MAX_EXTENSION];		/*!< Extension where to start */
  	char refer_to[AST_MAX_EXTENSION];	/*!< Place to store REFER-TO extension */
  	char referred_by[AST_MAX_EXTENSION];	/*!< Place to store REFERRED-BY extension */
  	char refer_contact[SIP_LEN_CONTACT];	/*!< Place to store Contact info from a REFER extension */
@@ -5833,7 +5585,7 @@
  	struct sip_pvt *refer_call;		/*!< Call we are referring */
  	struct sip_route *route;		/*!< Head of linked list of routing steps (fm Record-Route) */
  	int route_persistant;			/*!< Is this the "real" route? */
-@@ -645,6 +647,7 @@
+@@ -647,6 +650,7 @@
  	char peername[256];			/*!< [peer] name, not set if [user] */
  	char authname[256];			/*!< Who we use for authentication */
  	char uri[256];				/*!< Original requested URI */
@@ -5841,7 +5593,17 @@
  	char okcontacturi[SIP_LEN_CONTACT];	/*!< URI from the 200 OK on INVITE */
  	char peersecret[256];			/*!< Password */
  	char peermd5secret[256];
-@@ -768,6 +771,9 @@
+@@ -748,6 +752,9 @@
+ 	struct ast_variable *chanvars;	/*!< Variables to set for channel created by user */
+ };
+ 
++#define SIP_DIALPLAN_LOCAL 0
++#define SIP_DIALPLAN_INTERNATIONAL 1
++
+ /* Structure for SIP peer data, we place calls to peers if registered  or fixed IP address (host) */
+ struct sip_peer {
+ 	ASTOBJ_COMPONENTS(struct sip_peer);	/*!< name, refcount, objflags,  object pointers */
+@@ -770,6 +777,9 @@
  	int callingpres;		/*!< Calling id presentation */
  	int inUse;			/*!< Number of calls in use */
  	int call_limit;			/*!< Limit of concurrent calls */
@@ -5851,8 +5613,25 @@
  	char vmexten[AST_MAX_EXTENSION]; /*!< Dialplan extension for MWI notify message*/
  	char mailbox[AST_MAX_EXTENSION]; /*!< Mailbox setting for MWI checks */
  	char language[MAX_LANGUAGE];	/*!<  Default language for prompts */
-@@ -910,7 +916,7 @@
+@@ -791,6 +801,16 @@
+ 	struct ast_dnsmgr_entry *dnsmgr;/*!<  DNS refresh manager for peer */
+ 	struct sockaddr_in addr;	/*!<  IP address of peer */
  
++	/* Dialplan */
++	char countrycode[10]; 
++	char prefix[10]; 
++	char nationalprefix[10]; 
++	char internationalprefix[10]; 
++	int dialplan;
++	
++	/* RTP IP address */
++	struct in_addr rtpip; 
++		
+ 	/* Qualification */
+ 	struct sip_pvt *call;		/*!<  Call pointer */
+ 	int pokeexpire;			/*!<  When to expire poke (qualify= checking) */
+@@ -912,7 +932,7 @@
+ 
  static struct ast_channel *sip_request_call(const char *type, int format, void *data, int *cause);
  static int sip_devicestate(void *data);
 -static int sip_sendtext(struct ast_channel *ast, const char *text);
@@ -5860,7 +5639,7 @@
  static int sip_call(struct ast_channel *ast, char *dest, int timeout);
  static int sip_hangup(struct ast_channel *ast);
  static int sip_answer(struct ast_channel *ast);
-@@ -928,7 +934,7 @@
+@@ -930,7 +950,7 @@
  static int determine_firstline_parts(struct sip_request *req);
  static void sip_dump_history(struct sip_pvt *dialog);	/* Dump history to LOG_DEBUG at end of dialog, before destroying data */
  static const struct cfsubscription_types *find_subscription_type(enum subscriptiontype subtype);
@@ -5869,7 +5648,7 @@
  static char *gettag(struct sip_request *req, char *header, char *tagbuf, int tagbufsize);
  
  /*! \brief Definition of this channel for PBX channel registration */
-@@ -1322,7 +1328,7 @@
+@@ -1324,7 +1344,7 @@
  
  	/* If this is a subscription, tell the phone that we got a timeout */
  	if (p->subscribed) {
@@ -5878,7 +5657,7 @@
  		p->subscribed = NONE;
  		append_history(p, "Subscribestatus", "timeout");
  		return 10000;	/* Reschedule this destruction so that we know that it's gone */
-@@ -1588,24 +1594,6 @@
+@@ -1590,24 +1610,6 @@
  	}
  }
  
@@ -5903,7 +5682,7 @@
  
  /*! \brief  realtime_update_peer: Update peer object in realtime storage ---*/
  static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, const char *username, const char *fullcontact, int expirey)
-@@ -3188,16 +3176,30 @@
+@@ -3197,16 +3199,30 @@
  
  /*! \brief  find_call: Connect incoming SIP message to current dialog or create new dialog structure */
  /*               Called by handle_request, sipsock_read */
@@ -5935,7 +5714,7 @@
  	if (pedanticsipchecking) {
  		/* In principle Call-ID's uniquely identify a call, but with a forking SIP proxy
  		   we need more to identify a branch - so we have to check branch, from
-@@ -4212,6 +4214,7 @@
+@@ -4224,6 +4240,7 @@
  	if (sipmethod == SIP_CANCEL) {
  		c = p->initreq.rlPart2;	/* Use original URI */
  	} else if (sipmethod == SIP_ACK) {
@@ -5943,7 +5722,18 @@
  		/* Use URI from Contact: in 200 OK (if INVITE) 
  		(we only have the contacturi on INVITEs) */
  		if (!ast_strlen_zero(p->okcontacturi))
-@@ -5019,13 +5022,15 @@
+@@ -4572,6 +4589,10 @@
+ 		dest.sin_addr = p->redirip.sin_addr;
+ 		if (p->redircodecs)
+ 			capability = p->redircodecs;
++	} else if (p->rtpip.s_addr) {
++		if (option_verbose > 3) ast_log(LOG_NOTICE, "setting RTP IP to %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), p->rtpip));
++		dest.sin_addr = p->rtpip;
++		dest.sin_port = sin.sin_port;
+ 	} else {
+ 		dest.sin_addr = p->ourip;
+ 		dest.sin_port = sin.sin_port;
+@@ -5034,13 +5055,15 @@
  		ast_build_string(&invite, &invite_max, ";%s", p->options->uri_options);
  
  	ast_copy_string(p->uri, invite_buf, sizeof(p->uri));
@@ -5960,7 +5750,7 @@
  	} else {
  		snprintf(to, sizeof(to), "<%s>", p->uri);
  	}
-@@ -5056,6 +5061,45 @@
+@@ -5072,6 +5095,45 @@
  		add_header(req, "Remote-Party-ID", p->rpid);
  }
  
@@ -6006,7 +5796,7 @@
  /*! \brief  transmit_invite: Build REFER/INVITE/OPTIONS message and transmit it ---*/
  static int transmit_invite(struct sip_pvt *p, int sipmethod, int sdp, int init)
  {
-@@ -5082,6 +5126,11 @@
+@@ -5098,6 +5160,11 @@
  		if (!ast_strlen_zero(p->referred_by))
  			add_header(&req, "Referred-By", p->referred_by);
  	}
@@ -6018,7 +5808,7 @@
  #ifdef OSP_SUPPORT
  	if ((req.method != SIP_OPTIONS) && p->options && !ast_strlen_zero(p->options->osptoken)) {
  		ast_log(LOG_DEBUG,"Adding OSP Token: %s\n", p->options->osptoken);
-@@ -5156,7 +5205,7 @@
+@@ -5172,7 +5239,7 @@
  }
  
  /*! \brief  transmit_state_notify: Used in the SUBSCRIBE notification subsystem ----*/
@@ -6027,7 +5817,7 @@
  {
  	char tmp[4000], from[256], to[256];
  	char *t = tmp, *c, *a, *mfrom, *mto;
-@@ -5301,10 +5350,19 @@
+@@ -5320,10 +5387,19 @@
  	case DIALOG_INFO_XML: /* SNOM subscribes in this format */
  		ast_build_string(&t, &maxbytes, "<?xml version=\"1.0\"?>\n");
  		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);
@@ -6050,7 +5840,7 @@
  		ast_build_string(&t, &maxbytes, "<state>%s</state>\n", statestring);
  		ast_build_string(&t, &maxbytes, "</dialog>\n</dialog-info>\n");
  		break;
-@@ -6134,8 +6192,10 @@
+@@ -6161,8 +6237,10 @@
  		p->expire = -1;
  	pvt->expiry = expiry;
  	snprintf(data, sizeof(data), "%s:%d:%d:%s:%s", ast_inet_ntoa(iabuf, sizeof(iabuf), p->addr.sin_addr), ntohs(p->addr.sin_port), expiry, p->username, p->fullcontact);
@@ -6062,7 +5852,7 @@
  	manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: SIP/%s\r\nPeerStatus: Registered\r\n", p->name);
  	if (inaddrcmp(&p->addr, &oldsin)) {
  		sip_poke_peer(p);
-@@ -6526,7 +6586,7 @@
+@@ -6553,7 +6631,7 @@
  /*! \brief  cb_extensionstate: Callback for the devicestate notification (SUBSCRIBE) support subsystem ---*/
  /*    If you add an "hint" priority to the extension in the dial plan,
        you will get notifications on device state changes */
@@ -6071,7 +5861,7 @@
  {
  	struct sip_pvt *p = data;
  
-@@ -6545,7 +6605,7 @@
+@@ -6572,7 +6650,7 @@
  		p->laststate = state;
  		break;
  	}
@@ -6080,7 +5870,7 @@
  
  	if (option_verbose > 1)
  		ast_verbose(VERBOSE_PREFIX_1 "Extension Changed %s new state %s for Notify User %s\n", exten, ast_extension_state2str(state), p->username);
-@@ -6571,7 +6631,13 @@
+@@ -6598,7 +6676,13 @@
  	char *name, *c;
  	char *t;
  	char *domain;
@@ -6095,9 +5885,9 @@
  	/* Terminate URI */
  	t = uri;
  	while(*t && (*t > 32) && (*t != ';'))
-@@ -6622,9 +6688,68 @@
- 		if (!ast_test_flag(&peer->flags_page2, SIP_PAGE2_DYNAMIC)) {
+@@ -6651,9 +6735,68 @@
  			ast_log(LOG_ERROR, "Peer '%s' is trying to register, but not configured as host=dynamic\n", peer->name);
+ 			res = -5;
  		} else {
 +			callid = get_header(req, "Call-ID");
 +			ast_copy_string(peer_name, peer->name, sizeof(peer_name));
@@ -6165,7 +5955,7 @@
  				sip_cancel_destroy(p);
  
  				switch (parse_register_contact(p, peer, req)) {
-@@ -6645,6 +6770,7 @@
+@@ -6674,6 +6817,7 @@
  					transmit_response_with_date(p, "200 OK", req);
  					peer->lastmsgssent = -1;
  					res = 0;
@@ -6173,7 +5963,7 @@
  					break;
  				}
  			} 
-@@ -6992,6 +7118,11 @@
+@@ -7019,6 +7163,11 @@
  			/* XXX The refer_to could contain a call on an entirely different machine, requiring an 
  	    		  INVITE with a replaces header -anthm XXX */
  			/* The only way to find out is to use the dialplan - oej */
@@ -6185,7 +5975,7 @@
  		}
  	} else if (ast_exists_extension(NULL, *transfercontext, refer_to, 1, NULL) || !strcmp(refer_to, ast_parking_ext())) {
  		/* This is an unsupervised transfer (blind transfer) */
-@@ -7715,6 +7846,8 @@
+@@ -7744,6 +7893,8 @@
  	int peers_offline = 0;
  	char *id;
  	char idtext[256] = "";
@@ -6194,7 +5984,7 @@
  
  	if (s) {	/* Manager - get ActionID */
  		id = astman_get_header(m,"ActionID");
-@@ -7757,6 +7890,7 @@
+@@ -7786,6 +7937,7 @@
  		else
  			ast_copy_string(name, iterator->name, sizeof(name));
  
@@ -6202,7 +5992,7 @@
  		pstatus = peer_status(iterator, status, sizeof(status));
  		if (pstatus) 	
  			peers_online++;
-@@ -7773,14 +7907,24 @@
+@@ -7802,14 +7954,24 @@
  			}
  		}			
  		
@@ -6228,7 +6018,7 @@
  			ast_cli(fd, FORMAT, name, 
  			iterator->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), iterator->addr.sin_addr) : "(Unspecified)",
  			ast_test_flag(&iterator->flags_page2, SIP_PAGE2_DYNAMIC) ? " D " : "   ",  /* Dynamic or not? */
-@@ -7788,6 +7932,7 @@
+@@ -7817,6 +7979,7 @@
  			iterator->ha ? " A " : "   ",       /* permit/deny */
  			
  			ntohs(iterator->addr.sin_port), status);
@@ -6236,7 +6026,7 @@
  		} else {	/* Manager format */
  			/* The names here need to be the same as other channels */
  			ast_cli(fd, 
-@@ -7813,7 +7958,9 @@
+@@ -7842,7 +8005,9 @@
  
  		ASTOBJ_UNLOCK(iterator);
  
@@ -6247,7 +6037,7 @@
  	} while(0) );
  
  	if (!s) {
-@@ -8848,6 +8995,7 @@
+@@ -8878,6 +9043,7 @@
  	char buf[1024];
  	unsigned int event;
  	char *c;
@@ -6255,7 +6045,7 @@
  	
  	/* Need to check the media/type */
  	if (!strcasecmp(get_header(req, "Content-Type"), "application/dtmf-relay") ||
-@@ -8911,6 +9059,19 @@
+@@ -8941,6 +9107,19 @@
  			ast_queue_control(p->owner, AST_CONTROL_VIDUPDATE);
  		transmit_response(p, "200 OK", req);
  		return;
@@ -6275,7 +6065,7 @@
  	} else if ((c = get_header(req, "X-ClientCode"))) {
  		/* Client code (from SNOM phone) */
  		if (ast_test_flag(p, SIP_USECLIENTCODE)) {
-@@ -9010,12 +9171,63 @@
+@@ -9040,12 +9219,63 @@
  	return RESULT_SUCCESS;
  }
  
@@ -6340,7 +6130,7 @@
  	if (argc < 4)
  		return RESULT_SHOWUSAGE;
  
-@@ -9032,41 +9244,13 @@
+@@ -9062,41 +9292,13 @@
  	}
  
  	for (i = 3; i < argc; i++) {
@@ -6387,7 +6177,7 @@
  /*! \brief  sip_do_history: Enable SIP History logging (CLI) ---*/
  static int sip_do_history(int fd, int argc, char *argv[])
  {
-@@ -9732,7 +9916,7 @@
+@@ -9762,7 +9964,7 @@
  		if (!ignore && p->owner) {
  			ast_queue_control(p->owner, AST_CONTROL_RINGING);
  			if (p->owner->_state != AST_STATE_UP)
@@ -6396,7 +6186,7 @@
  		}
  		if (find_sdp(req)) {
  			process_sdp(p, req);
-@@ -10433,6 +10617,8 @@
+@@ -10472,6 +10674,8 @@
  static int attempt_transfer(struct sip_pvt *p1, struct sip_pvt *p2)
  {
  	int res = 0;
@@ -6405,7 +6195,7 @@
  	struct ast_channel 
  		*chana = NULL,
  		*chanb = NULL,
-@@ -10442,6 +10628,9 @@
+@@ -10481,6 +10685,9 @@
  		*peerb = NULL,
  		*peerc = NULL,
  		*peerd = NULL;
@@ -6415,7 +6205,7 @@
  
  	if (!p1->owner || !p2->owner) {
  		ast_log(LOG_WARNING, "Transfer attempted without dual ownership?\n");
-@@ -10470,6 +10659,12 @@
+@@ -10509,6 +10716,12 @@
  		ast_quiet_chan(peerc);
  		ast_quiet_chan(peerd);
  
@@ -6428,7 +6218,7 @@
  		if (peera->cdr && peerb->cdr) {
  			peerb->cdr = ast_cdr_append(peerb->cdr, peera->cdr);
  		} else if (peera->cdr) {
-@@ -10488,6 +10683,13 @@
+@@ -10527,6 +10740,13 @@
  			ast_log(LOG_WARNING, "Failed to masquerade %s into %s\n", peerb->name, peerc->name);
  			res = -1;
  		}
@@ -6442,7 +6232,7 @@
  		return res;
  	} else {
  		ast_log(LOG_NOTICE, "Transfer attempted with no appropriate bridged calls to transfer\n");
-@@ -10499,7 +10701,6 @@
+@@ -10538,7 +10758,6 @@
  	}
  	return 0;
  }
@@ -6450,7 +6240,7 @@
  /*! \brief  gettag: Get tag from packet */
  static char *gettag(struct sip_request *req, char *header, char *tagbuf, int tagbufsize) 
  {
-@@ -10799,6 +11000,7 @@
+@@ -10841,6 +11060,7 @@
  	int res;
  	struct ast_channel *transfer_to;
  	char *transfercontext = NULL;
@@ -6458,7 +6248,7 @@
  
  	if (option_debug > 2)
  		ast_log(LOG_DEBUG, "SIP call transfer received for call %s (REFER)!\n", p->callid);
-@@ -10809,9 +11011,73 @@
+@@ -10851,9 +11071,73 @@
  		transfercontext = p->context;
  	if (res < 0)
  		transmit_response(p, "603 Declined", req);
@@ -6534,7 +6324,7 @@
  		int nobye = 0;
  		if (!ignore) {
  			if (p->refer_call) {
-@@ -11150,7 +11416,7 @@
+@@ -11213,7 +11497,7 @@
  			struct sip_pvt *p_old;
  
  			transmit_response(p, "200 OK", req);
@@ -6543,7 +6333,7 @@
  			append_history(p, "Subscribestatus", ast_extension_state2str(firststate));
  
  			/* remove any old subscription from this peer for the same exten/context,
-@@ -11340,6 +11606,8 @@
+@@ -11425,6 +11709,8 @@
  		res = handle_request_options(p, req, debug);
  		break;
  	case SIP_INVITE:
@@ -6552,7 +6342,7 @@
  		res = handle_request_invite(p, req, debug, ignore, seqno, sin, recount, e);
  		break;
  	case SIP_REFER:
-@@ -11457,7 +11725,7 @@
+@@ -11542,7 +11828,7 @@
  	/* Process request, with netlock held */
  retrylock:
  	ast_mutex_lock(&netlock);
@@ -6561,7 +6351,7 @@
  	if (p) {
  		/* Go ahead and lock the owner if it has one -- we may need it */
  		if (p->owner && ast_mutex_trylock(&p->owner->lock)) {
-@@ -11798,6 +12066,52 @@
+@@ -11890,6 +12176,52 @@
  	return 0;
  }
  
@@ -6614,26 +6404,106 @@
  /*! \brief  sip_devicestate: Part of PBX channel interface ---*/
  
  /* Return values:---
-@@ -12335,6 +12649,7 @@
+@@ -11961,9 +12293,13 @@
+ {
+ 	int oldformat;
+ 	struct sip_pvt *p;
++	struct sip_peer *peer = NULL;
+ 	struct ast_channel *tmpc = NULL;
+ 	char *ext, *host;
+ 	char tmp[256];
++	char *number = NULL;
++	int strip = 0;
++	int ton = 0; /* 0 local, 1 national, 2 international */
+ 	char *dest = data;
  
+ 	oldformat = format;
+@@ -12026,6 +12362,56 @@
+ 	if (ext) {
+ 		ast_copy_string(p->username, ext, sizeof(p->username));
+ 		p->fullcontact[0] = 0;	
++		peer = find_peer(host, NULL, 1);
++		if (peer) {
++		    if (peer->dialplan != SIP_DIALPLAN_LOCAL) {
++			/* do the dialplan thingie */
++			ton = 0;
++			strip = 0;
++			if (!ast_strlen_zero(peer->internationalprefix)) {
++			    number = strstr(p->username, peer->internationalprefix);
++			    if (number == p->username) {
++				strip += strlen(peer->internationalprefix);
++				if (option_verbose > 4) ast_log(LOG_NOTICE, "found int prefix, rest is %s\n",number+strip); 
++			    }
++			    ton = 2;
++			}
++			if (!ton && (!ast_strlen_zero(peer->nationalprefix))) {
++			    number = strstr(p->username, peer->nationalprefix);
++			    if (number == p->username) {
++				strip += strlen(peer->nationalprefix);
++			        if (option_verbose > 4) ast_log(LOG_NOTICE, "found national prefix, rest is %s\n",number+strip); 
++			    }
++			    ton = 1;
++			}
++			if (peer->dialplan == SIP_DIALPLAN_INTERNATIONAL) {
++			    if (ton == 1) {
++				char tmp[128];
++				/* add countrycode */
++				snprintf(tmp, sizeof(tmp) - 1, "%s%s", peer->countrycode, p->username + strip);
++				ast_copy_string(p->username, tmp, sizeof(p->username));
++			    } else {
++				snprintf(tmp, sizeof(tmp) - 1, "%s", p->username + strip);
++				ast_copy_string(p->username, tmp, sizeof(p->username));
++			    }
++			}
++			if (option_verbose > 4) ast_log(LOG_NOTICE, "calling %s\n", p->username);
++		    }
++		    if (!ast_strlen_zero(peer->prefix)) {
++			char tmp[128];
++			snprintf(tmp, sizeof(tmp) - 1, "%s%s", peer->prefix, p->username);
++			ast_copy_string(p->username, tmp, sizeof(p->username));
++			if (option_verbose > 4) ast_log(LOG_NOTICE, "calling %s (prefix %s)\n", p->username, peer->prefix);
++		    }
++		    if (peer->rtpip.s_addr) {
++			memcpy(&p->rtpip, &peer->rtpip, sizeof(p->rtpip)); 
++			if (p->rtp) {
++			    ast_rtp_destroy(p->rtp);
++			}
++			p->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, p->rtpip);
++		    }
++		    
++		}
+ 	}
+ #if 0
+ 	printf("Setting up to call extension '%s' at '%s'\n", ext ? ext : "<none>", host);
+@@ -12424,6 +12810,7 @@
+ 
  	peer->expire = -1;
  	peer->pokeexpire = -1;
 +	peer->max_regs = 1;
  	ast_copy_string(peer->name, name, sizeof(peer->name));
  	ast_copy_flags(peer, &global_flags, SIP_FLAGS_TO_COPY);
  	strcpy(peer->context, default_context);
-@@ -12380,7 +12695,9 @@
+@@ -12452,6 +12839,8 @@
+ 	int obproxyfound=0;
+ 	int found=0;
+ 	int format=0;		/* Ama flags */
++	struct ast_hostent ahp;
++	struct hostent *hp;
+ 	time_t regseconds;
+ 	char *varname = NULL, *varval = NULL;
+ 	struct ast_variable *tmpvar = NULL;
+@@ -12469,7 +12858,9 @@
  
  	if (peer) {
  		/* Already in the list, remove it and it will be added back (or FREE'd)  */
--		found++;
+-		found = 1;
 +		if (peer->max_regs == 1) {
-+		    found++;
++		    found = 1;
 +		}
   	} else {
  		peer = malloc(sizeof(*peer));
  		if (peer) {
-@@ -12392,6 +12709,7 @@
+@@ -12481,6 +12872,7 @@
  			ASTOBJ_INIT(peer);
  			peer->expire = -1;
  			peer->pokeexpire = -1;
@@ -6641,7 +6511,7 @@
  		} else {
  			ast_log(LOG_WARNING, "Can't allocate SIP peer memory\n");
  		}
-@@ -12537,6 +12855,10 @@
+@@ -12626,6 +13018,10 @@
  			peer->call_limit = atoi(v->value);
  			if (peer->call_limit < 0)
  				peer->call_limit = 0;
@@ -6652,34 +6522,57 @@
  		} else if (!strcasecmp(v->name, "amaflags")) {
  			format = ast_cdr_amaflags2int(v->value);
  			if (format < 0) {
-@@ -12932,8 +13254,24 @@
- 				if (!strcasecmp(utype, "peer") || !strcasecmp(utype, "friend")) {
+@@ -12684,6 +13080,26 @@
+ 				ast_log(LOG_WARNING, "Qualification of peer '%s' should be 'yes', 'no', or a number of milliseconds at line %d of sip.conf\n", peer->name, v->lineno);
+ 				peer->maxms = 0;
+ 			}
++		} else if (!strcasecmp(v->name, "prefix")) {
++			ast_copy_string(peer->prefix, v->value, sizeof(peer->prefix));
++		} else if (!strcasecmp(v->name, "nationalprefix")) {
++			ast_copy_string(peer->nationalprefix, v->value, sizeof(peer->nationalprefix));
++		} else if (!strcasecmp(v->name, "internationalprefix")) {
++			ast_copy_string(peer->internationalprefix, v->value, sizeof(peer->internationalprefix));
++		} else if (!strcasecmp(v->name, "countrycode")) {
++			ast_copy_string(peer->countrycode, v->value, sizeof(peer->countrycode));
++		} else if (!strcasecmp(v->name, "dialplan")) {
++			if (!strcasecmp(v->value, "international")) {
++			    peer->dialplan = SIP_DIALPLAN_INTERNATIONAL;
++			} else {
++			    peer->dialplan = SIP_DIALPLAN_LOCAL;
++			}
++		} else if (!strcasecmp(v->name, "rtpip")) {
++			if (!(hp = ast_gethostbyname(v->value, &ahp))) {
++				ast_log(LOG_WARNING, "Invalid address: %s\n", v->value);
++			} else {
++				memcpy(&peer->rtpip, hp->h_addr, sizeof(peer->rtpip));
++			}
+ 		}
+ 		v = v->next;
+ 	}
+@@ -13016,6 +13432,22 @@
  					peer = build_peer(cat, ast_variable_browse(cfg, cat), 0);
  					if (peer) {
--						ASTOBJ_CONTAINER_LINK(&peerl,peer);
--						ASTOBJ_UNREF(peer, sip_destroy_peer);
-+					    if (peer->max_regs > 1) {
-+						int i = 0;
-+						int clones = peer->max_regs - 1;
-+						struct sip_peer *clone = NULL;
-+						char clone_name[sizeof(clone->name)];
-+						/* clone clone clone */
-+						for (i=0;i<clones;i++) {
-+						    snprintf(clone_name, sizeof(clone_name), "%s@%d", cat, i);
-+						    clone = build_peer(clone_name, ast_variable_browse(cfg, cat), 0);
-+						    if (clone) {
-+							clone->subpeer = 1;
-+							ASTOBJ_CONTAINER_LINK(&peerl,clone);
-+							ASTOBJ_UNREF(clone, sip_destroy_peer);
+ 						ast_device_state_changed("SIP/%s", peer->name);
++						if (peer->max_regs > 1) {
++						    int i = 0;
++						    int clones = peer->max_regs - 1;
++						    struct sip_peer *clone = NULL;
++						    char clone_name[sizeof(clone->name)];
++						    /* clone clone clone */
++						    for (i=0;i<clones;i++) {
++							snprintf(clone_name, sizeof(clone_name), "%s@%d", cat, i);
++							clone = build_peer(clone_name, ast_variable_browse(cfg, cat), 0);
++							if (clone) {
++							    clone->subpeer = 1;
++							    ASTOBJ_CONTAINER_LINK(&peerl,clone);
++							    ASTOBJ_UNREF(clone, sip_destroy_peer);
++							}
 +						    }
 +						}
-+					    }
-+					    ASTOBJ_CONTAINER_LINK(&peerl,peer);
-+					    ASTOBJ_UNREF(peer, sip_destroy_peer);
+ 						ASTOBJ_CONTAINER_LINK(&peerl,peer);
+ 						ASTOBJ_UNREF(peer, sip_destroy_peer);
  					}
- 				} else if (strcasecmp(utype, "user")) {
- 					ast_log(LOG_WARNING, "Unknown type '%s' for '%s' in %s\n", utype, cat, "sip.conf");
-@@ -13535,6 +13873,8 @@
+@@ -13619,6 +14051,8 @@
  			"List SIP peers (text format)", mandescr_show_peers);
  	ast_manager_register2("SIPshowpeer", EVENT_FLAG_SYSTEM, manager_sip_show_peer,
  			"Show SIP peer (text format)", mandescr_show_peer);
@@ -6688,7 +6581,7 @@
  
  	sip_poke_all_peers();	
  	sip_send_all_registers();
-@@ -13565,6 +13905,7 @@
+@@ -13649,6 +14083,7 @@
  
  	ast_rtp_proto_unregister(&sip_rtp);
  
@@ -6696,9 +6589,9 @@
  	ast_manager_unregister("SIPpeers");
  	ast_manager_unregister("SIPshowpeer");
  
-diff -urNad asterisk-1.2.15~dfsg~/channels/chan_zap.c asterisk-1.2.15~dfsg/channels/chan_zap.c
---- asterisk-1.2.15~dfsg~/channels/chan_zap.c	2007-02-11 06:04:49.000000000 +0200
-+++ asterisk-1.2.15~dfsg/channels/chan_zap.c	2007-02-11 13:34:34.000000000 +0200
+diff -urN asterisk-1.2.19.orig/channels/chan_zap.c asterisk-1.2.19/channels/chan_zap.c
+--- asterisk-1.2.19.orig/channels/chan_zap.c	2007-05-23 15:06:17.000000000 +0200
++++ asterisk-1.2.19/channels/chan_zap.c	2007-06-25 15:44:42.863171289 +0200
 @@ -11,6 +11,10 @@
   * the project provides a web site, mailing lists and IRC
   * channels for your use.
@@ -6745,7 +6638,19 @@
  #define NUM_DCHANS		4	/*!< No more than 4 d-channels */
  #define MAX_CHANNELS	672		/*!< No more than a DS3 per trunk group */
  
-@@ -210,8 +219,6 @@
+@@ -198,6 +207,11 @@
+ static char defaultcic[64] = "";
+ static char defaultozz[64] = "";
+ 
++static char nocid[256] = "No CID available";
++static char withheldcid[256] = "CID withheld";
++static char gsm_modem_pin[20];
++static char gsm_modem_exten[AST_MAX_EXTENSION];
++
+ static char language[MAX_LANGUAGE] = "";
+ static char progzone[10]= "";
+ 
+@@ -210,8 +224,6 @@
  #ifdef PRI_GETSET_TIMERS
  static int pritimers[PRI_MAX_TIMERS];
  #endif
@@ -6754,7 +6659,7 @@
  #endif
  
  /*! \brief Wait up to 16 seconds for first digit (FXO logic) */
-@@ -232,10 +239,6 @@
+@@ -232,10 +244,6 @@
  
  static int ifcount = 0;
  
@@ -6765,7 +6670,7 @@
  /*! \brief Protect the monitoring thread, so only one process can kill or start it, and not
     when it's doing something critical. */
  AST_MUTEX_DEFINE_STATIC(monlock);
-@@ -248,7 +251,7 @@
+@@ -248,7 +256,7 @@
  
  static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms);
  
@@ -6774,7 +6679,7 @@
  
  /*! \brief Avoid the silly zt_getevent which ignores a bunch of events */
  static inline int zt_get_event(int fd)
-@@ -282,6 +285,19 @@
+@@ -282,6 +290,19 @@
  
  struct zt_pvt;
  
@@ -6794,7 +6699,7 @@
  
  #ifdef ZAPATA_R2
  static int r2prot = -1;
-@@ -296,6 +312,28 @@
+@@ -296,6 +317,28 @@
  #define PRI_SPAN(p) (((p) >> 8) & 0xff)
  #define PRI_EXPLICIT(p) (((p) >> 16) & 0x01)
  
@@ -6823,24 +6728,24 @@
  struct zt_pri {
  	pthread_t master;						/*!< Thread of master */
  	ast_mutex_t lock;						/*!< Mutex */
-@@ -309,6 +347,8 @@
+@@ -309,6 +352,8 @@
  	int nsf;							/*!< Network-Specific Facilities */
  	int dialplan;							/*!< Dialing plan */
  	int localdialplan;						/*!< Local dialing plan */
-+ 	char nocid[256];						/*!< (Bristuff) Caller ID to use when none availble (?) */
-+ 	char withheldcid[256];						/*!< (Bristuff) Caller ID to use when caller ID is withheld (?) */
++ 	char nocid[256];
++ 	char withheldcid[256];
  	char internationalprefix[10];					/*!< country access code ('00' for european dialplans) */
  	char nationalprefix[10];					/*!< area access code ('0' for european dialplans) */
  	char localprefix[20];						/*!< area access code + area code ('0'+area code for european dialplans) */
-@@ -328,6 +368,7 @@
- 	int fds[NUM_DCHANS];						/*!< FD's for d-channels */
- 	int offset;
- 	int span;
-+ 	int usercid;							/* trust user provided callerid (callerani) ?? */
- 	int resetting;
- 	int resetpos;
- 	time_t lastreset;						/*!< time when unused channels were last reset */
-@@ -335,6 +376,9 @@
+@@ -320,6 +365,7 @@
+ 	int prilogicalspan;						/*!< Logical span number within trunk group */
+ 	int numchans;							/*!< Num of channels we represent */
+ 	int overlapdial;						/*!< In overlap dialing mode */
++	int usercid;
+ 	int facilityenable;						/*!< Enable facility IEs */
+ 	struct pri *dchans[NUM_DCHANS];					/*!< Actual d-channels */
+ 	int dchanavail[NUM_DCHANS];					/*!< Whether each channel is available */
+@@ -335,6 +381,9 @@
  	struct zt_pvt *pvts[MAX_CHANNELS];				/*!< Member channel pvt structs */
  	struct zt_pvt *crvs;						/*!< Member CRV structs */
  	struct zt_pvt *crvend;						/*!< Pointer to end of CRV structs */
@@ -6850,45 +6755,43 @@
  };
  
  
-@@ -422,6 +466,9 @@
- 	int minidle;
- 	char idleext[AST_MAX_EXTENSION];
- 	char idledial[AST_MAX_EXTENSION];
-+	char nocid[256];
-+	char withheldcid[256];
+@@ -430,6 +479,11 @@
+ 	char privateprefix[20];
+ 	char unknownprefix[20];
+ 	long resetinterval;
 +	int usercid;
- 	int overlapdial;
- 	int facilityenable;
- 	char internationalprefix[10];
-@@ -445,6 +492,10 @@
-  */
- struct zt_chan_conf {
- 	struct zt_pri_conf pri;
-+#ifdef ZAPATA_GSM
-+	/* \todo: when converting to 1.4, this is already part of the zt_pvt */
-+	struct zt_gsm gsm; 
-+#endif
- 	char context[AST_MAX_CONTEXT];
- 	char cid_num[AST_MAX_EXTENSION];
- 	char cid_name[AST_MAX_EXTENSION];
-@@ -534,6 +585,7 @@
- 	int polarityonanswerdelay;
++	int priindication_oob;
++	int pritransfer;
++ 	char nocid[256];
++ 	char withheldcid[256];
+ #endif
+ };
+ 
+@@ -535,6 +589,7 @@
  	int sendcalleridafter;
  
-+        int pritransfer;
  	int priindication_oob;
++	int pritransfer;
  	int radio;
  };
-@@ -547,6 +599,8 @@
- 			.minidle = 0,
+ 
+@@ -548,6 +603,7 @@
  			.idleext = "",
  			.idledial = "",
-+			.nocid = "No CID available",
-+			.withheldcid = "CID withheld",
  			.overlapdial = 0,
++			.usercid = 0,
  			.facilityenable = 0,
  			.internationalprefix = "",
-@@ -712,6 +766,8 @@
+ 			.nationalprefix = "",
+@@ -660,6 +716,7 @@
+ 		.sendcalleridafter = DEFAULT_CIDRINGS,
+ 
+ 		.priindication_oob = 0,
++		.pritransfer = 0,
+ 
+ 		/* Add fields above this comment. "radio" will be 
+ 		 * kept as the one without the comma. for the moment, 
+@@ -712,6 +769,8 @@
  	unsigned int echocanbridged:1;
  	unsigned int echocanon:1;
  	unsigned int faxhandled:1;			/*!< Has a fax tone already been handled? */
@@ -6897,7 +6800,7 @@
  	unsigned int firstradio:1;
  	unsigned int hanguponpolarityswitch:1;
  	unsigned int hardwaredtmf:1;
-@@ -724,7 +780,8 @@
+@@ -724,7 +783,8 @@
  	unsigned int overlapdial:1;
  	unsigned int permcallwaiting:1;
  	unsigned int permhidecallerid:1;		/*!< Whether to hide our outgoing caller ID or not */
@@ -6907,7 +6810,7 @@
  	unsigned int priexclusive:1;
  	unsigned int pulse:1;
  	unsigned int pulsedial:1;			/*!< whether a pulse dial phone is detected */
-@@ -763,6 +820,7 @@
+@@ -763,6 +823,7 @@
  #endif
  	char cid_num[AST_MAX_EXTENSION];
  	int cid_ton;					/*!< Type Of Number (TON) */
@@ -6915,7 +6818,7 @@
  	char cid_name[AST_MAX_EXTENSION];
  	char lastcid_num[AST_MAX_EXTENSION];
  	char lastcid_name[AST_MAX_EXTENSION];
-@@ -823,10 +881,15 @@
+@@ -823,10 +884,15 @@
  	int polarityonanswerdelay;
  	struct timeval polaritydelaytv;
  	int sendcalleridafter;
@@ -6931,7 +6834,7 @@
  	q931_call *call;
  	int prioffset;
  	int logicalspan;
-@@ -842,7 +905,7 @@
+@@ -842,7 +908,7 @@
  
  static struct ast_channel *zt_request(const char *type, int format, void *data, int *cause);
  static int zt_digit(struct ast_channel *ast, char digit);
@@ -6940,7 +6843,7 @@
  static int zt_call(struct ast_channel *ast, char *rdest, int timeout);
  static int zt_hangup(struct ast_channel *ast);
  static int zt_answer(struct ast_channel *ast);
-@@ -852,11 +915,14 @@
+@@ -852,11 +918,14 @@
  static int zt_indicate(struct ast_channel *chan, int condition);
  static int zt_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
  static int zt_setoption(struct ast_channel *chan, int option, void *data, int datalen);
@@ -6956,7 +6859,7 @@
  	.requester = zt_request,
  	.send_digit = zt_digit,
  	.send_text = zt_sendtext,
-@@ -870,6 +936,7 @@
+@@ -870,6 +939,7 @@
  	.indicate = zt_indicate,
  	.fixup = zt_fixup,
  	.setoption = zt_setoption,
@@ -6964,7 +6867,7 @@
  };
  
  #ifdef ZAPATA_PRI
-@@ -881,6 +948,13 @@
+@@ -881,6 +951,13 @@
  struct zt_pvt *round_robin[32];
  
  #ifdef ZAPATA_PRI
@@ -6978,7 +6881,7 @@
  static inline int pri_grab(struct zt_pvt *pvt, struct zt_pri *pri)
  {
  	int res;
-@@ -928,6 +1002,112 @@
+@@ -928,6 +1005,124 @@
  #define CANBUSYDETECT(p) (ISTRUNK(p) || (p->sig & (SIG_EM | SIG_EM_E1 | SIG_SF)) /* || (p->sig & __ZT_SIG_FXO) */)
  #define CANPROGRESSDETECT(p) (ISTRUNK(p) || (p->sig & (SIG_EM | SIG_EM_E1 | SIG_SF)) /* || (p->sig & __ZT_SIG_FXO) */)
  
@@ -6996,7 +6899,10 @@
 +	ast_mutex_t *lock;
 +
 +//	ast_log(LOG_NOTICE, "data = %s\n", (char *)data);
++
++#ifndef ZAPATA_DEVICE_STATES
 +	return AST_DEVICE_UNKNOWN;
++#endif
 +	
 +	/* Assume we're locking the iflock */
 +	lock = &iflock;
@@ -7037,7 +6943,7 @@
 +			return AST_DEVICE_INVALID;
 +		} else {
 +			channelmatch = x;
-+			ast_log(LOG_NOTICE, "channelmatch = %d\n", channelmatch);
++//			ast_log(LOG_NOTICE, "channelmatch = %d\n", channelmatch);
 +		}
 +	}
 +	/* Search for an unowned channel */
@@ -7061,29 +6967,38 @@
 +			    }
 +			}
 +#endif
-+			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))))) {
-+			    res = AST_DEVICE_UNKNOWN;
-+			    if (p->owner) {
-+				    if ((p->owner->_state == AST_STATE_RINGING) && (p->outgoing)) {
++		    }
++
++		    if ((channelmatch && (p->channel == channelmatch)) || (groupmatch && ((p->group & groupmatch) != 0))){
++			res = AST_DEVICE_UNKNOWN;
++			if (p->owner) {
++			    if (p->outgoing) {
++				/* outgoing */
++				switch(p->owner->_state) {
++				    case AST_STATE_DIALING:
++				    case AST_STATE_RINGING:
 +			    		res = AST_DEVICE_RINGING;
-+				    }
-+				    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)){
++					break;
++				    default:				
 +			    		res = AST_DEVICE_INUSE;
-+				    }
++				}
++			    } else {
++				/* incoming */
++				res = AST_DEVICE_INUSE;
 +			    }
-+			    if ((res == AST_DEVICE_INUSE) || (res == AST_DEVICE_RINGING)) {
-+				/* stop searching now, one non-idle channel is sufficient */
-+				ast_mutex_unlock(&p->lock);
-+				break;
-+			    }
 +			}
++			if ((res == AST_DEVICE_INUSE) || (res == AST_DEVICE_RINGING)) {
++			    /* stop searching now, one non-idle channel is sufficient */
++			    ast_mutex_unlock(&p->lock);
++			    break;
++			}
 +		    }
++		    
 +		    ast_mutex_unlock(&p->lock);
 +		}	
 +		p = p->next;
 +	}
 +	ast_mutex_unlock(lock);
-+
 +	return res;
 +
 +}
@@ -7091,7 +7006,7 @@
  static int zt_get_index(struct ast_channel *ast, struct zt_pvt *p, int nullok)
  {
  	int res;
-@@ -1330,6 +1510,8 @@
+@@ -1330,6 +1525,8 @@
  		return "GR-303 Signalling with FXOKS";
  	case SIG_GR303FXSKS:
  		return "GR-303 Signalling with FXSKS";
@@ -7100,7 +7015,7 @@
  	case 0:
  		return "Pseudo Signalling";
  	default:
-@@ -1530,12 +1712,16 @@
+@@ -1530,12 +1727,16 @@
  	int res;
  	if (!p)
  		return;
@@ -7118,7 +7033,7 @@
  		return;
  	}
  	if (p->echocancel) {
-@@ -1561,7 +1747,7 @@
+@@ -1561,7 +1762,7 @@
  {
  	int x;
  	int res;
@@ -7127,7 +7042,7 @@
  		x = p->echotraining;
  		res = ioctl(p->subs[SUB_REAL].zfd, ZT_ECHOTRAIN, &x);
  		if (res) 
-@@ -1741,7 +1927,7 @@
+@@ -1741,7 +1942,7 @@
  {
  	int x, y, res;
  	x = muted;
@@ -7136,7 +7051,7 @@
  		y = 1;
  		res = ioctl(p->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &y);
  		if (res)
-@@ -1923,7 +2109,12 @@
+@@ -1923,7 +2124,12 @@
  		ast_log(LOG_WARNING, "Unable to flush input on channel %d\n", p->channel);
  	p->outgoing = 1;
  
@@ -7150,7 +7065,7 @@
  
  	switch(p->sig) {
  	case SIG_FXOLS:
-@@ -2147,6 +2338,26 @@
+@@ -2147,6 +2353,26 @@
  	case SIG_PRI:
  		/* We'll get it in a moment -- but use dialdest to store pre-setup_ack digits */
  		p->dialdest[0] = '\0';
@@ -7177,7 +7092,7 @@
  		break;
  	default:
  		ast_log(LOG_DEBUG, "not yet implemented\n");
-@@ -2165,6 +2376,12 @@
+@@ -2165,6 +2391,12 @@
  		int ldp_strip;
  		int exclusive;
  
@@ -7190,7 +7105,7 @@
  		c = strchr(dest, '/');
  		if (c)
  			c++;
-@@ -2182,6 +2399,7 @@
+@@ -2182,6 +2414,7 @@
  			ast_mutex_unlock(&p->lock);
  			return -1;
  		}
@@ -7198,7 +7113,7 @@
  		if (p->sig != SIG_FXSKS) {
  			p->dop.op = ZT_DIAL_OP_REPLACE;
  			s = strchr(c + p->stripmsd, 'w');
-@@ -2205,6 +2423,8 @@
+@@ -2205,6 +2438,8 @@
  			pri_rel(p->pri);
  			ast_mutex_unlock(&p->lock);
  			return -1;
@@ -7207,7 +7122,7 @@
  		}
  		if (!(sr = pri_sr_new())) {
  			ast_log(LOG_WARNING, "Failed to allocate setup request channel %d\n", p->channel);
-@@ -2234,7 +2454,7 @@
+@@ -2234,7 +2469,7 @@
  		pri_sr_set_channel(sr, p->bearer ? PVT_TO_CHANNEL(p->bearer) : PVT_TO_CHANNEL(p), exclusive, 1);
  		pri_sr_set_bearer(sr, p->digital ? PRI_TRANS_CAP_DIGITAL : ast->transfercapability, 
  					(p->digital ? -1 : 
@@ -7216,7 +7131,7 @@
  		if (p->pri->facilityenable)
  			pri_facility_enable(p->pri->pri);
  
-@@ -2435,8 +2655,10 @@
+@@ -2435,8 +2670,10 @@
  	}
  	if (newslot < 0) {
  		newslot = 0;
@@ -7228,7 +7143,7 @@
  	}
  	if (old && (oldslot != newslot))
  		ast_log(LOG_NOTICE, "Switching from from d-channel %d to channel %d!\n",
-@@ -2492,8 +2714,7 @@
+@@ -2492,8 +2729,7 @@
  
  	ast_log(LOG_DEBUG, "Hangup: channel: %d index = %d, normal = %d, callwait = %d, thirdcall = %d\n",
  		p->channel, index, p->subs[SUB_REAL].zfd, p->subs[SUB_CALLWAIT].zfd, p->subs[SUB_THREEWAY].zfd);
@@ -7238,7 +7153,7 @@
  	if (index > -1) {
  		/* Real channel, do some fixup */
  		p->subs[index].owner = NULL;
-@@ -2590,6 +2811,7 @@
+@@ -2590,6 +2826,7 @@
  
  
  	if (!p->subs[SUB_REAL].owner && !p->subs[SUB_CALLWAIT].owner && !p->subs[SUB_THREEWAY].owner) {
@@ -7246,7 +7161,7 @@
  		p->owner = NULL;
  		p->ringt = 0;
  		p->distinctivering = 0;
-@@ -2626,19 +2848,61 @@
+@@ -2626,19 +2863,61 @@
  			if (p->call && (!p->bearer || (p->bearer->call == p->call))) {
  				if (!pri_grab(p, p->pri)) {
  					if (p->alreadyhungup) {
@@ -7309,7 +7224,7 @@
  						ast_log(LOG_DEBUG, "Not yet hungup...  Calling hangup once with icause, and clearing call\n");
  
  #ifdef SUPPORT_USERUSER
-@@ -2652,7 +2916,28 @@
+@@ -2652,7 +2931,28 @@
  							if (atoi(cause))
  								icause = atoi(cause);
  						}
@@ -7317,9 +7232,9 @@
 +
 +						pri_hangup(p->pri->pri, p->call, icause, -1);
 +
-+						/* if we send a release complete we wont ge no hangup event, so clear the call here */
++						/* if we send a rel9999ease complete we wont ge no hangup event, so clear the call here */
 +						if (icause == 34 || icause == 44 || icause == 82 || icause == 1 || icause == 81 || icause == 17) {
-+						    if ((ast->_state == AST_STATE_RING) || (ast->_state == AST_STATE_RINGING) || (ast->_state == AST_STATE_DIALING)) {
++						    if ((ast->_state == AST_STATE_RING) || (ast->_state == AST_STATE_RINGING) || (ast->_state == AST_STATE_DIALING) || (ast->_state == AST_STATE_RESERVED)) {
 +							p->call = NULL;
 +						    } else {
 +							ast_log(LOG_ERROR, "What is wrong with you? You cannot use cause %d number when in state %d!\n", icause, ast->_state);
@@ -7339,7 +7254,7 @@
  					}
  					if (res < 0) 
  						ast_log(LOG_WARNING, "pri_disconnect failed\n");
-@@ -2680,7 +2965,13 @@
+@@ -2680,7 +2980,13 @@
  
  		}
  #endif
@@ -7354,7 +7269,7 @@
  			res = zt_set_hook(p->subs[SUB_REAL].zfd, ZT_ONHOOK);
  		if (res < 0) {
  			ast_log(LOG_WARNING, "Unable to hangup line %s\n", ast->name);
-@@ -2849,10 +3140,14 @@
+@@ -2849,10 +3155,14 @@
  			p->proceeding = 1;
  			res = pri_answer(p->pri->pri, p->call, 0, !p->digital);
  			pri_rel(p->pri);
@@ -7369,7 +7284,7 @@
  		break;
  #endif
  #ifdef ZAPATA_R2
-@@ -2862,6 +3157,13 @@
+@@ -2862,6 +3172,13 @@
  			ast_log(LOG_WARNING, "R2 Answer call failed :( on %s\n", ast->name);
  		break;
  #endif			
@@ -7383,7 +7298,7 @@
  	case 0:
  		ast_mutex_unlock(&p->lock);
  		return 0;
-@@ -3428,6 +3730,15 @@
+@@ -3428,6 +3745,15 @@
  {
  	struct zt_pvt *p = newchan->tech_pvt;
  	int x;
@@ -7399,7 +7314,16 @@
  	ast_mutex_lock(&p->lock);
  	ast_log(LOG_DEBUG, "New owner for channel %d is %s\n", p->channel, newchan->name);
  	if (p->owner == oldchan) {
-@@ -3785,7 +4096,7 @@
+@@ -3700,7 +4026,7 @@
+ 					if (ast_async_goto(ast, target_context, "fax", 1))
+ 						ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", ast->name, target_context);
+ 				} else
+-					ast_log(LOG_NOTICE, "Fax detected, but no fax extension\n");
++				    if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Fax detected, but no fax extension\n");
+ 			} else
+ 				ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n");
+ 		} else
+@@ -3855,7 +4181,7 @@
  			if (p->call) {
  				if (p->pri && p->pri->pri) {
  					if (!pri_grab(p, p->pri)) {
@@ -7408,7 +7332,7 @@
  						pri_destroycall(p->pri->pri, p->call);
  						p->call = NULL;
  						pri_rel(p->pri);
-@@ -4751,7 +5062,7 @@
+@@ -4821,7 +5147,7 @@
  		p->subs[index].f.data = NULL;
  		p->subs[index].f.datalen= 0;
  	}
@@ -7417,7 +7341,7 @@
  		/* Perform busy detection. etc on the zap line */
  		f = ast_dsp_process(ast, p->dsp, &p->subs[index].f);
  		if (f) {
-@@ -4763,8 +5074,9 @@
+@@ -4833,8 +5159,9 @@
  				}
  			} else if (f->frametype == AST_FRAME_DTMF) {
  #ifdef ZAPATA_PRI
@@ -7429,20 +7353,7 @@
  					f->frametype = AST_FRAME_NULL;
  					f->subclass = 0;
  				}
-@@ -4812,8 +5124,10 @@
- 						pbx_builtin_setvar_helper(ast, "FAXEXTEN", ast->exten);
- 						if (ast_async_goto(ast, target_context, "fax", 1))
- 							ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", ast->name, target_context);
--					} else
--						ast_log(LOG_NOTICE, "Fax detected, but no fax extension\n");
-+					} else {
-+					    if (option_verbose > 2)
-+						ast_verbose(VERBOSE_PREFIX_3 "Fax detected, but no fax extension\n");
-+					}
- 				} else
- 					ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n");
- 			} else
-@@ -4899,7 +5213,9 @@
+@@ -4909,7 +5236,9 @@
  #endif
  	/* Write a frame of (presumably voice) data */
  	if (frame->frametype != AST_FRAME_VOICE) {
@@ -7453,7 +7364,7 @@
  			ast_log(LOG_WARNING, "Don't know what to do with frame type '%d'\n", frame->frametype);
  		return 0;
  	}
-@@ -4970,7 +5286,7 @@
+@@ -4980,7 +5309,7 @@
  		switch(condition) {
  		case AST_CONTROL_BUSY:
  #ifdef ZAPATA_PRI
@@ -7462,7 +7373,25 @@
  				chan->hangupcause = AST_CAUSE_USER_BUSY;
  				chan->_softhangup |= AST_SOFTHANGUP_DEV;
  				res = 0;
-@@ -5051,7 +5367,7 @@
+@@ -5024,7 +5353,7 @@
+ 		case AST_CONTROL_PROCEEDING:
+ 			ast_log(LOG_DEBUG,"Received AST_CONTROL_PROCEEDING on %s\n",chan->name);
+ #ifdef ZAPATA_PRI
+-			if (!p->proceeding && p->sig==SIG_PRI && p->pri && !p->outgoing) {
++			if (!p->proceeding && p->sig==SIG_PRI && p->pri && !p->outgoing && (chan->_state != AST_STATE_UP)) {
+ 				if (p->pri->pri) {		
+ 					if (!pri_grab(p, p->pri)) {
+ 						pri_proceeding(p->pri->pri,p->call, PVT_TO_CHANNEL(p), !p->digital);
+@@ -5043,7 +5372,7 @@
+ 			ast_log(LOG_DEBUG,"Received AST_CONTROL_PROGRESS on %s\n",chan->name);
+ #ifdef ZAPATA_PRI
+ 			p->digital = 0;	/* Digital-only calls isn't allows any inband progress messages */
+-			if (!p->progress && p->sig==SIG_PRI && p->pri && !p->outgoing) {
++			if (!p->progress && p->sig==SIG_PRI && p->pri && !p->outgoing && (chan->_state != AST_STATE_UP)) {
+ 				if (p->pri->pri) {		
+ 					if (!pri_grab(p, p->pri)) {
+ 						pri_progress(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1);
+@@ -5061,7 +5390,7 @@
  		case AST_CONTROL_CONGESTION:
  			chan->hangupcause = AST_CAUSE_CONGESTION;
  #ifdef ZAPATA_PRI
@@ -7471,7 +7400,7 @@
  				chan->hangupcause = AST_CAUSE_SWITCH_CONGESTION;
  				chan->_softhangup |= AST_SOFTHANGUP_DEV;
  				res = 0;
-@@ -5236,8 +5552,12 @@
+@@ -5248,8 +5577,12 @@
  		if (state == AST_STATE_RING)
  			tmp->rings = 1;
  		tmp->tech_pvt = i;
@@ -7486,15 +7415,15 @@
  			tmp->callgroup = i->callgroup;
  			tmp->pickupgroup = i->pickupgroup;
  		}
-@@ -5379,6 +5699,7 @@
+@@ -5391,6 +5724,7 @@
  	int len = 0;
  	int res;
  	int index;
 +	int network;
- 	if (option_verbose > 2) 
- 		ast_verbose( VERBOSE_PREFIX_3 "Starting simple switch on '%s'\n", chan->name);
- 	index = zt_get_index(chan, p, 1);
-@@ -5397,10 +5718,17 @@
+ 
+ 	/* in the bizarre case where the channel has become a zombie before we
+ 	   even get started here, abort safely
+@@ -5419,10 +5753,17 @@
  		len = strlen(exten);
  		res = 0;
  		while((len < AST_MAX_EXTENSION-1) && ast_matchmore_extension(chan, chan->context, exten, 1, p->cid_num)) {
@@ -7515,7 +7444,7 @@
  			if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num))
  				timeout = matchdigittimeout;
  			else
-@@ -6497,18 +6825,44 @@
+@@ -6519,18 +6860,44 @@
  		break;
  	case ZT_EVENT_NOALARM:
  		i->inalarm = 0;
@@ -7560,7 +7489,7 @@
  		/* fall thru intentionally */
  	case ZT_EVENT_ONHOOK:
  		if (i->radio) break;
-@@ -6548,8 +6902,10 @@
+@@ -6570,8 +6937,10 @@
  			zt_set_hook(i->subs[SUB_REAL].zfd, ZT_ONHOOK);
  			break;
  		case SIG_PRI:
@@ -7573,7 +7502,7 @@
  			break;
  		default:
  			ast_log(LOG_WARNING, "Don't know how to handle on hook with signalling %s on channel %d\n", sig2str(i->sig), i->channel);
-@@ -6875,6 +7231,8 @@
+@@ -6891,6 +7260,8 @@
  		} else {
  			if (si->totalchans == 31) { /* if it's an E1 */
  				pris[*span].dchannels[0] = 16 + offset;
@@ -7582,7 +7511,7 @@
  			} else {
  				pris[*span].dchannels[0] = 24 + offset;
  			}
-@@ -6962,6 +7320,10 @@
+@@ -6978,6 +7349,10 @@
  
  #endif
  
@@ -7593,7 +7522,7 @@
  static struct zt_pvt *mkintf(int channel, struct zt_chan_conf chan_conf, struct zt_pri *pri, int reloading)
  {
  	/* Make a zt_pvt structure for this interface (or CRV if "pri" is specified) */
-@@ -7120,6 +7482,11 @@
+@@ -7141,6 +7516,11 @@
  							destroy_zt_pvt(&tmp);
  							return NULL;
  						}
@@ -7602,10 +7531,10 @@
 + 							destroy_zt_pvt(&tmp);
 +                                                 	return NULL;
 +  						}
- 						if (!ast_strlen_zero(pris[span].idledial) && strcmp(pris[span].idledial, chan_conf.pri.idledial)) {
- 							ast_log(LOG_ERROR, "Span %d already has idledial '%s'.\n", span + 1, chan_conf.pri.idledial);
+ 						if (!ast_strlen_zero(pris[span].idleext) && strcmp(pris[span].idleext, chan_conf.pri.idleext)) {
+ 							ast_log(LOG_ERROR, "Span %d already has idleext '%s'.\n", span + 1, chan_conf.pri.idleext);
  							destroy_zt_pvt(&tmp);
-@@ -7147,6 +7514,17 @@
+@@ -7163,6 +7543,17 @@
  							return NULL;
  						}
  						pris[span].nodetype = pritype;
@@ -7623,22 +7552,22 @@
  						pris[span].switchtype = myswitchtype;
  						pris[span].nsf = nsf;
  						pris[span].dialplan = dialplan;
-@@ -7155,9 +7533,14 @@
+@@ -7171,9 +7562,14 @@
  						pris[span].minunused = chan_conf.pri.minunused;
  						pris[span].minidle = chan_conf.pri.minidle;
  						pris[span].overlapdial = chan_conf.pri.overlapdial;
-+						pris[span].usercid = chan_conf.pri.usercid;
-+						pris[span].suspended_calls = NULL;
-+						pris[span].holded_calls = NULL;
++   						pris[span].usercid = chan_conf.pri.usercid;
++   						pris[span].suspended_calls = NULL;
++   						pris[span].holded_calls = NULL;
  						pris[span].facilityenable = chan_conf.pri.facilityenable;
  						ast_copy_string(pris[span].idledial, chan_conf.pri.idledial, sizeof(pris[span].idledial));
  						ast_copy_string(pris[span].idleext, chan_conf.pri.idleext, sizeof(pris[span].idleext));
-+						ast_copy_string(pris[span].nocid, chan_conf.pri.nocid, sizeof(pris[span].nocid) - 1);
-+						ast_copy_string(pris[span].withheldcid, chan_conf.pri.withheldcid, sizeof(pris[span].withheldcid) - 1);
++  						ast_copy_string(pris[span].nocid, nocid, sizeof(pris[span].nocid) - 1);
++  						ast_copy_string(pris[span].withheldcid, withheldcid, sizeof(pris[span].withheldcid) - 1);
  						ast_copy_string(pris[span].internationalprefix, chan_conf.pri.internationalprefix, sizeof(pris[span].internationalprefix));
  						ast_copy_string(pris[span].nationalprefix, chan_conf.pri.nationalprefix, sizeof(pris[span].nationalprefix));
  						ast_copy_string(pris[span].localprefix, chan_conf.pri.localprefix, sizeof(pris[span].localprefix));
-@@ -7178,6 +7561,37 @@
+@@ -7194,6 +7590,37 @@
  				tmp->prioffset = 0;
  			}
  #endif
@@ -7646,8 +7575,8 @@
 +		if (chan_conf.signalling == SIG_GSM) {
 +		    struct zt_bufferinfo bi;
 +		    ast_mutex_init(&tmp->gsm.lock);
-+		    strncpy(tmp->gsm.pin, chan_conf.gsm.pin, sizeof(tmp->gsm.pin) - 1);
-+		    strncpy(tmp->gsm.exten, chan_conf.gsm.exten, sizeof(tmp->gsm.exten) - 1);
++		    strncpy(tmp->gsm.pin, gsm_modem_pin, sizeof(tmp->gsm.pin) - 1);
++		    strncpy(tmp->gsm.exten, gsm_modem_exten, sizeof(tmp->gsm.exten) - 1);
 +		    tmp->gsm.available = 0;
 +		    snprintf(fn, sizeof(fn), "%d", channel + 1);
 +		    /* Open non-blocking */
@@ -7676,15 +7605,15 @@
  #ifdef ZAPATA_R2
  			if (chan_conf.signalling == SIG_R2) {
  				if (r2prot < 0) {
-@@ -7311,6 +7725,7 @@
+@@ -7327,6 +7754,7 @@
  		tmp->restrictcid = chan_conf.restrictcid;
  		tmp->use_callingpres = chan_conf.use_callingpres;
  		tmp->priindication_oob = chan_conf.priindication_oob;
-+		tmp->pritransfer = chan_conf.pritransfer;
++ 		tmp->pritransfer = chan_conf.pritransfer;
  		tmp->priexclusive = chan_conf.priexclusive;
  		if (tmp->usedistinctiveringdetection) {
  			if (!tmp->use_callerid) {
-@@ -7463,6 +7878,12 @@
+@@ -7479,6 +7907,12 @@
  				return 1;
  		}
  #endif
@@ -7697,7 +7626,7 @@
  #ifdef ZAPATA_R2
  		/* Trust R2 as well */
  		if (p->r2) {
-@@ -7584,7 +8005,7 @@
+@@ -7600,7 +8034,7 @@
  			break;
  		if (!backwards && (x >= pri->numchans))
  			break;
@@ -7706,7 +7635,7 @@
  			ast_log(LOG_DEBUG, "Found empty available channel %d/%d\n", 
  				pri->pvts[x]->logicalspan, pri->pvts[x]->prioffset);
  			return x;
-@@ -7631,7 +8052,7 @@
+@@ -7647,7 +8081,7 @@
  	end = ifend;
  	/* We do signed linear */
  	oldformat = format;
@@ -7715,7 +7644,7 @@
  	if (!format) {
  		ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", oldformat);
  		return NULL;
-@@ -7791,6 +8212,11 @@
+@@ -7807,6 +8241,11 @@
  					p->digital = 1;
  					if (tmp)
  						tmp->transfercapability = AST_TRANS_CAP_DIGITAL;
@@ -7727,7 +7656,7 @@
  				} else {
  					ast_log(LOG_WARNING, "Unknown option '%c' in '%s'\n", opt, (char *)data);
  				}
-@@ -7824,12 +8250,189 @@
+@@ -7840,12 +8279,242 @@
  				*cause = AST_CAUSE_BUSY;
  		} else if (groupmatched) {
  			*cause = AST_CAUSE_CONGESTION;
@@ -7740,6 +7669,33 @@
  }
  
 +#ifdef ZAPATA_GSM
++static int zt_reset_span(int span, int sleep) {
++	int ctl;
++	int res;
++
++	ctl = open("/dev/zap/ctl", O_RDWR);
++	if (ctl < 0) {
++		ast_log(LOG_WARNING, "Unable to open /dev/zap/ctl: %s\n", strerror(errno));
++		return -1;
++	}
++	ast_verbose(VERBOSE_PREFIX_2 "Shutting down span %d. Please wait...\n", span);
++	res = ioctl(ctl, ZT_SHUTDOWN, &span);
++	if (res) {
++		ast_log(LOG_WARNING, "error shutting down span %d\n", span);
++		return -1;
++	}
++	usleep(sleep * 1000);
++	ast_verbose(VERBOSE_PREFIX_2 "Starting up span %d. Please wait...\n", span);
++	res = ioctl(ctl, ZT_STARTUP, &span);
++	if (res) {
++		ast_log(LOG_WARNING, "error starting up span %d\n", span);
++		return -1;
++	}
++	ast_verbose(VERBOSE_PREFIX_2 "Reset of span %d completed.\n", span);
++	return 0;
++}
++
++
 +static void handle_gsm_event(struct zt_gsm *gsm, gsm_event *e)
 +{
 +	struct ast_channel *c = NULL;
@@ -7756,6 +7712,12 @@
 +		if (option_verbose > 2)
 +		    ast_verbose(VERBOSE_PREFIX_3 "GSM Span %d unregistered from network!\n", gsm->span);
 +		gsm->available = 0;
++/*		ast_mutex_lock(&gsm->pvt->lock);
++		gsm->pvt->alreadyhungup = 1;
++		if (gsm->pvt->owner) {
++		    gsm->pvt->owner->_softhangup |= AST_SOFTHANGUP_DEV;
++		}
++		ast_mutex_unlock(&gsm->pvt->lock); */
 +		break;
 +	case GSM_EVENT_RING:
 +		ast_mutex_lock(&gsm->pvt->lock);
@@ -7792,10 +7754,30 @@
 +		ast_mutex_lock(&gsm->pvt->lock);
 +		gsm->pvt->alreadyhungup = 1;
 +		if (gsm->pvt->owner) {
++		    gsm->pvt->owner->hangupcause = e->hangup.cause;
 +		    gsm->pvt->owner->_softhangup |= AST_SOFTHANGUP_DEV;
 +		}
 +		ast_mutex_unlock(&gsm->pvt->lock);
 +		break;
++	case GSM_EVENT_ERROR:
++		ast_log(LOG_WARNING, "Got error on channel\n");
++		ast_mutex_lock(&gsm->pvt->lock);
++		gsm->pvt->alreadyhungup = 1;
++		if (gsm->pvt->owner) {
++		    gsm->pvt->owner->hangupcause = e->error.cause;
++		    gsm->pvt->owner->_softhangup |= AST_SOFTHANGUP_DEV;
++		}
++		ast_mutex_unlock(&gsm->pvt->lock);
++		if (e->error.hard) {
++//		    gsm_poweroff(gsm->modul);
++		    zt_reset_span(gsm->span, 8000);
++//		    gsm_restart(gsm->modul, 10000);
++		} else {
++//		    gsm_poweroff(gsm->modul);
++		    zt_reset_span(gsm->span, 8000);
++//		    gsm_restart(gsm->modul, 10000);
++		}
++		break;
 +	case GSM_EVENT_ALERTING:
 +		ast_mutex_lock(&gsm->pvt->lock);
 +		gsm->pvt->subs[SUB_REAL].needringing =1;
@@ -7898,7 +7880,7 @@
 +			    case ZT_EVENT_NOALARM:
 +				ast_log(LOG_NOTICE, "Alarm cleared on span %d\n", gsm->span);
 +				usleep(1000);
-+				gsm_restart(gsm->modul);
++				gsm_restart(gsm->modul, 10000);
 +			    break;
 +			    case ZT_EVENT_ALARM:
 +				ast_log(LOG_NOTICE, "Alarm detected on span %d\n", gsm->span);
@@ -7917,12 +7899,16 @@
  
  #ifdef ZAPATA_PRI
  static struct zt_pvt *pri_find_crv(struct zt_pri *pri, int crv)
-@@ -7844,6 +8447,57 @@
+@@ -7860,11 +8529,62 @@
  	return NULL;
  }
  
+-
+-static int pri_find_principle(struct zt_pri *pri, int channel)
 +static int pri_find_tei(struct zt_pri *pri, q931_call *c, int tei)
-+{
+ {
+-	int x;
+-	int span = PRI_SPAN(channel);
 +	int x=0;
 +	for (x=0;x<pri->numchans;x++) {
 +		if (!pri->pvts[x]) continue;
@@ -7972,10 +7958,15 @@
 +	}
 +	return 0;	
 +}
- 
- static int pri_find_principle(struct zt_pri *pri, int channel)
- {
-@@ -7876,7 +8530,9 @@
++
++static int pri_find_principle(struct zt_pri *pri, int channel)
++{
++	int x;
++	int span = PRI_SPAN(channel);
+ 	int spanfd;
+ 	ZT_PARAMS param;
+ 	int principle = -1;
+@@ -7892,7 +8612,9 @@
  static int pri_fixup_principle(struct zt_pri *pri, int principle, q931_call *c)
  {
  	int x;
@@ -7985,7 +7976,7 @@
  	if (!c) {
  		if (principle < 0)
  			return -1;
-@@ -7890,6 +8546,7 @@
+@@ -7906,6 +8628,7 @@
  	/* First, check for other bearers */
  	for (x=0;x<pri->numchans;x++) {
  		if (!pri->pvts[x]) continue;
@@ -7993,7 +7984,7 @@
  		if (pri->pvts[x]->call == c) {
  			/* Found our call */
  			if (principle != x) {
-@@ -7903,19 +8560,56 @@
+@@ -7919,19 +8642,56 @@
  				}
  				/* Fix it all up now */
  				pri->pvts[principle]->owner = pri->pvts[x]->owner;
@@ -8051,7 +8042,7 @@
  			}
  			return principle;
  		}
-@@ -7944,7 +8638,9 @@
+@@ -7960,7 +8720,9 @@
  		}
  		crv = crv->next;
  	}
@@ -8062,7 +8053,7 @@
  	return -1;
  }
  
-@@ -8003,86 +8699,33 @@
+@@ -8019,86 +8781,33 @@
  #ifndef PRI_RESTART
  #error "Upgrade your libpri"
  #endif
@@ -8166,7 +8157,7 @@
  	do {
  		pri->resetpos++;
  	} while((pri->resetpos < pri->numchans) &&
-@@ -8165,6 +8808,32 @@
+@@ -8181,6 +8890,32 @@
  	}
  }
  
@@ -8199,7 +8190,7 @@
  static void *pri_dchannel(void *vpri)
  {
  	struct zt_pri *pri = vpri;
-@@ -8342,15 +9011,44 @@
+@@ -8358,15 +9093,44 @@
  					/* Check for an event */
  					x = 0;
  					res = ioctl(pri->fds[which], ZT_GETEVENT, &x);
@@ -8247,7 +8238,7 @@
  					}
  				
  					if (option_debug)
-@@ -8362,8 +9060,7 @@
+@@ -8378,8 +9142,7 @@
  					break;
  			}
  		} else if (errno != EINTR)
@@ -8257,8 +8248,8 @@
  		if (e) {
  			if (pri->debug)
  				pri_dump_event(pri->dchans[which], e);
-@@ -8371,32 +9068,102 @@
- 				pri->dchanavail[which] |= DCHAN_UP;
+@@ -8392,32 +9155,102 @@
+ 
  			switch(e->e) {
  			case PRI_EVENT_DCHAN_UP:
 -				if (option_verbose > 1) 
@@ -8384,7 +8375,7 @@
  					pri->resetting = 0;
  					/* Hangup active channels and put them in alarm mode */
  					for (i=0; i<pri->numchans; i++) {
-@@ -8404,19 +9171,29 @@
+@@ -8425,19 +9258,29 @@
  						if (p) {
  							if (p->call) {
  								if (p->pri && p->pri->pri) {
@@ -8421,7 +8412,7 @@
  				}
  				break;
  			case PRI_EVENT_RESTART:
-@@ -8451,8 +9228,8 @@
+@@ -8472,8 +9315,8 @@
  								pri_destroycall(pri->pri, pri->pvts[x]->call);
  								pri->pvts[x]->call = NULL;
  							}
@@ -8432,7 +8423,7 @@
   							else if (pri->pvts[x]->owner)
  								pri->pvts[x]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
  							ast_mutex_unlock(&pri->pvts[x]->lock);
-@@ -8486,7 +9263,6 @@
+@@ -8507,7 +9350,6 @@
  					}
  				}
  				break;
@@ -8440,7 +8431,7 @@
  			case PRI_EVENT_INFO_RECEIVED:
  				chanpos = pri_find_principle(pri, e->ring.channel);
  				if (chanpos < 0) {
-@@ -8495,9 +9271,11 @@
+@@ -8516,9 +9358,11 @@
  				} else {
  					chanpos = pri_fixup_principle(pri, chanpos, e->ring.call);
  					if (chanpos > -1) {
@@ -8453,7 +8444,7 @@
  							/* how to do that */
  							int digitlen = strlen(e->ring.callednum);
  							char digit;
-@@ -8509,6 +9287,14 @@
+@@ -8530,6 +9374,14 @@
  									zap_queue_frame(pri->pvts[chanpos], &f, pri);
  								}
  							}
@@ -8468,55 +8459,54 @@
  						}
  						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
  					}
-@@ -8516,36 +9302,58 @@
+@@ -8537,36 +9389,59 @@
  				break;
  			case PRI_EVENT_RING:
  				crv = NULL;
 -				if (e->ring.channel == -1)
-+				if (e->ring.channel == -1) {
-+					/* if no channel specified find one empty */
++ 				if (e->ring.channel == -1) {
++ 					/* if no channel specified find one empty */
  					chanpos = pri_find_empty_chan(pri, 1);
 -				else
 +				} else {
  					chanpos = pri_find_principle(pri, e->ring.channel);
--				/* if no channel specified find one empty */
 +				}
+ 				/* if no channel specified find one empty */
  				if (chanpos < 0) {
 -					ast_log(LOG_WARNING, "Ring requested on unconfigured channel %d/%d span %d\n", 
 -						PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), pri->span);
-+					/* no channel specified and no free channel. this is a callwating SETUP */
-+					if (e->ring.channel == -1) {
-+					    if (option_verbose > 2)
-+						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);
-+					    pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_USER_BUSY, -1);
-+					    break;
-+					}
++ 					/* no channel specified and no free channel. this is a callwating SETUP */
++ 					if (e->ring.channel <= 0) {
++ 					    if (option_verbose > 2)
++ 						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);
++ 					    pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_USER_BUSY, -1);
++ 					    break;
++ 					}
  				} else {
 +					/* ok, we got a b channel for this call, lock it */
  					ast_mutex_lock(&pri->pvts[chanpos]->lock);
  					if (pri->pvts[chanpos]->owner) {
 -						if (pri->pvts[chanpos]->call == e->ring.call) {
 -							ast_log(LOG_WARNING, "Duplicate setup requested on channel %d/%d already in use on span %d\n", 
--								PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), pri->span);
--							break;
--						} else {
--							/* This is where we handle initial glare */
--							ast_log(LOG_DEBUG, "Ring requested on channel %d/%d already in use or previously requested on span %d.  Attempting to renegotiating channel.\n", 
 +					    /* safety check, for messed up retransmissions? */
 +					    if (pri->pvts[chanpos]->call == e->ring.call) {
 +						ast_log(LOG_WARNING, "Duplicate setup requested on channel %d/%d already in use on span %d\n", 
- 							PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), pri->span);
--							ast_mutex_unlock(&pri->pvts[chanpos]->lock);
--							chanpos = -1;
+ 								PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), pri->span);
+-							break;
 +						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
 +						chanpos = -1;
 +						break;
 +					    } else {
-+						ast_log(LOG_WARNING, "Ring requested on channel %d/%d already in use on span %d. Hanging up owner.\n", 
++ 						ast_log(LOG_WARNING, "Ring requested on channel %d/%d already in use on span %d. Hanging up owner.\n", 
 +						PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), pri->span);
 +						if (pri->pvts[chanpos]->realcall) {
-+							pri_hangup_all(pri->pvts[chanpos]->realcall, pri);
-+						} else {
++ 							pri_hangup_all(pri->pvts[chanpos]->realcall, pri);
+ 						} else {
+-							/* This is where we handle initial glare */
+-							ast_log(LOG_DEBUG, "Ring requested on channel %d/%d already in use or previously requested on span %d.  Attempting to renegotiating channel.\n", 
+-							PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), pri->span);
+-							ast_mutex_unlock(&pri->pvts[chanpos]->lock);
+-							chanpos = -1;
 +							pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
 +							/* XXX destroy the call here, so we can accept the retransmission as a new call */
 +							pri_destroycall(pri->pri, e->ring.call);
@@ -8528,14 +8518,14 @@
 +						break;
 +					    }
 +					}
-+					if (chanpos > -1) {
++ 					if (chanpos > -1) {
 +						/* everything is ok with the b channel */
 +					    ast_mutex_unlock(&pri->pvts[chanpos]->lock);
 +					}
  				}
 -				if ((chanpos < 0) && (e->ring.flexible))
 -					chanpos = pri_find_empty_chan(pri, 1);
-+				/* actually, we already got a valid channel by now */
++ 				/* actually, we already got a valid channel by now */
  				if (chanpos > -1) {
  					ast_mutex_lock(&pri->pvts[chanpos]->lock);
 +					/* dont detect dtmfs before the signalling is done */
@@ -8545,7 +8535,7 @@
  					if (pri->switchtype == PRI_SWITCH_GR303_TMC) {
  						/* Should be safe to lock CRV AFAIK while bearer is still locked */
  						crv = pri_find_crv(pri, pri_get_crv(pri->pri, e->ring.call, NULL));
-@@ -8562,13 +9367,14 @@
+@@ -8580,13 +9455,14 @@
  								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);
  							} else
  								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);
@@ -8561,7 +8551,7 @@
  					pri->pvts[chanpos]->call = e->ring.call;
  					apply_plan_to_number(plancallingnum, sizeof(plancallingnum), pri, e->ring.callingnum, e->ring.callingplan);
  					if (pri->pvts[chanpos]->use_callerid) {
-@@ -8593,29 +9399,78 @@
+@@ -8611,29 +9487,78 @@
  					}
  					apply_plan_to_number(pri->pvts[chanpos]->rdnis, sizeof(pri->pvts[chanpos]->rdnis), pri,
  							     e->ring.redirectingnum, e->ring.callingplanrdnis);
@@ -8622,6 +8612,7 @@
  							ast_verbose(VERBOSE_PREFIX_3 "Going to extension s|1 because of Complete received\n");
  						pri->pvts[chanpos]->exten[0] = 's';
  						pri->pvts[chanpos]->exten[1] = '\0';
+-					}
 + 					    }
 +  					} else {
 +  						/* Get called number */
@@ -8644,7 +8635,7 @@
 +  							}
 +  						    }
 +  						}
- 					}
++					}
 +  					/* Part 3: create channel, setup audio... */
 + 					/* Set DNID on all incoming calls -- even immediate */
 + 					if (!ast_strlen_zero(e->ring.callednum))
@@ -8652,7 +8643,7 @@
  					/* Make sure extension exists (or in overlap dial mode, can exist) */
  					if ((pri->overlapdial && ast_canmatch_extension(NULL, pri->pvts[chanpos]->context, pri->pvts[chanpos]->exten, 1, pri->pvts[chanpos]->cid_num)) ||
  						ast_exists_extension(NULL, pri->pvts[chanpos]->context, pri->pvts[chanpos]->exten, 1, pri->pvts[chanpos]->cid_num)) {
-@@ -8634,19 +9489,36 @@
+@@ -8652,19 +9577,36 @@
  						res = zt_setlaw(pri->pvts[chanpos]->subs[SUB_REAL].zfd, law);
  						if (res < 0) 
  							ast_log(LOG_WARNING, "Unable to set law on channel %d\n", pri->pvts[chanpos]->channel);
@@ -8693,7 +8684,7 @@
  						/* Get the use_callingpres state */
  						pri->pvts[chanpos]->callingpres = e->ring.callingpres;
  					
-@@ -8658,14 +9530,31 @@
+@@ -8676,14 +9618,31 @@
  								/* Set bearer and such */
  								pri_assign_bearer(crv, pri, pri->pvts[chanpos]);
  								c = zt_new(crv, AST_STATE_RESERVED, 0, SUB_REAL, law, e->ring.ctype);
@@ -8725,7 +8716,7 @@
  							if(e->ring.ani2 >= 0) {
  								snprintf(ani2str, 5, "%.2d", e->ring.ani2);
  								pbx_builtin_setvar_helper(c, "ANI2", ani2str);
-@@ -8687,8 +9576,8 @@
+@@ -8705,8 +9664,8 @@
  							pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
  							if (c && !ast_pthread_create(&threadid, &attr, ss_thread, c)) {
  								if (option_verbose > 2)
@@ -8736,7 +8727,7 @@
  										pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span);
  							} else {
  								ast_log(LOG_WARNING, "Unable to start PBX on channel %d/%d, span %d\n", 
-@@ -8696,15 +9585,19 @@
+@@ -8714,15 +9673,19 @@
  								if (c)
  									ast_hangup(c);
  								else {
@@ -8752,12 +8743,12 @@
  							/* Release PRI lock while we create the channel */
  							c = zt_new(pri->pvts[chanpos], AST_STATE_RING, 1, SUB_REAL, law, e->ring.ctype);
 +							if (c && (e->ring.lowlayercompat[0] > 0)) {
-+								memcpy(c->lowlayercompat, e->ring.lowlayercompat, sizeof(c->lowlayercompat));
++							    memcpy(c->lowlayercompat, e->ring.lowlayercompat, sizeof(c->lowlayercompat));
 +							}
  							ast_mutex_lock(&pri->lock);
  							if (c) {
  								char calledtonstr[10];
-@@ -8725,23 +9618,40 @@
+@@ -8743,23 +9706,40 @@
  								snprintf(calledtonstr, sizeof(calledtonstr)-1, "%d", e->ring.calledplan);
  								pbx_builtin_setvar_helper(c, "CALLEDTON", calledtonstr);
  								if (option_verbose > 2)
@@ -8802,7 +8793,7 @@
  						pri->pvts[chanpos]->call = NULL;
  						pri->pvts[chanpos]->exten[0] = '\0';
  					}
-@@ -8749,9 +9659,9 @@
+@@ -8768,9 +9748,9 @@
  					ast_mutex_unlock(&pri->pvts[chanpos]->lock);
  				} else {
  					if (e->ring.flexible)
@@ -8814,7 +8805,7 @@
  				}
  				break;
  			case PRI_EVENT_RINGING:
-@@ -8767,7 +9677,7 @@
+@@ -8789,7 +9769,7 @@
  					} else {
  						ast_mutex_lock(&pri->pvts[chanpos]->lock);
  						if (ast_strlen_zero(pri->pvts[chanpos]->dop.dialstr)) {
@@ -8823,7 +8814,7 @@
  							pri->pvts[chanpos]->subs[SUB_REAL].needringing = 1;
  							pri->pvts[chanpos]->alerting = 1;
  						} else
-@@ -8796,9 +9706,16 @@
+@@ -8818,9 +9798,16 @@
  				}
  				break;
  			case PRI_EVENT_PROGRESS:
@@ -8841,7 +8832,7 @@
  #ifdef PRI_PROGRESS_MASK
  					if ((!pri->pvts[chanpos]->progress) || (e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE)) {
  #else
-@@ -8845,6 +9762,12 @@
+@@ -8867,6 +9854,12 @@
  			case PRI_EVENT_PROCEEDING:
  				chanpos = pri_find_principle(pri, e->proceeding.channel);
  				if (chanpos > -1) {
@@ -8854,7 +8845,7 @@
  					if (!pri->pvts[chanpos]->proceeding) {
  						struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_PROCEEDING, };
  						
-@@ -8895,6 +9818,295 @@
+@@ -8917,6 +9910,295 @@
  					}
  				}
  				break;				
@@ -9150,7 +9141,7 @@
  			case PRI_EVENT_ANSWER:
  				chanpos = pri_find_principle(pri, e->answer.channel);
  				if (chanpos < 0) {
-@@ -8910,6 +10122,7 @@
+@@ -8932,6 +10214,7 @@
  						chanpos = -1;
  					} else {
  						ast_mutex_lock(&pri->pvts[chanpos]->lock);
@@ -9158,7 +9149,7 @@
  						/* Now we can do call progress detection */
  
  						/* We changed this so it turns on the DSP no matter what... progress or no progress.
-@@ -8939,11 +10152,16 @@
+@@ -8961,11 +10244,16 @@
  								ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", pri->pvts[chanpos]->dop.dialstr);
  							pri->pvts[chanpos]->dop.dialstr[0] = '\0';
  						} else if (pri->pvts[chanpos]->confirmanswer) {
@@ -9176,12 +9167,12 @@
  						}
  
  #ifdef SUPPORT_USERUSER
-@@ -8992,23 +10210,32 @@
+@@ -9014,23 +10302,32 @@
  								}
  							}
  							if (option_verbose > 2) 
--								ast_verbose(VERBOSE_PREFIX_3 "Channel %d/%d, span %d got hangup\n", 
--									pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span);
+-								ast_verbose(VERBOSE_PREFIX_3 "Channel %d/%d, span %d got hangup, cause %d\n", 
+-									pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span, e->hangup.cause);
 +								ast_verbose(VERBOSE_PREFIX_3 "Channel %d/%d, span %d got hangup, cause %d\n", 
 +									pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span, e->hangup.cause);
  						} else {
@@ -9216,7 +9207,7 @@
  
  #ifdef SUPPORT_USERUSER
  						if (!ast_strlen_zero(e->hangup.useruserinfo)) {
-@@ -9018,8 +10245,20 @@
+@@ -9040,8 +10337,20 @@
  
  						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
  					} else {
@@ -9239,7 +9230,7 @@
  					}
  				} 
  				break;
-@@ -9029,17 +10268,25 @@
+@@ -9051,17 +10360,25 @@
  			case PRI_EVENT_HANGUP_REQ:
  				chanpos = pri_find_principle(pri, e->hangup.channel);
  				if (chanpos < 0) {
@@ -9268,10 +9259,10 @@
  							pri->pvts[chanpos]->owner->hangupcause = e->hangup.cause;
  							switch(e->hangup.cause) {
  							case PRI_CAUSE_USER_BUSY:
-@@ -9058,20 +10305,87 @@
+@@ -9080,20 +10397,87 @@
  							}
  							if (option_verbose > 2) 
- 								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);
+ 								ast_verbose(VERBOSE_PREFIX_3 "Channel %d/%d, span %d got hangup request, cause %d\n", PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span, e->hangup.cause);
 -							if (e->hangup.aoc_units > -1)
 -								if (option_verbose > 2)
 -									ast_verbose(VERBOSE_PREFIX_3 "Channel %d/%d, span %d received AOC-E charging %d unit%s\n",
@@ -9366,7 +9357,7 @@
  						}
  
  #ifdef SUPPORT_USERUSER
-@@ -9082,9 +10396,39 @@
+@@ -9104,9 +10488,39 @@
  
  						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
  					} else {
@@ -9407,7 +9398,7 @@
  				break;
  			case PRI_EVENT_HANGUP_ACK:
  				chanpos = pri_find_principle(pri, e->hangup.channel);
-@@ -9098,6 +10442,7 @@
+@@ -9120,6 +10534,7 @@
  					if (chanpos > -1) {
  						ast_mutex_lock(&pri->pvts[chanpos]->lock);
  						pri->pvts[chanpos]->call = NULL;
@@ -9415,7 +9406,7 @@
  						pri->pvts[chanpos]->resetting = 0;
  						if (pri->pvts[chanpos]->owner) {
  							if (option_verbose > 2) 
-@@ -9111,7 +10456,9 @@
+@@ -9133,7 +10548,9 @@
  #endif
  
  						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
@@ -9425,7 +9416,7 @@
  				}
  				break;
  			case PRI_EVENT_CONFIG_ERR:
-@@ -9203,10 +10550,22 @@
+@@ -9225,10 +10642,22 @@
  					ast_mutex_lock(&pri->pvts[chanpos]->lock);
  					switch(e->notify.info) {
  					case PRI_NOTIFY_REMOTE_HOLD:
@@ -9448,7 +9439,7 @@
  						f.subclass = AST_CONTROL_UNHOLD;
  						zap_queue_frame(pri->pvts[chanpos], &f, pri);
  						break;
-@@ -9214,6 +10573,77 @@
+@@ -9236,6 +10665,77 @@
  					ast_mutex_unlock(&pri->pvts[chanpos]->lock);
  				}
  				break;
@@ -9526,7 +9517,7 @@
  			default:
  				ast_log(LOG_DEBUG, "Event: %d\n", e->e);
  			}
-@@ -9275,7 +10705,7 @@
+@@ -9297,7 +10797,7 @@
  			pri->fds[i] = -1;
  			return -1;
  		}
@@ -9535,7 +9526,7 @@
  		/* Force overlap dial if we're doing GR-303! */
  		if (pri->switchtype == PRI_SWITCH_GR303_TMC)
  			pri->overlapdial = 1;
-@@ -9344,39 +10774,77 @@
+@@ -9366,39 +10866,77 @@
  
  static int handle_pri_set_debug_file(int fd, int argc, char **argv)
  {
@@ -9635,7 +9626,7 @@
  	}
  
  	return RESULT_SUCCESS;
-@@ -9408,6 +10876,7 @@
+@@ -9430,6 +10968,7 @@
  
  
  
@@ -9643,7 +9634,7 @@
  static int handle_pri_no_debug(int fd, int argc, char *argv[])
  {
  	int span;
-@@ -9514,36 +10983,6 @@
+@@ -9536,36 +11075,6 @@
  	return RESULT_SUCCESS;
  }
  
@@ -9680,7 +9671,7 @@
  static char pri_debug_help[] = 
  	"Usage: pri debug span <span>\n"
  	"       Enables debugging on a given PRI span\n";
-@@ -9560,6 +10999,18 @@
+@@ -9582,6 +11091,18 @@
  	"Usage: pri show span <span>\n"
  	"       Displays PRI Information\n";
  
@@ -9699,7 +9690,7 @@
  static struct ast_cli_entry zap_pri_cli[] = {
  	{ { "pri", "debug", "span", NULL }, handle_pri_debug,
  	  "Enables PRI debugging on a span", pri_debug_help, complete_span_4 },
-@@ -9567,19 +11018,301 @@
+@@ -9589,18 +11110,327 @@
  	  "Disables PRI debugging on a span", pri_no_debug_help, complete_span_5 },
  	{ { "pri", "intense", "debug", "span", NULL }, handle_pri_really_debug,
  	  "Enables REALLY INTENSE PRI debugging", pri_really_debug_help, complete_span_5 },
@@ -9728,6 +9719,10 @@
 +{
 +    struct zt_pvt *p = chan->tech_pvt;
 +
++    if((!p->pri) || (!p->pri->pri)) {
++	return -1;
++    }
++
 +    if(!data) {
 +        ast_log(LOG_WARNING, "zapCD wants a number to deflect to\n");
 +	return -1;
@@ -9747,8 +9742,24 @@
 +}
  #endif /* ZAPATA_PRI */
  
- 
 +#ifdef ZAPATA_GSM
++static int handle_zap_reset_span(int fd, int argc, char *argv[])
++{
++	int span;
++	int sleep = 5000;
++	if (argc < 4)
++		return RESULT_SHOWUSAGE;
++	span = atoi(argv[3]);
++	if ((span < 1) || (span > NUM_SPANS)) {
++		ast_cli(fd, "Invalid span '%s'.  Should be a number from %d to %d\n", argv[3], 1, NUM_SPANS);
++		return RESULT_SUCCESS;
++	}
++	if (zt_reset_span(span, sleep)) {
++	    return RESULT_FAILURE;
++	}
++	return RESULT_SUCCESS;
++}
++
 +static int handle_gsm_debug_helper(int fd, int channel, int debug)
 +{
 +/* gsm debug channel <channel> */
@@ -9797,6 +9808,10 @@
 +    return handle_gsm_debug_helper(fd, channel, GSM_DEBUG_NONE);
 +}
 +
++static char zap_reset_help[] = 
++	"Usage: zap reset span <span>\n"
++	"       Reset/Restart a zaptel span\n";
++
 +static char gsm_debug_help[] = 
 +	"Usage: gsm debug channel <channel>\n"
 +	"       Enables debugging on a given GSM channel\n";
@@ -9806,6 +9821,8 @@
 +	"       Disables debugging on a given GSM channel\n";
 +
 +static struct ast_cli_entry zap_gsm_cli[] = {
++	{ { "zap", "reset", "span", NULL }, handle_zap_reset_span,
++	  "Restart a zaptel span", zap_reset_help, complete_span_4 },
 +	{ { "gsm", "debug", "channel", NULL }, handle_gsm_debug,
 +	  "Enables GSM debugging on a channel", gsm_debug_help },
 +	{ { "gsm", "no", "debug", "channel", NULL }, handle_gsm_no_debug,
@@ -9819,6 +9836,7 @@
 +	"       Sends a PDU on a GSM channel\n";
 +
 +
++
 +static int handle_gsm_send_pdu(int fd, int argc, char *argv[])
 +{
 +/* gsm send sms <channel> <destination> <message> */
@@ -10000,11 +10018,10 @@
 +static char *zapEC_synopsis = "Enable/Disable Echo Cancelation on a Zap channel";
 +
 +
-+
+ 
  #ifdef ZAPATA_R2
  static int handle_r2_no_debug(int fd, int argc, char *argv[])
- {
-@@ -10191,6 +11924,14 @@
+@@ -10213,6 +12043,14 @@
  			pthread_cancel(pris[i].master);
  	}
  	ast_cli_unregister_multiple(zap_pri_cli, sizeof(zap_pri_cli) / sizeof(zap_pri_cli[0]));
@@ -10019,7 +10036,7 @@
  #endif
  #ifdef ZAPATA_R2
  	ast_cli_unregister_multiple(zap_r2_cli, sizeof(zap_r2_cli) / sizeof(zap_r2_cli[0]));
-@@ -10202,6 +11943,7 @@
+@@ -10224,6 +12062,7 @@
  	ast_manager_unregister( "ZapDNDoff" );
  	ast_manager_unregister( "ZapDNDon" );
  	ast_manager_unregister("ZapShowChannels");
@@ -10027,7 +10044,7 @@
  	ast_channel_unregister(&zap_tech);
  	if (!ast_mutex_lock(&iflock)) {
  		/* Hangup all interfaces if they have an owner */
-@@ -10560,8 +12302,8 @@
+@@ -10582,8 +12421,8 @@
  			}
  		} else if (!strcasecmp(v->name, "echotraining")) {
  			if (sscanf(v->value, "%d", &y) == 1) {
@@ -10038,26 +10055,26 @@
  				} else {
  					chan_conf.echotraining = y;
  				}
-@@ -10747,12 +12489,33 @@
+@@ -10769,12 +12608,33 @@
  					chan_conf.signalling = SIG_GR303FXSKS;
  					chan_conf.radio = 0;
  					pritype = PRI_CPE;
-+				} else if (!strcasecmp(v->value, "bri_net_ptmp")) {
-+					chan_conf.radio = 0;
-+					chan_conf.signalling = SIG_PRI;
-+					pritype = BRI_NETWORK_PTMP;
-+				} else if (!strcasecmp(v->value, "bri_cpe_ptmp")) {
-+					chan_conf.signalling = SIG_PRI;
-+					chan_conf.radio = 0;
-+					pritype = BRI_CPE_PTMP;
-+				} else if (!strcasecmp(v->value, "bri_net")) {
-+					chan_conf.radio = 0;
-+					chan_conf.signalling = SIG_PRI;
-+					pritype = BRI_NETWORK;
-+				} else if (!strcasecmp(v->value, "bri_cpe")) {
-+					chan_conf.signalling = SIG_PRI;
-+					chan_conf.radio = 0;
-+					pritype = BRI_CPE;
++ 				} else if (!strcasecmp(v->value, "bri_net_ptmp")) {
++ 					chan_conf.radio = 0;
++ 					chan_conf.signalling = SIG_PRI;
++ 					pritype = BRI_NETWORK_PTMP;
++ 				} else if (!strcasecmp(v->value, "bri_cpe_ptmp")) {
++ 					chan_conf.signalling = SIG_PRI;
++ 					chan_conf.radio = 0;
++ 					pritype = BRI_CPE_PTMP;
++ 				} else if (!strcasecmp(v->value, "bri_net")) {
++ 					chan_conf.radio = 0;
++ 					chan_conf.signalling = SIG_PRI;
++ 					pritype = BRI_NETWORK;
++ 				} else if (!strcasecmp(v->value, "bri_cpe")) {
++ 					chan_conf.signalling = SIG_PRI;
++ 					chan_conf.radio = 0;
++ 					pritype = BRI_CPE;
  #endif
  #ifdef ZAPATA_R2
  				} else if (!strcasecmp(v->value, "r2")) {
@@ -10072,30 +10089,30 @@
  				} else {
  					ast_log(LOG_ERROR, "Unknown signalling method '%s'\n", v->value);
  				}
-@@ -10835,8 +12598,20 @@
-					chan_conf.priindication_oob = 1;
+@@ -10857,9 +12717,21 @@
+ 					chan_conf.priindication_oob = 1;
  				else if (!strcasecmp(v->value, "inband"))
  					chan_conf.priindication_oob = 0;
--				else
++				else if (!strcasecmp(v->value, "passthrough"))
++					chan_conf.pri.priindication_oob = 2;
+ 				else
 -					ast_log(LOG_WARNING, "'%s' is not a valid pri indication value, should be 'inband' or 'outofband' at line %d\n",
-+				else if (!strcasecmp(v->value, "passthrough"))
-+					chan_conf.priindication_oob = 2;
-+				else
-+					ast_log(LOG_WARNING, "'%s' is not a valid pri indication value, should be 'inband' , 'outofband' or 'passthrough' at line %d\n",
-+						v->value, v->lineno);
++					ast_log(LOG_WARNING, "'%s' is not a valid pri indication value, should be 'inband', 'passthrough' or 'outofband' at line %d\n",
+ 						v->value, v->lineno);
 +			} else if (!strcasecmp(v->name, "pritransfer")) {
 +				if (!strcasecmp(v->value, "no"))
-+					chan_conf.pritransfer = 0;
++					chan_conf.pri.pritransfer = 0;
 +				else if (!strcasecmp(v->value, "ect"))
-+					chan_conf.pritransfer = 1;
++					chan_conf.pri.pritransfer = 1;
 +				else if (!strcasecmp(v->value, "hangup"))
-+					chan_conf.pritransfer = 2;
-+				else
-+					ast_log(LOG_WARNING, "'%s' is not a valid pri transfer value, should be 'no' , 'ect' or 'hangup' at line %d\n",
- 						v->value, v->lineno);
++					chan_conf.pri.pritransfer = 2;
++  				else
++ 					ast_log(LOG_WARNING, "'%s' is not a valid pri transfer value, should be 'no' , 'ect' or 'hangup' at line %d\n",
++  						v->value, v->lineno);
  			} else if (!strcasecmp(v->name, "priexclusive")) {
  				chan_conf.priexclusive = ast_true(v->value);
-@@ -10850,6 +12626,16 @@
+ 			} else if (!strcasecmp(v->name, "internationalprefix")) {
+@@ -10872,6 +12744,14 @@
  				ast_copy_string(chan_conf.pri.privateprefix, v->value, sizeof(chan_conf.pri.privateprefix));
  			} else if (!strcasecmp(v->name, "unknownprefix")) {
  				ast_copy_string(chan_conf.pri.unknownprefix, v->value, sizeof(chan_conf.pri.unknownprefix));
@@ -10103,25 +10120,23 @@
 +  				ast_copy_string(chan_conf.pri.nocid, v->value, sizeof(chan_conf.pri.nocid) - 1);
 +  			} else if (!strcasecmp(v->name, "withheldcid")) {
 +  				ast_copy_string(chan_conf.pri.withheldcid, v->value, sizeof(chan_conf.pri.withheldcid) - 1);
-+#ifdef ZAPATA_GSM
 +			} else if (!strcasecmp(v->name, "pin")) {
-+				ast_copy_string(chan_conf.gsm.pin, v->value, sizeof(chan_conf.gsm.pin) - 1);
++				ast_copy_string(gsm_modem_pin, v->value, sizeof(gsm_modem_pin) - 1);
 +			} else if (!strcasecmp(v->name, "exten")) {
-+				ast_copy_string(chan_conf.gsm.exten, v->value, sizeof(chan_conf.gsm.exten) - 1);
-+#endif
++				ast_copy_string(gsm_modem_exten, v->value, sizeof(gsm_modem_exten) - 1);
  			} else if (!strcasecmp(v->name, "resetinterval")) {
  				if (!strcasecmp(v->value, "never"))
  					chan_conf.pri.resetinterval = -1;
-@@ -10866,6 +12650,8 @@
+@@ -10888,6 +12768,8 @@
  				ast_copy_string(chan_conf.pri.idleext, v->value, sizeof(chan_conf.pri.idleext));
  			} else if (!strcasecmp(v->name, "idledial")) {
  				ast_copy_string(chan_conf.pri.idledial, v->value, sizeof(chan_conf.pri.idledial));
-+ 			} else if (!strcasecmp(v->name, "pritrustusercid")) {
-+ 				chan_conf.pri.usercid = ast_true(v->value);
++  			} else if (!strcasecmp(v->name, "pritrustusercid")) {
++  				chan_conf.pri.usercid = ast_true(v->value);
  			} else if (!strcasecmp(v->name, "overlapdial")) {
  				chan_conf.pri.overlapdial = ast_true(v->value);
  			} else if (!strcasecmp(v->name, "pritimer")) {
-@@ -11051,6 +12837,7 @@
+@@ -11073,6 +12955,7 @@
  #ifdef ZAPATA_PRI
  	if (!reload) {
  		for (x=0;x<NUM_SPANS;x++) {
@@ -10129,7 +10144,7 @@
  			if (pris[x].pvts[0]) {
  				if (start_pri(pris + x)) {
  					ast_log(LOG_ERROR, "Unable to start D-channel on span %d\n", x + 1);
-@@ -11083,6 +12870,10 @@
+@@ -11105,6 +12988,10 @@
  	pri_set_error(zt_pri_error);
  	pri_set_message(zt_pri_message);
  #endif
@@ -10140,7 +10155,7 @@
  	res = setup_zap(0);
  	/* Make sure we can register our Zap channel type */
  	if(res) {
-@@ -11100,6 +12891,12 @@
+@@ -11122,6 +13009,12 @@
  	ast_cli_register_multiple(zap_r2_cli, sizeof(zap_r2_cli) / sizeof(zap_r2_cli[0]));
  #endif	
  	ast_cli_register_multiple(zap_cli, sizeof(zap_cli) / sizeof(zap_cli[0]));
@@ -10153,7 +10168,7 @@
  	
  	memset(round_robin, 0, sizeof(round_robin));
  	ast_manager_register( "ZapTransfer", 0, action_transfer, "Transfer Zap Channel" );
-@@ -11108,11 +12905,56 @@
+@@ -11130,11 +13023,56 @@
  	ast_manager_register( "ZapDNDon", 0, action_zapdndon, "Toggle Zap channel Do Not Disturb status ON" );
  	ast_manager_register( "ZapDNDoff", 0, action_zapdndoff, "Toggle Zap channel Do Not Disturb status OFF" );
  	ast_manager_register("ZapShowChannels", 0, action_zapshowchannels, "Show status zapata channels");
@@ -10212,7 +10227,7 @@
  {
  #define	END_SILENCE_LEN 400
  #define	HEADER_MS 50
-@@ -11131,6 +12973,7 @@
+@@ -11153,6 +13091,7 @@
  	float scont = 0.0;
  	int index;
  
@@ -10220,9 +10235,84 @@
  	index = zt_get_index(c, p, 0);
  	if (index < 0) {
  		ast_log(LOG_WARNING, "Huh?  I don't exist?\n");
-diff -urNad asterisk-1.2.15~dfsg~/codecs/codec_ilbc.c asterisk-1.2.15~dfsg/codecs/codec_ilbc.c
---- asterisk-1.2.15~dfsg~/codecs/codec_ilbc.c	2005-11-29 20:24:39.000000000 +0200
-+++ asterisk-1.2.15~dfsg/codecs/codec_ilbc.c	2007-02-11 06:04:59.000000000 +0200
+diff -urN asterisk-1.2.19.orig/channels/Makefile asterisk-1.2.19/channels/Makefile
+--- asterisk-1.2.19.orig/channels/Makefile	2007-03-26 12:21:56.000000000 +0200
++++ asterisk-1.2.19/channels/Makefile	2007-06-25 16:07:37.549148740 +0200
+@@ -108,8 +108,16 @@
+   ZAPR2=-lmfcr2
+ endif
+ 
++ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/lib/libgsmat.so.1)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/lib/libgsmat.so.1),)
++  CFLAGS+=-DZAPATA_GSM
++  ZAPGSM=-lgsmat
++endif
++
+ ALSA_SRC=chan_alsa.c
+ 
++# uncomment this if you want to try out the zaptel device state support 
++#CFLAGS+=-DZAPATA_DEVICE_STATES
++
+ ifneq ($(wildcard alsa-monitor.h),)
+   CFLAGS+=-DALSA_MONITOR
+   ALSA_SRC+=alsa-monitor.h
+@@ -128,6 +136,35 @@
+ endif
+ endif # WITHOUT_ZAPTEL
+ 
++ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/capi20.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/capi20.h),)
++  CHANNEL_LIBS+=chan_capi.so
++# uncomment the following line if you really never ever want early b3 connects,
++# you can also configure it in the dialstring, this is just for performance
++# NOTE: this is probably obsolete by using the "R" dial option
++#CFLAGS+=-DCAPI_NEVER_EVER_EARLY_B3_CONNECTS
++
++# uncommnet next line to force dtmf software detection/generation, can also be configured
++# in capi.conf on a perdevice basis (softdtmf=1)
++#CFLAGS+=-DCAPI_FORCE_SOFTWARE_DTMF
++
++# uncomment the next line if you are in the ulaw world
++#CFLAGS+=-DCAPI_ULAW
++
++# very experimental echo squelching
++CFLAGS+=-DCAPI_ES
++
++#gains
++CFLAGS+=-DCAPI_GAIN
++
++# what do to with call waiting connect indications?
++# uncomment the next line for call deflection in that case
++CFLAGS+=-DCAPI_DEFLECT_ON_CIRCUITBUSY
++
++# audio sync
++CFLAGS+=-DCAPI_SYNC
++
++endif
++
+ ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/vpbapi.h),)
+   CHANNEL_LIBS+=chan_vpb.so
+   CFLAGS+=-DLINUX
+@@ -211,7 +248,7 @@
+ 	$(CC) -c $(CFLAGS) -o chan_zap.o chan_zap.c
+ 
+ chan_zap.so: chan_zap.o
+-	$(CC) $(SOLINK) -o $@ $<  $(ZAPPRI) $(ZAPR2) -ltonezone
++	$(CC) $(SOLINK) -o $@ $<  $(ZAPPRI) $(ZAPGSM) $(ZAPR2) -ltonezone
+ 
+ chan_sip.so: chan_sip.o
+ 	$(CC) $(SOLINK) -o $@ ${CYGSOLINK} chan_sip.o ${CYGSOLIB}
+@@ -227,6 +264,9 @@
+ chan_nbs.so: chan_nbs.o
+ 	$(CC) $(SOLINK) -o $@ $< -lnbs
+ 
++chan_capi.so: chan_capi.o
++	$(CC) $(SOLINK) -o $@ $< -lcapi20
++
+ chan_vpb.o: chan_vpb.c
+ 	$(CXX) -c $(CFLAGS) -o $@ chan_vpb.c
+ 
+diff -urN asterisk-1.2.19.orig/codecs/codec_ilbc.c asterisk-1.2.19/codecs/codec_ilbc.c
+--- asterisk-1.2.19.orig/codecs/codec_ilbc.c	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.19/codecs/codec_ilbc.c	2007-06-25 11:13:51.517650822 +0200
 @@ -49,7 +49,7 @@
  #include "slin_ilbc_ex.h"
  #include "ilbc_slin_ex.h"
@@ -10232,9 +10322,9 @@
  #define ILBC_MS 			30
  /* #define ILBC_MS			20 */
  
-diff -urNad asterisk-1.2.15~dfsg~/configs/capi.conf.sample asterisk-1.2.15~dfsg/configs/capi.conf.sample
---- asterisk-1.2.15~dfsg~/configs/capi.conf.sample	1970-01-01 02:00:00.000000000 +0200
-+++ asterisk-1.2.15~dfsg/configs/capi.conf.sample	2007-02-11 06:04:59.000000000 +0200
+diff -urN asterisk-1.2.19.orig/configs/capi.conf.sample asterisk-1.2.19/configs/capi.conf.sample
+--- asterisk-1.2.19.orig/configs/capi.conf.sample	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.19/configs/capi.conf.sample	2007-06-25 11:13:51.517650822 +0200
 @@ -0,0 +1,44 @@
 +;
 +; CAPI config
@@ -10280,9 +10370,9 @@
 +;msn=55512
 +;controller=2
 +;devices => 30
-diff -urNad asterisk-1.2.15~dfsg~/configs/esel.conf.sample asterisk-1.2.15~dfsg/configs/esel.conf.sample
---- asterisk-1.2.15~dfsg~/configs/esel.conf.sample	1970-01-01 02:00:00.000000000 +0200
-+++ asterisk-1.2.15~dfsg/configs/esel.conf.sample	2007-02-11 06:04:59.000000000 +0200
+diff -urN asterisk-1.2.19.orig/configs/esel.conf.sample asterisk-1.2.19/configs/esel.conf.sample
+--- asterisk-1.2.19.orig/configs/esel.conf.sample	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.19/configs/esel.conf.sample	2007-06-25 11:13:51.517650822 +0200
 @@ -0,0 +1,12 @@
 +;
 +; Configuration file for res_esel
@@ -10296,9 +10386,9 @@
 +
 +; export the extension snom in context phones to DS/100 on asterisk-2
 +;export => snom at phones,100
-diff -urNad asterisk-1.2.15~dfsg~/configs/modules.conf.sample asterisk-1.2.15~dfsg/configs/modules.conf.sample
---- asterisk-1.2.15~dfsg~/configs/modules.conf.sample	2005-11-29 20:24:39.000000000 +0200
-+++ asterisk-1.2.15~dfsg/configs/modules.conf.sample	2007-02-11 06:04:59.000000000 +0200
+diff -urN asterisk-1.2.19.orig/configs/modules.conf.sample asterisk-1.2.19/configs/modules.conf.sample
+--- asterisk-1.2.19.orig/configs/modules.conf.sample	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.19/configs/modules.conf.sample	2007-06-25 11:13:51.537655547 +0200
 @@ -46,8 +46,12 @@
  ;
  noload => chan_alsa.so
@@ -10312,9 +10402,30 @@
  ;
  [global]
 +chan_capi.so=yes
-diff -urNad asterisk-1.2.15~dfsg~/configs/watchdog.conf.sample asterisk-1.2.15~dfsg/configs/watchdog.conf.sample
---- asterisk-1.2.15~dfsg~/configs/watchdog.conf.sample	1970-01-01 02:00:00.000000000 +0200
-+++ asterisk-1.2.15~dfsg/configs/watchdog.conf.sample	2007-02-11 06:04:59.000000000 +0200
+diff -urN asterisk-1.2.19.orig/configs/sip.conf.sample asterisk-1.2.19/configs/sip.conf.sample
+--- asterisk-1.2.19.orig/configs/sip.conf.sample	2006-11-30 18:55:23.000000000 +0100
++++ asterisk-1.2.19/configs/sip.conf.sample	2007-06-25 11:13:51.537655547 +0200
+@@ -329,7 +329,16 @@
+ ;call-limit=5				; permit only 5 simultaneous outgoing calls to this peer
+ ;outboundproxy=proxy.provider.domain	; send outbound signaling to this proxy, not directly to the peer
+ ;port=80				; The port number we want to connect to on the remote side
+-
++;nationalprefix=0
++;internationalprefix=00
++;countrycode=49
++;areacode=30
++;dialplan=international			; convert 123456 to 004930123456
++;dialplan=national			; convert 123456 to 030123456
++;dialplan=local				; do not change the dialed number, default behaviour.
++;prefix=666				
++;rtpip=192.168.1.1			; if RTP should go to asterisk you can configure the
++					; used IP address here (for multihomed machines)
+ ;------------------------------------------------------------------------------
+ ; Definitions of locally connected SIP phones
+ ;
+diff -urN asterisk-1.2.19.orig/configs/watchdog.conf.sample asterisk-1.2.19/configs/watchdog.conf.sample
+--- asterisk-1.2.19.orig/configs/watchdog.conf.sample	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.19/configs/watchdog.conf.sample	2007-06-25 11:13:51.537655547 +0200
 @@ -0,0 +1,22 @@
 +;
 +; Configuration file for res_watchdog
@@ -10338,9 +10449,9 @@
 +;device = /dev/watchdog
 +;interval = 100
 +
-diff -urNad asterisk-1.2.15~dfsg~/configs/zapata.conf.sample asterisk-1.2.15~dfsg/configs/zapata.conf.sample
---- asterisk-1.2.15~dfsg~/configs/zapata.conf.sample	2006-09-18 18:05:56.000000000 +0300
-+++ asterisk-1.2.15~dfsg/configs/zapata.conf.sample	2007-02-11 06:04:59.000000000 +0200
+diff -urN asterisk-1.2.19.orig/configs/zapata.conf.sample asterisk-1.2.19/configs/zapata.conf.sample
+--- asterisk-1.2.19.orig/configs/zapata.conf.sample	2006-09-18 17:05:56.000000000 +0200
++++ asterisk-1.2.19/configs/zapata.conf.sample	2007-06-25 11:13:51.537655547 +0200
 @@ -123,9 +123,20 @@
  ; 
  ; outofband:      Signal Busy/Congestion out of band with RELEASE/DISCONNECT
@@ -10362,9 +10473,9 @@
  ; If you need to override the existing channels selection routine and force all
  ; PRI channels to be marked as exclusively selected, set this to yes.
  ; priexclusive = yes
-diff -urNad asterisk-1.2.15~dfsg~/db.c asterisk-1.2.15~dfsg/db.c
---- asterisk-1.2.15~dfsg~/db.c	2006-01-09 20:09:53.000000000 +0200
-+++ asterisk-1.2.15~dfsg/db.c	2007-02-11 06:04:59.000000000 +0200
+diff -urN asterisk-1.2.19.orig/db.c asterisk-1.2.19/db.c
+--- asterisk-1.2.19.orig/db.c	2006-01-09 19:09:53.000000000 +0100
++++ asterisk-1.2.19/db.c	2007-06-25 11:13:51.537655547 +0200
 @@ -516,11 +516,18 @@
  struct ast_cli_entry cli_database_deltree =
  { { "database", "deltree", NULL }, database_deltree, "Removes database keytree/values", database_deltree_usage };
@@ -10458,9 +10569,9 @@
 +	ast_manager_register("DBdel", EVENT_FLAG_SYSTEM, manager_dbdel, mandescr_dbdel);
  	return 0;
  }
-diff -urNad asterisk-1.2.15~dfsg~/devicestate.c asterisk-1.2.15~dfsg/devicestate.c
---- asterisk-1.2.15~dfsg~/devicestate.c	2006-02-10 22:38:59.000000000 +0200
-+++ asterisk-1.2.15~dfsg/devicestate.c	2007-02-11 06:04:59.000000000 +0200
+diff -urN asterisk-1.2.19.orig/devicestate.c asterisk-1.2.19/devicestate.c
+--- asterisk-1.2.19.orig/devicestate.c	2007-06-06 14:18:36.000000000 +0200
++++ asterisk-1.2.19/devicestate.c	2007-06-25 11:13:51.541656492 +0200
 @@ -62,6 +62,8 @@
  
  struct state_change {
@@ -10494,9 +10605,9 @@
 -static int __ast_device_state_changed_literal(char *buf)
 +static int __ast_device_state_changed_literal(char *buf, char *cid_num, char *cid_name)
  {
- 	char *device, *tmp;
+ 	char *device;
  	struct state_change *change = NULL;
-@@ -209,10 +211,16 @@
+@@ -212,10 +214,16 @@
  	if (!change) {
  		/* we could not allocate a change struct, or */
  		/* there is no background thread, so process the change now */
@@ -10514,7 +10625,7 @@
  		AST_LIST_LOCK(&state_changes);
  		AST_LIST_INSERT_TAIL(&state_changes, change, list);
  		if (AST_LIST_FIRST(&state_changes) == change)
-@@ -224,11 +232,17 @@
+@@ -227,11 +235,17 @@
  	return 1;
  }
  
@@ -10534,7 +10645,7 @@
  }
  
  /*--- ast_device_state_changed: Accept change notification, add it to change queue */
-@@ -240,7 +254,7 @@
+@@ -243,7 +257,7 @@
  	va_start(ap, fmt);
  	vsnprintf(buf, sizeof(buf), fmt, ap);
  	va_end(ap);
@@ -10543,7 +10654,7 @@
  }
  
  /*--- do_devstate_changes: Go through the dev state change queue and update changes in the dev state thread */
-@@ -255,7 +269,7 @@
+@@ -258,7 +272,7 @@
  		if (cur) {
  			/* we got an entry, so unlock the list while we process it */
  			AST_LIST_UNLOCK(&state_changes);
@@ -10552,9 +10663,9 @@
  			free(cur);
  			AST_LIST_LOCK(&state_changes);
  		} else {
-diff -urNad asterisk-1.2.15~dfsg~/doc/README.asterisk.conf asterisk-1.2.15~dfsg/doc/README.asterisk.conf
---- asterisk-1.2.15~dfsg~/doc/README.asterisk.conf	2005-11-29 20:24:39.000000000 +0200
-+++ asterisk-1.2.15~dfsg/doc/README.asterisk.conf	2007-02-11 06:04:59.000000000 +0200
+diff -urN asterisk-1.2.19.orig/doc/README.asterisk.conf asterisk-1.2.19/doc/README.asterisk.conf
+--- asterisk-1.2.19.orig/doc/README.asterisk.conf	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.19/doc/README.asterisk.conf	2007-06-25 11:13:51.541656492 +0200
 @@ -62,6 +62,7 @@
  maxcalls = 255					; The maximum number of concurrent calls you want to allow 
  execincludes = yes | no 			; Allow #exec entries in configuration files
@@ -10563,9 +10674,32 @@
  
  [files]
  ; Changing the following lines may compromise your security
-diff -urNad asterisk-1.2.15~dfsg~/include/asterisk/agi.h asterisk-1.2.15~dfsg/include/asterisk/agi.h
---- asterisk-1.2.15~dfsg~/include/asterisk/agi.h	2005-11-29 20:24:39.000000000 +0200
-+++ asterisk-1.2.15~dfsg/include/asterisk/agi.h	2007-02-11 06:04:59.000000000 +0200
+diff -urN asterisk-1.2.19.orig/HARDWARE asterisk-1.2.19/HARDWARE
+--- asterisk-1.2.19.orig/HARDWARE	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.19/HARDWARE	2007-06-25 11:13:51.541656492 +0200
+@@ -37,6 +37,19 @@
+    * Wildcard TE410P - Quad T1/E1 switchable interface.  Supports PRI and 
+      RBS signalling, as well as PPP, FR, and HDLC data modes.
+ 
++-- Junghanns.NET (Primary author of BRIstuff)
++	http://www.junghanns.net
++	
++    * quadBRI PCI ISDN - 4port BRI ISDN interface, supports NT and TE mode
++    
++    * octoBRI PCI ISDN - 8port BRI ISDN interface, supports NT and TE mode
++
++    * singleE1 PCI ISDN - Single E1 interface
++
++    * doubleE1 PCI ISDN - Double E1 interface
++    
++    * uno/duo/quad GSM PCI - 1/2/4 channel GSM interface cards
++
+ Non-zaptel compatible hardware
+ ==============================
+ 
+diff -urN asterisk-1.2.19.orig/include/asterisk/agi.h asterisk-1.2.19/include/asterisk/agi.h
+--- asterisk-1.2.19.orig/include/asterisk/agi.h	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.19/include/asterisk/agi.h	2007-06-25 11:13:51.541656492 +0200
 @@ -29,7 +29,8 @@
  
  typedef struct agi_state {
@@ -10576,9 +10710,43 @@
  	int ctrl;	/* FD for input control */
  } AGI;
  
-diff -urNad asterisk-1.2.15~dfsg~/include/asterisk/chan_capi.h asterisk-1.2.15~dfsg/include/asterisk/chan_capi.h
---- asterisk-1.2.15~dfsg~/include/asterisk/chan_capi.h	1970-01-01 02:00:00.000000000 +0200
-+++ asterisk-1.2.15~dfsg/include/asterisk/chan_capi.h	2007-02-11 06:04:59.000000000 +0200
+diff -urN asterisk-1.2.19.orig/include/asterisk/chan_capi_app.h asterisk-1.2.19/include/asterisk/chan_capi_app.h
+--- asterisk-1.2.19.orig/include/asterisk/chan_capi_app.h	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.19/include/asterisk/chan_capi_app.h	2007-06-25 11:13:51.541656492 +0200
+@@ -0,0 +1,30 @@
++/*
++ * (CAPI*)
++ *
++ * An implementation of Common ISDN API 2.0 for Asterisk
++ *
++ * include file for helper applications
++ *
++ * Copyright (C) 2002, 2003, 2004, Junghanns.NET GmbH
++ *
++ * Klaus-Peter Junghanns <kapejod at ns1.jnetdns.de>
++ *
++ * This program is free software and may be modified and 
++ * distributed under the terms of the GNU Public License.
++ */
++
++#ifndef _ASTERISK_CAPI_IF_H
++#define _ASTERISK_CAPI_IF_H
++ 
++// exported symbols from chan_capi
++
++// important things we need
++extern unsigned ast_capi_ApplID;
++extern unsigned ast_capi_MessageNumber;
++extern int capidebug;
++
++extern int capi_call(struct ast_channel *c, char *idest, int timeout);
++extern int capi_detect_dtmf(struct ast_channel *c, int flag);
++extern MESSAGE_EXCHANGE_ERROR _capi_put_cmsg(_cmsg *CMSG);
++
++#endif
+diff -urN asterisk-1.2.19.orig/include/asterisk/chan_capi.h asterisk-1.2.19/include/asterisk/chan_capi.h
+--- asterisk-1.2.19.orig/include/asterisk/chan_capi.h	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.19/include/asterisk/chan_capi.h	2007-06-25 11:13:51.541656492 +0200
 @@ -0,0 +1,276 @@
 +/*
 + * (CAPI*)
@@ -10856,43 +11024,9 @@
 +#define CAPI_ETSI_NPLAN_INTERNAT	0x10
 +
 +#endif
-diff -urNad asterisk-1.2.15~dfsg~/include/asterisk/chan_capi_app.h asterisk-1.2.15~dfsg/include/asterisk/chan_capi_app.h
---- asterisk-1.2.15~dfsg~/include/asterisk/chan_capi_app.h	1970-01-01 02:00:00.000000000 +0200
-+++ asterisk-1.2.15~dfsg/include/asterisk/chan_capi_app.h	2007-02-11 06:04:59.000000000 +0200
-@@ -0,0 +1,30 @@
-+/*
-+ * (CAPI*)
-+ *
-+ * An implementation of Common ISDN API 2.0 for Asterisk
-+ *
-+ * include file for helper applications
-+ *
-+ * Copyright (C) 2002, 2003, 2004, Junghanns.NET GmbH
-+ *
-+ * Klaus-Peter Junghanns <kapejod at ns1.jnetdns.de>
-+ *
-+ * This program is free software and may be modified and 
-+ * distributed under the terms of the GNU Public License.
-+ */
-+
-+#ifndef _ASTERISK_CAPI_IF_H
-+#define _ASTERISK_CAPI_IF_H
-+ 
-+// exported symbols from chan_capi
-+
-+// important things we need
-+extern unsigned ast_capi_ApplID;
-+extern unsigned ast_capi_MessageNumber;
-+extern int capidebug;
-+
-+extern int capi_call(struct ast_channel *c, char *idest, int timeout);
-+extern int capi_detect_dtmf(struct ast_channel *c, int flag);
-+extern MESSAGE_EXCHANGE_ERROR _capi_put_cmsg(_cmsg *CMSG);
-+
-+#endif
-diff -urNad asterisk-1.2.15~dfsg~/include/asterisk/channel.h asterisk-1.2.15~dfsg/include/asterisk/channel.h
---- asterisk-1.2.15~dfsg~/include/asterisk/channel.h	2006-11-07 20:22:01.000000000 +0200
-+++ asterisk-1.2.15~dfsg/include/asterisk/channel.h	2007-02-11 06:04:59.000000000 +0200
+diff -urN asterisk-1.2.19.orig/include/asterisk/channel.h asterisk-1.2.19/include/asterisk/channel.h
+--- asterisk-1.2.19.orig/include/asterisk/channel.h	2006-11-07 19:22:01.000000000 +0100
++++ asterisk-1.2.19/include/asterisk/channel.h	2007-06-25 11:13:51.545657437 +0200
 @@ -86,6 +86,9 @@
  #ifndef _ASTERISK_CHANNEL_H
  #define _ASTERISK_CHANNEL_H
@@ -10961,10 +11095,10 @@
   */
 -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 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);
++
++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);
  
 -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);
-+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);
-+
 +/*! \brief "Requests" a channel for sending a message
 + * \param type type of channel to request
 + * \param data data to pass to the channel requester
@@ -11013,9 +11147,9 @@
  
  /*! Gives the string form of a given cause code */
  /*! 
-diff -urNad asterisk-1.2.15~dfsg~/include/asterisk/devicestate.h asterisk-1.2.15~dfsg/include/asterisk/devicestate.h
---- asterisk-1.2.15~dfsg~/include/asterisk/devicestate.h	2005-11-29 20:24:39.000000000 +0200
-+++ asterisk-1.2.15~dfsg/include/asterisk/devicestate.h	2007-02-11 06:05:00.000000000 +0200
+diff -urN asterisk-1.2.19.orig/include/asterisk/devicestate.h asterisk-1.2.19/include/asterisk/devicestate.h
+--- asterisk-1.2.19.orig/include/asterisk/devicestate.h	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.19/include/asterisk/devicestate.h	2007-06-25 11:13:51.545657437 +0200
 @@ -42,7 +42,7 @@
  /*! Device is ringing */
  #define AST_DEVICE_RINGING	6
@@ -11034,9 +11168,9 @@
  
  /*! \brief Registers a device state change callback 
   * \param callback Callback
-diff -urNad asterisk-1.2.15~dfsg~/include/asterisk/features.h asterisk-1.2.15~dfsg/include/asterisk/features.h
---- asterisk-1.2.15~dfsg~/include/asterisk/features.h	2005-11-29 20:24:39.000000000 +0200
-+++ asterisk-1.2.15~dfsg/include/asterisk/features.h	2007-02-11 06:05:00.000000000 +0200
+diff -urN asterisk-1.2.19.orig/include/asterisk/features.h asterisk-1.2.19/include/asterisk/features.h
+--- asterisk-1.2.19.orig/include/asterisk/features.h	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.19/include/asterisk/features.h	2007-06-25 11:13:51.545657437 +0200
 @@ -45,6 +45,8 @@
  };
  
@@ -11079,9 +11213,9 @@
 +extern struct ast_call_feature *ast_find_builtin_feature(char *name);
 +
  #endif /* _AST_FEATURES_H */
-diff -urNad asterisk-1.2.15~dfsg~/include/asterisk/manager.h asterisk-1.2.15~dfsg/include/asterisk/manager.h
---- asterisk-1.2.15~dfsg~/include/asterisk/manager.h	2006-02-11 20:15:00.000000000 +0200
-+++ asterisk-1.2.15~dfsg/include/asterisk/manager.h	2007-02-11 06:05:00.000000000 +0200
+diff -urN asterisk-1.2.19.orig/include/asterisk/manager.h asterisk-1.2.19/include/asterisk/manager.h
+--- asterisk-1.2.19.orig/include/asterisk/manager.h	2006-02-11 19:15:00.000000000 +0100
++++ asterisk-1.2.19/include/asterisk/manager.h	2007-06-25 11:13:51.545657437 +0200
 @@ -54,6 +54,7 @@
  #define EVENT_FLAG_COMMAND		(1 << 4) /* Ability to read/set commands */
  #define EVENT_FLAG_AGENT		(1 << 5) /* Ability to read/set agent info */
@@ -11090,9 +11224,9 @@
  
  /* Export manager structures */
  #define AST_MAX_MANHEADERS 80
-diff -urNad asterisk-1.2.15~dfsg~/include/asterisk/monitor.h asterisk-1.2.15~dfsg/include/asterisk/monitor.h
---- asterisk-1.2.15~dfsg~/include/asterisk/monitor.h	2005-11-29 20:24:39.000000000 +0200
-+++ asterisk-1.2.15~dfsg/include/asterisk/monitor.h	2007-02-11 06:05:00.000000000 +0200
+diff -urN asterisk-1.2.19.orig/include/asterisk/monitor.h asterisk-1.2.19/include/asterisk/monitor.h
+--- asterisk-1.2.19.orig/include/asterisk/monitor.h	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.19/include/asterisk/monitor.h	2007-06-25 11:13:51.545657437 +0200
 @@ -35,6 +35,8 @@
  	char write_filename[FILENAME_MAX];
  	char filename_base[FILENAME_MAX];
@@ -11111,9 +11245,9 @@
  
  /* Stop monitoring a channel */
  int ast_monitor_stop(struct ast_channel *chan, int need_lock);
-diff -urNad asterisk-1.2.15~dfsg~/include/asterisk/pbx.h asterisk-1.2.15~dfsg/include/asterisk/pbx.h
---- asterisk-1.2.15~dfsg~/include/asterisk/pbx.h	2006-03-29 21:11:18.000000000 +0200
-+++ asterisk-1.2.15~dfsg/include/asterisk/pbx.h	2007-02-11 06:05:00.000000000 +0200
+diff -urN asterisk-1.2.19.orig/include/asterisk/pbx.h asterisk-1.2.19/include/asterisk/pbx.h
+--- asterisk-1.2.19.orig/include/asterisk/pbx.h	2006-03-29 21:11:18.000000000 +0200
++++ asterisk-1.2.19/include/asterisk/pbx.h	2007-06-25 11:13:51.545657437 +0200
 @@ -57,7 +57,7 @@
  	AST_EXTENSION_BUSY = 1 << 1,
  	/*! All devices UNAVAILABLE/UNREGISTERED */
@@ -11164,9 +11298,9 @@
  
  #if defined(__cplusplus) || defined(c_plusplus)
  }
-diff -urNad asterisk-1.2.15~dfsg~/include/asterisk/xlaw.h asterisk-1.2.15~dfsg/include/asterisk/xlaw.h
---- asterisk-1.2.15~dfsg~/include/asterisk/xlaw.h	1970-01-01 02:00:00.000000000 +0200
-+++ asterisk-1.2.15~dfsg/include/asterisk/xlaw.h	2007-02-11 06:05:00.000000000 +0200
+diff -urN asterisk-1.2.19.orig/include/asterisk/xlaw.h asterisk-1.2.19/include/asterisk/xlaw.h
+--- asterisk-1.2.19.orig/include/asterisk/xlaw.h	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.19/include/asterisk/xlaw.h	2007-06-25 11:13:51.549658382 +0200
 @@ -0,0 +1,1665 @@
 +#ifndef _ASTERISK_XLAW_H
 +#define _ASTERISK_XLAW_H
@@ -12833,10 +12967,10 @@
 +#endif // CAPI_ULAW
 +#endif
 +
-diff -urNad asterisk-1.2.15~dfsg~/include/asterisk.h asterisk-1.2.15~dfsg/include/asterisk.h
---- asterisk-1.2.15~dfsg~/include/asterisk.h	2007-02-11 06:04:48.000000000 +0200
-+++ asterisk-1.2.15~dfsg/include/asterisk.h	2007-02-11 06:05:00.000000000 +0200
-@@ -36,6 +36,7 @@
+diff -urN asterisk-1.2.19.orig/include/asterisk.h asterisk-1.2.19/include/asterisk.h
+--- asterisk-1.2.19.orig/include/asterisk.h	2007-04-09 04:49:06.000000000 +0200
++++ asterisk-1.2.19/include/asterisk.h	2007-06-25 11:13:51.549658382 +0200
+@@ -38,6 +38,7 @@
  extern char ast_config_AST_PID[AST_CONFIG_MAX_PATH];
  extern char ast_config_AST_SOCKET[AST_CONFIG_MAX_PATH];
  extern char ast_config_AST_RUN_DIR[AST_CONFIG_MAX_PATH];
@@ -12844,9 +12978,37 @@
  extern char ast_config_AST_CTL_PERMISSIONS[AST_CONFIG_MAX_PATH];
  extern char ast_config_AST_CTL_OWNER[AST_CONFIG_MAX_PATH];
  extern char ast_config_AST_CTL_GROUP[AST_CONFIG_MAX_PATH];
-diff -urNad asterisk-1.2.15~dfsg~/manager.c asterisk-1.2.15~dfsg/manager.c
---- asterisk-1.2.15~dfsg~/manager.c	2007-02-06 08:58:28.000000000 +0200
-+++ asterisk-1.2.15~dfsg/manager.c	2007-02-11 06:05:00.000000000 +0200
+diff -urN asterisk-1.2.19.orig/LICENSE asterisk-1.2.19/LICENSE
+--- asterisk-1.2.19.orig/LICENSE	2006-10-17 19:22:01.000000000 +0200
++++ asterisk-1.2.19/LICENSE	2007-06-25 11:13:51.549658382 +0200
+@@ -1,7 +1,7 @@
+-Asterisk is distributed under the GNU General Public License version 2
+-and is also available under alternative licenses negotiated directly
+-with Digium, Inc. If you obtained Asterisk under the GPL, then the GPL
+-applies to all loadable Asterisk modules used on your system as well,
++BRIstuffed Asterisk is distributed under the GNU General Public License version 2
++and is not available under any alternative licenses.
++If you obtained BRIstuffed Asterisk under the GPL, then the GPL
++applies to all loadable BRIstuffed Asterisk modules used on your system as well,
+ except as defined below. The GPL (version 2) is included in this
+ source tree in the file COPYING.
+ 
+diff -urN asterisk-1.2.19.orig/Makefile asterisk-1.2.19/Makefile
+--- asterisk-1.2.19.orig/Makefile	2007-05-11 18:31:03.000000000 +0200
++++ asterisk-1.2.19/Makefile	2007-06-25 11:13:51.549658382 +0200
+@@ -781,6 +781,9 @@
+ 		echo ";astctlowner = root" ; \
+ 		echo ";astctlgroup = apache" ; \
+ 		echo ";astctl = asterisk.ctl" ; \
++		echo "[options]" ; \
++		echo "uniquename = `hostname`" ;\
++		echo "silence_suppression = yes" ;\
+ 		) > $(DESTDIR)$(ASTCONFPATH) ; \
+ 	else \
+ 		echo "Skipping asterisk.conf creation"; \
+diff -urN asterisk-1.2.19.orig/manager.c asterisk-1.2.19/manager.c
+--- asterisk-1.2.19.orig/manager.c	2007-04-24 23:33:59.000000000 +0200
++++ asterisk-1.2.19/manager.c	2007-06-25 11:13:51.553659327 +0200
 @@ -11,6 +11,9 @@
   * the project provides a web site, mailing lists and IRC
   * channels for your use.
@@ -12882,7 +13044,7 @@
  	{ -1, "all" },
  	{ 0, "none" },
  };
-@@ -657,11 +664,17 @@
+@@ -658,11 +665,17 @@
  {
  	struct ast_channel *c = NULL;
  	char *name = astman_get_header(m, "Channel");
@@ -12903,7 +13065,7 @@
  	if (!c) {
  		astman_send_error(s, m, "No such channel");
  		return 0;
-@@ -672,6 +685,49 @@
+@@ -673,6 +686,49 @@
  	return 0;
  }
  
@@ -12953,7 +13115,7 @@
  static char mandescr_setvar[] = 
  "Description: Set a global or local channel variable.\n"
  "Variables: (Names marked with * are required)\n"
-@@ -760,6 +816,7 @@
+@@ -761,6 +817,7 @@
  }
  
  
@@ -12961,7 +13123,7 @@
  /*! \brief  action_status: Manager "status" command to show channels */
  /* Needs documentation... */
  static int action_status(struct mansession *s, struct message *m)
-@@ -866,32 +923,50 @@
+@@ -867,19 +924,29 @@
  	char *exten = astman_get_header(m, "Exten");
  	char *context = astman_get_header(m, "Context");
  	char *priority = astman_get_header(m, "Priority");
@@ -12994,31 +13156,47 @@
  	if (!chan) {
  		char buf[BUFSIZ];
  		snprintf(buf, sizeof(buf), "Channel does not exist: %s", name);
- 		astman_send_error(s, m, buf);
- 		return 0;
+@@ -901,19 +968,27 @@
  	}
--	if (!ast_strlen_zero(name2))
-+ 	if (!ast_strlen_zero(uniqueid2)) {
-+ 		chan2 = ast_get_channel_by_uniqueid_locked(uniqueid2);
-+ 		if (!ast_strlen_zero(priority2) && (sscanf(priority2, "%d", &pi2) != 1)) {
-+ 		    astman_send_error(s, m, "Invalid priority2\n");
-+ 		    return 0;
-+ 		}
-+ 	} else {
-+	    if (!ast_strlen_zero(name2))
- 		chan2 = ast_get_channel_by_name_locked(name2);
-+	}
  	res = ast_async_goto(chan, context, exten, pi);
  	if (!res) {
 -		if (!ast_strlen_zero(name2)) {
-+ 		if ((!ast_strlen_zero(name2)) || (!ast_strlen_zero(uniqueid2))){
- 			if (chan2)
+-			if (chan2)
 -				res = ast_async_goto(chan2, context, exten, pi);
-+ 				res = ast_async_goto(chan2, context2, exten2, pi2);
- 			else
- 				res = -1;
- 			if (!res)
-@@ -937,15 +1012,15 @@
+-			else
+-				res = -1;
+-			if (!res)
+-				astman_send_ack(s, m, "Dual Redirect successful");
+-			else
+-				astman_send_error(s, m, "Secondary redirect failed");
+-		} else
++		if (!ast_strlen_zero(uniqueid2)) {
++		    chan2 = ast_get_channel_by_uniqueid_locked(uniqueid2);
++ 		    if (!ast_strlen_zero(priority2) && (sscanf(priority2, "%d", &pi2) != 1)) {
++ 			astman_send_error(s, m, "Invalid priority2\n");
++ 		        return 0;
++ 		    }
++ 		} else if (!ast_strlen_zero(name2)) {
++  			chan2 = ast_get_channel_by_name_locked(name2);
++		} else {
+ 			astman_send_ack(s, m, "Redirect successful");
+-	} else
+-		astman_send_error(s, m, "Redirect failed");
++		}
++		if (chan2) {
++		    res = ast_async_goto(chan2, context2, exten2, pi2);
++		    if (!res)
++			astman_send_ack(s, m, "Dual Redirect successful");
++		    else
++			astman_send_error(s, m, "Secondary redirect failed");
++		}
++	} else {
++	    astman_send_error(s, m, "Redirect failed");
++	}
+ 	if (chan)
+ 		ast_mutex_unlock(&chan->lock);
+ 	if (chan2)
+@@ -949,15 +1024,15 @@
  	struct ast_channel *chan = NULL;
  
  	if (!ast_strlen_zero(in->app)) {
@@ -13038,7 +13216,7 @@
  	}   
  	if (!res)
  		manager_event(EVENT_FLAG_CALL,
-@@ -956,7 +1031,7 @@
+@@ -968,7 +1043,7 @@
  			"Exten: %s\r\n"
  			"Reason: %d\r\n"
  			"Uniqueid: %s\r\n",
@@ -13047,7 +13225,7 @@
  	else
  		manager_event(EVENT_FLAG_CALL,
  			"OriginateFailure",
-@@ -966,7 +1041,7 @@
+@@ -978,7 +1053,7 @@
  			"Exten: %s\r\n"
  			"Reason: %d\r\n"
  			"Uniqueid: %s\r\n",
@@ -13056,7 +13234,7 @@
  
  	/* Locked by ast_pbx_outgoing_exten or ast_pbx_outgoing_app */
  	if (chan)
-@@ -999,6 +1074,7 @@
+@@ -1011,6 +1086,7 @@
  	char *priority = astman_get_header(m, "Priority");
  	char *timeout = astman_get_header(m, "Timeout");
  	char *callerid = astman_get_header(m, "CallerID");
@@ -13064,7 +13242,7 @@
  	char *account = astman_get_header(m, "Account");
  	char *app = astman_get_header(m, "Application");
  	char *appdata = astman_get_header(m, "Data");
-@@ -1007,12 +1083,15 @@
+@@ -1019,12 +1095,15 @@
  	struct ast_variable *vars = astman_get_variables(m);
  	char *tech, *data;
  	char *l=NULL, *n=NULL;
@@ -13080,7 +13258,7 @@
  	
  	pthread_t th;
  	pthread_attr_t attr;
-@@ -1028,6 +1107,10 @@
+@@ -1040,6 +1119,10 @@
  		astman_send_error(s, m, "Invalid timeout\n");
  		return 0;
  	}
@@ -13091,7 +13269,7 @@
  	ast_copy_string(tmp, name, sizeof(tmp));
  	tech = tmp;
  	data = strchr(tmp, '/');
-@@ -1048,6 +1131,7 @@
+@@ -1060,6 +1143,7 @@
  		if (ast_strlen_zero(l))
  			l = NULL;
  	}
@@ -13099,7 +13277,7 @@
  	if (ast_true(async)) {
  		struct fast_originate_helper *fast = malloc(sizeof(struct fast_originate_helper));
  		if (!fast) {
-@@ -1068,8 +1152,10 @@
+@@ -1080,8 +1164,10 @@
  			ast_copy_string(fast->context, context, sizeof(fast->context));
  			ast_copy_string(fast->exten, exten, sizeof(fast->exten));
  			ast_copy_string(fast->account, account, sizeof(fast->account));
@@ -13110,7 +13288,7 @@
  			pthread_attr_init(&attr);
  			pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
  			if (ast_pthread_create(&th, &attr, fast_originate, fast)) {
-@@ -1080,19 +1166,28 @@
+@@ -1092,19 +1178,28 @@
  			pthread_attr_destroy(&attr);
  		}
  	} else if (!ast_strlen_zero(app)) {
@@ -13144,7 +13322,7 @@
  	return 0;
  }
  
-@@ -1566,10 +1661,12 @@
+@@ -1578,10 +1673,12 @@
  	return 0;
  }
  
@@ -13159,7 +13337,7 @@
  	return 0;
  }
  
-@@ -1654,6 +1751,7 @@
+@@ -1666,6 +1763,7 @@
  		ast_manager_register2("Events", 0, action_events, "Control Event Flow", mandescr_events);
  		ast_manager_register2("Logoff", 0, action_logoff, "Logoff Manager", mandescr_logoff);
  		ast_manager_register2("Hangup", EVENT_FLAG_CALL, action_hangup, "Hangup Channel", mandescr_hangup);
@@ -13167,9 +13345,9 @@
  		ast_manager_register("Status", EVENT_FLAG_CALL, action_status, "Lists channel status" );
  		ast_manager_register2("Setvar", EVENT_FLAG_CALL, action_setvar, "Set Channel Variable", mandescr_setvar );
  		ast_manager_register2("Getvar", EVENT_FLAG_CALL, action_getvar, "Gets a Channel Variable", mandescr_getvar );
-diff -urNad asterisk-1.2.15~dfsg~/pbx/pbx_spool.c asterisk-1.2.15~dfsg/pbx/pbx_spool.c
---- asterisk-1.2.15~dfsg~/pbx/pbx_spool.c	2007-01-31 23:25:11.000000000 +0200
-+++ asterisk-1.2.15~dfsg/pbx/pbx_spool.c	2007-02-11 06:05:00.000000000 +0200
+diff -urN asterisk-1.2.19.orig/pbx/pbx_spool.c asterisk-1.2.19/pbx/pbx_spool.c
+--- asterisk-1.2.19.orig/pbx/pbx_spool.c	2007-01-31 22:25:11.000000000 +0100
++++ asterisk-1.2.19/pbx/pbx_spool.c	2007-06-25 11:13:51.553659327 +0200
 @@ -77,6 +77,10 @@
  	char app[256];
  	char data[256];
@@ -13241,10 +13419,10 @@
  	}
  	free_outgoing(o);
  	return NULL;
-diff -urNad asterisk-1.2.15~dfsg~/pbx.c asterisk-1.2.15~dfsg/pbx.c
---- asterisk-1.2.15~dfsg~/pbx.c	2007-02-01 21:13:53.000000000 +0200
-+++ asterisk-1.2.15~dfsg/pbx.c	2007-02-11 06:05:00.000000000 +0200
-@@ -354,7 +354,8 @@
+diff -urN asterisk-1.2.19.orig/pbx.c asterisk-1.2.19/pbx.c
+--- asterisk-1.2.19.orig/pbx.c	2007-05-02 22:10:32.000000000 +0200
++++ asterisk-1.2.19/pbx.c	2007-06-25 11:13:51.557660272 +0200
+@@ -374,7 +374,8 @@
  	
  	{ "Hangup", pbx_builtin_hangup,
  	"Hang up the calling channel",
@@ -13254,7 +13432,7 @@
  	},
  
  	{ "NoOp", pbx_builtin_noop,
-@@ -1883,7 +1884,7 @@
+@@ -1903,7 +1904,7 @@
  	return ast_extension_state2(e);    		/* Check all devices in the hint */
  }
  
@@ -13263,7 +13441,7 @@
  {
  	struct ast_hint *hint;
  	struct ast_state_cb *cblist;
-@@ -1911,11 +1912,11 @@
+@@ -1931,11 +1932,11 @@
  			
  			/* For general callbacks */
  			for (cblist = statecbs; cblist; cblist = cblist->next)
@@ -13277,7 +13455,7 @@
  			
  			hint->laststate = state;
  			break;
-@@ -2156,7 +2157,7 @@
+@@ -2176,7 +2177,7 @@
  				/* Notify with -1 and remove all callbacks */
  				cbprev = cblist;	    
  				cblist = cblist->next;
@@ -13286,7 +13464,7 @@
  				free(cbprev);
  	    		}
  	    		list->callbacks = NULL;
-@@ -3779,7 +3780,7 @@
+@@ -3799,7 +3800,7 @@
  			while (thiscb) {
  				prevcb = thiscb;	    
  				thiscb = thiscb->next;
@@ -13295,7 +13473,7 @@
  				free(prevcb);
  	    		}
  		} else {
-@@ -4984,7 +4985,7 @@
+@@ -5004,7 +5005,7 @@
  	return 0;  /* success */
  }
  
@@ -13304,7 +13482,7 @@
  {
  	struct ast_channel *chan;
  	struct async_stat *as;
-@@ -4994,7 +4995,7 @@
+@@ -5014,7 +5015,7 @@
  
  	if (sync) {
  		LOAD_OH(oh);
@@ -13313,7 +13491,7 @@
  		if (channel) {
  			*channel = chan;
  			if (chan)
-@@ -5096,7 +5097,7 @@
+@@ -5116,7 +5117,7 @@
  			goto outgoing_exten_cleanup;
  		}	
  		memset(as, 0, sizeof(struct async_stat));
@@ -13322,7 +13500,7 @@
  		if (channel) {
  			*channel = chan;
  			if (chan)
-@@ -5144,7 +5145,7 @@
+@@ -5164,7 +5165,7 @@
  	pthread_t t;
  };
  
@@ -13331,7 +13509,7 @@
  {
  	struct app_tmp *tmp = data;
  	struct ast_app *app;
-@@ -5160,7 +5161,7 @@
+@@ -5180,7 +5181,7 @@
  	return NULL;
  }
  
@@ -13340,7 +13518,7 @@
  {
  	struct ast_channel *chan;
  	struct async_stat *as;
-@@ -5180,7 +5181,7 @@
+@@ -5200,7 +5201,7 @@
  		goto outgoing_app_cleanup;	
  	}
  	if (sync) {
@@ -13349,7 +13527,7 @@
  		if (chan) {
  			if (chan->cdr) { /* check if the channel already has a cdr record, if not give it one */
  				ast_log(LOG_WARNING, "%s already has a call record??\n", chan->name);
-@@ -5268,7 +5269,8 @@
+@@ -5288,7 +5289,8 @@
  			goto outgoing_app_cleanup;
  		}
  		memset(as, 0, sizeof(struct async_stat));
@@ -13359,7 +13537,7 @@
  		if (!chan) {
  			free(as);
  			res = -1;
-@@ -5559,6 +5561,9 @@
+@@ -5579,6 +5581,9 @@
   */
  static int pbx_builtin_hangup(struct ast_channel *chan, void *data)
  {
@@ -13369,7 +13547,7 @@
  	/* Just return non-zero and it will hang up */
  	if (!chan->hangupcause)
  		chan->hangupcause = AST_CAUSE_NORMAL_CLEARING;
-@@ -6213,6 +6218,9 @@
+@@ -6233,6 +6238,9 @@
  			return -1;
  		}
  	}
@@ -13379,7 +13557,7 @@
  	return res = ast_say_number(chan, atoi((char *) tmp), "", chan->language, options);
  }
  
-@@ -6220,8 +6228,12 @@
+@@ -6240,8 +6248,12 @@
  {
  	int res = 0;
  
@@ -13393,7 +13571,7 @@
  	return res;
  }
  	
-@@ -6229,8 +6241,12 @@
+@@ -6249,8 +6261,12 @@
  {
  	int res = 0;
  
@@ -13407,7 +13585,7 @@
  	return res;
  }
  	
-@@ -6238,8 +6254,12 @@
+@@ -6258,8 +6274,12 @@
  {
  	int res = 0;
  
@@ -13421,9 +13599,171 @@
  	return res;
  }
  	
-diff -urNad asterisk-1.2.15~dfsg~/res/Makefile asterisk-1.2.15~dfsg/res/Makefile
---- asterisk-1.2.15~dfsg~/res/Makefile	2005-11-29 20:24:39.000000000 +0200
-+++ asterisk-1.2.15~dfsg/res/Makefile	2007-02-11 06:05:00.000000000 +0200
+diff -urN asterisk-1.2.19.orig/README asterisk-1.2.19/README
+--- asterisk-1.2.19.orig/README	2006-03-03 09:12:33.000000000 +0100
++++ asterisk-1.2.19/README	2007-06-25 11:13:51.557660272 +0200
+@@ -4,6 +4,8 @@
+ 
+ Copyright (C) 2001-2005 Digium, Inc.
+ and other copyright holders.
++Copyright (C) 2002-2005 Junghanns.NET GmbH 
++and other copyright holders.
+ ================================================================
+ 
+ * SECURITY
+diff -urN asterisk-1.2.19.orig/README.chan_capi asterisk-1.2.19/README.chan_capi
+--- asterisk-1.2.19.orig/README.chan_capi	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.19/README.chan_capi	2007-06-25 11:13:51.557660272 +0200
+@@ -0,0 +1,146 @@
++(CAPI*) chan_capi a Common ISDN API 2.0 implementation for Asterisk
++(C) 2002, 2003, 2004, 2005 Junghanns.NET GmbH 
++Klaus-Peter Junghanns <kpj at junghanns.net>
++
++This program is free software and may be modified and distributed under
++the terms of the GNU Public License. There is _NO_ warranty for this!
++
++Thanks go to the debuggers and bugfixers (listed in chronological order) :)
++===========================================================================
++Lele Forzani <lele at windmill.it>
++Florian Overkamp <florian at obsimref.com>
++Gareth Watts <gareth at omnipotent.net>
++Jeff Noxon <jeff at planetfall.com>
++Petr Michalek <petr.michalek at aca.cz>
++Jan Stocker
++(...and all the others that i forgot..) :-)
++
++chan_capi version 0.4.0-PRE1 includes:
++======================================
++
++- multiple controller support
++- CID,DNID (callling party, called party)
++- CLIR/CLIP
++- supplementary services, CD,HOLD,RETRIEVE,ECT
++- DTMF (dependend on card) + software DTMF support
++- early B3 connects (always,success,never)
++- digital audio (what did you think?)
++- incoming/outgoing calls
++- overlap sending (dialtone)
++- E(xplicit) C(all) T(ransfer) (...although it's done implicit .. but dont tell!)
++- tuneable latency ;) you can configure the size of B3 blocks at compile time
++  (in chan_capi_pvt.h, AST_CAPI_MAX_B3_BLOCK_SIZE)
++  the default is 160 samples, for non-VoIP use you can tune it down to 130
++- use asterisk's internal dsp functions for dtmf
++- alaw support 
++- ulaw support! 
++- Eicon CAPI echo cancelation (echocancel=1)
++- reject call waiting (ACO)
++- DID for Point to Point mode (a.k.a overlap receiving)
++- experimental echo squelching (echosquelch=1)
++- call progress, no need to add ||r to your dialstring anymore
++- rx/tx gains (rxgain=1.0)
++- call deflection on circuitbusy (makefile option) (deflect=12345678)
++- (inter)national dialing prefix (for callerid) configurable in capi.conf
++- CLI command "capi info" shows B channel status
++- capiECT will announce the callerID since it gets lost on most isdn pbxes
++  the called party can press # to drop the call
++- audio syncing (timing outgoing dataB3 on incoming dataB3), supposed to fix
++  the DATA_B3_REQ (error = 0x1103) problem
++- catch all MSN (incomingmsn=*)
++- some configuration enhancements (msn=123,124,125 and controller=1,2,3,4)
++- accountcode= added.
++- finally the echo squelching works!
++- callgroup support
++- fixed pipe leak
++- updated to support the new frame->delivery field
++- compiles with latest cvs with a makefile option (LOOK AT THE MAKEFILE)
++- fixed channel name bug in p2p mode
++- added app_capiNoES for disabling the primitive echo suppressor, use this before
++  you start recording voicemail or your files may get choppy
++- fixed for latest cvs (AST_MUTEX_DEFINE_STATIC)
++- fixed for latest cvs (asterisk/parking.h -> asterisk/features.h)
++- fixed for latest cvs ast_pthread_create
++
++- ATTENTION! the dialstring syntax now uses the zaptel dialstring syntax 
++  it used to be:  Dial(CAPI/[@]<outgoingMSN>:[b|B]<destination>)
++ 
++  now it is:      Dial(CAPI/g<group>/[b|B]<destination>)
++  or:             Dial(CAPI/contr<controller>/[b|B]<destination>)
++ 
++  CLIP/CLIR is now uses the calling presentation of the calling channel, this can
++  be modified using the CallingPres() application. Use CallinPres(32) for CLIR.
++  That is why the msn= param in capi.conf is now obsolete. The callerID is also
++  taken from the calling channel.
++
++- fixes for BSD (Jan Stocker)
++
++Helper applications
++===================
++kapejod says: "No No No, dont use those yet....!" (except maybe HOLD,ECT...)
++
++app_capiCD.c		forwards an unanswered call to another phone (does not rely on sservice CD)
++			example:
++			exten => s,1,Wait,1
++			exten => s,2,capiCD,12345678
++			
++app_capiHOLD.c		puts an answered call on hold, this has nothing to do with asterisk's onhold thingie (music et al)
++			after putting a call onhold, never use the Wait application!
++
++app_capiRETRIEVE.c	gets the holded call back
++
++app_capiECT.c		explicit call transfer of the holded call (must put call on hold first!)
++			example:
++			exten => s,1,Answer
++			exten => s,2,capiHOLD
++			exten => s,3,capiECT,55:50
++			will ECT the call to 50 using 55 as the callerid/outgoing msn
++
++
++Using CLIR
++==========
++Use the CallingPres() application before you dial:
++exten => _X.,1,CallingPres(32)
++exten => _X.,2,Dial(CAPI/contr1/${EXTEN})    
++
++Enjoying early B3 connects (inband call progress, tones and announcements)
++==========================================================================
++early B3 is now configurable in the dialstring :)
++if you prefix the destination number with a 'b' early B3 will always be used, also if the call fails
++because the number is unprovisioned, etc ...
++if you prefix it with a 'B' early B3 will only be used on successful calls, giving you ring indication,etc...
++
++dont use indications in the Dial command, your local exchange will do that for you:
++exten => _X.,1,Dial(CAPI/contr1/B${EXTEN},30)		(early B3 on success)
++exten => _X.,1,Dial(CAPI/contr1/b${EXTEN},30)		(always early B3)
++exten => _X.,1,Dial(CAPI/contr1/${EXTEN},30,r)		(no early B3, fake ring indication)
++
++exten => _X.,1,Dial(CAPI/contr1/b${EXTEN},30,r)		(always early B3, fake indicatons if the exchange
++							does not give us indications)
++exten => _X.,1,Dial(CAPI/contr1/B${EXTEN},30,r)		(early B3 on success, fake indicatons if the exchange
++							does not give us indications)
++    
++you can totally turn B3 off in the Makefile at buildtime (-DNEVER_EVER_EARLY_B3_CONNECTS).
++
++For normal PBX usage you would use the "b" option, always early B3.
++
++Overlap sending (a.k.a. real dialtone)
++======================================
++when you dial an empty number, and have early B3 enabled, with:
++    Dial(CAPI/g1/b)
++the channel will come up at once and give you the dialtone it gets from the local exchange.
++at this point the channel is like a legacy phone, now you can send dtmf digits to dial.    
++
++Example context for incoming calls on MSN 12345678:
++===================================================
++
++[capi-in]
++exten => 12345678,1,Dial(SIP/phone1)
++exten => 12345678,2,Hangup
++
++
++More information/documentation and commercial support can be found at:
++	http://www.junghanns.net/asterisk/
++	
++
++
+diff -urN asterisk-1.2.19.orig/res/Makefile asterisk-1.2.19/res/Makefile
+--- asterisk-1.2.19.orig/res/Makefile	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.19/res/Makefile	2007-06-25 11:13:51.557660272 +0200
 @@ -11,7 +11,7 @@
  # the GNU General Public License
  #
@@ -13433,9 +13773,9 @@
  
  ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/odbcinst.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/odbcinst.h),)
    ifneq (${OSARCH},FreeBSD)
-diff -urNad asterisk-1.2.15~dfsg~/res/res_agi.c asterisk-1.2.15~dfsg/res/res_agi.c
---- asterisk-1.2.15~dfsg~/res/res_agi.c	2006-12-11 02:33:59.000000000 +0200
-+++ asterisk-1.2.15~dfsg/res/res_agi.c	2007-02-11 06:05:00.000000000 +0200
+diff -urN asterisk-1.2.19.orig/res/res_agi.c asterisk-1.2.19/res/res_agi.c
+--- asterisk-1.2.19.orig/res/res_agi.c	2007-02-16 12:38:03.000000000 +0100
++++ asterisk-1.2.19/res/res_agi.c	2007-06-25 11:13:51.561661216 +0200
 @@ -11,6 +11,9 @@
   * the project provides a web site, mailing lists and IRC
   * channels for your use.
@@ -13596,20 +13936,20 @@
  	if (res >= 0)
  		return RESULT_SUCCESS;
 @@ -577,7 +625,7 @@
- 		else
- 			return RESULT_FAILURE;
- 	}
+ 	ast_seekstream(fs, sample_offset, SEEK_SET);
+ 	res = ast_applystream(chan, fs);
+ 	ast_playstream(fs);
 -	res = ast_waitstream_full(chan, argv[3], agi->audio, agi->ctrl);
 +	res = ast_waitstream_full(chan, argv[3], agi->audio_out, agi->ctrl);
  	/* this is to check for if ast_waitstream closed the stream, we probably are at
  	 * the end of the stream, return that amount, else check for the amount */
  	sample_offset = (chan->stream) ? ast_tellstream(fs) : max_length;
 @@ -637,7 +685,7 @@
-                 else
-                         return RESULT_FAILURE;
-         }
+         ast_seekstream(fs, sample_offset, SEEK_SET);
+         res = ast_applystream(chan, fs);
+         ast_playstream(fs);
 -        res = ast_waitstream_full(chan, argv[3], agi->audio, agi->ctrl);
-+        res = ast_waitstream_full(chan, argv[3], agi->audio_out, agi->ctrl);
++	res = ast_waitstream_full(chan, argv[3], agi->audio_out, agi->ctrl);
          /* this is to check for if ast_waitstream closed the stream, we probably are at
           * the end of the stream, return that amount, else check for the amount */
          sample_offset = (chan->stream)?ast_tellstream(fs):max_length;
@@ -13822,9 +14162,9 @@
  	return ast_register_application(app, agi_exec, synopsis, descrip);
  }
  
-diff -urNad asterisk-1.2.15~dfsg~/res/res_esel.c asterisk-1.2.15~dfsg/res/res_esel.c
---- asterisk-1.2.15~dfsg~/res/res_esel.c	1970-01-01 02:00:00.000000000 +0200
-+++ asterisk-1.2.15~dfsg/res/res_esel.c	2007-02-11 06:05:00.000000000 +0200
+diff -urN asterisk-1.2.19.orig/res/res_esel.c asterisk-1.2.19/res/res_esel.c
+--- asterisk-1.2.19.orig/res/res_esel.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.19/res/res_esel.c	2007-06-25 11:13:51.561661216 +0200
 @@ -0,0 +1,399 @@
 +/*
 + * Asterisk -- A telephony toolkit for Linux.
@@ -14225,9 +14565,9 @@
 +{
 +	return ASTERISK_GPL_KEY;
 +}
-diff -urNad asterisk-1.2.15~dfsg~/res/res_features.c asterisk-1.2.15~dfsg/res/res_features.c
---- asterisk-1.2.15~dfsg~/res/res_features.c	2007-01-16 19:36:50.000000000 +0200
-+++ asterisk-1.2.15~dfsg/res/res_features.c	2007-02-11 06:05:00.000000000 +0200
+diff -urN asterisk-1.2.19.orig/res/res_features.c asterisk-1.2.19/res/res_features.c
+--- asterisk-1.2.19.orig/res/res_features.c	2007-05-01 23:55:19.000000000 +0200
++++ asterisk-1.2.19/res/res_features.c	2007-06-25 11:13:51.561661216 +0200
 @@ -11,6 +11,10 @@
   * the project provides a web site, mailing lists and IRC
   * channels for your use.
@@ -15226,9 +15566,9 @@
  	ast_unregister_application(parkcall);
  	return ast_unregister_application(parkedcall);
  }
-diff -urNad asterisk-1.2.15~dfsg~/res/res_monitor.c asterisk-1.2.15~dfsg/res/res_monitor.c
---- asterisk-1.2.15~dfsg~/res/res_monitor.c	2006-11-01 20:24:17.000000000 +0200
-+++ asterisk-1.2.15~dfsg/res/res_monitor.c	2007-02-11 06:05:00.000000000 +0200
+diff -urN asterisk-1.2.19.orig/res/res_monitor.c asterisk-1.2.19/res/res_monitor.c
+--- asterisk-1.2.19.orig/res/res_monitor.c	2007-03-21 19:03:20.000000000 +0100
++++ asterisk-1.2.19/res/res_monitor.c	2007-06-25 11:13:51.565662161 +0200
 @@ -90,7 +90,7 @@
  
  /* Start monitoring a channel */
@@ -15281,7 +15621,7 @@
  		}
  		
  		free(chan->monitor->format);
-@@ -410,7 +427,7 @@
+@@ -411,7 +428,7 @@
  		return 0;
  	}
  
@@ -15290,7 +15630,7 @@
  	if (res < 0)
  		res = ast_monitor_change_fname(chan, fname_base, 1);
  	ast_monitor_setjoinfiles(chan, joinfiles);
-@@ -446,19 +463,30 @@
+@@ -447,19 +464,30 @@
  {
  	struct ast_channel *c = NULL;
  	char *name = astman_get_header(m, "Channel");
@@ -15325,7 +15665,7 @@
  	}
  
  	if (ast_strlen_zero(fname)) {
-@@ -475,7 +503,7 @@
+@@ -476,7 +504,7 @@
  		if ((d=strchr(fname, '/'))) *d='-';
  	}
  	
@@ -15334,7 +15674,7 @@
  		if (ast_monitor_change_fname(c, fname, 1)) {
  			astman_send_error(s, m, "Could not start monitoring channel");
  			ast_mutex_unlock(&c->lock);
-@@ -501,16 +529,26 @@
+@@ -502,16 +530,26 @@
  {
  	struct ast_channel *c = NULL;
  	char *name = astman_get_header(m, "Channel");
@@ -15365,9 +15705,9 @@
  	res = ast_monitor_stop(c, 1);
  	ast_mutex_unlock(&c->lock);
  	if (res) {
-diff -urNad asterisk-1.2.15~dfsg~/res/res_watchdog.c asterisk-1.2.15~dfsg/res/res_watchdog.c
---- asterisk-1.2.15~dfsg~/res/res_watchdog.c	1970-01-01 02:00:00.000000000 +0200
-+++ asterisk-1.2.15~dfsg/res/res_watchdog.c	2007-02-11 06:05:00.000000000 +0200
+diff -urN asterisk-1.2.19.orig/res/res_watchdog.c asterisk-1.2.19/res/res_watchdog.c
+--- asterisk-1.2.19.orig/res/res_watchdog.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.19/res/res_watchdog.c	2007-06-25 11:13:51.565662161 +0200
 @@ -0,0 +1,149 @@
 +/*
 + * Asterisk -- A telephony toolkit for Linux.
@@ -15427,7 +15767,7 @@
 +    struct watchdog_pvt *woof = (struct watchdog_pvt *)data;
 +    for (;;) {
 +	if (woof->fd) {
-+	    write(woof->fd, "PING\n", 1);
++	    write(woof->fd, "PING\n", 5);
 +	}
 +	usleep(woof->interval * 1000);
 +    }
@@ -15518,10 +15858,10 @@
 +{
 +	return ASTERISK_GPL_KEY;
 +}
-diff -urNad asterisk-1.2.15~dfsg~/rtp.c asterisk-1.2.15~dfsg/rtp.c
---- asterisk-1.2.15~dfsg~/rtp.c	2007-01-31 19:41:51.000000000 +0200
-+++ asterisk-1.2.15~dfsg/rtp.c	2007-02-11 06:05:00.000000000 +0200
-@@ -445,6 +445,11 @@
+diff -urN asterisk-1.2.19.orig/rtp.c asterisk-1.2.19/rtp.c
+--- asterisk-1.2.19.orig/rtp.c	2007-06-12 16:18:57.000000000 +0200
++++ asterisk-1.2.19/rtp.c	2007-06-25 11:13:51.565662161 +0200
+@@ -447,6 +447,11 @@
  	struct rtpPayloadType rtpPT;
  	
  	len = sizeof(sin);
@@ -15533,3 +15873,9 @@
  	
  	/* Cache where the header will go */
  	res = recvfrom(rtp->s, rtp->rawdata + AST_FRIENDLY_OFFSET, sizeof(rtp->rawdata) - AST_FRIENDLY_OFFSET,
+diff -urN asterisk-1.2.19.orig/.version asterisk-1.2.19/.version
+--- asterisk-1.2.19.orig/.version	2007-06-15 23:00:17.000000000 +0200
++++ asterisk-1.2.19/.version	2007-06-25 11:13:51.565662161 +0200
+@@ -1 +1 @@
+-1.2.21.1
++1.2.21.1-BRIstuffed-0.3.0-PRE-1y-h

Added: asterisk1.2/trunk/debian/patches/h323_fix_1217.dpatch
===================================================================
--- asterisk1.2/trunk/debian/patches/h323_fix_1217.dpatch	                        (rev 0)
+++ asterisk1.2/trunk/debian/patches/h323_fix_1217.dpatch	2007-07-15 16:12:48 UTC (rev 3742)
@@ -0,0 +1,29 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## h323_fix_1217.dpatch by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Upstream changeset 58008 broke h323 building. Revert it.
+## DP: Upstream issue: http://bugs.digium.com/view.php?id=9501
+
+ at DPATCH@
+diff -urNad asterisk-1.2.17~dfsg~/channels/h323/Makefile asterisk-1.2.17~dfsg/channels/h323/Makefile
+--- asterisk-1.2.17~dfsg~/channels/h323/Makefile	2007-03-06 17:17:16.000000000 +0200
++++ asterisk-1.2.17~dfsg/channels/h323/Makefile	2007-04-08 17:46:34.000000000 +0300
+@@ -21,8 +21,7 @@
+ OPENH323DIR=$(HOME)/openh323
+ endif
+ 
+-clean:
+-	rm -f *.so *.o .depend
++-include $(OPENH323DIR)/openh323u.mak
+ 
+ $(SOURCES)::	$(SOURCES:.cxx=.cpp)
+ 	ln -f $< $@
+@@ -31,7 +30,6 @@
+ 	touch $(SOURCES)
+ 
+ libchanh323.a:	$(OBJS)
+-	include $(OPENH323DIR)/openh323u.mak
+ 	ar crv $@ $(OBJS)
+ 
+ Makefile.ast:	FORCE


Property changes on: asterisk1.2/trunk/debian/patches/h323_fix_1217.dpatch
___________________________________________________________________
Name: svn:executable
   + *

Modified: asterisk1.2/trunk/debian/rules
===================================================================
--- asterisk1.2/trunk/debian/rules	2007-07-14 20:21:04 UTC (rev 3741)
+++ asterisk1.2/trunk/debian/rules	2007-07-15 16:12:48 UTC (rev 3742)
@@ -147,7 +147,7 @@
 	
 	# Add here commands to install the package into debian/<packagename>
 	$(MAKE) DESTDIR=$(CURDIR)/debian/tmp install samples
-	cp channels/h323/h323.conf.sample $(CURDIR)/debian/tmp/etc/asterisk1.2/h323.conf
+	cp channels/h323/h323.conf.sample $(CURDIR)/debian/tmp/etc/asterisk/h323.conf
 	mkdir -p $(CURDIR)/debian/tmp/usr/lib/cgi-bin/asterisk/
 	cp contrib/scripts/vmail.cgi $(CURDIR)/debian/tmp/usr/lib/cgi-bin/asterisk/
 	chmod +x $(CURDIR)/debian/tmp/usr/lib/cgi-bin/asterisk/vmail.cgi




More information about the Pkg-voip-commits mailing list