[Pkg-voip-commits] r1580 - in asterisk/branches/sarge/debian: . patches

Kilian Krause kilian at costa.debian.org
Fri Apr 14 10:42:08 UTC 2006


Author: kilian
Date: 2006-04-14 10:42:06 +0000 (Fri, 14 Apr 2006)
New Revision: 1580

Added:
   asterisk/branches/sarge/debian/asterisk.logrotate
   asterisk/branches/sarge/debian/patches/backport_playdtmf.dpatch
   asterisk/branches/sarge/debian/patches/zap_restart.dpatch
Removed:
   asterisk/branches/sarge/debian/asterisk-bristuff.asterisk.init
   asterisk/branches/sarge/debian/asterisk-bristuff.asterisk.logrotate
   asterisk/branches/sarge/debian/asterisk-classic.asterisk.logrotate
   asterisk/branches/sarge/debian/patches/80_app_voicemail-italian.dpatch
Modified:
   asterisk/branches/sarge/debian/asterisk.default
   asterisk/branches/sarge/debian/changelog
   asterisk/branches/sarge/debian/patches/00list
   asterisk/branches/sarge/debian/patches/30_ast-data-dir.dpatch
   asterisk/branches/sarge/debian/patches/bristuff.dpatch
   asterisk/branches/sarge/debian/patches/nomarch.dpatch
   asterisk/branches/sarge/debian/rules
Log:
sync back trunk to sarge-backports


Deleted: asterisk/branches/sarge/debian/asterisk-bristuff.asterisk.init
===================================================================
--- asterisk/branches/sarge/debian/asterisk-bristuff.asterisk.init	2006-04-14 10:29:53 UTC (rev 1579)
+++ asterisk/branches/sarge/debian/asterisk-bristuff.asterisk.init	2006-04-14 10:42:06 UTC (rev 1580)
@@ -1,162 +0,0 @@
-#! /bin/sh
-#
-# asterisk	start the asterisk PBX
-# (c) Mark Purcell <msp at debian.org>
-# May be distributed under the terms of this General Public License
-#
-# Based on:
-#
-# skeleton	example file to build /etc/init.d/ scripts.
-#		This file should be used to construct scripts for /etc/init.d.
-#
-#		Written by Miquel van Smoorenburg <miquels at cistron.nl>.
-#		Modified for Debian GNU/Linux
-#		by Ian Murdock <imurdock at gnu.ai.mit.edu>.
-#
-# Version:	@(#)skeleton  1.9  26-Feb-2001  miquels at cistron.nl
-#
-
-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-NAME=asterisk
-USER=$NAME
-GROUP=$USER
-DAEMON=/usr/sbin/$NAME
-DESC="Asterisk PBX"
-PIDFILE="/var/run/asterisk/asterisk.pid"
-
-# by default: use real-time priority
-PARAMS=""
-AST_REALTIME="yes"
-RUNASTERISK="no"
-if [ -r /etc/default/$NAME ]; then . /etc/default/$NAME; fi
-
-if [ "$RUNASTERISK" != "yes" ];then
-	echo "Asterisk not yet configured. Edit /etc/default/asterisk first."
-	exit 1
-fi
-
-if [ "$AST_REALTIME" != "no" ]
-then
-  PARAMS="$PARAMS -p"
-fi
-
-if [ "x$USER" = "x" ]
-then
-  echo "Error: empty USER name"
-  exit 1
-fi
-if [ `id -u "$USER"` = 0 ]
-then
-  echo "Starting as root not supported."
-  exit 1
-fi
-PARAMS="$PARAMS -U $USER"
-
-if [ "x$AST_DEBUG_PARAMS" = x ] 
-then
-  AST_DEBUG_PARAMS=-cvvvvvddddd
-fi
-if [ "$RUNASTSAFE" = "yes" ];then
-	# The value of WRAPPER_DAEMON in can be set in /etc/default/asterisk
-	WRAPPER_DAEMON=${WRAPPER_DAEMON:-/usr/sbin/safe_asterisk}
-	REALDAEMON="$WRAPPER_DAEMON"
-else
-	REALDAEMON="$DAEMON"
-fi
-
-test -x $DAEMON || exit 0
-
-set -e
-
-status() {
-	plist=`ps auxw | grep "$DAEMON" | grep -v grep | awk '{print $2}' | tr '\012' ' '`
-	if [ "$plist" = "" ]; then
-		echo "$DESC is stopped"
-		return 1
-	else
-		echo "$DESC is running: $plist"
-		return 0
-	fi
-}
-
-case "$1" in
-  debug)
-	# we add too many special parameters that I don't want to skip
-	# accidentally. I'm afraid that skipping -U once may cause
-	# confusing results. I also want to maintain the user's choice
-	# of -p
-	echo "Debugging $DESC: "
-	$DAEMON $PARAMS $AST_DEBUG_PARAMS
-	exit 0
-	;;
-  start)
-	if status > /dev/null; then
-		echo "$DESC is already running. Use restart."
-		exit 1
-	fi
-	echo -n "Starting $DESC: "
-	if [ "$RUNASTSAFE" != "yes" ];then
-		# TODO: what if we cought the wrapper just as its asterisk
-		# was killed? status should check for the wrapper if we're in
-		# "safe mode"
-		if status > /dev/null; then
-			echo "$DESC is already running. Use restart."
-			exit 1
-		fi
-	fi
-	echo -n "Starting $DESC: "
-	start-stop-daemon --start --group $GROUP --pidfile "$PIDFILE" \
-		--exec $REALDAEMON -- $PARAMS
-	echo "$NAME."
-	;;
-  stop)
-	echo -n "Stopping $DESC: "
-	if [ "$RUNASTSAFE" = "yes" ];then
-		# hopefully this will work. Untested
-		$REALDAEMON -rx 'stop now' > /dev/null  || true
-	else
-		# Try gracefully.
-		# this may hang in some cases. Specifically, when the asterisk
-		# processes is stopped. No bother to worry about cleanup: 
-		# it will either fail or die when asterisk dies.
-		( $DAEMON -rx 'stop now' > /dev/null 2>&1 & ) &
-	fi
-	echo -n "$NAME"
-	## giving a small grace time to shut down cleanly.
-	#sleep 2 # you can add timeouts in the comma
-	if [ "$RUNASTSAFE" = "yes" ];then
-		start-stop-daemon --quiet --oknodo --stop --exec $WRAPPER_DAEMON 
-	fi
-	# just making sure it's really, really dead. 
-	# KILL is necessary just in case there's an asterisk -r in the background
-	start-stop-daemon --stop --quiet --oknodo --retry=0/2/TERM/2/KILL/5 --exec $REALDAEMON
-	echo "."
-	;;
-  reload)
-	echo "Reloading $DESC configuration files."
-	$DAEMON -rx 'reload'
-	;;
-  logger-reload)
-	$DAEMON -rx 'logger reload'
-	;;
-  extensions-reload)
-	echo "Reloading $DESC configuration files."
-	$DAEMON -rx 'extensions reload'
-	;;
-  restart|force-reload)
-	$0 stop
-	$0 start
-	;;
-  status)
-	status
-	exit $?
-	;;
-  *)
-	N=/etc/init.d/$NAME
-	# echo "Usage: $N {start|stop|restart|reload|logger-reload|extensions-reload|force-reload}" >&2
-	echo "Usage: $N {start|stop|status|debug|restart|force-reload}" >&2
-	exit 1
-	;;
-esac
-
-exit 0

Deleted: asterisk/branches/sarge/debian/asterisk-bristuff.asterisk.logrotate
===================================================================
--- asterisk/branches/sarge/debian/asterisk-bristuff.asterisk.logrotate	2006-04-14 10:29:53 UTC (rev 1579)
+++ asterisk/branches/sarge/debian/asterisk-bristuff.asterisk.logrotate	2006-04-14 10:42:06 UTC (rev 1580)
@@ -1,9 +0,0 @@
-/var/log/asterisk/cdr-custom/Master.csv /var/log/asterisk/debug /var/log/asterisk/event_log /var/log/asterisk/messages {
-        weekly
-        missingok
-        rotate 4
-        sharedscripts
-        postrotate
-                /usr/sbin/invoke-rc.d asterisk logger-reload
-        endscript
-}

Deleted: asterisk/branches/sarge/debian/asterisk-classic.asterisk.logrotate
===================================================================
--- asterisk/branches/sarge/debian/asterisk-classic.asterisk.logrotate	2006-04-14 10:29:53 UTC (rev 1579)
+++ asterisk/branches/sarge/debian/asterisk-classic.asterisk.logrotate	2006-04-14 10:42:06 UTC (rev 1580)
@@ -1,9 +0,0 @@
-/var/log/asterisk/cdr-custom/Master.csv /var/log/asterisk/debug /var/log/asterisk/event_log /var/log/asterisk/messages {
-        weekly
-        missingok
-        rotate 4
-        sharedscripts
-        postrotate
-                /usr/sbin/invoke-rc.d asterisk logger-reload
-        endscript
-}

Modified: asterisk/branches/sarge/debian/asterisk.default
===================================================================
--- asterisk/branches/sarge/debian/asterisk.default	2006-04-14 10:29:53 UTC (rev 1579)
+++ asterisk/branches/sarge/debian/asterisk.default	2006-04-14 10:42:06 UTC (rev 1580)
@@ -17,7 +17,7 @@
 #         *not**intended**for**production**use*.
 #         When you give -G *only* that group will be used,
 #         else all groups of the asterisk user.
-#PARAMS="-g -vvv"
+#PARAMS="-D -g -vvv"
 #
 #
 # RUNASTSAFE: run safe_asterisk rather than asterisk (will auto-restart upon

Added: asterisk/branches/sarge/debian/asterisk.logrotate
===================================================================
--- asterisk/branches/sarge/debian/asterisk.logrotate	2006-04-14 10:29:53 UTC (rev 1579)
+++ asterisk/branches/sarge/debian/asterisk.logrotate	2006-04-14 10:42:06 UTC (rev 1580)
@@ -0,0 +1,9 @@
+/var/log/asterisk/cdr-custom/Master.csv /var/log/asterisk/debug /var/log/asterisk/event_log /var/log/asterisk/messages {
+        weekly
+        missingok
+        rotate 4
+        sharedscripts
+        postrotate
+                /usr/sbin/invoke-rc.d asterisk logger-reload
+        endscript
+}

Modified: asterisk/branches/sarge/debian/changelog
===================================================================
--- asterisk/branches/sarge/debian/changelog	2006-04-14 10:29:53 UTC (rev 1579)
+++ asterisk/branches/sarge/debian/changelog	2006-04-14 10:42:06 UTC (rev 1580)
@@ -1,13 +1,31 @@
-asterisk (1:1.2.6.dfsg-1) UNRELEASED; urgency=low
+asterisk (1:1.2.7.1.dfsg-1) UNRELEASED; urgency=low
 
-  * NOT RELEASED YET
+  * NOT RELEASED YET (unofficial sarge backport for pkg-voip)
+  * New upstream release.
+  * nomarch.dpatch: removed the patching to internal libgsm, as we don't use
+    it (and it broke in this version)
+  * bristuff.dpatch: based on the patch from bristuff-0.3.0-PRE1n
+  * bristuff.dpatch: A small fix in chan_sip.c
+  * bristuff.dpatch: Disabling "libgsm" until it is renamed
+  * 30_ast-data-dir.dpatch: the symlink sounds/voicemail is now gone
+  * rules: do fail if bristuff patching hasfailed
+  * zap_restart.dpatch: allow restarting zaptel channel with "zap restart"
+  * backport_playdtmf.dpatch: a harmless backport (no impact if not used)
+  * completed the merge of logrotate and init.d scripts
+
+ -- Kilian Krause <kilian at debian.org>  Fri, 14 Apr 2006 12:41:33 +0200
+
+asterisk (1:1.2.6.dfsg-1) unstable; urgency=low
+
   * New upstream release. (Closes: #355299)
   * correct_pid_display.dpatch: adjusted to 1.2.6
   * 30_ast-data-dir.dpatch: adjusted to 1.2.6
   * debian/control: Add adduser to depends of asterisk-config to shut up
     lintian.
+  * rules: no need to copy config to the bristuff install
+  * rules: but use cp -a for ast_config, as there may be subdirs.
 
- -- Kilian Krause <kilian at debian.org>  Thu, 30 Mar 2006 13:28:25 +0300
+ -- Tzafrir Cohen <tzafrir.cohen at xorcom.com>  Mon, 10 Apr 2006 19:00:12 +0300
 
 asterisk (1:1.2.4.dfsg-7) unstable; urgency=low
 

Modified: asterisk/branches/sarge/debian/patches/00list
===================================================================
--- asterisk/branches/sarge/debian/patches/00list	2006-04-14 10:29:53 UTC (rev 1579)
+++ asterisk/branches/sarge/debian/patches/00list	2006-04-14 10:42:06 UTC (rev 1580)
@@ -22,3 +22,5 @@
 chanzap_disable_r2.dpatch
 arm
 correct_pid_display
+zap_restart
+backport_playdtmf

Modified: asterisk/branches/sarge/debian/patches/30_ast-data-dir.dpatch
===================================================================
--- asterisk/branches/sarge/debian/patches/30_ast-data-dir.dpatch	2006-04-14 10:29:53 UTC (rev 1579)
+++ asterisk/branches/sarge/debian/patches/30_ast-data-dir.dpatch	2006-04-14 10:42:06 UTC (rev 1580)
@@ -203,26 +203,15 @@
  	mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
  	mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/dictate
  	mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/system
-@@ -645,8 +647,8 @@
+@@ -645,7 +647,7 @@
  	if [ -n "$(OLDHEADERS)" ]; then \
  		rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\
  	fi
--	rm -f $(DESTDIR)$(ASTVARLIBDIR)/sounds/voicemail
 -	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds
-+	rm -f $(DESTDIR)$(ASTDATADIR)/sounds/voicemail
 +	mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds
  	mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
  	mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom
  	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/keys
-@@ -664,7 +666,7 @@
- 	else \
- 		echo "You need to do cvs update -d not just cvs update" ; \
- 	fi 
--	( cd $(DESTDIR)$(ASTVARLIBDIR)/sounds  ; ln -s $(ASTSPOOLDIR)/voicemail . )
-+	( cd $(DESTDIR)$(ASTDATADIR)/sounds  ; ln -s /var/spool/asterisk/voicemail . )
- 	if [ -f mpg123-0.59r/mpg123 ]; then $(MAKE) -C mpg123-0.59r install; fi
- 	@echo " +---- Asterisk Installation Complete -------+"  
- 	@echo " +                                           +"
 @@ -763,10 +765,10 @@
  	else \
  		echo "Skipping asterisk.conf creation"; \

Deleted: asterisk/branches/sarge/debian/patches/80_app_voicemail-italian.dpatch
===================================================================
--- asterisk/branches/sarge/debian/patches/80_app_voicemail-italian.dpatch	2006-04-14 10:29:53 UTC (rev 1579)
+++ asterisk/branches/sarge/debian/patches/80_app_voicemail-italian.dpatch	2006-04-14 10:42:06 UTC (rev 1580)
@@ -1,97 +0,0 @@
-#! /bin/sh -e
-## 80_app_voicemail.dpatch by Kilian Krause <kk at verfaction.de>
-##
-## All lines beginning with `## DP:' are a description of the patch.
-## DP: include italian voicemail support.
-
-if [ $# -lt 1 ]; then
-    echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
-    exit 1
-fi
-
-[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
-patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"
-
-case "$1" in
-    -patch) patch -p1 ${patch_opts} < $0;;
-    -unpatch) patch -R -p1 ${patch_opts} < $0;;
-    *)
-        echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
-        exit 1;;
-esac
-
-exit 0
-
- at DPATCH@
-diff -urNad --exclude=CVS --exclude=.svn ./apps/app_voicemail.c /tmp/dpep-work.bUuHc5/asterisk-1.0.9.dfsg/apps/app_voicemail.c
---- ./apps/app_voicemail.c	2005-05-31 14:08:45.000000000 +0100
-+++ /tmp/dpep-work.bUuHc5/asterisk-1.0.9.dfsg/apps/app_voicemail.c	2005-07-03 13:04:00.283882088 +0100
-@@ -2719,6 +2719,59 @@
- 	return res;
- }
- 
-+/* ITALIAN syntax */
-+static int vm_intro_it(struct ast_channel *chan,struct vm_state *vms)
-+{
-+        /* Introduce messages they have */
-+        int res;
-+        if (!vms->oldmessages && !vms->newmessages) {
-+		res = ast_play_and_wait(chan, "vm-no");
-+		if (!res)
-+			res = ast_play_and_wait(chan, "vm-message");
-+        } else {
-+                res = ast_play_and_wait(chan, "vm-youhave");
-+        }
-+        if (!res) {
-+                if (vms->newmessages) {
-+                        if (!res) {
-+                                if ((vms->newmessages == 1)) {
-+                                        res = ast_play_and_wait(chan, "digits/un");
-+                                        if (!res)
-+                                                res = ast_play_and_wait(chan, "vm-message");
-+                                        if (!res)
-+                                                res = ast_play_and_wait(chan, "vm-nuovo");
-+                                } else {
-+                                        res = say_and_wait(chan, vms->newmessages, chan->language);
-+                                        if (!res)
-+                                                res = ast_play_and_wait(chan, "vm-messages");
-+                                        if (!res)
-+                                                res = ast_play_and_wait(chan, "vm-nuovi");
-+                                }
-+                        }
-+                        if (vms->oldmessages && !res)
-+                                res = ast_play_and_wait(chan, "vm-and");
-+                }
-+                if (vms->oldmessages) {
-+                        if (!res) {
-+                                if (vms->oldmessages == 1) {
-+                                        res = ast_play_and_wait(chan, "digits/un");
-+                                        if (!res)
-+                                                res = ast_play_and_wait(chan, "vm-message");
-+                                        if (!res)
-+                                                res = ast_play_and_wait(chan, "vm-vecchio");
-+                                } else {
-+                                        res = say_and_wait(chan, vms->oldmessages, chan->language);
-+                                        if (!res)
-+                                                res = ast_play_and_wait(chan, "vm-messages");
-+                                        if (!res)
-+                                                res = ast_play_and_wait(chan, "vm-vecchi");
-+                                }
-+                        }
-+                }
-+        }
-+	return res;
-+}
-+
- /* GERMAN syntax */
- static int vm_intro_de(struct ast_channel *chan,struct vm_state *vms)
- {
-@@ -3046,6 +3099,8 @@
- 		return vm_intro_de(chan, vms);
- 	} else if (!strcasecmp(chan->language, "es")) { /* SPANISH syntax */
- 		return vm_intro_es(chan, vms);
-+	} else if (!strcasecmp(chan->language, "it")) { /* ITALIAN syntax */
-+		return vm_intro_it(chan, vms);
- 	} else if (!strcasecmp(chan->language, "fr")) {	/* FRENCH syntax */
- 		return vm_intro_fr(chan, vms);
- 	} else if (!strcasecmp(chan->language, "nl")) {	/* DUTCH syntax */

Added: asterisk/branches/sarge/debian/patches/backport_playdtmf.dpatch
===================================================================
--- asterisk/branches/sarge/debian/patches/backport_playdtmf.dpatch	2006-04-14 10:29:53 UTC (rev 1579)
+++ asterisk/branches/sarge/debian/patches/backport_playdtmf.dpatch	2006-04-14 10:42:06 UTC (rev 1580)
@@ -0,0 +1,69 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## ukcid.dpatch by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: A backport of playdtmf. See http://bugs.digium.com/view.php?id=6682
+## DP: patch: svn diff -r 10646:13356 http://svn.digium.com/svn/asterisk/team/oej/test-this-branch/apps/app_senddtmf.c
+## DP: From: http://www.lusyn.com/asterisk/patches.html
+
+ at DPATCH@
+Index: app_senddtmf.c
+===================================================================
+--- asterisk-old/apps/app_senddtmf.c	(revision 10646)
++++ asterisk-new/apps/app_senddtmf.c	(revision 13356)
+@@ -43,6 +43,7 @@
+ #include "asterisk/options.h"
+ #include "asterisk/utils.h"
+ #include "asterisk/app.h"
++#include "asterisk/manager.h"
+ 
+ static char *tdesc = "Send DTMF digits Application";
+ 
+@@ -93,11 +94,39 @@
+ 	return res;
+ }
+ 
++static char mandescr_playdtmf[] =
++	"Description: Plays a DTMF digit on the specified channel.\n"
++	"Variables: (all are required)\n"
++	"Channel: Channel name to send digit to\n"
++	"Digit: The dtmf digit to play\n";
++
++static int manager_play_dtmf(struct mansession *s, struct message *m)
++{
++	char *channel, *digit;
++
++	channel = astman_get_header(m, "Channel");
++	digit = astman_get_header(m, "Digit");
++	struct ast_channel *chan = ast_get_channel_by_name_locked(channel);
++	if (chan == NULL) {
++		astman_send_error(s, m, "No such channel");
++		return 0;
++	}
++	if (digit == NULL) {
++		astman_send_error(s, m, "No digit specified");
++		return 0;
++	}
++	ast_senddigit(chan, *digit);
++	ast_mutex_unlock(&chan->lock);
++	astman_send_ack(s, m, "DTMF successfully sent");
++	return 0;
++}
++
+ int unload_module(void)
+ {
+ 	int res;
+ 
+ 	res = ast_unregister_application(app);
++	res |= ast_manager_unregister("playDTMF");
+ 
+ 	STANDARD_HANGUP_LOCALUSERS;
+ 
+@@ -106,6 +135,7 @@
+ 
+ int load_module(void)
+ {
++	ast_manager_register2( "playDTMF", EVENT_FLAG_AGENT, manager_play_dtmf, "Play DTMF signal on a specific channel.", mandescr_playdtmf);
+ 	return ast_register_application(app, senddtmf_exec, synopsis, descrip);
+ }
+ 

Modified: asterisk/branches/sarge/debian/patches/bristuff.dpatch
===================================================================
--- asterisk/branches/sarge/debian/patches/bristuff.dpatch	2006-04-14 10:29:53 UTC (rev 1579)
+++ asterisk/branches/sarge/debian/patches/bristuff.dpatch	2006-04-14 10:42:06 UTC (rev 1580)
@@ -2,13 +2,232 @@
 ## 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-1k
-## DP: with some adjustments for asterisk 1.2.6
+## DP: bristuff support in asterisk: asterisk.patch from bristuff-0.3.0-PRE-1n
+## DP: with some adjustments for asterisk 1.2.7
 
 @DPATCH@
-diff -urN asterisk-1.2.4.orig/agi/Makefile asterisk-1.2.4/agi/Makefile
---- asterisk-1.2.4.orig/agi/Makefile	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.4/agi/Makefile	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/.version asterisk-1.2.6/.version
+--- asterisk-1.2.6.orig/.version	2006-03-26 18:49:52.000000000 +0200
++++ asterisk-1.2.6/.version	2006-04-10 10:41:06.000000000 +0200
+@@ -1 +1 @@
+-1.2.7.1
++1.2.7.1-BRIstuffed-0.3.0-PRE-1n
+diff -urN asterisk-1.2.6.orig/HARDWARE asterisk-1.2.6/HARDWARE
+--- asterisk-1.2.6.orig/HARDWARE	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.6/HARDWARE	2006-04-10 11:59:19.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 -urN asterisk-1.2.6.orig/LICENSE asterisk-1.2.6/LICENSE
+--- asterisk-1.2.6.orig/LICENSE	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.6/LICENSE	2006-04-10 10:40:28.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 -urN asterisk-1.2.6.orig/Makefile asterisk-1.2.6/Makefile
+--- asterisk-1.2.6.orig/Makefile	2006-03-03 18:13:37.000000000 +0100
++++ asterisk-1.2.6/Makefile	2006-04-10 10:40:28.000000000 +0200
+@@ -762,6 +762,9 @@
+ 		echo ";astctlowner = root" ; \
+ 		echo ";astctlgroup = apache" ; \
+ 		echo ";astctl = asterisk.ctl" ; \
++		echo "[options]" ; \
++		echo "uniquename = asterisk" ;\
++		echo "silence_suppression = yes" ;\
+ 		) > $(DESTDIR)$(ASTCONFPATH) ; \
+ 	else \
+ 		echo "Skipping asterisk.conf creation"; \
+diff -urN asterisk-1.2.6.orig/README asterisk-1.2.6/README
+--- asterisk-1.2.6.orig/README	2006-03-03 09:12:33.000000000 +0100
++++ asterisk-1.2.6/README	2006-04-10 10:40:28.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 -urN asterisk-1.2.6.orig/README.chan_capi asterisk-1.2.6/README.chan_capi
+--- asterisk-1.2.6.orig/README.chan_capi	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.6/README.chan_capi	2006-04-10 10:40:28.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 -urN asterisk-1.2.6.orig/agi/Makefile asterisk-1.2.6/agi/Makefile
+--- asterisk-1.2.6.orig/agi/Makefile	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.6/agi/Makefile	2006-04-10 10:40:28.000000000 +0200
 @@ -11,7 +11,7 @@
  # the GNU General Public License
  #
@@ -27,9 +246,9 @@
  
  %.so : %.o
  	$(CC) -shared -Xlinker -x -o $@ $<
-diff -urN asterisk-1.2.4.orig/agi/xagi-test.c asterisk-1.2.4/agi/xagi-test.c
---- asterisk-1.2.4.orig/agi/xagi-test.c	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.4/agi/xagi-test.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/agi/xagi-test.c asterisk-1.2.6/agi/xagi-test.c
+--- asterisk-1.2.6.orig/agi/xagi-test.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.6/agi/xagi-test.c	2006-04-10 10:40:28.000000000 +0200
 @@ -0,0 +1,176 @@
 +/*
 + * Asterisk -- A telephony toolkit for Linux.
@@ -207,9 +426,29 @@
 +		return -1;
 +	exit(0);
 +}
-diff -urN asterisk-1.2.4.orig/apps/app_callingpres.c asterisk-1.2.4/apps/app_callingpres.c
---- asterisk-1.2.4.orig/apps/app_callingpres.c	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.4/apps/app_callingpres.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/apps/Makefile asterisk-1.2.6/apps/Makefile
+--- asterisk-1.2.6.orig/apps/Makefile	2006-02-09 03:31:21.000000000 +0100
++++ asterisk-1.2.6/apps/Makefile	2006-04-10 10:40:28.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 -urN asterisk-1.2.6.orig/apps/app_callingpres.c asterisk-1.2.6/apps/app_callingpres.c
+--- asterisk-1.2.6.orig/apps/app_callingpres.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.6/apps/app_callingpres.c	2006-04-10 10:40:28.000000000 +0200
 @@ -0,0 +1,70 @@
 +/*
 + * An application to change the CallingPresentation for an Asterisk channel.
@@ -281,9 +520,9 @@
 +{
 +    return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.4.orig/apps/app_capiCD.c asterisk-1.2.4/apps/app_capiCD.c
---- asterisk-1.2.4.orig/apps/app_capiCD.c	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.4/apps/app_capiCD.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/apps/app_capiCD.c asterisk-1.2.6/apps/app_capiCD.c
+--- asterisk-1.2.6.orig/apps/app_capiCD.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.6/apps/app_capiCD.c	2006-04-10 10:40:28.000000000 +0200
 @@ -0,0 +1,172 @@
 +/*
 + * (CAPI*)
@@ -457,9 +696,9 @@
 +{
 +	return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.4.orig/apps/app_capiECT.c asterisk-1.2.4/apps/app_capiECT.c
---- asterisk-1.2.4.orig/apps/app_capiECT.c	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.4/apps/app_capiECT.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/apps/app_capiECT.c asterisk-1.2.6/apps/app_capiECT.c
+--- asterisk-1.2.6.orig/apps/app_capiECT.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.6/apps/app_capiECT.c	2006-04-10 10:40:28.000000000 +0200
 @@ -0,0 +1,210 @@
 +/*
 + * (CAPI*)
@@ -671,9 +910,9 @@
 +{
 +	return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.4.orig/apps/app_capiNoES.c asterisk-1.2.4/apps/app_capiNoES.c
---- asterisk-1.2.4.orig/apps/app_capiNoES.c	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.4/apps/app_capiNoES.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/apps/app_capiNoES.c asterisk-1.2.6/apps/app_capiNoES.c
+--- asterisk-1.2.6.orig/apps/app_capiNoES.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.6/apps/app_capiNoES.c	2006-04-10 10:40:28.000000000 +0200
 @@ -0,0 +1,96 @@
 +/*
 + * (CAPI*)
@@ -771,9 +1010,9 @@
 +{
 +	return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.4.orig/apps/app_chanisavail.c asterisk-1.2.4/apps/app_chanisavail.c
---- asterisk-1.2.4.orig/apps/app_chanisavail.c	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.4/apps/app_chanisavail.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/apps/app_chanisavail.c asterisk-1.2.6/apps/app_chanisavail.c
+--- asterisk-1.2.6.orig/apps/app_chanisavail.c	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.6/apps/app_chanisavail.c	2006-04-10 10:40:28.000000000 +0200
 @@ -118,7 +118,7 @@
  				snprintf(trychan, sizeof(trychan), "%s/%s",cur,number);
  				status = inuse = ast_device_state(trychan);
@@ -783,9 +1022,9 @@
  					pbx_builtin_setvar_helper(chan, "AVAILCHAN", tempchan->name);
  					/* Store the originally used channel too */
  					snprintf(tmp, sizeof(tmp), "%s/%s", tech, number);
-diff -urN asterisk-1.2.4.orig/apps/app_devstate.c asterisk-1.2.4/apps/app_devstate.c
---- asterisk-1.2.4.orig/apps/app_devstate.c	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.4/apps/app_devstate.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/apps/app_devstate.c asterisk-1.2.6/apps/app_devstate.c
+--- asterisk-1.2.6.orig/apps/app_devstate.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.6/apps/app_devstate.c	2006-04-10 10:40:28.000000000 +0200
 @@ -0,0 +1,219 @@
 +/*
 + * Devstate application
@@ -1006,9 +1245,9 @@
 +{
 +    return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.4.orig/apps/app_dial.c asterisk-1.2.4/apps/app_dial.c
---- asterisk-1.2.4.orig/apps/app_dial.c	2006-01-25 02:50:52.000000000 +0100
-+++ asterisk-1.2.4/apps/app_dial.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/apps/app_dial.c asterisk-1.2.6/apps/app_dial.c
+--- asterisk-1.2.6.orig/apps/app_dial.c	2006-03-19 10:59:55.000000000 +0100
++++ asterisk-1.2.6/apps/app_dial.c	2006-04-10 10:40:28.000000000 +0200
 @@ -11,6 +11,10 @@
   * the project provides a web site, mailing lists and IRC
   * channels for your use.
@@ -1020,8 +1259,8 @@
   * 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.
-@@ -113,7 +117,8 @@
- "           context may be specified. Otherwise, the current extension is used.\n"
+@@ -114,7 +118,8 @@
+ "           Otherwise, the current extension is used.\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"
 -"    j    - Jump to priority n+101 if all of the requested channels were busy.\n"
@@ -1030,7 +1269,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"
-@@ -158,8 +163,11 @@
+@@ -159,8 +164,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"
@@ -1043,7 +1282,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"
-@@ -210,6 +218,8 @@
+@@ -211,6 +219,8 @@
  	OPT_CALLEE_MONITOR = (1 << 21),
  	OPT_CALLER_MONITOR = (1 << 22),
  	OPT_GOTO = (1 << 23),
@@ -1052,7 +1291,7 @@
  } dial_exec_option_flags;
  
  #define DIAL_STILLGOING			(1 << 30)
-@@ -248,6 +258,8 @@
+@@ -249,6 +259,8 @@
  	AST_APP_OPTION('p', OPT_SCREENING),
  	AST_APP_OPTION_ARG('P', OPT_PRIVACY, OPT_ARG_PRIVACY),
  	AST_APP_OPTION('r', OPT_RINGBACK),
@@ -1061,7 +1300,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),
-@@ -383,7 +395,7 @@
+@@ -384,7 +396,7 @@
  	char *context = NULL;
  	char cidname[AST_MAX_EXTENSION];
  
@@ -1070,7 +1309,7 @@
  	
  	if (single) {
  		/* Turn off hold music, etc */
-@@ -462,7 +474,7 @@
+@@ -463,7 +475,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 */
@@ -1079,7 +1318,32 @@
  						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 {
-@@ -916,17 +928,24 @@
+@@ -579,12 +591,18 @@
+ 							HANDLE_CAUSE(AST_CAUSE_CONGESTION, in);
+ 							break;
+ 						case AST_CONTROL_RINGING:
+-							if (option_verbose > 2)
+-								ast_verbose( VERBOSE_PREFIX_3 "%s is ringing\n", o->chan->name);
+-							if (!(*sentringing) && !ast_test_flag(outgoing, OPT_MUSICBACK)) {
+-								ast_indicate(in, AST_CONTROL_RINGING);
+-								(*sentringing)++;
+-							}
++                                                        if (ast_test_flag(peerflags, OPT_CALLBACK_INIT)) {
++                                                            if (option_verbose > 2)
++                                                                ast_verbose( VERBOSE_PREFIX_3 "%s is ringing, hanging up.\n", o->chan->name);
++                                                            return NULL;
++                                                        } else {
++                                                            if (option_verbose > 2)
++                                                                ast_verbose( VERBOSE_PREFIX_3 "%s is ringing\n", o->chan->name);
++                                                            if (!(*sentringing) && !ast_test_flag(outgoing, OPT_MUSICBACK)) {
++                                                                ast_indicate(in, AST_CONTROL_RINGING);
++                                                                (*sentringing)++;
++                                                            }
++                                                        }
+ 							break;
+ 						case AST_CONTROL_PROGRESS:
+ 							if (option_verbose > 2)
+@@ -917,17 +935,24 @@
  		}
  		
  		if( privdb_val == AST_PRIVACY_DENY ) {
@@ -1106,7 +1370,16 @@
  			res = 0;
  			goto out; /* is this right??? */
  
-@@ -1005,7 +1024,7 @@
+@@ -964,7 +989,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");
+ 
+-	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);
+ 	cur = args.peers;
+ 	do {
+ 		/* Remember where to start next time */
+@@ -1006,7 +1031,7 @@
  				ast_log(LOG_DEBUG, "Dialing by extension %s\n", numsubst);
  		}
  		/* Request the peer */
@@ -1115,7 +1388,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));
-@@ -1036,7 +1055,7 @@
+@@ -1037,7 +1062,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 */
@@ -1124,7 +1397,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 {
-@@ -1155,8 +1174,11 @@
+@@ -1156,8 +1181,11 @@
  			ast_indicate(chan, AST_CONTROL_RINGING);
  			sentringing++;
  		}
@@ -1137,7 +1410,7 @@
  
  	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);
-@@ -1285,6 +1307,8 @@
+@@ -1286,6 +1314,8 @@
  								     opt_args[OPT_ARG_PRIVACY], privcid);
  						ast_privacy_set(opt_args[OPT_ARG_PRIVACY], privcid, AST_PRIVACY_DENY);
  					}
@@ -1146,9 +1419,9 @@
  					if (ast_test_flag(&opts, OPT_MUSICBACK)) {
  						ast_moh_stop(chan);
  					} else if (ast_test_flag(&opts, OPT_RINGBACK)) {
-diff -urN asterisk-1.2.4.orig/apps/app_directed_pickup.c asterisk-1.2.4/apps/app_directed_pickup.c
---- asterisk-1.2.4.orig/apps/app_directed_pickup.c	2005-12-20 18:34:00.000000000 +0100
-+++ asterisk-1.2.4/apps/app_directed_pickup.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/apps/app_directed_pickup.c asterisk-1.2.6/apps/app_directed_pickup.c
+--- asterisk-1.2.6.orig/apps/app_directed_pickup.c	2005-12-20 18:34:00.000000000 +0100
++++ asterisk-1.2.6/apps/app_directed_pickup.c	2006-04-10 10:40:28.000000000 +0200
 @@ -41,7 +41,7 @@
  #include "asterisk/app.h"
  
@@ -1158,9 +1431,9 @@
  static const char *synopsis = "Directed Call Pickup";
  static const char *descrip =
  "  Pickup(extension[@context]): This application can pickup any ringing channel\n"
-diff -urN asterisk-1.2.4.orig/apps/app_meetme.c asterisk-1.2.4/apps/app_meetme.c
---- asterisk-1.2.4.orig/apps/app_meetme.c	2006-01-18 22:02:06.000000000 +0100
-+++ asterisk-1.2.4/apps/app_meetme.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/apps/app_meetme.c asterisk-1.2.6/apps/app_meetme.c
+--- asterisk-1.2.6.orig/apps/app_meetme.c	2006-03-23 21:43:05.000000000 +0100
++++ asterisk-1.2.6/apps/app_meetme.c	2006-04-10 10:40:28.000000000 +0200
 @@ -454,7 +454,7 @@
  			ast_copy_string(cnf->pin, pin, sizeof(cnf->pin));
  			ast_copy_string(cnf->pinadmin, pinadmin, sizeof(cnf->pinadmin));
@@ -1170,7 +1443,7 @@
  			if (cnf->chan) {
  				cnf->fd = cnf->chan->fds[0];	/* for use by conf_play() */
  			} else {
-@@ -822,8 +822,9 @@
+@@ -824,8 +824,9 @@
  	char exitcontext[AST_MAX_CONTEXT] = "";
  	char recordingtmp[AST_MAX_EXTENSION] = "";
  	int dtmf;
@@ -1181,7 +1454,7 @@
  	char *buf = __buf + AST_FRIENDLY_OFFSET;
  	
  	if (!user) {
-@@ -986,7 +987,7 @@
+@@ -991,7 +992,7 @@
  		}
  		/* Setup buffering information */
  		memset(&bi, 0, sizeof(bi));
@@ -1190,7 +1463,7 @@
  		bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
  		bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
  		bi.numbufs = audio_buffers;
-@@ -1271,6 +1272,14 @@
+@@ -1276,6 +1277,14 @@
  				f = ast_read(c);
  				if (!f)
  					break;
@@ -1205,7 +1478,7 @@
  				if ((f->frametype == AST_FRAME_VOICE) && (f->subclass == AST_FORMAT_SLINEAR)) {
  					if (user->talk.actual)
  						ast_frame_adjust_volume(f, user->talk.actual);
-@@ -1500,7 +1509,7 @@
+@@ -1507,7 +1516,7 @@
  				}
  				ast_frfree(f);
  			} else if (outfd > -1) {
@@ -1214,9 +1487,9 @@
  				if (res > 0) {
  					memset(&fr, 0, sizeof(fr));
  					fr.frametype = AST_FRAME_VOICE;
-diff -urN asterisk-1.2.4.orig/apps/app_milliwatt.c asterisk-1.2.4/apps/app_milliwatt.c
---- asterisk-1.2.4.orig/apps/app_milliwatt.c	2006-01-19 05:17:45.000000000 +0100
-+++ asterisk-1.2.4/apps/app_milliwatt.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/apps/app_milliwatt.c asterisk-1.2.6/apps/app_milliwatt.c
+--- asterisk-1.2.6.orig/apps/app_milliwatt.c	2006-01-19 05:17:45.000000000 +0100
++++ asterisk-1.2.6/apps/app_milliwatt.c	2006-04-10 10:40:28.000000000 +0200
 @@ -74,20 +74,28 @@
  {
  	struct ast_frame wf;
@@ -1252,9 +1525,9 @@
  	wf.src = "app_milliwatt";
  	wf.delivery.tv_sec = 0;
  	wf.delivery.tv_usec = 0;
-diff -urN asterisk-1.2.4.orig/apps/app_page.c asterisk-1.2.4/apps/app_page.c
---- asterisk-1.2.4.orig/apps/app_page.c	2005-12-02 01:51:15.000000000 +0100
-+++ asterisk-1.2.4/apps/app_page.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/apps/app_page.c asterisk-1.2.6/apps/app_page.c
+--- asterisk-1.2.6.orig/apps/app_page.c	2006-02-11 20:16:23.000000000 +0100
++++ asterisk-1.2.6/apps/app_page.c	2006-04-10 11:04:08.000000000 +0200
 @@ -85,7 +85,7 @@
  {
  	struct calloutdata *cd = data;
@@ -1264,9 +1537,9 @@
  	free(cd);
  	return NULL;
  }
-diff -urN asterisk-1.2.4.orig/apps/app_parkandannounce.c asterisk-1.2.4/apps/app_parkandannounce.c
---- asterisk-1.2.4.orig/apps/app_parkandannounce.c	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.4/apps/app_parkandannounce.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/apps/app_parkandannounce.c asterisk-1.2.6/apps/app_parkandannounce.c
+--- asterisk-1.2.6.orig/apps/app_parkandannounce.c	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.6/apps/app_parkandannounce.c	2006-04-10 10:40:28.000000000 +0200
 @@ -183,7 +183,7 @@
  
  	memset(&oh, 0, sizeof(oh));
@@ -1276,9 +1549,9 @@
  
  	if(dchan) {
  		if(dchan->_state == AST_STATE_UP) {
-diff -urN asterisk-1.2.4.orig/apps/app_pickup.c asterisk-1.2.4/apps/app_pickup.c
---- asterisk-1.2.4.orig/apps/app_pickup.c	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.4/apps/app_pickup.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/apps/app_pickup.c asterisk-1.2.6/apps/app_pickup.c
+--- asterisk-1.2.6.orig/apps/app_pickup.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.6/apps/app_pickup.c	2006-04-10 10:40:28.000000000 +0200
 @@ -0,0 +1,319 @@
 +/*
 + * Asterisk -- A telephony toolkit for Linux.
@@ -1599,9 +1872,9 @@
 +{
 +	return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.4.orig/apps/app_queue.c asterisk-1.2.4/apps/app_queue.c
---- asterisk-1.2.4.orig/apps/app_queue.c	2006-01-22 20:03:53.000000000 +0100
-+++ asterisk-1.2.4/apps/app_queue.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/apps/app_queue.c asterisk-1.2.6/apps/app_queue.c
+--- asterisk-1.2.6.orig/apps/app_queue.c	2006-03-14 19:28:39.000000000 +0100
++++ asterisk-1.2.6/apps/app_queue.c	2006-04-10 10:40:28.000000000 +0200
 @@ -501,7 +501,7 @@
  	return NULL;
  }
@@ -1629,9 +1902,9 @@
  					if (status != o->oldstatus) 
  						update_dial_status(qe->parent, o->member, status);						
  					if (!o->chan) {
-diff -urN asterisk-1.2.4.orig/apps/app_readfile.c asterisk-1.2.4/apps/app_readfile.c
---- asterisk-1.2.4.orig/apps/app_readfile.c	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.4/apps/app_readfile.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/apps/app_readfile.c asterisk-1.2.6/apps/app_readfile.c
+--- asterisk-1.2.6.orig/apps/app_readfile.c	2006-03-23 21:13:48.000000000 +0100
++++ asterisk-1.2.6/apps/app_readfile.c	2006-04-10 10:40:28.000000000 +0200
 @@ -40,7 +40,7 @@
  #include "asterisk/app.h"
  #include "asterisk/module.h"
@@ -1641,9 +1914,9 @@
  
  static char *app_readfile = "ReadFile";
  
-diff -urN asterisk-1.2.4.orig/apps/app_segfault.c asterisk-1.2.4/apps/app_segfault.c
---- asterisk-1.2.4.orig/apps/app_segfault.c	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.4/apps/app_segfault.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/apps/app_segfault.c asterisk-1.2.6/apps/app_segfault.c
+--- asterisk-1.2.6.orig/apps/app_segfault.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.6/apps/app_segfault.c	2006-04-10 10:40:28.000000000 +0200
 @@ -0,0 +1,75 @@
 +/*
 + * Segfault application
@@ -1720,9 +1993,9 @@
 +{
 +    return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.4.orig/apps/app_sms.c asterisk-1.2.4/apps/app_sms.c
---- asterisk-1.2.4.orig/apps/app_sms.c	2005-12-26 19:19:12.000000000 +0100
-+++ asterisk-1.2.4/apps/app_sms.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/apps/app_sms.c asterisk-1.2.6/apps/app_sms.c
+--- asterisk-1.2.6.orig/apps/app_sms.c	2005-12-26 19:19:12.000000000 +0100
++++ asterisk-1.2.6/apps/app_sms.c	2006-04-10 10:40:28.000000000 +0200
 @@ -1179,32 +1179,31 @@
  {
  	struct ast_frame f = { 0 };
@@ -1777,9 +2050,9 @@
  }
  
  static void sms_process (sms_t * h, int samples, signed short *data)
-diff -urN asterisk-1.2.4.orig/apps/app_zapras.c asterisk-1.2.4/apps/app_zapras.c
---- asterisk-1.2.4.orig/apps/app_zapras.c	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.4/apps/app_zapras.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/apps/app_zapras.c asterisk-1.2.6/apps/app_zapras.c
+--- asterisk-1.2.6.orig/apps/app_zapras.c	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.6/apps/app_zapras.c	2006-04-10 10:40:28.000000000 +0200
 @@ -182,7 +182,7 @@
  				}
  			}
@@ -1789,30 +2062,10 @@
  			ioctl(chan->fds[0], ZT_AUDIOMODE, &x);
  
  			/* Restore saved values */
-diff -urN asterisk-1.2.4.orig/apps/Makefile asterisk-1.2.4/apps/Makefile
---- asterisk-1.2.4.orig/apps/Makefile	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.4/apps/Makefile	2006-01-31 09:41:43.000000000 +0100
-@@ -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.4.orig/asterisk.c asterisk-1.2.4/asterisk.c
---- asterisk-1.2.4.orig/asterisk.c	2006-01-24 23:55:32.000000000 +0100
-+++ asterisk-1.2.4/asterisk.c	2006-01-31 09:41:43.000000000 +0100
-@@ -221,6 +221,7 @@
+diff -urN asterisk-1.2.6.orig/asterisk.c asterisk-1.2.6/asterisk.c
+--- asterisk-1.2.6.orig/asterisk.c	2006-03-02 23:26:30.000000000 +0100
++++ asterisk-1.2.6/asterisk.c	2006-04-10 10:40:28.000000000 +0200
+@@ -228,6 +228,7 @@
  char ast_config_AST_CTL_OWNER[AST_CONFIG_MAX_PATH] = "\0";
  char ast_config_AST_CTL_GROUP[AST_CONFIG_MAX_PATH] = "\0";
  char ast_config_AST_CTL[AST_CONFIG_MAX_PATH] = "asterisk.ctl";
@@ -1820,7 +2073,7 @@
  
  static char *_argv[256];
  static int shuttingdown = 0;
-@@ -1878,6 +1879,7 @@
+@@ -1885,6 +1886,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));
@@ -1828,7 +2081,7 @@
  
  	/* no asterisk.conf? no problem, use buildtime config! */
  	if (!cfg) {
-@@ -1916,6 +1918,8 @@
+@@ -1924,6 +1926,8 @@
  			ast_copy_string(ast_config_AST_RUN_DIR, v->value, sizeof(ast_config_AST_RUN_DIR));
  		} else if (!strcasecmp(v->name, "astmoddir")) {
  			ast_copy_string(ast_config_AST_MODULE_DIR, v->value, sizeof(ast_config_AST_MODULE_DIR));
@@ -1837,9 +2090,9 @@
  		}
  		v = v->next;
  	}
-diff -urN asterisk-1.2.4.orig/build_tools/make_defaults_h asterisk-1.2.4/build_tools/make_defaults_h
---- asterisk-1.2.4.orig/build_tools/make_defaults_h	2005-06-20 19:26:08.000000000 +0200
-+++ asterisk-1.2.4/build_tools/make_defaults_h	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/build_tools/make_defaults_h asterisk-1.2.6/build_tools/make_defaults_h
+--- asterisk-1.2.6.orig/build_tools/make_defaults_h	2005-06-20 19:26:08.000000000 +0200
++++ asterisk-1.2.6/build_tools/make_defaults_h	2006-04-10 10:40:28.000000000 +0200
 @@ -16,6 +16,7 @@
  #define AST_KEY_DIR    "${INSTALL_PATH}${ASTVARLIBDIR}/keys"
  #define AST_DB         "${INSTALL_PATH}${ASTVARLIBDIR}/astdb"
@@ -1848,9 +2101,9 @@
  
  #define AST_CONFIG_FILE "${INSTALL_PATH}${ASTCONFPATH}"
  
-diff -urN asterisk-1.2.4.orig/channel.c asterisk-1.2.4/channel.c
---- asterisk-1.2.4.orig/channel.c	2006-01-25 10:46:43.000000000 +0100
-+++ asterisk-1.2.4/channel.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/channel.c asterisk-1.2.6/channel.c
+--- asterisk-1.2.6.orig/channel.c	2006-03-06 15:23:14.000000000 +0100
++++ asterisk-1.2.6/channel.c	2006-04-10 10:40:28.000000000 +0200
 @@ -94,8 +94,8 @@
   */
  static int shutting_down = 0;
@@ -2000,7 +2253,7 @@
  }
  
  int ast_channel_spy_add(struct ast_channel *chan, struct ast_channel_spy *spy)
-@@ -2364,7 +2393,7 @@
+@@ -2369,7 +2398,7 @@
  			  &chan->writetrans, 1);
  }
  
@@ -2009,7 +2262,7 @@
  {
  	int state = 0;
  	int cause = 0;
-@@ -2372,7 +2401,7 @@
+@@ -2377,7 +2406,7 @@
  	struct ast_frame *f;
  	int res = 0;
  	
@@ -2018,15 +2271,15 @@
  	if (chan) {
  		if (oh) {
  			if (oh->vars)	
-@@ -2384,6 +2413,7 @@
+@@ -2391,6 +2420,7 @@
  		}
  		ast_set_callerid(chan, cid_num, cid_name, cid_num);
  
 +		chan->cid.cid_pres = callingpres;
  		if (!ast_call(chan, data, 0)) {
- 			while(timeout && (chan->_state != AST_STATE_UP)) {
- 				res = ast_waitfor(chan, timeout);
-@@ -2406,6 +2436,7 @@
+ 			res = 1;	/* in case chan->_state is already AST_STATE_UP */
+ 			while (timeout && (chan->_state != AST_STATE_UP)) {
+@@ -2414,6 +2444,7 @@
  					if (f->subclass == AST_CONTROL_RINGING)
  						state = AST_CONTROL_RINGING;
  					else if ((f->subclass == AST_CONTROL_BUSY) || (f->subclass == AST_CONTROL_CONGESTION)) {
@@ -2034,7 +2287,7 @@
  						state = f->subclass;
  						ast_frfree(f);
  						break;
-@@ -2475,12 +2506,12 @@
+@@ -2483,12 +2514,12 @@
  	return chan;
  }
  
@@ -2050,7 +2303,7 @@
  {
  	struct chanlist *chan;
  	struct ast_channel *c;
-@@ -2517,6 +2548,7 @@
+@@ -2525,6 +2556,7 @@
  		if (!(c = chan->tech->requester(type, capabilities, data, cause)))
  			return NULL;
  
@@ -2058,7 +2311,7 @@
  		if (c->_state == AST_STATE_DOWN) {
  			manager_event(EVENT_FLAG_CALL, "Newchannel",
  				      "Channel: %s\r\n"
-@@ -2764,6 +2796,29 @@
+@@ -2772,6 +2804,29 @@
  	return res;
  }
  
@@ -2088,7 +2341,7 @@
  void ast_change_name(struct ast_channel *chan, char *newname)
  {
  	char tmp[256];
-@@ -3130,15 +3185,14 @@
+@@ -3138,15 +3193,14 @@
  				);
  }
  
@@ -2106,7 +2359,7 @@
  	manager_event(EVENT_FLAG_CALL,
  		      (oldstate == AST_STATE_DOWN) ? "Newchannel" : "Newstate",
  		      "Channel: %s\r\n"
-@@ -3154,6 +3208,10 @@
+@@ -3162,6 +3216,10 @@
  	return 0;
  }
  
@@ -2117,7 +2370,7 @@
  /*--- Find bridged channel */
  struct ast_channel *ast_bridged_channel(struct ast_channel *chan)
  {
-@@ -3331,6 +3389,7 @@
+@@ -3339,6 +3397,7 @@
  	char callee_warning = 0;
  	int to;
  
@@ -2125,7 +2378,7 @@
  	if (c0->_bridge) {
  		ast_log(LOG_WARNING, "%s is already in a bridge with %s\n", 
  			c0->name, c0->_bridge->name);
-@@ -3341,6 +3400,10 @@
+@@ -3349,6 +3408,10 @@
  			c1->name, c1->_bridge->name);
  		return -1;
  	}
@@ -2136,9 +2389,67 @@
  	
  	/* Stop if we're a zombie or need a soft hangup */
  	if (ast_test_flag(c0, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) ||
-diff -urN asterisk-1.2.4.orig/channels/chan_agent.c asterisk-1.2.4/channels/chan_agent.c
---- asterisk-1.2.4.orig/channels/chan_agent.c	2006-01-13 07:07:39.000000000 +0100
-+++ asterisk-1.2.4/channels/chan_agent.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/channels/Makefile asterisk-1.2.6/channels/Makefile
+--- asterisk-1.2.6.orig/channels/Makefile	2005-12-15 11:52:30.000000000 +0100
++++ asterisk-1.2.6/channels/Makefile	2006-04-10 11:37:13.000000000 +0200
+@@ -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 -urN asterisk-1.2.6.orig/channels/chan_agent.c asterisk-1.2.6/channels/chan_agent.c
+--- asterisk-1.2.6.orig/channels/chan_agent.c	2006-02-15 02:21:33.000000000 +0100
++++ asterisk-1.2.6/channels/chan_agent.c	2006-04-10 10:40:28.000000000 +0200
 @@ -1331,7 +1331,7 @@
  						chan = agent_new(p, AST_STATE_DOWN);
  					} else if (!p->owner && !ast_strlen_zero(p->loginchan)) {
@@ -2148,9 +2459,9 @@
  						if (p->chan)
  							chan = agent_new(p, AST_STATE_DOWN);
  					}
-diff -urN asterisk-1.2.4.orig/channels/chan_capi.c asterisk-1.2.4/channels/chan_capi.c
---- asterisk-1.2.4.orig/channels/chan_capi.c	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.4/channels/chan_capi.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/channels/chan_capi.c asterisk-1.2.6/channels/chan_capi.c
+--- asterisk-1.2.6.orig/channels/chan_capi.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.6/channels/chan_capi.c	2006-04-10 10:40:28.000000000 +0200
 @@ -0,0 +1,2888 @@
 +/*
 + * (CAPI*)
@@ -5040,9 +5351,9 @@
 +{
 +	return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.4.orig/channels/chan_features.c asterisk-1.2.4/channels/chan_features.c
---- asterisk-1.2.4.orig/channels/chan_features.c	2006-01-25 19:39:44.000000000 +0100
-+++ asterisk-1.2.4/channels/chan_features.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/channels/chan_features.c asterisk-1.2.6/channels/chan_features.c
+--- asterisk-1.2.6.orig/channels/chan_features.c	2006-01-25 19:39:44.000000000 +0100
++++ asterisk-1.2.6/channels/chan_features.c	2006-04-10 10:40:28.000000000 +0200
 @@ -438,7 +438,7 @@
  	}
  	ast_mutex_unlock(&featurelock);
@@ -5052,9 +5363,9 @@
  		if (!chan) {
  			ast_log(LOG_NOTICE, "Unable to allocate subchannel '%s/%s'\n", tech, dest);
  			return NULL;
-diff -urN asterisk-1.2.4.orig/channels/chan_iax2.c asterisk-1.2.4/channels/chan_iax2.c
---- asterisk-1.2.4.orig/channels/chan_iax2.c	2006-01-20 02:00:46.000000000 +0100
-+++ asterisk-1.2.4/channels/chan_iax2.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/channels/chan_iax2.c asterisk-1.2.6/channels/chan_iax2.c
+--- asterisk-1.2.6.orig/channels/chan_iax2.c	2006-03-20 18:36:45.000000000 +0100
++++ asterisk-1.2.6/channels/chan_iax2.c	2006-04-10 10:40:28.000000000 +0200
 @@ -11,6 +11,9 @@
   * the project provides a web site, mailing lists and IRC
   * channels for your use.
@@ -5065,7 +5376,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.
-@@ -3050,7 +3053,7 @@
+@@ -3064,7 +3067,7 @@
   	memset(&ied, 0, sizeof(ied));
  	ast_mutex_lock(&iaxsl[callno]);
  	if (callno && iaxs[callno]) {
@@ -5074,7 +5385,7 @@
  		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);
-@@ -3102,7 +3105,8 @@
+@@ -3116,7 +3119,8 @@
  static struct ast_frame *iax2_read(struct ast_channel *c) 
  {
  	static struct ast_frame f = { AST_FRAME_NULL, };
@@ -5084,7 +5395,7 @@
  	return &f;
  }
  
-@@ -6688,7 +6692,7 @@
+@@ -6701,7 +6705,7 @@
  		}
  		if (f.frametype == AST_FRAME_IAX) {
  			if (iaxs[fr.callno]->initid > -1) {
@@ -5093,9 +5404,9 @@
  				ast_sched_del(sched, iaxs[fr.callno]->initid);
  				iaxs[fr.callno]->initid = -1;
  			}
-diff -urN asterisk-1.2.4.orig/channels/chan_sip.c asterisk-1.2.4/channels/chan_sip.c
---- asterisk-1.2.4.orig/channels/chan_sip.c	2006-01-28 14:52:15.000000000 +0100
-+++ asterisk-1.2.4/channels/chan_sip.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/channels/chan_sip.c asterisk-1.2.6/channels/chan_sip.c
+--- asterisk-1.2.6.orig/channels/chan_sip.c	2006-03-22 10:10:13.000000000 +0100
++++ asterisk-1.2.6/channels/chan_sip.c	2006-04-10 10:40:28.000000000 +0200
 @@ -596,6 +596,7 @@
  	unsigned int flags;			/*!< SIP_ flags */	
  	int timer_t1;				/*!< SIP timer T1, ms rtt */
@@ -5138,7 +5449,7 @@
  		p->subscribed = NONE;
  		append_history(p, "Subscribestatus", "timeout");
  		return 10000;	/* Reschedule this destruction so that we know that it's gone */
-@@ -3109,16 +3112,30 @@
+@@ -3124,16 +3127,30 @@
  
  /*! \brief  find_call: Connect incoming SIP message to current dialog or create new dialog structure */
  /*               Called by handle_request, sipsock_read */
@@ -5170,29 +5481,23 @@
  	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
-@@ -4043,6 +4060,7 @@
- 	if (sipmethod == SIP_CANCEL) {
- 		c = p->initreq.rlPart2;	/* Use original URI */
- 	} else if (sipmethod == SIP_ACK) {
-+// XXX+	} else if (!strcasecmp(msg, "ACK") && !p->dialog_established) {
- 		/* Use URI from Contact: in 200 OK (if INVITE) 
- 		(we only have the contacturi on INVITEs) */
- 		if (!ast_strlen_zero(p->okcontacturi))
-@@ -4808,10 +4826,12 @@
+@@ -4824,13 +4842,14 @@
  		ast_build_string(&invite, &invite_max, ";%s", p->options->uri_options);
  
  	ast_copy_string(p->uri, invite_buf, sizeof(p->uri));
 +	ast_copy_string(p->origuri, invite, sizeof(p->origuri));
  
- 	/* If there is a VXML URL append it to the SIP URL */
- 	if (p->options && p->options->vxml_url) {
+	if (sipmethod == SIP_NOTIFY && !ast_strlen_zero(p->theirtag)) { 
+		/* If this is a NOTIFY, use the From: tag in the subscribe (RFC 3265) */
+		snprintf(to, sizeof(to), "<sip:%s>;tag=%s", p->uri, p->theirtag);
+	} else if (p->options && p->options->vxml_url) {
+		/* If there is a VXML URL append it to the SIP URL */
 -		snprintf(to, sizeof(to), "<%s>;%s", p->uri, p->options->vxml_url);
-+//		snprintf(to, sizeof(to), "<%s>;%s", p->uri, p->options->vxml_url);
 +		snprintf(to, sizeof(to), "<%s;%s>", p->uri, p->options->vxml_url);
  	} else {
  		snprintf(to, sizeof(to), "<%s>", p->uri);
  	}
-@@ -4867,6 +4887,11 @@
+@@ -4883,6 +4903,11 @@
  		if (!ast_strlen_zero(p->referred_by))
  			add_header(&req, "Referred-By", p->referred_by);
  	}
@@ -5204,7 +5509,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);
-@@ -4941,8 +4966,7 @@
+@@ -4957,8 +4982,7 @@
  }
  
  /*! \brief  transmit_state_notify: Used in the SUBSCRIBE notification subsystem ----*/
@@ -5214,7 +5519,7 @@
  	char tmp[4000], from[256], to[256];
  	char *t = tmp, *c, *a, *mfrom, *mto;
  	size_t maxbytes = sizeof(tmp);
-@@ -5086,10 +5110,19 @@
+@@ -5102,10 +5126,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);
@@ -5237,7 +5542,7 @@
  		ast_build_string(&t, &maxbytes, "<state>%s</state>\n", statestring);
  		ast_build_string(&t, &maxbytes, "</dialog>\n</dialog-info>\n");
  		break;
-@@ -6299,7 +6332,7 @@
+@@ -6315,7 +6348,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 */
@@ -5246,7 +5551,7 @@
  {
  	struct sip_pvt *p = data;
  
-@@ -6318,7 +6351,7 @@
+@@ -6334,7 +6367,7 @@
  		p->laststate = state;
  		break;
  	}
@@ -5255,7 +5560,7 @@
  
  	if (option_debug > 1)
  		ast_verbose(VERBOSE_PREFIX_1 "Extension Changed %s new state %s for Notify User %s\n", exten, ast_extension_state2str(state), p->username);
-@@ -8584,6 +8617,7 @@
+@@ -8600,6 +8633,7 @@
  	char buf[1024];
  	unsigned int event;
  	char *c;
@@ -5263,7 +5568,7 @@
  	
  	/* Need to check the media/type */
  	if (!strcasecmp(get_header(req, "Content-Type"), "application/dtmf-relay") ||
-@@ -8647,6 +8681,19 @@
+@@ -8663,6 +8697,19 @@
  			ast_queue_control(p->owner, AST_CONTROL_VIDUPDATE);
  		transmit_response(p, "200 OK", req);
  		return;
@@ -5283,7 +5588,7 @@
  	} else if ((c = get_header(req, "X-ClientCode"))) {
  		/* Client code (from SNOM phone) */
  		if (ast_test_flag(p, SIP_USECLIENTCODE)) {
-@@ -8746,12 +8793,63 @@
+@@ -8762,12 +8809,63 @@
  	return RESULT_SUCCESS;
  }
  
@@ -5348,7 +5653,7 @@
  	if (argc < 4)
  		return RESULT_SHOWUSAGE;
  
-@@ -8768,41 +8866,13 @@
+@@ -8784,41 +8882,13 @@
  	}
  
  	for (i = 3; i < argc; i++) {
@@ -5395,7 +5700,7 @@
  /*! \brief  sip_do_history: Enable SIP History logging (CLI) ---*/
  static int sip_do_history(int fd, int argc, char *argv[])
  {
-@@ -9447,7 +9517,7 @@
+@@ -9466,7 +9536,7 @@
  		if (!ignore && p->owner) {
  			ast_queue_control(p->owner, AST_CONTROL_RINGING);
  			if (p->owner->_state != AST_STATE_UP)
@@ -5404,7 +5709,7 @@
  		}
  		if (!strcasecmp(get_header(req, "Content-Type"), "application/sdp")) {
  			process_sdp(p, req);
-@@ -10801,7 +10871,7 @@
+@@ -10829,7 +10899,7 @@
  			struct sip_pvt *p_old;
  
  			transmit_response(p, "200 OK", req);
@@ -5413,7 +5718,7 @@
  			append_history(p, "Subscribestatus", ast_extension_state2str(firststate));
  
  			/* remove any old subscription from this peer for the same exten/context,
-@@ -11113,7 +11183,7 @@
+@@ -11141,7 +11211,7 @@
  	/* Process request, with netlock held */
  retrylock:
  	ast_mutex_lock(&netlock);
@@ -5422,7 +5727,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)) {
-@@ -11435,6 +11505,52 @@
+@@ -11460,6 +11530,52 @@
  	return 0;
  }
  
@@ -5475,7 +5780,7 @@
  /*! \brief  sip_devicestate: Part of PBX channel interface ---*/
  
  /* Return values:---
-@@ -13128,6 +13244,8 @@
+@@ -13155,6 +13271,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);
@@ -5484,7 +5789,7 @@
  
  	sip_poke_all_peers();	
  	sip_send_all_registers();
-@@ -13158,6 +13276,7 @@
+@@ -13185,6 +13303,7 @@
  
  	ast_rtp_proto_unregister(&sip_rtp);
  
@@ -5492,9 +5797,9 @@
  	ast_manager_unregister("SIPpeers");
  	ast_manager_unregister("SIPshowpeer");
  
-diff -urN asterisk-1.2.4.orig/channels/chan_zap.c asterisk-1.2.4/channels/chan_zap.c
---- asterisk-1.2.4.orig/channels/chan_zap.c	2006-01-30 18:08:28.000000000 +0100
-+++ asterisk-1.2.4/channels/chan_zap.c	2006-01-31 09:46:14.000000000 +0100
+diff -urN asterisk-1.2.6.orig/channels/chan_zap.c asterisk-1.2.6/channels/chan_zap.c
+--- asterisk-1.2.6.orig/channels/chan_zap.c	2006-03-23 22:44:36.000000000 +0100
++++ asterisk-1.2.6/channels/chan_zap.c	2006-04-10 14:01:20.000000000 +0200
 @@ -11,6 +11,10 @@
   * the project provides a web site, mailing lists and IRC
   * channels for your use.
@@ -5506,7 +5811,17 @@
   * 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.
-@@ -96,6 +100,7 @@
+@@ -65,6 +69,9 @@
+ #ifdef ZAPATA_R2
+ #include <libmfcr2.h>
+ #endif
++#ifdef ZAPATA_GSM
++#include <libgsm.h>
++#endif
+ 
+ #include "asterisk.h"
+ 
+@@ -96,6 +103,7 @@
  #include "asterisk/term.h"
  #include "asterisk/utils.h"
  #include "asterisk/transcap.h"
@@ -5514,7 +5829,15 @@
  
  #ifndef ZT_SIG_EM_E1
  #error "Your zaptel is too old.  please cvs update"
-@@ -183,7 +188,7 @@
+@@ -173,6 +181,7 @@
+ #define SIG_FXOGS	ZT_SIG_FXOGS
+ #define SIG_FXOKS	ZT_SIG_FXOKS
+ #define SIG_PRI		ZT_SIG_CLEAR
++#define SIG_GSM		(0x100000 | ZT_SIG_CLEAR)
+ #define SIG_R2		ZT_SIG_CAS
+ #define	SIG_SF		ZT_SIG_SF
+ #define SIG_SFWINK 	(0x0100000 | ZT_SIG_SF)
+@@ -183,7 +192,7 @@
  #define SIG_GR303FXOKS	(0x0100000 | ZT_SIG_FXOKS)
  #define SIG_GR303FXSKS	(0x0100000 | ZT_SIG_FXSKS)
  
@@ -5523,17 +5846,19 @@
  #define NUM_DCHANS		4	/*!< No more than 4 d-channels */
  #define MAX_CHANNELS	672		/*!< No more than a DS3 per trunk group */
  
-@@ -201,6 +206,9 @@
+@@ -201,6 +210,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 musicclass[MAX_MUSICCLASS] = "";
  static char progzone[10]= "";
-@@ -287,6 +295,7 @@
+@@ -287,6 +301,7 @@
  static int cur_priexclusive = 0;
  
  static int priindication_oob = 0;
@@ -5541,7 +5866,7 @@
  
  #ifdef ZAPATA_PRI
  static int minunused = 2;
-@@ -294,6 +303,7 @@
+@@ -294,6 +309,7 @@
  static char idleext[AST_MAX_EXTENSION];
  static char idledial[AST_MAX_EXTENSION];
  static int overlapdial = 0;
@@ -5549,7 +5874,7 @@
  static int facilityenable = 0;
  static char internationalprefix[10] = "";
  static char nationalprefix[10] = "";
-@@ -305,8 +315,6 @@
+@@ -305,8 +321,6 @@
  #ifdef PRI_GETSET_TIMERS
  static int pritimers[PRI_MAX_TIMERS];
  #endif
@@ -5558,7 +5883,7 @@
  #endif
  
  /*! \brief Wait up to 16 seconds for first digit (FXO logic) */
-@@ -327,10 +335,6 @@
+@@ -327,10 +341,6 @@
  
  static int ifcount = 0;
  
@@ -5569,7 +5894,26 @@
  /*! \brief Whether we answer on a Polarity Switch event */
  static int answeronpolarityswitch = 0;
  
-@@ -403,6 +407,27 @@
+@@ -389,6 +399,18 @@
+ 
+ struct zt_pvt;
+ 
++#ifdef ZAPATA_GSM
++struct zt_gsm {
++	pthread_t master;
++	ast_mutex_t lock;		/* Mutex */
++	int fd;
++	int span;
++	struct gsm_modul *modul;
++	char pin[256];
++	char exten[AST_MAX_EXTENSION];		/* Where to idle extra calls */
++	struct zt_pvt *pvt;
++};
++#endif
+ 
+ #ifdef ZAPATA_R2
+ static int r2prot = -1;
+@@ -403,6 +425,28 @@
  #define PRI_SPAN(p) (((p) >> 8) & 0xff)
  #define PRI_EXPLICIT(p) (((p) >> 16) & 0x01)
  
@@ -5594,10 +5938,11 @@
 +	struct zt_holded_call *next;
 +};
 +
++
  struct zt_pri {
  	pthread_t master;						/*!< Thread of master */
  	ast_mutex_t lock;						/*!< Mutex */
-@@ -416,6 +441,8 @@
+@@ -416,6 +460,8 @@
  	int nsf;							/*!< Network-Specific Facilities */
  	int dialplan;							/*!< Dialing plan */
  	int localdialplan;						/*!< Local dialing plan */
@@ -5606,7 +5951,7 @@
  	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) */
-@@ -435,6 +462,7 @@
+@@ -435,6 +481,7 @@
  	int fds[NUM_DCHANS];						/*!< FD's for d-channels */
  	int offset;
  	int span;
@@ -5614,7 +5959,7 @@
  	int resetting;
  	int resetpos;
  	time_t lastreset;						/*!< time when unused channels were last reset */
-@@ -442,6 +470,9 @@
+@@ -442,6 +489,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 */
@@ -5624,7 +5969,7 @@
  };
  
  
-@@ -561,6 +592,8 @@
+@@ -561,6 +611,8 @@
  	unsigned int echocanbridged:1;
  	unsigned int echocanon:1;
  	unsigned int faxhandled:1;			/*!< Has a fax tone already been handled? */
@@ -5633,7 +5978,7 @@
  	unsigned int firstradio:1;
  	unsigned int hanguponpolarityswitch:1;
  	unsigned int hardwaredtmf:1;
-@@ -573,7 +606,8 @@
+@@ -573,7 +625,8 @@
  	unsigned int overlapdial:1;
  	unsigned int permcallwaiting:1;
  	unsigned int permhidecallerid:1;		/*!< Whether to hide our outgoing caller ID or not */
@@ -5643,7 +5988,7 @@
  	unsigned int priexclusive:1;
  	unsigned int pulse:1;
  	unsigned int pulsedial:1;			/*!< whether a pulse dial phone is detected */
-@@ -612,6 +646,7 @@
+@@ -612,6 +665,7 @@
  #endif
  	char cid_num[AST_MAX_EXTENSION];
  	int cid_ton;					/*!< Type Of Number (TON) */
@@ -5651,7 +5996,14 @@
  	char cid_name[AST_MAX_EXTENSION];
  	char lastcid_num[AST_MAX_EXTENSION];
  	char lastcid_name[AST_MAX_EXTENSION];
-@@ -676,6 +711,8 @@
+@@ -672,10 +726,15 @@
+ 	int polarityonanswerdelay;
+ 	struct timeval polaritydelaytv;
+ 	int sendcalleridafter;
++#ifdef ZAPATA_GSM
++	struct zt_gsm gsm;
++#endif
+ #ifdef ZAPATA_PRI
  	struct zt_pri *pri;
  	struct zt_pvt *bearer;
  	struct zt_pvt *realcall;
@@ -5660,7 +6012,7 @@
  	q931_call *call;
  	int prioffset;
  	int logicalspan;
-@@ -701,11 +738,14 @@
+@@ -701,11 +760,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);
@@ -5676,7 +6028,7 @@
  	.requester = zt_request,
  	.send_digit = zt_digit,
  	.send_text = zt_sendtext,
-@@ -719,6 +759,7 @@
+@@ -719,6 +781,7 @@
  	.indicate = zt_indicate,
  	.fixup = zt_fixup,
  	.setoption = zt_setoption,
@@ -5684,7 +6036,7 @@
  };
  
  #ifdef ZAPATA_PRI
-@@ -730,6 +771,13 @@
+@@ -730,6 +793,13 @@
  struct zt_pvt *round_robin[32];
  
  #ifdef ZAPATA_PRI
@@ -5698,7 +6050,7 @@
  static inline int pri_grab(struct zt_pvt *pvt, struct zt_pri *pri)
  {
  	int res;
-@@ -779,6 +827,112 @@
+@@ -779,6 +849,112 @@
  #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) */)
  
@@ -5811,7 +6163,16 @@
  static int zt_get_index(struct ast_channel *ast, struct zt_pvt *p, int nullok)
  {
  	int res;
-@@ -1381,12 +1535,16 @@
+@@ -1181,6 +1357,8 @@
+ 		return "GR-303 Signalling with FXOKS";
+ 	case SIG_GR303FXSKS:
+ 		return "GR-303 Signalling with FXSKS";
++	case SIG_GSM:
++		return "GSM Signalling";
+ 	case 0:
+ 		return "Pseudo Signalling";
+ 	default:
+@@ -1381,12 +1559,16 @@
  	int res;
  	if (!p)
  		return;
@@ -5829,7 +6190,7 @@
  		return;
  	}
  	if (p->echocancel) {
-@@ -1412,7 +1570,7 @@
+@@ -1412,7 +1594,7 @@
  {
  	int x;
  	int res;
@@ -5838,7 +6199,16 @@
  		x = p->echotraining;
  		res = ioctl(p->subs[SUB_REAL].zfd, ZT_ECHOTRAIN, &x);
  		if (res) 
-@@ -1774,7 +1932,13 @@
+@@ -1592,7 +1774,7 @@
+ {
+ 	int x, y, res;
+ 	x = muted;
+-	if (p->sig == SIG_PRI) {
++	if ((p->sig == SIG_PRI) || (p->sig == SIG_GSM)) {
+ 		y = 1;
+ 		res = ioctl(p->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &y);
+ 		if (res)
+@@ -1774,7 +1956,13 @@
  		ast_log(LOG_WARNING, "Unable to flush input on channel %d\n", p->channel);
  	p->outgoing = 1;
  
@@ -5853,7 +6223,33 @@
  
  	switch(p->sig) {
  	case SIG_FXOLS:
-@@ -2016,6 +2180,12 @@
+@@ -1999,6 +2187,25 @@
+ 		/* We'll get it in a moment -- but use dialdest to store pre-setup_ack digits */
+ 		p->dialdest[0] = '\0';
+ 		break;
++	case SIG_GSM:
++#ifdef ZAPATA_GSM
++		if (p->gsm.modul) {
++		    c = strchr(dest, '/');
++		    if (c)
++			c++;
++		    else
++			c = dest;
++		    ast_mutex_lock(&p->gsm.lock);
++		    if (gsm_dial(p->gsm.modul, 0, c)) {
++			ast_log(LOG_WARNING, "dialing failed on channel %d\n", p->channel);
++			ast_mutex_unlock(&p->gsm.lock);
++			ast_mutex_unlock(&p->lock);
++			return -1;
++		    }
++		    ast_mutex_unlock(&p->gsm.lock);
++		}
++#endif
++		break;
+ 	default:
+ 		ast_log(LOG_DEBUG, "not yet implemented\n");
+ 		ast_mutex_unlock(&p->lock);
+@@ -2016,6 +2223,12 @@
  		int ldp_strip;
  		int exclusive;
  
@@ -5866,7 +6262,7 @@
  		c = strchr(dest, '/');
  		if (c)
  			c++;
-@@ -2033,6 +2203,7 @@
+@@ -2033,6 +2246,7 @@
  			ast_mutex_unlock(&p->lock);
  			return -1;
  		}
@@ -5874,7 +6270,7 @@
  		if (p->sig != SIG_FXSKS) {
  			p->dop.op = ZT_DIAL_OP_REPLACE;
  			s = strchr(c + p->stripmsd, 'w');
-@@ -2056,6 +2227,8 @@
+@@ -2056,6 +2270,8 @@
  			pri_rel(p->pri);
  			ast_mutex_unlock(&p->lock);
  			return -1;
@@ -5883,7 +6279,7 @@
  		}
  		if (!(sr = pri_sr_new())) {
  			ast_log(LOG_WARNING, "Failed to allocate setup request channel %d\n", p->channel);
-@@ -2287,8 +2460,10 @@
+@@ -2287,8 +2503,10 @@
  	}
  	if (newslot < 0) {
  		newslot = 0;
@@ -5895,7 +6291,7 @@
  	}
  	if (old && (oldslot != newslot))
  		ast_log(LOG_NOTICE, "Switching from from d-channel %d to channel %d!\n",
-@@ -2344,8 +2519,7 @@
+@@ -2344,8 +2562,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);
@@ -5905,7 +6301,7 @@
  	if (index > -1) {
  		/* Real channel, do some fixup */
  		p->subs[index].owner = NULL;
-@@ -2442,6 +2616,7 @@
+@@ -2442,6 +2659,7 @@
  
  
  	if (!p->subs[SUB_REAL].owner && !p->subs[SUB_CALLWAIT].owner && !p->subs[SUB_THREEWAY].owner) {
@@ -5913,7 +6309,7 @@
  		p->owner = NULL;
  		p->ringt = 0;
  		p->distinctivering = 0;
-@@ -2505,6 +2680,26 @@
+@@ -2505,6 +2723,26 @@
  								icause = atoi(cause);
  						}
  						pri_hangup(p->pri->pri, p->call, icause);
@@ -5940,7 +6336,22 @@
  					}
  					if (res < 0) 
  						ast_log(LOG_WARNING, "pri_disconnect failed\n");
-@@ -2701,10 +2896,14 @@
+@@ -2532,7 +2770,13 @@
+ 
+ 		}
+ #endif
+-		if (p->sig && (p->sig != SIG_PRI) && (p->sig != SIG_R2))
++#ifdef ZAPATA_GSM
++		if (p->gsm.modul) {
++		    if (!p->alreadyhungup)
++			gsm_hangup(p->gsm.modul);
++		}
++#endif
++		if (p->sig && (p->sig != SIG_PRI) && (p->sig != SIG_R2) && (p->sig != SIG_GSM))
+ 			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);
+@@ -2701,10 +2945,14 @@
  			p->proceeding = 1;
  			res = pri_answer(p->pri->pri, p->call, 0, !p->digital);
  			pri_rel(p->pri);
@@ -5955,7 +6366,21 @@
  		break;
  #endif
  #ifdef ZAPATA_R2
-@@ -3274,6 +3473,15 @@
+@@ -2714,6 +2962,13 @@
+ 			ast_log(LOG_WARNING, "R2 Answer call failed :( on %s\n", ast->name);
+ 		break;
+ #endif			
++#ifdef ZAPATA_GSM
++	case SIG_GSM:
++		if (p->gsm.modul) {
++		    gsm_answer(p->gsm.modul);
++		}
++		break;
++#endif
+ 	case 0:
+ 		ast_mutex_unlock(&p->lock);
+ 		return 0;
+@@ -3274,6 +3529,15 @@
  {
  	struct zt_pvt *p = newchan->tech_pvt;
  	int x;
@@ -5971,7 +6396,7 @@
  	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) {
-@@ -4600,7 +4808,7 @@
+@@ -4600,7 +4864,7 @@
  		p->subs[index].f.data = NULL;
  		p->subs[index].f.datalen= 0;
  	}
@@ -5980,19 +6405,32 @@
  		/* Perform busy detection. etc on the zap line */
  		f = ast_dsp_process(ast, p->dsp, &p->subs[index].f);
  		if (f) {
-@@ -4612,8 +4820,9 @@
+@@ -4612,8 +4876,9 @@
  				}
  			} else if (f->frametype == AST_FRAME_DTMF) {
  #ifdef ZAPATA_PRI
 -				if (!p->proceeding && p->sig==SIG_PRI && p->pri && p->pri->overlapdial) {
 -					/* Don't accept in-band DTMF when in overlap dial mode */
-+				if (p->ignoredtmf) {
++				if (p->sig==SIG_PRI && p->pri && p->pri->overlapdial && p->ignoredtmf) {
 +					/* Don't accept in-band DTMF when in overlap dial mode 
 +					   or when in non-overlap overlapdialing mode ... */
  					f->frametype = AST_FRAME_NULL;
  					f->subclass = 0;
  				}
-@@ -4748,7 +4957,9 @@
+@@ -4661,8 +4926,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
+@@ -4748,7 +5015,9 @@
  #endif
  	/* Write a frame of (presumably voice) data */
  	if (frame->frametype != AST_FRAME_VOICE) {
@@ -6003,7 +6441,7 @@
  			ast_log(LOG_WARNING, "Don't know what to do with frame type '%d'\n", frame->frametype);
  		return 0;
  	}
-@@ -4819,7 +5030,7 @@
+@@ -4819,7 +5088,7 @@
  		switch(condition) {
  		case AST_CONTROL_BUSY:
  #ifdef ZAPATA_PRI
@@ -6012,7 +6450,7 @@
  				chan->hangupcause = AST_CAUSE_USER_BUSY;
  				chan->_softhangup |= AST_SOFTHANGUP_DEV;
  				res = 0;
-@@ -4901,7 +5112,7 @@
+@@ -4901,7 +5170,7 @@
  		case AST_CONTROL_CONGESTION:
  			chan->hangupcause = AST_CAUSE_CONGESTION;
  #ifdef ZAPATA_PRI
@@ -6021,7 +6459,7 @@
  				chan->hangupcause = AST_CAUSE_SWITCH_CONGESTION;
  				chan->_softhangup |= AST_SOFTHANGUP_DEV;
  				res = 0;
-@@ -5086,8 +5297,12 @@
+@@ -5086,8 +5355,12 @@
  		if (state == AST_STATE_RING)
  			tmp->rings = 1;
  		tmp->tech_pvt = i;
@@ -6036,7 +6474,7 @@
  			tmp->callgroup = i->callgroup;
  			tmp->pickupgroup = i->pickupgroup;
  		}
-@@ -5217,6 +5432,7 @@
+@@ -5217,6 +5490,7 @@
  	int len = 0;
  	int res;
  	int index;
@@ -6044,7 +6482,7 @@
  	if (option_verbose > 2) 
  		ast_verbose( VERBOSE_PREFIX_3 "Starting simple switch on '%s'\n", chan->name);
  	index = zt_get_index(chan, p, 1);
-@@ -5235,10 +5451,17 @@
+@@ -5235,10 +5509,17 @@
  		len = strlen(exten);
  		res = 0;
  		while((len < AST_MAX_EXTENSION-1) && ast_matchmore_extension(chan, chan->context, exten, 1, p->cid_num)) {
@@ -6065,7 +6503,7 @@
  			if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num))
  				timeout = matchdigittimeout;
  			else
-@@ -6720,6 +6943,8 @@
+@@ -6720,6 +7001,8 @@
  		} else {
  			if (si->totalchans == 31) { /* if it's an E1 */
  				pris[*span].dchannels[0] = 16 + offset;
@@ -6074,7 +6512,18 @@
  			} else {
  				pris[*span].dchannels[0] = 24 + offset;
  			}
-@@ -6965,6 +7190,11 @@
+@@ -6807,6 +7090,10 @@
+ 
+ #endif
+ 
++#ifdef ZAPATA_GSM
++static void *gsm_dchannel(void *vgsm);
++#endif
++
+ static struct zt_pvt *mkintf(int channel, int signalling, int radio, struct zt_pri *pri, int reloading)
+ {
+ 	/* Make a zt_pvt structure for this interface (or CRV if "pri" is specified) */
+@@ -6965,6 +7252,11 @@
  							destroy_zt_pvt(&tmp);
  							return NULL;
  						}
@@ -6086,7 +6535,7 @@
  						if (!ast_strlen_zero(pris[span].idledial) && strcmp(pris[span].idledial, idledial)) {
  							ast_log(LOG_ERROR, "Span %d already has idledial '%s'.\n", span + 1, idledial);
  							destroy_zt_pvt(&tmp);
-@@ -6992,6 +7222,17 @@
+@@ -6992,6 +7284,17 @@
  							return NULL;
  						}
  						pris[span].nodetype = pritype;
@@ -6104,7 +6553,7 @@
  						pris[span].switchtype = myswitchtype;
  						pris[span].nsf = nsf;
  						pris[span].dialplan = dialplan;
-@@ -7000,9 +7241,14 @@
+@@ -7000,9 +7303,14 @@
  						pris[span].minunused = minunused;
  						pris[span].minidle = minidle;
  						pris[span].overlapdial = overlapdial;
@@ -6119,7 +6568,44 @@
  						ast_copy_string(pris[span].internationalprefix, internationalprefix, sizeof(pris[span].internationalprefix));
  						ast_copy_string(pris[span].nationalprefix, nationalprefix, sizeof(pris[span].nationalprefix));
  						ast_copy_string(pris[span].localprefix, localprefix, sizeof(pris[span].localprefix));
-@@ -7156,6 +7402,7 @@
+@@ -7023,6 +7331,36 @@
+ 				tmp->prioffset = 0;
+ 			}
+ #endif
++#ifdef ZAPATA_GSM
++		if (signalling == SIG_GSM) {
++		    struct zt_bufferinfo bi;
++		    ast_mutex_init(&tmp->gsm.lock);
++		    strncpy(tmp->gsm.pin, gsm_modem_pin, sizeof(tmp->gsm.pin) - 1);
++		    strncpy(tmp->gsm.exten, gsm_modem_exten, sizeof(tmp->gsm.exten) - 1);
++		    snprintf(fn, sizeof(fn), "%d", channel + 1);
++		    /* Open non-blocking */
++		    tmp->gsm.fd = zt_open(fn);
++		    bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
++		    bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
++		    bi.numbufs = 16;
++		    bi.bufsize = 1024;
++		    if (ioctl(tmp->gsm.fd, ZT_SET_BUFINFO, &bi)) {
++			ast_log(LOG_ERROR, "Unable to set buffer info on channel '%s': %s\n", fn, strerror(errno));
++			return NULL;
++		    }
++		    tmp->gsm.pvt = tmp;
++		    tmp->gsm.span = tmp->span;
++		    tmp->gsm.modul = gsm_new(tmp->gsm.fd, 0, tmp->gsm.pin, tmp->span);
++		    if (ioctl(tmp->subs[SUB_REAL].zfd, ZT_AUDIOMODE, tmp->channel)) {
++			ast_log(LOG_ERROR, "Unable to set clear mode on clear channel %d: %s\n", tmp->channel, strerror(errno));
++			destroy_zt_pvt(&tmp);
++			return NULL;
++		    }
++		    if (ast_pthread_create(&tmp->gsm.master, NULL, gsm_dchannel, &tmp->gsm)) {
++			zt_close(tmp->gsm.fd);
++		    }
++		}
++#endif
+ #ifdef ZAPATA_R2
+ 			if (signalling == SIG_R2) {
+ 				if (r2prot < 0) {
+@@ -7156,6 +7494,7 @@
  		tmp->restrictcid = restrictcid;
  		tmp->use_callingpres = use_callingpres;
  		tmp->priindication_oob = priindication_oob;
@@ -6127,7 +6613,7 @@
  		tmp->priexclusive = cur_priexclusive;
  		if (tmp->usedistinctiveringdetection) {
  			if (!tmp->use_callerid) {
-@@ -7429,7 +7676,7 @@
+@@ -7429,7 +7768,7 @@
  			break;
  		if (!backwards && (x >= pri->numchans))
  			break;
@@ -6136,7 +6622,7 @@
  			ast_log(LOG_DEBUG, "Found empty available channel %d/%d\n", 
  				pri->pvts[x]->logicalspan, pri->pvts[x]->prioffset);
  			return x;
-@@ -7476,7 +7723,7 @@
+@@ -7476,7 +7815,7 @@
  	end = ifend;
  	/* We do signed linear */
  	oldformat = format;
@@ -6145,7 +6631,7 @@
  	if (!format) {
  		ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", oldformat);
  		return NULL;
-@@ -7636,6 +7883,11 @@
+@@ -7636,6 +7975,11 @@
  					p->digital = 1;
  					if (tmp)
  						tmp->transfercapability = AST_TRANS_CAP_DIGITAL;
@@ -6157,7 +6643,172 @@
  				} else {
  					ast_log(LOG_WARNING, "Unknown option '%c' in '%s'\n", opt, (char *)data);
  				}
-@@ -7689,6 +7941,57 @@
+@@ -7675,6 +8019,164 @@
+ 	return tmp;
+ }
+ 
++#ifdef ZAPATA_GSM
++static void handle_gsm_event(struct zt_gsm *gsm, gsm_event *e)
++{
++	struct ast_channel *c = NULL;
++	int law = ZT_LAW_ALAW;
++	int res = 0;
++
++	switch(e->e) {
++	case GSM_EVENT_DCHAN_UP:
++		if (option_verbose > 2)
++		    ast_verbose(VERBOSE_PREFIX_3 "GSM Span %d registered to network!\n", gsm->span);
++		break;
++	case GSM_EVENT_DCHAN_DOWN:
++		if (option_verbose > 2)
++		    ast_verbose(VERBOSE_PREFIX_3 "GSM Span %d unregistered from network!\n", gsm->span);
++		break;
++	case GSM_EVENT_RING:
++		ast_mutex_lock(&gsm->pvt->lock);
++		if (!ast_strlen_zero(e->ring.callingnum)) {
++		    strncpy(gsm->pvt->cid_num, e->ring.callingnum, sizeof(gsm->pvt->cid_num) - 1);
++		}
++		if (!ast_strlen_zero(gsm->exten)) {
++		    strncpy(gsm->pvt->exten, gsm->exten, sizeof(gsm->pvt->exten) - 1);
++		} else {
++		    gsm->pvt->exten[0] = 's';
++		    gsm->pvt->exten[1] = '\0';
++		}
++		c = zt_new(gsm->pvt, AST_STATE_RING, 1, SUB_REAL, ZT_LAW_ALAW, AST_TRANS_CAP_SPEECH);
++		if (c) {
++		    if (option_verbose > 2)
++			ast_verbose(VERBOSE_PREFIX_3 "Ring on channel %d (from %s to %s)\n", e->ring.channel, e->ring.callingnum, gsm->exten);
++		    gsm->pvt->owner = c;
++		    if (ioctl(gsm->pvt->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &law) == -1)
++			ast_log(LOG_WARNING, "Unable to set audio mode on channel %d to %d\n", gsm->pvt->channel, law);
++		    res = zt_setlaw(gsm->pvt->subs[SUB_REAL].zfd, law);
++		    res = set_actual_gain(gsm->pvt->subs[SUB_REAL].zfd, 0, gsm->pvt->rxgain, gsm->pvt->txgain, law);
++		    if (res < 0) {
++ 		        ast_log(LOG_WARNING, "Unable to set gains on channel %d\n", gsm->pvt->channel);
++//		    } else {
++//		        ast_log(LOG_NOTICE, "tx gain %f rx gain %f law %d pvt->law %d\n", gsm->pvt->txgain, gsm->pvt->rxgain, law, gsm->pvt->law);
++		    }
++		}
++		ast_mutex_unlock(&gsm->pvt->lock);
++		break;
++	case GSM_EVENT_HANGUP:
++		ast_verbose(VERBOSE_PREFIX_3 "Got hang up on channel %d\n", e->hangup.channel);
++		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_ALERTING:
++		ast_mutex_lock(&gsm->pvt->lock);
++		gsm->pvt->subs[SUB_REAL].needringing =1;
++		ast_mutex_unlock(&gsm->pvt->lock);
++		break;
++	case GSM_EVENT_ANSWER:
++		ast_mutex_lock(&gsm->pvt->lock);
++		gsm->pvt->dialing = 0;
++		gsm->pvt->subs[SUB_REAL].needanswer =1;
++		gsm->pvt->ignoredtmf = 0;
++		ast_mutex_unlock(&gsm->pvt->lock);
++		break;
++	case GSM_EVENT_PIN_REQUIRED:
++		gsm_send_pin(gsm->modul, gsm->pin);
++		break;
++	case GSM_EVENT_SM_RECEIVED:
++		ast_verbose(VERBOSE_PREFIX_3 "SMS received on span %d. PDU: %s\n", gsm->span, e->sm_received.pdu);
++		break;
++	default:
++		ast_log(LOG_WARNING,"!! Unknown GSM event %d !!\n", e->e);
++	}
++}
++
++static void *gsm_dchannel(void *vgsm)
++{
++	struct zt_gsm *gsm = vgsm;
++	gsm_event *e;
++	struct timeval tv = {0,0}, *next;
++	fd_set rfds, efds;
++	int res,x;
++
++	if (!gsm) return NULL;
++
++	if (!gsm->modul) {
++		fprintf(stderr, "No gsm_mod\n");
++		return NULL;
++	}
++	gsm_set_debug(gsm->modul, 1);
++	for (;;) {
++		
++		/* Run the D-Channel */
++		FD_ZERO(&rfds);
++		FD_ZERO(&efds);
++		FD_SET(gsm->fd, &rfds);
++		FD_SET(gsm->fd, &efds);
++
++		if ((next = gsm_schedule_next(gsm->modul))) {
++			gettimeofday(&tv, NULL);
++			tv.tv_sec = next->tv_sec - tv.tv_sec;
++			tv.tv_usec = next->tv_usec - tv.tv_usec;
++			if (tv.tv_usec < 0) {
++				tv.tv_usec += 1000000;
++				tv.tv_sec -= 1;
++			}
++			if (tv.tv_sec < 0) {
++				tv.tv_sec = 0;
++				tv.tv_usec = 0;
++			}
++		}
++		res = select(gsm->fd + 1, &rfds, NULL, &efds, next ? &tv : NULL);
++		e = NULL;
++
++		ast_mutex_lock(&gsm->lock);
++		if (!res) {
++			e = gsm_schedule_run(gsm->modul);
++		} else if (res > 0) {
++			e = gsm_check_event(gsm->modul, 1);
++		} else if (errno == ELAST) {
++			res = ioctl(gsm->fd, ZT_GETEVENT, &x);
++			printf("Got Zaptel event: %d\n", x);
++		} else if (errno != EINTR) 
++			fprintf(stderr, "Error (%d) on select: %s\n", ELAST, strerror(errno));
++
++		if (!e) {
++		    e = gsm_check_event(gsm->modul, 0);
++		}
++
++		if (e) {
++			handle_gsm_event(gsm, e);
++		}
++		ast_mutex_unlock(&gsm->lock);
++
++		res = ioctl(gsm->fd, ZT_GETEVENT, &x);
++
++		if (!res && x) {
++			switch (x) {
++			    case ZT_EVENT_NOALARM:
++				ast_log(LOG_NOTICE, "Alarm cleared on span %d\n", gsm->span);
++				usleep(1000);
++				gsm_restart(gsm->modul);
++			    break;
++			    case ZT_EVENT_ALARM:
++				ast_log(LOG_NOTICE, "Alarm detected on span %d\n", gsm->span);
++			    break;
++			    default:
++				fprintf(stderr, "Got event on GSM interface: %d\n", x);
++			}
++		}
++
++
++	}
++	return NULL;
++}
++
++#endif
+ 
+ #ifdef ZAPATA_PRI
+ static struct zt_pvt *pri_find_crv(struct zt_pri *pri, int crv)
+@@ -7689,6 +8191,57 @@
  	return NULL;
  }
  
@@ -6215,7 +6866,7 @@
  
  static int pri_find_principle(struct zt_pri *pri, int channel)
  {
-@@ -7721,7 +8024,9 @@
+@@ -7721,7 +8274,9 @@
  static int pri_fixup_principle(struct zt_pri *pri, int principle, q931_call *c)
  {
  	int x;
@@ -6225,7 +6876,7 @@
  	if (!c) {
  		if (principle < 0)
  			return -1;
-@@ -7735,6 +8040,7 @@
+@@ -7735,6 +8290,7 @@
  	/* First, check for other bearers */
  	for (x=0;x<pri->numchans;x++) {
  		if (!pri->pvts[x]) continue;
@@ -6233,7 +6884,7 @@
  		if (pri->pvts[x]->call == c) {
  			/* Found our call */
  			if (principle != x) {
-@@ -7748,19 +8054,56 @@
+@@ -7748,19 +8304,56 @@
  				}
  				/* Fix it all up now */
  				pri->pvts[principle]->owner = pri->pvts[x]->owner;
@@ -6291,7 +6942,7 @@
  			}
  			return principle;
  		}
-@@ -7789,7 +8132,9 @@
+@@ -7789,7 +8382,9 @@
  		}
  		crv = crv->next;
  	}
@@ -6302,7 +6953,7 @@
  	return -1;
  }
  
-@@ -7851,86 +8196,21 @@
+@@ -7851,86 +8446,33 @@
  #ifndef PRI_RESTART
  #error "Upgrade your libpri"
  #endif
@@ -6380,13 +7031,23 @@
 -		ast_log(LOG_WARNING, "%s", s);
 -
 -	ast_mutex_lock(&pridebugfdlock);
--
++	ast_log(LOG_WARNING, "%d %s", span, s);
++}
+ 
 -	if (pridebugfd >= 0)
 -		write(pridebugfd, s, strlen(s));
--
++#ifdef ZAPATA_GSM
++static void zt_gsm_message(char *s, int span)
++{
++//	ast_verbose("%d %s", span, s);
++}
+ 
 -	ast_mutex_unlock(&pridebugfdlock);
-+	ast_log(LOG_WARNING, "%d %s", span, s);
++static void zt_gsm_error(char *s, int span)
++{
++	ast_log(LOG_WARNING, "GSM: %d %s", span, s);
  }
++#endif
  
  static int pri_check_restart(struct zt_pri *pri)
  {
@@ -6396,7 +7057,7 @@
  	do {
  		pri->resetpos++;
  	} while((pri->resetpos < pri->numchans) &&
-@@ -8013,6 +8293,32 @@
+@@ -8013,6 +8555,32 @@
  	}
  }
  
@@ -6429,7 +7090,7 @@
  static void *pri_dchannel(void *vpri)
  {
  	struct zt_pri *pri = vpri;
-@@ -8104,6 +8410,8 @@
+@@ -8104,6 +8672,8 @@
  				} else if (pri->pvts[x] && pri->pvts[x]->owner && pri->pvts[x]->isidlecall)
  					activeidles++;
  			}
@@ -6438,7 +7099,7 @@
  #if 0
  			printf("nextidle: %d, haveidles: %d, minunsed: %d\n",
  				nextidle, haveidles, minunused);
-@@ -8205,9 +8513,36 @@
+@@ -8205,9 +8775,36 @@
  					if (x == ZT_EVENT_ALARM) {
  						pri->dchanavail[which] &= ~(DCHAN_NOTINALARM | DCHAN_UP);
  						pri_find_dchan(pri);
@@ -6477,7 +7138,7 @@
  					}
  				
  					if (option_debug)
-@@ -8219,8 +8554,7 @@
+@@ -8219,8 +8816,7 @@
  					break;
  			}
  		} else if (errno != EINTR)
@@ -6487,7 +7148,7 @@
  		if (e) {
  			if (pri->debug)
  				pri_dump_event(pri->dchans[which], e);
-@@ -8228,32 +8562,101 @@
+@@ -8228,32 +8824,102 @@
  				pri->dchanavail[which] |= DCHAN_UP;
  			switch(e->e) {
  			case PRI_EVENT_DCHAN_UP:
@@ -6555,11 +7216,12 @@
 + 							if (p->owner->_state != AST_STATE_UP) {
 + 							    p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
 + 							    pri_destroycall(p->pri->pri, p->call);
++ 							    p->call = NULL;
 + 							}
 + 						    } else {
 + 							pri_destroycall(p->pri->pri, p->call);
++ 							p->call = NULL;
 + 						    }
-+ 						    p->call = NULL;
 + 						}
 + 					    }
 +   					}
@@ -6585,7 +7247,7 @@
 +  					    if (p->tei == e->gen.tei) {
 +  						if (p->call) {
 +  							if (p->pri && p->pri->pri) {
-+  								pri_hangup(p->pri->pri, p->call, -1);
++  							//	pri_hangup(p->pri->pri, p->call, -1);
 +  								pri_destroycall(p->pri->pri, p->call);
 +  								p->tei = -1;
 +  								p->call = NULL;
@@ -6613,24 +7275,44 @@
  					pri->resetting = 0;
  					/* Hangup active channels and put them in alarm mode */
  					for (i=0; i<pri->numchans; i++) {
-@@ -8261,7 +8664,7 @@
+@@ -8261,19 +8927,29 @@
  						if (p) {
  							if (p->call) {
  								if (p->pri && p->pri->pri) {
 -									pri_hangup(p->pri->pri, p->call, -1);
-+								//	pri_hangup(p->pri->pri, p->call, -1);
- 									pri_destroycall(p->pri->pri, p->call);
- 									p->call = NULL;
+-									pri_destroycall(p->pri->pri, p->call);
+-									p->call = NULL;
++								    if (p->owner) {
++									if (p->owner->_state != AST_STATE_UP) {
++								//	    pri_hangup(p->pri->pri, p->call, -1);
++									    pri_destroycall(p->pri->pri, p->call);
++									    p->call = NULL;
++									    p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
++									    p->inalarm = 1;
++									}
++								    } else {
++									    pri_destroycall(p->pri->pri, p->call);
++									    p->call = NULL;
++									    p->inalarm = 1;
++								    }
  								} else
-@@ -8274,6 +8677,7 @@
- 							p->inalarm = 1;
+ 									ast_log(LOG_WARNING, "The PRI Call have not been destroyed\n");
+ 							}
+ 							if (p->realcall) {
+-								pri_hangup_all(p->realcall, pri);
+-							} else if (p->owner)
+-								p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+-							p->inalarm = 1;
++							    pri_hangup_all(p->realcall, pri);
++							    p->inalarm = 1;
++							} 
  						}
  					}
 +				    }
  				}
  				break;
  			case PRI_EVENT_RESTART:
-@@ -8308,8 +8712,8 @@
+@@ -8308,8 +8984,8 @@
  								pri_destroycall(pri->pri, pri->pvts[x]->call);
  								pri->pvts[x]->call = NULL;
  							}
@@ -6641,7 +7323,7 @@
   							else if (pri->pvts[x]->owner)
  								pri->pvts[x]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
  							ast_mutex_unlock(&pri->pvts[x]->lock);
-@@ -8343,7 +8747,6 @@
+@@ -8343,7 +9019,6 @@
  					}
  				}
  				break;
@@ -6649,7 +7331,7 @@
  			case PRI_EVENT_INFO_RECEIVED:
  				chanpos = pri_find_principle(pri, e->ring.channel);
  				if (chanpos < 0) {
-@@ -8352,9 +8755,11 @@
+@@ -8352,9 +9027,11 @@
  				} else {
  					chanpos = pri_fixup_principle(pri, chanpos, e->ring.call);
  					if (chanpos > -1) {
@@ -6662,7 +7344,7 @@
  							/* how to do that */
  							int digitlen = strlen(e->ring.callednum);
  							char digit;
-@@ -8366,6 +8771,14 @@
+@@ -8366,6 +9043,14 @@
  									zap_queue_frame(pri->pvts[chanpos], &f, pri);
  								}
  							}
@@ -6677,7 +7359,7 @@
  						}
  						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
  					}
-@@ -8373,39 +8786,55 @@
+@@ -8373,39 +9058,55 @@
  				break;
  			case PRI_EVENT_RING:
  				crv = NULL;
@@ -6755,7 +7437,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));
-@@ -8426,6 +8855,7 @@
+@@ -8426,6 +9127,7 @@
  							break;
  						}
  					}
@@ -6763,7 +7445,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) {
-@@ -8450,29 +8880,78 @@
+@@ -8450,29 +9152,78 @@
  					}
  					apply_plan_to_number(pri->pvts[chanpos]->rdnis, sizeof(pri->pvts[chanpos]->rdnis), pri,
  							     e->ring.redirectingnum, e->ring.callingplanrdnis);
@@ -6855,7 +7537,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)) {
-@@ -8491,22 +8970,38 @@
+@@ -8491,22 +9242,38 @@
  						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);
@@ -6901,7 +7583,7 @@
  						if (pri->overlapdial && ast_matchmore_extension(NULL, pri->pvts[chanpos]->context, pri->pvts[chanpos]->exten, 1, pri->pvts[chanpos]->cid_num)) {
  							/* Release the PRI lock while we create the channel */
  							ast_mutex_unlock(&pri->lock);
-@@ -8518,10 +9013,21 @@
+@@ -8518,10 +9285,21 @@
  								ast_log(LOG_DEBUG, "Started up crv %d:%d on bearer channel %d\n", pri->trunkgroup, crv->channel, crv->bearer->channel);
  							} else {
  								c = zt_new(pri->pvts[chanpos], AST_STATE_RESERVED, 0, SUB_REAL, law, e->ring.ctype);
@@ -6918,12 +7600,12 @@
 + 							if (!ast_strlen_zero(e->ring.callingani)) {
 + 							    char tmpstr[256];
 + 							    pri_make_callerid(pri, tmpstr, sizeof(tmpstr), e->ring.callingani, sizeof(e->ring.callingani), e->ring.callingplanuser, e->ring.callingpresuser, 0);
-+ 							    pbx_builtin_setvar_helper(c, "PRI_USER_CID", e->ring.callednum);
++ 							    pbx_builtin_setvar_helper(c, "PRI_USER_CID", tmpstr);
 + 							}
  							if(e->ring.ani2 >= 0) {
  								snprintf(ani2str, 5, "%.2d", e->ring.ani2);
  								pbx_builtin_setvar_helper(c, "ANI2", ani2str);
-@@ -8541,8 +9047,8 @@
+@@ -8541,8 +9319,8 @@
  							ast_mutex_lock(&pri->lock);
  							if (c && !ast_pthread_create(&threadid, &attr, ss_thread, c)) {
  								if (option_verbose > 2)
@@ -6934,7 +7616,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", 
-@@ -8555,6 +9061,7 @@
+@@ -8555,6 +9333,7 @@
  								}
  							}
  						} else  {
@@ -6942,7 +7624,7 @@
  							ast_mutex_unlock(&pri->lock);
  							/* Release PRI lock while we create the channel */
  							c = zt_new(pri->pvts[chanpos], AST_STATE_RING, 1, SUB_REAL, law, e->ring.ctype);
-@@ -8578,10 +9085,26 @@
+@@ -8578,10 +9357,26 @@
  								snprintf(calledtonstr, sizeof(calledtonstr)-1, "%d", e->ring.calledplan);
  								pbx_builtin_setvar_helper(c, "CALLEDTON", calledtonstr);
  								if (option_verbose > 2)
@@ -6971,7 +7653,7 @@
  							} else {
  								ast_log(LOG_WARNING, "Unable to start PBX on channel %d/%d, span %d\n", 
  									pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span);
-@@ -8590,6 +9113,7 @@
+@@ -8590,6 +9385,7 @@
  							}
  						}
  					} else {
@@ -6979,7 +7661,7 @@
  						if (option_verbose > 2)
  							ast_verbose(VERBOSE_PREFIX_3 "Extension '%s' in context '%s' from '%s' does not exist.  Rejecting call on channel %d/%d, span %d\n",
  								pri->pvts[chanpos]->exten, pri->pvts[chanpos]->context, pri->pvts[chanpos]->cid_num, pri->pvts[chanpos]->logicalspan, 
-@@ -8620,7 +9144,7 @@
+@@ -8620,7 +9416,7 @@
  					} else {
  						ast_mutex_lock(&pri->pvts[chanpos]->lock);
  						if (ast_strlen_zero(pri->pvts[chanpos]->dop.dialstr)) {
@@ -6988,7 +7670,7 @@
  							pri->pvts[chanpos]->subs[SUB_REAL].needringing = 1;
  							pri->pvts[chanpos]->alerting = 1;
  						} else
-@@ -8649,9 +9173,15 @@
+@@ -8649,9 +9445,15 @@
  				}
  				break;
  			case PRI_EVENT_PROGRESS:
@@ -7005,7 +7687,7 @@
  #ifdef PRI_PROGRESS_MASK
  					if ((!pri->pvts[chanpos]->progress) || (e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE)) {
  #else
-@@ -8698,6 +9228,12 @@
+@@ -8698,6 +9500,12 @@
  			case PRI_EVENT_PROCEEDING:
  				chanpos = pri_find_principle(pri, e->proceeding.channel);
  				if (chanpos > -1) {
@@ -7018,7 +7700,7 @@
  					if (!pri->pvts[chanpos]->proceeding) {
  						struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_PROCEEDING, };
  						
-@@ -8748,6 +9284,295 @@
+@@ -8748,6 +9556,295 @@
  					}
  				}
  				break;				
@@ -7314,7 +7996,7 @@
  			case PRI_EVENT_ANSWER:
  				chanpos = pri_find_principle(pri, e->answer.channel);
  				if (chanpos < 0) {
-@@ -8763,6 +9588,7 @@
+@@ -8763,6 +9860,7 @@
  						chanpos = -1;
  					} else {
  						ast_mutex_lock(&pri->pvts[chanpos]->lock);
@@ -7322,7 +8004,7 @@
  						/* Now we can do call progress detection */
  
  						/* We changed this so it turns on the DSP no matter what... progress or no progress.
-@@ -8792,11 +9618,15 @@
+@@ -8792,11 +9890,15 @@
  								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) {
@@ -7339,7 +8021,7 @@
  						}
  
  #ifdef SUPPORT_USERUSER
-@@ -8845,18 +9675,21 @@
+@@ -8845,18 +9947,21 @@
  								}
  							}
  							if (option_verbose > 2) 
@@ -7366,7 +8048,7 @@
  						}
  						if (e->hangup.aoc_units > -1)
  							if (option_verbose > 2)
-@@ -8871,8 +9704,20 @@
+@@ -8871,8 +9976,20 @@
  
  						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
  					} else {
@@ -7389,7 +8071,7 @@
  					}
  				} 
  				break;
-@@ -8882,17 +9727,25 @@
+@@ -8882,17 +9999,25 @@
  			case PRI_EVENT_HANGUP_REQ:
  				chanpos = pri_find_principle(pri, e->hangup.channel);
  				if (chanpos < 0) {
@@ -7418,7 +8100,7 @@
  							pri->pvts[chanpos]->owner->hangupcause = e->hangup.cause;
  							switch(e->hangup.cause) {
  							case PRI_CAUSE_USER_BUSY:
-@@ -8915,16 +9768,73 @@
+@@ -8915,16 +10040,73 @@
  								if (option_verbose > 2)
  									ast_verbose(VERBOSE_PREFIX_3 "Channel %d/%d, span %d received AOC-E charging %d unit%s\n",
  										pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span, (int)e->hangup.aoc_units, (e->hangup.aoc_units == 1) ? "" : "s");
@@ -7497,7 +8179,7 @@
  						}
  
  #ifdef SUPPORT_USERUSER
-@@ -8935,9 +9845,28 @@
+@@ -8935,9 +10117,28 @@
  
  						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
  					} else {
@@ -7527,7 +8209,7 @@
  				break;
  			case PRI_EVENT_HANGUP_ACK:
  				chanpos = pri_find_principle(pri, e->hangup.channel);
-@@ -8951,6 +9880,7 @@
+@@ -8951,6 +10152,7 @@
  					if (chanpos > -1) {
  						ast_mutex_lock(&pri->pvts[chanpos]->lock);
  						pri->pvts[chanpos]->call = NULL;
@@ -7535,7 +8217,7 @@
  						pri->pvts[chanpos]->resetting = 0;
  						if (pri->pvts[chanpos]->owner) {
  							if (option_verbose > 2) 
-@@ -8964,7 +9894,9 @@
+@@ -8964,7 +10166,9 @@
  #endif
  
  						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
@@ -7545,7 +8227,7 @@
  				}
  				break;
  			case PRI_EVENT_CONFIG_ERR:
-@@ -9063,6 +10005,78 @@
+@@ -9067,6 +10271,78 @@
  					ast_mutex_unlock(&pri->pvts[chanpos]->lock);
  				}
  				break;
@@ -7624,7 +8306,7 @@
  			default:
  				ast_log(LOG_DEBUG, "Event: %d\n", e->e);
  			}
-@@ -9124,7 +10138,7 @@
+@@ -9128,7 +10404,7 @@
  			pri->fds[i] = -1;
  			return -1;
  		}
@@ -7633,7 +8315,7 @@
  		/* Force overlap dial if we're doing GR-303! */
  		if (pri->switchtype == PRI_SWITCH_GR303_TMC)
  			pri->overlapdial = 1;
-@@ -9193,39 +10207,77 @@
+@@ -9197,39 +10473,77 @@
  
  static int handle_pri_set_debug_file(int fd, int argc, char **argv)
  {
@@ -7733,7 +8415,7 @@
  	}
  
  	return RESULT_SUCCESS;
-@@ -9257,6 +10309,7 @@
+@@ -9261,6 +10575,7 @@
  
  
  
@@ -7741,7 +8423,7 @@
  static int handle_pri_no_debug(int fd, int argc, char *argv[])
  {
  	int span;
-@@ -9363,36 +10416,6 @@
+@@ -9367,36 +10682,6 @@
  	return RESULT_SUCCESS;
  }
  
@@ -7778,7 +8460,7 @@
  static char pri_debug_help[] = 
  	"Usage: pri debug span <span>\n"
  	"       Enables debugging on a given PRI span\n";
-@@ -9409,6 +10432,18 @@
+@@ -9413,6 +10698,18 @@
  	"Usage: pri show span <span>\n"
  	"       Displays PRI Information\n";
  
@@ -7797,7 +8479,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 },
-@@ -9416,19 +10451,77 @@
+@@ -9420,19 +10717,207 @@
  	  "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 },
@@ -7835,6 +8517,136 @@
  #endif /* ZAPATA_PRI */
  
  
++#ifdef ZAPATA_GSM
++
++static char gsm_send_pdu_help[] = 
++	"Usage: gsm send pdu <channel> <length> <pdu>\n"
++	"       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> */
++	int channel;
++	int len;
++	struct zt_pvt *pvt = NULL;
++	if (argc < 6) {
++		return RESULT_SHOWUSAGE;
++	}
++	channel = atoi(argv[3]);
++	if (channel < 1) {
++		ast_cli(fd, "Invalid channel %s.  Should be a number.\n", argv[3]);
++		return RESULT_SUCCESS;
++	}
++	len = atoi(argv[4]);
++	if (len < 1) {
++		ast_cli(fd, "Invalid length %s.  Should be a number.\n", argv[4]);
++		return RESULT_SUCCESS;
++	}
++	pvt = iflist;
++	while (pvt) {
++	    if (pvt->channel == channel) {
++		if (pvt->owner) {
++		    ast_cli(fd, "Channel in use.\n");
++		    return RESULT_FAILURE;
++		} else {
++		    ast_mutex_lock(&pvt->lock);
++		    gsm_sms_send_pdu(pvt->gsm.modul, argv[5], len);
++		    ast_mutex_unlock(&pvt->lock);
++		    return RESULT_SUCCESS;
++		}
++	    }
++	    pvt = pvt->next;
++	}
++	
++	return RESULT_SUCCESS;
++}
++
++static struct ast_cli_entry gsm_send_pdu = {
++	{ "gsm", "send", "pdu", NULL }, handle_gsm_send_pdu, "Sends a SM on a GSM channel", gsm_send_pdu_help, complete_span_4 };
++
++
++static char gsm_send_sms_help[] = 
++	"Usage: gsm send sms <channel> <destination> <message>\n"
++	"       Sends a SM on a GSM channel\n";
++
++
++static int handle_gsm_send_sms(int fd, int argc, char *argv[])
++{
++/* gsm send sms <channel> <destination> <message> */
++	int channel;
++	struct zt_pvt *pvt = NULL;
++	if (argc < 6) {
++		return RESULT_SHOWUSAGE;
++	}
++	channel = atoi(argv[3]);
++	if (channel < 1) {
++		ast_cli(fd, "Invalid channel %s.  Should be a number.\n", argv[3]);
++		return RESULT_SUCCESS;
++	}
++	pvt = iflist;
++	while (pvt) {
++	    if (pvt->channel == channel) {
++		if (pvt->owner) {
++		    ast_cli(fd, "Channel in use.\n");
++		    return RESULT_FAILURE;
++		} else {
++		    ast_mutex_lock(&pvt->lock);
++		    gsm_sms_send_text(pvt->gsm.modul, argv[4], argv[5]);
++		    ast_mutex_unlock(&pvt->lock);
++		    return RESULT_SUCCESS;
++		}
++	    }
++	    pvt = pvt->next;
++	}
++	
++	return RESULT_SUCCESS;
++}
++
++static struct ast_cli_entry gsm_send_sms = {
++	{ "gsm", "send", "sms", NULL }, handle_gsm_send_sms, "Sends a SM on a GSM channel", gsm_send_sms_help, complete_span_4 };
++
++static char gsm_show_status_help[] = 
++	"Usage: gsm show status <channel>>\n"
++	"       Displays status information about the GSM channel.\n";
++
++
++static int handle_gsm_show_status(int fd, int argc, char *argv[])
++{
++	int channel;
++	struct zt_pvt *pvt = NULL;
++	if (argc < 4) {
++		return RESULT_SHOWUSAGE;
++	}
++	channel = atoi(argv[3]);
++	if (channel < 1) {
++		ast_cli(fd, "Invalid channel %s.  Should be a number.\n", argv[3]);
++		return RESULT_SUCCESS;
++	}
++	pvt = iflist;
++	while (pvt) {
++	    if (pvt->channel == channel) {
++		if (pvt->owner) {
++		    ast_cli(fd, "Channel in use.\n");
++		    return RESULT_FAILURE;
++		} else {
++		    ast_mutex_lock(&pvt->lock);
++		    gsm_request_status(pvt->gsm.modul);
++		    ast_mutex_unlock(&pvt->lock);
++		    return RESULT_SUCCESS;
++		}
++	    }
++	    pvt = pvt->next;
++	}
++	
++	return RESULT_SUCCESS;
++}
++
++static struct ast_cli_entry gsm_show_status = {
++	{ "gsm", "show", "status", NULL }, handle_gsm_show_status, "Displays status information about the GSM channel.", gsm_show_status_help, complete_span_4 };
++
++#endif /* ZAPATA_GSM */
++
 +static int app_zapEC(struct ast_channel *chan, void *data)
 +{
 + int res=-1;
@@ -7878,7 +8690,19 @@
  #ifdef ZAPATA_R2
  static int handle_r2_no_debug(int fd, int argc, char *argv[])
  {
-@@ -10051,6 +11144,7 @@
+@@ -10045,6 +11530,11 @@
+ 	}
+ 	ast_cli_unregister_multiple(zap_pri_cli, sizeof(zap_pri_cli) / sizeof(zap_pri_cli[0]));
+ #endif
++#ifdef ZAPATA_GSM
++	ast_cli_unregister(&gsm_send_sms);
++	ast_cli_unregister(&gsm_send_pdu);
++	ast_cli_unregister(&gsm_show_status);
++#endif
+ #ifdef ZAPATA_R2
+ 	ast_cli_unregister_multiple(zap_r2_cli, sizeof(zap_r2_cli) / sizeof(zap_r2_cli[0]));
+ #endif
+@@ -10055,6 +11545,7 @@
  	ast_manager_unregister( "ZapDNDoff" );
  	ast_manager_unregister( "ZapDNDon" );
  	ast_manager_unregister("ZapShowChannels");
@@ -7886,7 +8710,7 @@
  	ast_channel_unregister(&zap_tech);
  	if (!ast_mutex_lock(&iflock)) {
  		/* Hangup all interfaces if they have an owner */
-@@ -10409,8 +11503,8 @@
+@@ -10413,8 +11904,8 @@
  			}
  		} else if (!strcasecmp(v->name, "echotraining")) {
  			if (sscanf(v->value, "%d", &y) == 1) {
@@ -7897,7 +8721,7 @@
  				} else {
  					echotraining = y;
  				}
-@@ -10596,6 +11690,22 @@
+@@ -10600,12 +12091,33 @@
  					cur_signalling = SIG_GR303FXSKS;
  					cur_radio = 0;
  					pritype = PRI_CPE;
@@ -7920,14 +8744,24 @@
  #endif
  #ifdef ZAPATA_R2
  				} else if (!strcasecmp(v->value, "r2")) {
-@@ -10684,8 +11794,20 @@
+ 					cur_signalling = SIG_R2;
+ 					cur_radio = 0;
+ #endif			
++#ifdef ZAPATA_GSM
++				} else if (!strcasecmp(v->value, "gsm")) {
++					cur_signalling = SIG_GSM;
++					cur_radio = 0;
++#endif				
+ 				} else {
+ 					ast_log(LOG_ERROR, "Unknown signalling method '%s'\n", v->value);
+ 				}
+@@ -10688,8 +12200,20 @@
  					priindication_oob = 1;
  				else if (!strcasecmp(v->value, "inband"))
  					priindication_oob = 0;
 +				else if (!strcasecmp(v->value, "passthrough"))
 +					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
 +					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);
 +			} else if (!strcasecmp(v->name, "pritransfer")) {
@@ -7937,12 +8771,13 @@
 +					pritransfer = 1;
 +				else if (!strcasecmp(v->value, "hangup"))
 +					pritransfer = 2;
-+				else
+ 				else
+-					ast_log(LOG_WARNING, "'%s' is not a valid pri indication value, should be 'inband' or 'outofband' at line %d\n",
 +					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")) {
  				cur_priexclusive = ast_true(v->value);
-@@ -10699,6 +11821,10 @@
+@@ -10703,6 +12227,14 @@
  				ast_copy_string(privateprefix, v->value, sizeof(privateprefix));
  			} else if (!strcasecmp(v->name, "unknownprefix")) {
  				ast_copy_string(unknownprefix, v->value, sizeof(unknownprefix));
@@ -7950,10 +8785,14 @@
 +  				ast_copy_string(nocid, v->value, sizeof(nocid) - 1);
 +  			} else if (!strcasecmp(v->name, "withheldcid")) {
 +  				ast_copy_string(withheldcid, v->value, sizeof(withheldcid) - 1);
++			} else if (!strcasecmp(v->name, "pin")) {
++				ast_copy_string(gsm_modem_pin, v->value, sizeof(gsm_modem_pin) - 1);
++			} else if (!strcasecmp(v->name, "exten")) {
++				ast_copy_string(gsm_modem_exten, v->value, sizeof(gsm_modem_exten) - 1);
  			} else if (!strcasecmp(v->name, "resetinterval")) {
  				if (!strcasecmp(v->value, "never"))
  					resetinterval = -1;
-@@ -10713,6 +11839,8 @@
+@@ -10717,6 +12249,8 @@
  				ast_copy_string(idleext, v->value, sizeof(idleext));
  			} else if (!strcasecmp(v->name, "idledial")) {
  				ast_copy_string(idledial, v->value, sizeof(idledial));
@@ -7962,7 +8801,7 @@
  			} else if (!strcasecmp(v->name, "overlapdial")) {
  				overlapdial = ast_true(v->value);
  			} else if (!strcasecmp(v->name, "pritimer")) {
-@@ -10898,6 +12026,7 @@
+@@ -10902,6 +12436,7 @@
  #ifdef ZAPATA_PRI
  	if (!reload) {
  		for (x=0;x<NUM_SPANS;x++) {
@@ -7970,7 +8809,30 @@
  			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);
-@@ -10955,11 +12084,46 @@
+@@ -10934,6 +12469,10 @@
+ 	pri_set_error(zt_pri_error);
+ 	pri_set_message(zt_pri_message);
+ #endif
++#ifdef ZAPATA_GSM
++	gsm_set_error(zt_gsm_error);
++	gsm_set_message(zt_gsm_message);
++#endif
+ 	res = setup_zap(0);
+ 	/* Make sure we can register our Zap channel type */
+ 	if(res) {
+@@ -10951,6 +12490,11 @@
+ 	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]));
++#ifdef ZAPATA_GSM
++	ast_cli_register(&gsm_send_sms);
++	ast_cli_register(&gsm_send_pdu);
++	ast_cli_register(&gsm_show_status);
++#endif
+ 	
+ 	memset(round_robin, 0, sizeof(round_robin));
+ 	ast_manager_register( "ZapTransfer", 0, action_transfer, "Transfer Zap Channel" );
+@@ -10959,11 +12503,46 @@
  	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");
@@ -8018,7 +8880,7 @@
  {
  #define	END_SILENCE_LEN 400
  #define	HEADER_MS 50
-@@ -10978,6 +12142,7 @@
+@@ -10982,6 +12561,7 @@
  	float scont = 0.0;
  	int index;
  
@@ -8026,58 +8888,9 @@
  	index = zt_get_index(c, p, 0);
  	if (index < 0) {
  		ast_log(LOG_WARNING, "Huh?  I don't exist?\n");
-diff -urN asterisk-1.2.4.orig/channels/Makefile asterisk-1.2.4/channels/Makefile
---- asterisk-1.2.4.orig/channels/Makefile	2005-12-15 11:52:30.000000000 +0100
-+++ asterisk-1.2.4/channels/Makefile	2006-01-31 09:41:43.000000000 +0100
-@@ -122,6 +122,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
-@@ -220,6 +249,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.4.orig/codecs/codec_ilbc.c asterisk-1.2.4/codecs/codec_ilbc.c
---- asterisk-1.2.4.orig/codecs/codec_ilbc.c	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.4/codecs/codec_ilbc.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/codecs/codec_ilbc.c asterisk-1.2.6/codecs/codec_ilbc.c
+--- asterisk-1.2.6.orig/codecs/codec_ilbc.c	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.6/codecs/codec_ilbc.c	2006-04-10 10:40:28.000000000 +0200
 @@ -49,7 +49,7 @@
  #include "slin_ilbc_ex.h"
  #include "ilbc_slin_ex.h"
@@ -8087,9 +8900,9 @@
  #define ILBC_MS 			30
  /* #define ILBC_MS			20 */
  
-diff -urN asterisk-1.2.4.orig/configs/capi.conf.sample asterisk-1.2.4/configs/capi.conf.sample
---- asterisk-1.2.4.orig/configs/capi.conf.sample	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.4/configs/capi.conf.sample	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/configs/capi.conf.sample asterisk-1.2.6/configs/capi.conf.sample
+--- asterisk-1.2.6.orig/configs/capi.conf.sample	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.6/configs/capi.conf.sample	2006-04-10 10:40:28.000000000 +0200
 @@ -0,0 +1,44 @@
 +;
 +; CAPI config
@@ -8135,17 +8948,17 @@
 +;msn=55512
 +;controller=2
 +;devices => 30
-diff -urN asterisk-1.2.4.orig/configs/modules.conf.sample asterisk-1.2.4/configs/modules.conf.sample
---- asterisk-1.2.4.orig/configs/modules.conf.sample	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.4/configs/modules.conf.sample	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/configs/modules.conf.sample asterisk-1.2.6/configs/modules.conf.sample
+--- asterisk-1.2.6.orig/configs/modules.conf.sample	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.6/configs/modules.conf.sample	2006-04-10 10:40:28.000000000 +0200
 @@ -51,3 +51,4 @@
  ; exported to modules loaded after them.
  ;
  [global]
 +chan_capi.so=yes
-diff -urN asterisk-1.2.4.orig/configs/watchdog.conf.sample asterisk-1.2.4/configs/watchdog.conf.sample
---- asterisk-1.2.4.orig/configs/watchdog.conf.sample	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.4/configs/watchdog.conf.sample	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/configs/watchdog.conf.sample asterisk-1.2.6/configs/watchdog.conf.sample
+--- asterisk-1.2.6.orig/configs/watchdog.conf.sample	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.6/configs/watchdog.conf.sample	2006-04-10 10:40:28.000000000 +0200
 @@ -0,0 +1,22 @@
 +;
 +; Configuration file for res_watchdog
@@ -8169,9 +8982,9 @@
 +;device = /dev/watchdog
 +;interval = 100
 +
-diff -urN asterisk-1.2.4.orig/configs/zapata.conf.sample asterisk-1.2.4/configs/zapata.conf.sample
---- asterisk-1.2.4.orig/configs/zapata.conf.sample	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.4/configs/zapata.conf.sample	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/configs/zapata.conf.sample asterisk-1.2.6/configs/zapata.conf.sample
+--- asterisk-1.2.6.orig/configs/zapata.conf.sample	2006-03-06 03:32:35.000000000 +0100
++++ asterisk-1.2.6/configs/zapata.conf.sample	2006-04-10 10:40:28.000000000 +0200
 @@ -121,9 +121,20 @@
  ; 
  ; outofband:      Signal Busy/Congestion out of band with RELEASE/DISCONNECT
@@ -8193,9 +9006,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 -urN asterisk-1.2.4.orig/db.c asterisk-1.2.4/db.c
---- asterisk-1.2.4.orig/db.c	2006-01-09 19:09:53.000000000 +0100
-+++ asterisk-1.2.4/db.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/db.c asterisk-1.2.6/db.c
+--- asterisk-1.2.6.orig/db.c	2006-01-09 19:09:53.000000000 +0100
++++ asterisk-1.2.6/db.c	2006-04-10 10:40:28.000000000 +0200
 @@ -516,11 +516,18 @@
  struct ast_cli_entry cli_database_deltree =
  { { "database", "deltree", NULL }, database_deltree, "Removes database keytree/values", database_deltree_usage };
@@ -8289,9 +9102,9 @@
 +	ast_manager_register("DBdel", EVENT_FLAG_SYSTEM, manager_dbdel, mandescr_dbdel);
  	return 0;
  }
-diff -urN asterisk-1.2.4.orig/devicestate.c asterisk-1.2.4/devicestate.c
---- asterisk-1.2.4.orig/devicestate.c	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.4/devicestate.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/devicestate.c asterisk-1.2.6/devicestate.c
+--- asterisk-1.2.6.orig/devicestate.c	2006-02-10 21:38:59.000000000 +0100
++++ asterisk-1.2.6/devicestate.c	2006-04-10 10:40:28.000000000 +0200
 @@ -62,6 +62,8 @@
  
  struct state_change {
@@ -8408,9 +9221,9 @@
  			free(cur);
  			AST_LIST_LOCK(&state_changes);
  		} else {
-diff -urN asterisk-1.2.4.orig/doc/README.asterisk.conf asterisk-1.2.4/doc/README.asterisk.conf
---- asterisk-1.2.4.orig/doc/README.asterisk.conf	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.4/doc/README.asterisk.conf	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/doc/README.asterisk.conf asterisk-1.2.6/doc/README.asterisk.conf
+--- asterisk-1.2.6.orig/doc/README.asterisk.conf	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.6/doc/README.asterisk.conf	2006-04-10 10:40:28.000000000 +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
@@ -8419,9 +9232,9 @@
  
  [files]
  ; Changing the following lines may compromise your security
-diff -urN asterisk-1.2.4.orig/editline/cygdef.h asterisk-1.2.4/editline/cygdef.h
---- asterisk-1.2.4.orig/editline/cygdef.h	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.4/editline/cygdef.h	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/editline/cygdef.h asterisk-1.2.6/editline/cygdef.h
+--- asterisk-1.2.6.orig/editline/cygdef.h	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.6/editline/cygdef.h	2006-04-10 10:40:29.000000000 +0200
 @@ -0,0 +1,11 @@
 +/* cygdef.h. Generated automatically by configure. */ 
 +#ifndef _CYGDEF_H_
@@ -8434,32 +9247,9 @@
 + 
 +
 +#endif /* _CYGDEF_H_ */
-diff -urN asterisk-1.2.4.orig/HARDWARE asterisk-1.2.4/HARDWARE
---- asterisk-1.2.4.orig/HARDWARE	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.4/HARDWARE	2006-01-31 09:41:43.000000000 +0100
-@@ -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
-+    
-+    * quadGSM PCI ISDN - 4 channel GSM interface
-+
- Non-zaptel compatible hardware
- ==============================
- 
-diff -urN asterisk-1.2.4.orig/include/asterisk/agi.h asterisk-1.2.4/include/asterisk/agi.h
---- asterisk-1.2.4.orig/include/asterisk/agi.h	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.4/include/asterisk/agi.h	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/include/asterisk/agi.h asterisk-1.2.6/include/asterisk/agi.h
+--- asterisk-1.2.6.orig/include/asterisk/agi.h	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.6/include/asterisk/agi.h	2006-04-10 10:40:29.000000000 +0200
 @@ -29,7 +29,8 @@
  
  typedef struct agi_state {
@@ -8470,43 +9260,9 @@
  	int ctrl;	/* FD for input control */
  } AGI;
  
-diff -urN asterisk-1.2.4.orig/include/asterisk/chan_capi_app.h asterisk-1.2.4/include/asterisk/chan_capi_app.h
---- asterisk-1.2.4.orig/include/asterisk/chan_capi_app.h	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.4/include/asterisk/chan_capi_app.h	2006-01-31 09:41:43.000000000 +0100
-@@ -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.4.orig/include/asterisk/chan_capi.h asterisk-1.2.4/include/asterisk/chan_capi.h
---- asterisk-1.2.4.orig/include/asterisk/chan_capi.h	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.4/include/asterisk/chan_capi.h	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/include/asterisk/chan_capi.h asterisk-1.2.6/include/asterisk/chan_capi.h
+--- asterisk-1.2.6.orig/include/asterisk/chan_capi.h	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.6/include/asterisk/chan_capi.h	2006-04-10 10:40:29.000000000 +0200
 @@ -0,0 +1,276 @@
 +/*
 + * (CAPI*)
@@ -8784,9 +9540,43 @@
 +#define CAPI_ETSI_NPLAN_INTERNAT	0x10
 +
 +#endif
-diff -urN asterisk-1.2.4.orig/include/asterisk/channel.h asterisk-1.2.4/include/asterisk/channel.h
---- asterisk-1.2.4.orig/include/asterisk/channel.h	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.4/include/asterisk/channel.h	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/include/asterisk/chan_capi_app.h asterisk-1.2.6/include/asterisk/chan_capi_app.h
+--- asterisk-1.2.6.orig/include/asterisk/chan_capi_app.h	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.6/include/asterisk/chan_capi_app.h	2006-04-10 10:40:29.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 -urN asterisk-1.2.6.orig/include/asterisk/channel.h asterisk-1.2.6/include/asterisk/channel.h
+--- asterisk-1.2.6.orig/include/asterisk/channel.h	2006-02-11 19:15:00.000000000 +0100
++++ asterisk-1.2.6/include/asterisk/channel.h	2006-04-10 10:40:29.000000000 +0200
 @@ -86,6 +86,9 @@
  #ifndef _ASTERISK_CHANNEL_H
  #define _ASTERISK_CHANNEL_H
@@ -8806,7 +9596,7 @@
  
  	/* Why is the channel hanged up */
  	int hangupcause;
-@@ -531,6 +534,11 @@
+@@ -533,6 +536,11 @@
  #define AST_STATE_MUTE		(1 << 16)	
  /*! @} */
  
@@ -8818,7 +9608,7 @@
  /*! \brief Change the state of a channel */
  int ast_setstate(struct ast_channel *chan, int state);
  
-@@ -567,7 +575,7 @@
+@@ -569,7 +577,7 @@
   * by the low level module
   * \return Returns an ast_channel on success, NULL on failure.
   */
@@ -8827,7 +9617,7 @@
  
  /*!
   * \brief Request a channel of a given type, with data as optional information used 
-@@ -582,9 +590,9 @@
+@@ -584,9 +592,9 @@
   * \return Returns an ast_channel on success or no answer, NULL on failure.  Check the value of chan->_state
   * to know if the call was answered or not.
   */
@@ -8839,7 +9629,7 @@
  
  /*!\brief Register a channel technology (a new channel driver)
   * Called by a channel module to register the kind of channels it supports.
-@@ -837,6 +845,10 @@
+@@ -839,6 +847,10 @@
  /*--- ast_get_channel_by_exten_locked: Get channel by exten (and optionally context) and lock it */
  struct ast_channel *ast_get_channel_by_exten_locked(const char *exten, const char *context);
  
@@ -8850,7 +9640,7 @@
  /*! Waits for a digit */
  /*! 
   * \param c channel to wait for a digit on
-@@ -907,6 +919,9 @@
+@@ -909,6 +921,9 @@
     p->owner pointer) that is affected by the change.  The physical layer of the original
     channel is hung up.  */
  int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clone);
@@ -8860,9 +9650,9 @@
  
  /*! Gives the string form of a given cause code */
  /*! 
-diff -urN asterisk-1.2.4.orig/include/asterisk/devicestate.h asterisk-1.2.4/include/asterisk/devicestate.h
---- asterisk-1.2.4.orig/include/asterisk/devicestate.h	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.4/include/asterisk/devicestate.h	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/include/asterisk/devicestate.h asterisk-1.2.6/include/asterisk/devicestate.h
+--- asterisk-1.2.6.orig/include/asterisk/devicestate.h	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.6/include/asterisk/devicestate.h	2006-04-10 10:40:29.000000000 +0200
 @@ -42,7 +42,7 @@
  /*! Device is ringing */
  #define AST_DEVICE_RINGING	6
@@ -8881,9 +9671,9 @@
  
  /*! \brief Registers a device state change callback 
   * \param callback Callback
-diff -urN asterisk-1.2.4.orig/include/asterisk/features.h asterisk-1.2.4/include/asterisk/features.h
---- asterisk-1.2.4.orig/include/asterisk/features.h	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.4/include/asterisk/features.h	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/include/asterisk/features.h asterisk-1.2.6/include/asterisk/features.h
+--- asterisk-1.2.6.orig/include/asterisk/features.h	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.6/include/asterisk/features.h	2006-04-10 10:40:29.000000000 +0200
 @@ -45,6 +45,8 @@
  };
  
@@ -8926,9 +9716,9 @@
 +extern struct ast_call_feature *ast_find_builtin_feature(char *name);
 +
  #endif /* _AST_FEATURES_H */
-diff -urN asterisk-1.2.4.orig/include/asterisk/pbx.h asterisk-1.2.4/include/asterisk/pbx.h
---- asterisk-1.2.4.orig/include/asterisk/pbx.h	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.4/include/asterisk/pbx.h	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/include/asterisk/pbx.h asterisk-1.2.6/include/asterisk/pbx.h
+--- asterisk-1.2.6.orig/include/asterisk/pbx.h	2006-02-11 19:15:00.000000000 +0100
++++ asterisk-1.2.6/include/asterisk/pbx.h	2006-04-10 13:40:23.000000000 +0200
 @@ -57,7 +57,7 @@
  	AST_EXTENSION_BUSY = 1 << 1,
  	/*! All devices UNAVAILABLE/UNREGISTERED */
@@ -8975,13 +9765,13 @@
  void ast_func_write(struct ast_channel *chan, const char *in, const char *value);
  
 -void ast_hint_state_changed(const char *device);
-+void ast_hint_state_changed(const char *device, const char *cid_num, const char *cid_name);
++void ast_hint_state_changed(const char *device, char *cid_num, char *cid_name);
  
  #if defined(__cplusplus) || defined(c_plusplus)
  }
-diff -urN asterisk-1.2.4.orig/include/asterisk/xlaw.h asterisk-1.2.4/include/asterisk/xlaw.h
---- asterisk-1.2.4.orig/include/asterisk/xlaw.h	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.4/include/asterisk/xlaw.h	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/include/asterisk/xlaw.h asterisk-1.2.6/include/asterisk/xlaw.h
+--- asterisk-1.2.6.orig/include/asterisk/xlaw.h	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.6/include/asterisk/xlaw.h	2006-04-10 10:40:29.000000000 +0200
 @@ -0,0 +1,1665 @@
 +#ifndef _ASTERISK_XLAW_H
 +#define _ASTERISK_XLAW_H
@@ -10648,9 +11438,9 @@
 +#endif // CAPI_ULAW
 +#endif
 +
-diff -urN asterisk-1.2.4.orig/include/asterisk.h asterisk-1.2.4/include/asterisk.h
---- asterisk-1.2.4.orig/include/asterisk.h	2005-11-30 04:37:37.000000000 +0100
-+++ asterisk-1.2.4/include/asterisk.h	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/include/asterisk.h asterisk-1.2.6/include/asterisk.h
+--- asterisk-1.2.6.orig/include/asterisk.h	2005-11-30 04:37:37.000000000 +0100
++++ asterisk-1.2.6/include/asterisk.h	2006-04-10 10:40:29.000000000 +0200
 @@ -36,6 +36,7 @@
  extern char ast_config_AST_PID[AST_CONFIG_MAX_PATH];
  extern char ast_config_AST_SOCKET[AST_CONFIG_MAX_PATH];
@@ -10659,37 +11449,9 @@
  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 -urN asterisk-1.2.4.orig/LICENSE asterisk-1.2.4/LICENSE
---- asterisk-1.2.4.orig/LICENSE	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.4/LICENSE	2006-01-31 09:41:43.000000000 +0100
-@@ -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.4.orig/Makefile asterisk-1.2.4/Makefile
---- asterisk-1.2.4.orig/Makefile	2005-12-05 07:47:51.000000000 +0100
-+++ asterisk-1.2.4/Makefile	2006-01-31 09:41:43.000000000 +0100
-@@ -759,6 +759,9 @@
- 		echo ";astctlowner = root" ; \
- 		echo ";astctlgroup = apache" ; \
- 		echo ";astctl = asterisk.ctl" ; \
-+		echo "[options]" ; \
-+		echo "uniquename = asterisk" ;\
-+		echo "silence_suppression = yes" ;\
- 		) > $(DESTDIR)$(ASTCONFPATH) ; \
- 	else \
- 		echo "Skipping asterisk.conf creation"; \
-diff -urN asterisk-1.2.4.orig/manager.c asterisk-1.2.4/manager.c
---- asterisk-1.2.4.orig/manager.c	2006-01-09 05:52:16.000000000 +0100
-+++ asterisk-1.2.4/manager.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/manager.c asterisk-1.2.6/manager.c
+--- asterisk-1.2.6.orig/manager.c	2006-02-11 19:15:00.000000000 +0100
++++ asterisk-1.2.6/manager.c	2006-04-10 11:07:15.000000000 +0200
 @@ -11,6 +11,9 @@
   * the project provides a web site, mailing lists and IRC
   * channels for your use.
@@ -10707,17 +11469,17 @@
 +#include "asterisk/astdb.h"
  
  struct fast_originate_helper {
- 	char tech[256];
-@@ -75,6 +79,8 @@
- 	char exten[256];
- 	char idtext[256];
+ 	char tech[AST_MAX_MANHEADER_LEN];
+@@ -76,6 +80,8 @@
+ 	char idtext[AST_MAX_MANHEADER_LEN];
+ 	char account[AST_MAX_ACCOUNT_CODE];
  	int priority;
 +	int callingpres;
 +	char uniqueid[64];
  	struct ast_variable *vars;
  };
  
-@@ -656,11 +662,17 @@
+@@ -657,11 +663,17 @@
  {
  	struct ast_channel *c = NULL;
  	char *name = astman_get_header(m, "Channel");
@@ -10738,7 +11500,7 @@
  	if (!c) {
  		astman_send_error(s, m, "No such channel");
  		return 0;
-@@ -759,6 +771,7 @@
+@@ -760,6 +772,7 @@
  }
  
  
@@ -10746,7 +11508,7 @@
  /*! \brief  action_status: Manager "status" command to show channels */
  /* Needs documentation... */
  static int action_status(struct mansession *s, struct message *m)
-@@ -865,32 +878,50 @@
+@@ -866,32 +879,50 @@
  	char *exten = astman_get_header(m, "Exten");
  	char *context = astman_get_header(m, "Context");
  	char *priority = astman_get_header(m, "Priority");
@@ -10803,7 +11565,7 @@
  			else
  				res = -1;
  			if (!res)
-@@ -936,15 +967,15 @@
+@@ -937,15 +968,15 @@
  	struct ast_channel *chan = NULL;
  
  	if (!ast_strlen_zero(in->app)) {
@@ -10823,7 +11585,7 @@
  	}   
  	if (!res)
  		manager_event(EVENT_FLAG_CALL,
-@@ -955,7 +986,7 @@
+@@ -956,7 +987,7 @@
  			"Exten: %s\r\n"
  			"Reason: %d\r\n"
  			"Uniqueid: %s\r\n",
@@ -10832,7 +11594,7 @@
  	else
  		manager_event(EVENT_FLAG_CALL,
  			"OriginateFailure",
-@@ -965,7 +996,7 @@
+@@ -966,7 +997,7 @@
  			"Exten: %s\r\n"
  			"Reason: %d\r\n"
  			"Uniqueid: %s\r\n",
@@ -10841,7 +11603,7 @@
  
  	/* Locked by ast_pbx_outgoing_exten or ast_pbx_outgoing_app */
  	if (chan)
-@@ -998,6 +1029,7 @@
+@@ -999,6 +1030,7 @@
  	char *priority = astman_get_header(m, "Priority");
  	char *timeout = astman_get_header(m, "Timeout");
  	char *callerid = astman_get_header(m, "CallerID");
@@ -10849,7 +11611,7 @@
  	char *account = astman_get_header(m, "Account");
  	char *app = astman_get_header(m, "Application");
  	char *appdata = astman_get_header(m, "Data");
-@@ -1006,12 +1038,15 @@
+@@ -1007,12 +1039,15 @@
  	struct ast_variable *vars = astman_get_variables(m);
  	char *tech, *data;
  	char *l=NULL, *n=NULL;
@@ -10865,7 +11627,7 @@
  	
  	pthread_t th;
  	pthread_attr_t attr;
-@@ -1027,6 +1062,10 @@
+@@ -1028,6 +1063,10 @@
  		astman_send_error(s, m, "Invalid timeout\n");
  		return 0;
  	}
@@ -10876,15 +11638,15 @@
  	ast_copy_string(tmp, name, sizeof(tmp));
  	tech = tmp;
  	data = strchr(tmp, '/');
-@@ -1053,6 +1092,7 @@
- 		newvar->next = vars;
- 		vars = newvar;
+@@ -1048,6 +1087,7 @@
+ 		if (ast_strlen_zero(l))
+ 			l = NULL;
  	}
 + 	uniqueid = ast_alloc_uniqueid();
  	if (ast_true(async)) {
  		struct fast_originate_helper *fast = malloc(sizeof(struct fast_originate_helper));
  		if (!fast) {
-@@ -1072,8 +1113,10 @@
+@@ -1068,8 +1108,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));
@@ -10895,12 +11657,12 @@
  			pthread_attr_init(&attr);
  			pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
  			if (ast_pthread_create(&th, &attr, fast_originate, fast)) {
-@@ -1083,19 +1125,28 @@
+@@ -1079,19 +1121,28 @@
  			}
  		}
  	} else if (!ast_strlen_zero(app)) {
 -        	res = ast_pbx_outgoing_app(tech, AST_FORMAT_SLINEAR, data, to, app, appdata, &reason, 1, l, n, vars, account, NULL);
-+        	res = ast_pbx_outgoing_app(tech, AST_FORMAT_SLINEAR, data, to, app, appdata, &reason, 1, cpresi, l, n, vars, account, NULL, uniqueid);
++     		res = ast_pbx_outgoing_app(tech, AST_FORMAT_SLINEAR, data, to, app, appdata, &reason, 1, cpresi, l, n, vars, account, NULL, uniqueid);
      	} else {
  		if (exten && context && pi)
 -	        	res = ast_pbx_outgoing_exten(tech, AST_FORMAT_SLINEAR, data, to, context, exten, pi, &reason, 1, l, n, vars, account, NULL);
@@ -10915,7 +11677,7 @@
 -	else
 + 	if (!res) {
 + 	        if (id && !ast_strlen_zero(id)) {
-+          	    snprintf(idText,256,"ActionID: %s\r\n",id);
++       		    snprintf(idText,256,"ActionID: %s\r\n",id);
 +  		}
 + 		ast_cli(s->fd, "Response: Success\r\n"
 + 				    "%s"
@@ -10929,7 +11691,7 @@
  	return 0;
  }
  
-@@ -1569,10 +1620,10 @@
+@@ -1565,10 +1616,10 @@
  	return 0;
  }
  
@@ -10942,10 +11704,10 @@
  	return 0;
  }
  
-diff -urN asterisk-1.2.4.orig/pbx/pbx_spool.c asterisk-1.2.4/pbx/pbx_spool.c
---- asterisk-1.2.4.orig/pbx/pbx_spool.c	2006-01-09 21:08:24.000000000 +0100
-+++ asterisk-1.2.4/pbx/pbx_spool.c	2006-01-31 09:41:43.000000000 +0100
-@@ -260,11 +260,11 @@
+diff -urN asterisk-1.2.6.orig/pbx/pbx_spool.c asterisk-1.2.6/pbx/pbx_spool.c
+--- asterisk-1.2.6.orig/pbx/pbx_spool.c	2006-02-11 19:15:00.000000000 +0100
++++ asterisk-1.2.6/pbx/pbx_spool.c	2006-04-10 10:56:30.000000000 +0200
+@@ -259,11 +259,11 @@
  	if (!ast_strlen_zero(o->app)) {
  		if (option_verbose > 2)
  			ast_verbose(VERBOSE_PREFIX_3 "Attempting call on %s/%s for application %s(%s) (Retry %d)\n", o->tech, o->dest, o->app, o->data, o->retries);
@@ -10959,10 +11721,10 @@
  	}
  	if (res) {
  		ast_log(LOG_NOTICE, "Call failed to go through, reason %d\n", reason);
-diff -urN asterisk-1.2.4.orig/pbx.c asterisk-1.2.4/pbx.c
---- asterisk-1.2.4.orig/pbx.c	2006-01-22 03:05:41.000000000 +0100
-+++ asterisk-1.2.4/pbx.c	2006-01-31 09:41:43.000000000 +0100
-@@ -350,7 +350,8 @@
+diff -urN asterisk-1.2.6.orig/pbx.c asterisk-1.2.6/pbx.c
+--- asterisk-1.2.6.orig/pbx.c	2006-03-22 21:59:21.000000000 +0100
++++ asterisk-1.2.6/pbx.c	2006-04-10 13:40:34.000000000 +0200
+@@ -351,7 +351,8 @@
  	
  	{ "Hangup", pbx_builtin_hangup,
  	"Hang up the calling channel",
@@ -10977,7 +11739,7 @@
  }
  
 -void ast_hint_state_changed(const char *device)
-+void ast_hint_state_changed(const char *device, const char *cid_num, const char *cid_name)
++void ast_hint_state_changed(const char *device, char *cid_num, char *cid_name)
  {
  	struct ast_hint *hint;
  	struct ast_state_cb *cblist;
@@ -11013,7 +11775,7 @@
  				free(prevcb);
  	    		}
  		} else {
-@@ -4957,7 +4958,7 @@
+@@ -4958,7 +4959,7 @@
  	return 0;  /* success */
  }
  
@@ -11022,7 +11784,7 @@
  {
  	struct ast_channel *chan;
  	struct async_stat *as;
-@@ -4967,7 +4968,7 @@
+@@ -4968,7 +4969,7 @@
  
  	if (sync) {
  		LOAD_OH(oh);
@@ -11031,7 +11793,7 @@
  		if (channel) {
  			*channel = chan;
  			if (chan)
-@@ -5063,7 +5064,7 @@
+@@ -5066,7 +5067,7 @@
  			goto outgoing_exten_cleanup;
  		}	
  		memset(as, 0, sizeof(struct async_stat));
@@ -11040,7 +11802,7 @@
  		if (channel) {
  			*channel = chan;
  			if (chan)
-@@ -5105,7 +5106,7 @@
+@@ -5110,7 +5111,7 @@
  	pthread_t t;
  };
  
@@ -11049,7 +11811,7 @@
  {
  	struct app_tmp *tmp = data;
  	struct ast_app *app;
-@@ -5121,7 +5122,7 @@
+@@ -5126,7 +5127,7 @@
  	return NULL;
  }
  
@@ -11058,7 +11820,7 @@
  {
  	struct ast_channel *chan;
  	struct async_stat *as;
-@@ -5140,7 +5141,7 @@
+@@ -5146,7 +5147,7 @@
  		goto outgoing_app_cleanup;	
  	}
  	if (sync) {
@@ -11067,7 +11829,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);
-@@ -5225,7 +5226,8 @@
+@@ -5233,7 +5234,8 @@
  			goto outgoing_app_cleanup;
  		}
  		memset(as, 0, sizeof(struct async_stat));
@@ -11077,7 +11839,7 @@
  		if (!chan) {
  			free(as);
  			res = -1;
-@@ -5510,6 +5512,9 @@
+@@ -5520,6 +5522,9 @@
   */
  static int pbx_builtin_hangup(struct ast_channel *chan, void *data)
  {
@@ -11087,7 +11849,7 @@
  	/* Just return non-zero and it will hang up */
  	if (!chan->hangupcause)
  		chan->hangupcause = AST_CAUSE_NORMAL_CLEARING;
-@@ -6151,6 +6156,9 @@
+@@ -6176,6 +6181,9 @@
  			return -1;
  		}
  	}
@@ -11097,7 +11859,7 @@
  	return res = ast_say_number(chan, atoi((char *) tmp), "", chan->language, options);
  }
  
-@@ -6158,8 +6166,12 @@
+@@ -6183,8 +6191,12 @@
  {
  	int res = 0;
  
@@ -11111,7 +11873,7 @@
  	return res;
  }
  	
-@@ -6167,8 +6179,12 @@
+@@ -6192,8 +6204,12 @@
  {
  	int res = 0;
  
@@ -11125,7 +11887,7 @@
  	return res;
  }
  	
-@@ -6176,8 +6192,12 @@
+@@ -6201,8 +6217,12 @@
  {
  	int res = 0;
  
@@ -11139,171 +11901,9 @@
  	return res;
  }
  	
-diff -urN asterisk-1.2.4.orig/README asterisk-1.2.4/README
---- asterisk-1.2.4.orig/README	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.4/README	2006-01-31 09:41:43.000000000 +0100
-@@ -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.4.orig/README.chan_capi asterisk-1.2.4/README.chan_capi
---- asterisk-1.2.4.orig/README.chan_capi	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.4/README.chan_capi	2006-01-31 09:41:43.000000000 +0100
-@@ -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.4.orig/res/Makefile asterisk-1.2.4/res/Makefile
---- asterisk-1.2.4.orig/res/Makefile	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.4/res/Makefile	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/res/Makefile asterisk-1.2.6/res/Makefile
+--- asterisk-1.2.6.orig/res/Makefile	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.6/res/Makefile	2006-04-10 10:40:29.000000000 +0200
 @@ -11,7 +11,7 @@
  # the GNU General Public License
  #
@@ -11313,9 +11913,9 @@
  
  ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/odbcinst.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/odbcinst.h),)
    ifneq (${OSARCH},FreeBSD)
-diff -urN asterisk-1.2.4.orig/res/res_agi.c asterisk-1.2.4/res/res_agi.c
---- asterisk-1.2.4.orig/res/res_agi.c	2005-12-20 21:21:26.000000000 +0100
-+++ asterisk-1.2.4/res/res_agi.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/res/res_agi.c asterisk-1.2.6/res/res_agi.c
+--- asterisk-1.2.6.orig/res/res_agi.c	2006-02-28 19:31:04.000000000 +0100
++++ asterisk-1.2.6/res/res_agi.c	2006-04-10 10:59:02.000000000 +0200
 @@ -11,6 +11,9 @@
   * the project provides a web site, mailing lists and IRC
   * channels for your use.
@@ -11347,18 +11947,16 @@
  "program on a channel. AGI allows Asterisk to launch external programs\n"
  "written in any language to control a telephony channel, play audio,\n"
  "read DTMF digits, etc. by communicating with the AGI protocol on stdin\n"
-@@ -91,7 +97,9 @@
- "Returns -1 on hangup (except for DeadAGI) or if application requested\n"
+@@ -92,6 +98,8 @@
  " hangup, or 0 on non-hangup exit. \n"
  "Using 'EAGI' provides enhanced AGI, with incoming audio available out of band\n"
--"on file descriptor 3\n\n"
-+" on file descriptor 3\n"
+ "on file descriptor 3\n\n"
 +"Using 'XAGI' provides enhanced AGI, with incoming audio available out of band"
 +" on file descriptor 3 and outgoing audio available out of band on file descriptor 4\n\n"
  "Use the CLI command 'show agi' to list available agi commands\n";
  
  static int agidebug = 0;
-@@ -214,13 +222,14 @@
+@@ -220,13 +228,14 @@
  	return 0;
  }
  
@@ -11374,7 +11972,7 @@
  	int x;
  	int res;
  	sigset_t signal_set;
-@@ -265,6 +274,33 @@
+@@ -271,6 +280,33 @@
  			return -1;
  		}
  	}
@@ -11408,7 +12006,7 @@
  	pid = fork();
  	if (pid < 0) {
  		ast_log(LOG_WARNING, "Failed to fork(): %s\n", strerror(errno));
-@@ -279,15 +315,19 @@
+@@ -285,15 +321,19 @@
  		} else {
  			close(STDERR_FILENO + 1);
  		}
@@ -11430,7 +12028,7 @@
  			close(x);
  
  		/* Don't run AGI scripts with realtime priority -- it causes audio stutter */
-@@ -306,6 +346,9 @@
+@@ -312,6 +352,9 @@
  	if (efd) {
  		*efd = audio[1];
  	}
@@ -11440,7 +12038,7 @@
  	/* close what we're not using in the parent */
  	close(toast[1]);
  	close(fromast[0]);
-@@ -314,6 +357,9 @@
+@@ -320,6 +363,9 @@
  		/* [PHM 12/18/03] */
  		close(audio[0]);
  	}
@@ -11450,7 +12048,7 @@
  
  	*opid = pid;
  	return 0;
-@@ -344,7 +390,7 @@
+@@ -350,7 +396,7 @@
  	fdprintf(fd, "agi_context: %s\n", chan->context);
  	fdprintf(fd, "agi_extension: %s\n", chan->exten);
  	fdprintf(fd, "agi_priority: %d\n", chan->priority);
@@ -11459,7 +12057,7 @@
  
  	/* User information */
  	fdprintf(fd, "agi_accountcode: %s\n", chan->accountcode ? chan->accountcode : "");
-@@ -376,7 +422,7 @@
+@@ -382,7 +428,7 @@
  		return RESULT_SHOWUSAGE;
  	if (sscanf(argv[3], "%d", &to) != 1)
  		return RESULT_SHOWUSAGE;
@@ -11468,7 +12066,7 @@
  	fdprintf(agi->fd, "200 result=%d\n", res);
  	if (res >= 0)
  		return RESULT_SUCCESS;
-@@ -552,7 +598,7 @@
+@@ -558,7 +604,7 @@
  		else
  			return RESULT_FAILURE;
  	}
@@ -11477,7 +12075,7 @@
  	/* 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;
-@@ -612,7 +658,7 @@
+@@ -618,7 +664,7 @@
                  else
                          return RESULT_FAILURE;
          }
@@ -11486,7 +12084,7 @@
          /* 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;
-@@ -624,7 +670,7 @@
+@@ -630,7 +676,7 @@
  
  	/* If the user didnt press a key, wait for digitTimeout*/
  	if (res == 0 ) {
@@ -11495,7 +12093,7 @@
  		/* Make sure the new result is in the escape digits of the GET OPTION */
  		if ( !strchr(edigits,res) )
                  	res=0;
-@@ -651,7 +697,7 @@
+@@ -657,7 +703,7 @@
  		return RESULT_SHOWUSAGE;
  	if (sscanf(argv[2], "%d", &num) != 1)
  		return RESULT_SHOWUSAGE;
@@ -11504,7 +12102,7 @@
  	if (res == 1)
  		return RESULT_SUCCESS;
  	fdprintf(agi->fd, "200 result=%d\n", res);
-@@ -671,7 +717,7 @@
+@@ -677,7 +723,7 @@
  	if (sscanf(argv[2], "%d", &num) != 1)
  		return RESULT_SHOWUSAGE;
  
@@ -11513,7 +12111,7 @@
  	if (res == 1) /* New command */
  		return RESULT_SUCCESS;
  	fdprintf(agi->fd, "200 result=%d\n", res);
-@@ -688,7 +734,7 @@
+@@ -694,7 +740,7 @@
  	if (argc != 4)
  		return RESULT_SHOWUSAGE;
  
@@ -11522,7 +12120,7 @@
  	if (res == 1) /* New command */
  		return RESULT_SUCCESS;
  	fdprintf(agi->fd, "200 result=%d\n", res);
-@@ -778,7 +824,7 @@
+@@ -784,7 +830,7 @@
  	if (argc != 4)
  		return RESULT_SHOWUSAGE;
  
@@ -11531,7 +12129,7 @@
  	if (res == 1) /* New command */
  		return RESULT_SUCCESS;
  	fdprintf(agi->fd, "200 result=%d\n", res);
-@@ -805,7 +851,7 @@
+@@ -811,7 +857,7 @@
  		max = atoi(argv[4]); 
  	else
  		max = 1024;
@@ -11540,7 +12138,7 @@
  	if (res == 2)			/* New command */
  		return RESULT_SUCCESS;
  	else if (res == 1)
-@@ -1843,7 +1889,12 @@
+@@ -1849,7 +1895,12 @@
  	int ms;
  	int returnstatus = 0;
  	struct ast_frame *f;
@@ -11553,7 +12151,7 @@
  	FILE *readf;
  	/* how many times we'll retry if ast_waitfor_nandfs will return without either 
  	  channel or file descriptor in case select is interrupted by a system call (EINTR) */
-@@ -1857,10 +1908,22 @@
+@@ -1863,10 +1914,22 @@
  		return -1;
  	}
  	setlinebuf(readf);
@@ -11578,7 +12176,7 @@
  		if (c) {
  			retry = RETRY;
  			/* Idle the channel until we get a command */
-@@ -1871,13 +1934,24 @@
+@@ -1877,13 +1940,24 @@
  				break;
  			} else {
  				/* If it's voice, write it to the audio pipe */
@@ -11605,7 +12203,7 @@
  			retry = RETRY;
  			if (!fgets(buf, sizeof(buf), readf)) {
  				/* Program terminated */
-@@ -1899,6 +1973,7 @@
+@@ -1905,6 +1979,7 @@
  			if ((returnstatus < 0) || (returnstatus == AST_PBX_KEEPALIVE)) {
  				break;
  			}
@@ -11613,7 +12211,7 @@
  		} else {
  			if (--retry <= 0) {
  				ast_log(LOG_WARNING, "No channel, no fd?\n");
-@@ -2005,6 +2080,7 @@
+@@ -2011,6 +2086,7 @@
  	int argc = 0;
  	int fds[2];
  	int efd = -1;
@@ -11621,7 +12219,7 @@
  	int pid;
          char *stringp;
  	AGI agi;
-@@ -2030,15 +2106,18 @@
+@@ -2036,15 +2112,18 @@
  		}
  	}
  #endif
@@ -11642,7 +12240,7 @@
  	}
  	LOCAL_USER_REMOVE(u);
  	return res;
-@@ -2072,6 +2151,35 @@
+@@ -2078,6 +2157,35 @@
  	return res;
  }
  
@@ -11678,7 +12276,7 @@
  static int deadagi_exec(struct ast_channel *chan, void *data)
  {
  	return agi_exec_full(chan, data, 0, 1);
-@@ -2101,6 +2209,7 @@
+@@ -2107,6 +2215,7 @@
  	ast_cli_unregister(&dumpagihtml);
  	ast_cli_unregister(&cli_debug);
  	ast_cli_unregister(&cli_no_debug);
@@ -11686,7 +12284,7 @@
  	ast_unregister_application(eapp);
  	ast_unregister_application(deadapp);
  	return ast_unregister_application(app);
-@@ -2114,6 +2223,7 @@
+@@ -2120,6 +2229,7 @@
  	ast_cli_register(&cli_no_debug);
  	ast_register_application(deadapp, deadagi_exec, deadsynopsis, descrip);
  	ast_register_application(eapp, eagi_exec, esynopsis, descrip);
@@ -11694,9 +12292,9 @@
  	return ast_register_application(app, agi_exec, synopsis, descrip);
  }
  
-diff -urN asterisk-1.2.4.orig/res/res_features.c asterisk-1.2.4/res/res_features.c
---- asterisk-1.2.4.orig/res/res_features.c	2006-01-17 19:29:57.000000000 +0100
-+++ asterisk-1.2.4/res/res_features.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/res/res_features.c asterisk-1.2.6/res/res_features.c
+--- asterisk-1.2.6.orig/res/res_features.c	2006-03-23 22:51:50.000000000 +0100
++++ asterisk-1.2.6/res/res_features.c	2006-04-10 11:03:19.000000000 +0200
 @@ -11,6 +11,10 @@
   * the project provides a web site, mailing lists and IRC
   * channels for your use.
@@ -11892,7 +12490,7 @@
  		ast_set_callerid(chan, cid_num, cid_name, cid_num);
  		ast_channel_inherit_variables(caller, chan);	
  		if (!ast_call(chan, data, timeout)) {
-@@ -1538,9 +1616,10 @@
+@@ -1541,9 +1619,10 @@
  					"Channel: %s\r\n"
  					"CallerID: %s\r\n"
  					"CallerIDName: %s\r\n"
@@ -11904,7 +12502,7 @@
  					);
  
  				if (option_verbose > 1) 
-@@ -1583,9 +1662,10 @@
+@@ -1586,9 +1665,10 @@
  								"Channel: %s\r\n"
  								"CallerID: %s\r\n"
  								"CallerIDName: %s\r\n"
@@ -11916,7 +12514,7 @@
  								);
  
  							/* There's a problem, hang them up*/
-@@ -1672,6 +1752,280 @@
+@@ -1675,6 +1755,280 @@
  	return res;
  }
  
@@ -12197,7 +12795,7 @@
  static int park_exec(struct ast_channel *chan, void *data)
  {
  	int res=0;
-@@ -1720,9 +2074,10 @@
+@@ -1723,9 +2077,10 @@
  			"From: %s\r\n"
  			"CallerID: %s\r\n"
  			"CallerIDName: %s\r\n"
@@ -12209,7 +12807,7 @@
  			);
  
  		free(pu);
-@@ -1890,12 +2245,13 @@
+@@ -1893,12 +2248,13 @@
  			"Timeout: %ld\r\n"
  			"CallerID: %s\r\n"
  			"CallerIDName: %s\r\n"
@@ -12224,7 +12822,7 @@
  			,idText);
  
              cur = cur->next;
-@@ -1911,6 +2267,386 @@
+@@ -1914,6 +2270,386 @@
          return RESULT_SUCCESS;
  }
  
@@ -12611,7 +13209,7 @@
  
  int ast_pickup_call(struct ast_channel *chan)
  {
-@@ -2064,7 +2800,7 @@
+@@ -2067,7 +2803,7 @@
  			}
  
  			{
@@ -12620,7 +13218,7 @@
  				int mallocd=0;
  				
  				if (!feature) {
-@@ -2140,14 +2876,22 @@
+@@ -2143,14 +2879,22 @@
  	if ((res = load_config()))
  		return res;
  	ast_cli_register(&showparked);
@@ -12643,7 +13241,7 @@
  	return res;
  }
  
-@@ -2158,7 +2902,11 @@
+@@ -2161,7 +2905,11 @@
  
  	ast_manager_unregister("ParkedCalls");
  	ast_cli_unregister(&showfeatures);
@@ -12655,9 +13253,9 @@
  	ast_unregister_application(parkcall);
  	return ast_unregister_application(parkedcall);
  }
-diff -urN asterisk-1.2.4.orig/res/res_watchdog.c asterisk-1.2.4/res/res_watchdog.c
---- asterisk-1.2.4.orig/res/res_watchdog.c	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.4/res/res_watchdog.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/res/res_watchdog.c asterisk-1.2.6/res/res_watchdog.c
+--- asterisk-1.2.6.orig/res/res_watchdog.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.6/res/res_watchdog.c	2006-04-10 10:40:29.000000000 +0200
 @@ -0,0 +1,148 @@
 +/*
 + * Asterisk -- A telephony toolkit for Linux.
@@ -12807,9 +13405,9 @@
 +{
 +	return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.4.orig/rtp.c asterisk-1.2.4/rtp.c
---- asterisk-1.2.4.orig/rtp.c	2005-11-30 15:27:59.000000000 +0100
-+++ asterisk-1.2.4/rtp.c	2006-01-31 09:41:43.000000000 +0100
+diff -urN asterisk-1.2.6.orig/rtp.c asterisk-1.2.6/rtp.c
+--- asterisk-1.2.6.orig/rtp.c	2006-03-15 19:07:06.000000000 +0100
++++ asterisk-1.2.6/rtp.c	2006-04-10 10:40:29.000000000 +0200
 @@ -442,6 +442,11 @@
  	struct rtpPayloadType rtpPT;
  	
@@ -12822,9 +13420,3 @@
  	
  	/* 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.4.orig/.version asterisk-1.2.4/.version
---- asterisk-1.2.4.orig/.version	2006-01-31 04:55:50.000000000 +0100
-+++ asterisk-1.2.4/.version	2006-01-31 09:41:43.000000000 +0100
-@@ -1 +1 @@
--1.2.6
-+1.2.6-BRIstuffed-0.3.0-PRE-1k

Modified: asterisk/branches/sarge/debian/patches/nomarch.dpatch
===================================================================
--- asterisk/branches/sarge/debian/patches/nomarch.dpatch	2006-04-14 10:29:53 UTC (rev 1579)
+++ asterisk/branches/sarge/debian/patches/nomarch.dpatch	2006-04-14 10:42:06 UTC (rev 1580)
@@ -2,7 +2,7 @@
 ## nomarch.dpatch by Kilian Krause <kilian at debian.org>
 ##
 ## All lines beginning with `## DP:' are a description of the patch.
-## DP: No description.
+## DP: Don't optimize for i686 anywhere
 
 @DPATCH@
 diff -urNad asterisk-1.2.0.dfsg~/Makefile asterisk-1.2.0.dfsg/Makefile
@@ -19,39 +19,3 @@
  ifeq ($(PROC),ppc)
    ASTCFLAGS+=-fsigned-char
  endif
-diff -urNad asterisk-1.2.0.dfsg~/codecs/gsm/Makefile asterisk-1.2.0.dfsg/codecs/gsm/Makefile
---- asterisk-1.2.0.dfsg~/codecs/gsm/Makefile	2005-11-08 03:31:45.000000000 +0000
-+++ asterisk-1.2.0.dfsg/codecs/gsm/Makefile	2005-11-19 19:31:46.000000000 +0000
-@@ -37,32 +37,6 @@
- ######### ppro's, etc, as well as the AMD K6 and K7.  The compile will
- ######### probably require gcc. 
- 
--ifneq (${OSARCH},Darwin)
--ifneq (${OSARCH},SunOS)
--ifneq (${PROC},x86_64)
--ifneq (${PROC},ultrasparc)
--ifneq ($(shell uname -m),ppc)
--ifneq ($(shell uname -m),ppc64)
--ifneq ($(shell uname -m),alpha)
--ifneq ($(shell uname -m),armv4l)
--ifneq (${PROC},sparc64)
--ifneq (${PROC},arm)
--ifneq (${PROC},ppc)
--ifneq (${PROC},ppc64)
--OPTIMIZE+=-march=$(PROC)
--endif
--endif
--endif
--endif
--endif
--endif
--endif
--endif
--endif
--endif
--endif
--endif
--
- #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
- #This works for even old (2.96) versions of gcc and provides a small boost either way.
- #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.

Added: asterisk/branches/sarge/debian/patches/zap_restart.dpatch
===================================================================
--- asterisk/branches/sarge/debian/patches/zap_restart.dpatch	2006-04-14 10:29:53 UTC (rev 1579)
+++ asterisk/branches/sarge/debian/patches/zap_restart.dpatch	2006-04-14 10:42:06 UTC (rev 1580)
@@ -0,0 +1,79 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## zap_restart.dpatch by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Adds a CLI command "zap restart" that destroys all zaptel channels and
+## DP: re-loads zaptel configuration from scratch. 
+## DP: Thus we have a "reload" for zaptel
+
+ at DPATCH@
+--- asterisk-1.2.6/channels/chan_zap.c	2006-04-09 02:40:48.000000000 +0300
++++ asterisk-new/channels/chan_zap.c	2006-04-09 04:15:46.000000000 +0300
+@@ -9656,6 +9656,47 @@
+ 	return RESULT_FAILURE;
+ }
+ 
++static int setup_zap(int reload);
++static int zap_restart(void)
++{
++	if (option_verbose > 0)
++		ast_verbose(VERBOSE_PREFIX_1 "Destroying channels and reloading zaptel configuration.\n");
++	while (iflist) {
++		if (option_debug)
++			ast_log(LOG_DEBUG, "Destroying zaptel channel no. %d\n", iflist->channel);
++		/* Also updates iflist: */
++		destroy_channel(NULL, iflist, 1);
++	}
++	if (option_debug)
++		ast_log(LOG_DEBUG, "Channels destroyed. Now re-reading config.\n");
++	if (setup_zap(0) != 0) {
++		ast_log(LOG_WARNING, "Reload channels from zap config failed!\n");
++		return 1;
++	}
++	return 0;
++}
++
++static int zap_restart_cmd(int fd, int argc, char **argv)
++{
++	if (argc != 2) {
++		return RESULT_SHOWUSAGE;
++	}
++
++	if (zap_restart() != 0)
++		return RESULT_FAILURE;
++	return RESULT_SUCCESS;
++}
++
++static int action_zaprestart(struct mansession *s, struct message *m)
++{
++	if (zap_restart() != 0) {
++		astman_send_error(s, m, "Failed rereading zaptel configuration");
++		return 1;
++	}
++	astman_send_ack(s, m, "ZapRestart: Success");
++	return 0;
++}
++
+ static int zap_show_channels(int fd, int argc, char **argv)
+ {
+ #define FORMAT "%7s %-10.10s %-15.15s %-10.10s %-20.20s\n"
+@@ -9965,6 +10005,10 @@
+ 	"Usage: zap destroy channel <chan num>\n"
+ 	"	DON'T USE THIS UNLESS YOU KNOW WHAT YOU ARE DOING.  Immediately removes a given channel, whether it is in use or not\n";
+ 
++static char zap_restart_usage[] =
++	"Usage: zap restart\n"
++	"	fully restarts the zaptel channels: destroys them all and then re-reads from config.\n";
++
+ static struct ast_cli_entry zap_cli[] = {
+ 	{ { "zap", "show", "cadences", NULL }, handle_zap_show_cadences,
+ 	  "List cadences", zap_show_cadences_help },
+@@ -9974,6 +10018,8 @@
+ 	  "Show information on a channel", show_channel_usage },
+ 	{ {"zap", "destroy", "channel", NULL}, zap_destroy_channel,
+ 	  "Destroy a channel", destroy_channel_usage },
++	{ {"zap", "restart", NULL}, zap_restart_cmd,
++	  "Fully restart zaptel channels", zap_restart_usage },
+ 	{ {"zap", "show", "status", NULL}, zap_show_status,
+ 	  "Show all Zaptel cards status", zap_show_status_usage },
+ };

Modified: asterisk/branches/sarge/debian/rules
===================================================================
--- asterisk/branches/sarge/debian/rules	2006-04-14 10:29:53 UTC (rev 1579)
+++ asterisk/branches/sarge/debian/rules	2006-04-14 10:42:06 UTC (rev 1580)
@@ -84,7 +84,7 @@
 	mkdir -p $(BRISTUFF_DIR)
 	tar cf - --exclude ./debian . | (cd $(BRISTUFF_DIR); tar xf -)
 	#ls -1d * .version .cleancount|grep -v debian|grep -v ^.$$|xargs cp -alt debian/build/asterisk-bristuff
-	cd $(BRISTUFF_DIR) ; \
+	set -e; cd $(BRISTUFF_DIR) ; \
 	  patch -p1 <../../patches/bristuff.dpatch ; \
 	  patch -p1 <../../patches/libpri_bristuffed.dpatch 
 	
@@ -161,15 +161,13 @@
 	$(RM) -f $(CURDIR)/debian/tmp/usr/sbin/{stereorize,streamplayer}
 	# override some default configurations. Leave the original ones
 	# in the sample configs:
-	cp debian/ast_config/* $(CURDIR)/debian/tmp/etc/asterisk
+	cp -a debian/ast_config/* $(CURDIR)/debian/tmp/etc/asterisk
 	
 	# bristuf
 	$(MAKE) -C $(BRISTUFF_DIR) DESTDIR=$(CURDIR)/debian/tmp/bristuff install
 	mkdir -p $(CURDIR)/debian/tmp/bristuff/etc/default/
 	cp debian/asterisk.default $(CURDIR)/debian/tmp/bristuff/etc/default/asterisk
 	$(RM) -f $(CURDIR)/debian/tmp/bristuff/usr/sbin/{stereorize,streamplayer}
-	cp debian/ast_config/* $(CURDIR)/debian/tmp/bristuff/etc/asterisk
-	
 	dh_install --sourcedir=debian/tmp
 	
 	install -m 644 include/asterisk.h $(CURDIR)/debian/asterisk-dev/usr/include/asterisk.h




More information about the Pkg-voip-commits mailing list