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

tzafrir-guest at alioth.debian.org tzafrir-guest at alioth.debian.org
Thu Aug 9 23:29:48 UTC 2007


Author: tzafrir-guest
Date: 2007-08-09 23:29:48 +0000 (Thu, 09 Aug 2007)
New Revision: 3969

Added:
   asterisk1.2/trunk/debian/asterisk1.2.asterisk.init
   asterisk1.2/trunk/debian/asterisk_fix
Removed:
   asterisk1.2/trunk/debian/asterisk1.2.init
   asterisk1.2/trunk/debian/asterisk1.2_fix
Modified:
   asterisk1.2/trunk/debian/asterisk1.2-config.postinst
   asterisk1.2/trunk/debian/changelog
   asterisk1.2/trunk/debian/control
   asterisk1.2/trunk/debian/patches/bristuff.dpatch
   asterisk1.2/trunk/debian/rules
Log:
* set DH_COMPAT to 5 to allow building the -dbg package.
* Update bristuff patch (and fix it for 1.2.24).
* Rename the init.d script back as "asterisk" - don't break existing
  scripts.
* Renamed asterisk1.2_fix back to asterisk_fix .
* There's no such thing asterisk1.2-config-custom .


Modified: asterisk1.2/trunk/debian/asterisk1.2-config.postinst
===================================================================
--- asterisk1.2/trunk/debian/asterisk1.2-config.postinst	2007-08-09 22:05:15 UTC (rev 3968)
+++ asterisk1.2/trunk/debian/asterisk1.2-config.postinst	2007-08-09 23:29:48 UTC (rev 3969)
@@ -13,8 +13,8 @@
 
 case "$1" in
     configure)
-	if [ -x /usr/share/asterisk/bin/asterisk1.2_fix ]; then
-		/usr/share/asterisk/bin/asterisk1.2_fix
+	if [ -x /usr/share/asterisk/bin/asterisk_fix ]; then
+		/usr/share/asterisk/bin/asterisk_fix
 	fi
     ;;
 

Copied: asterisk1.2/trunk/debian/asterisk1.2.asterisk.init (from rev 3962, asterisk1.2/trunk/debian/asterisk1.2.init)
===================================================================
--- asterisk1.2/trunk/debian/asterisk1.2.asterisk.init	                        (rev 0)
+++ asterisk1.2/trunk/debian/asterisk1.2.asterisk.init	2007-08-09 23:29:48 UTC (rev 3969)
@@ -0,0 +1,190 @@
+#! /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"
+ASTSAFE_PIDFILE="/var/run/asterisk/asterisk_safe.pid"
+UMASK=007 # by default
+
+
+# by default: use real-time priority
+PARAMS=""
+AST_REALTIME="yes"
+RUNASTERISK="yes"
+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 0
+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
+
+if [ "$UMASK" != '' ]
+then
+	umask $UMASK
+fi
+
+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
+}
+
+asterisk_rx() {
+	if ! status >/dev/null; then return 0; fi
+	$DAEMON -rx "$1"
+}
+
+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 0
+	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 0
+		fi
+		start-stop-daemon --start --group $GROUP --pidfile "$PIDFILE" \
+			--exec $REALDAEMON -- $PARAMS
+	else
+		start-stop-daemon --start --group $GROUP --make-pidfile \
+			--pidfile "$ASTSAFE_PIDFILE" \
+			--exec $REALDAEMON -- $PARAMS
+	fi
+		
+	
+	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 --pidfile $ASTSAFE_PIDFILE --oknodo \
+			--stop
+	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 $DAEMON
+	echo "."
+	;;
+  reload)
+	echo "Reloading $DESC configuration files."
+	asterisk_rx 'reload'
+	;;
+  logger-reload)
+	asterisk_rx 'logger reload'
+	;;
+  extensions-reload)
+	echo "Reloading $DESC configuration files."
+	asterisk_rx 'extensions reload'
+	;;
+  restart|force-reload)
+	$0 stop
+	$0 start
+	;;
+  status)
+	status
+	exit $?
+	;;
+  zaptel-fix) 	 
+	echo "Unloading and reloading loading Asterisk and Zaptel:" 	 
+	$0 stop 	 
+	/etc/init.d/zaptel unload 	 
+	# load modules from /etc/modules. This will break if you count on 	 
+	# discover/hotplug 	 
+	/etc/init.d/module-init-tools 	 
+	/etc/init.d/zaptel start 	 
+	$0 start 	 
+	;; 	 
+  *)
+	N=/etc/init.d/$NAME
+	echo "Usage: $N {start|stop|restart|reload|status|debug|logger-reload|extensions-reload|force-reload}" >&2
+	exit 1
+	;;
+esac
+
+exit 0

Deleted: asterisk1.2/trunk/debian/asterisk1.2.init
===================================================================
--- asterisk1.2/trunk/debian/asterisk1.2.init	2007-08-09 22:05:15 UTC (rev 3968)
+++ asterisk1.2/trunk/debian/asterisk1.2.init	2007-08-09 23:29:48 UTC (rev 3969)
@@ -1,190 +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"
-ASTSAFE_PIDFILE="/var/run/asterisk/asterisk_safe.pid"
-UMASK=007 # by default
-
-
-# by default: use real-time priority
-PARAMS=""
-AST_REALTIME="yes"
-RUNASTERISK="yes"
-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 0
-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
-
-if [ "$UMASK" != '' ]
-then
-	umask $UMASK
-fi
-
-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
-}
-
-asterisk_rx() {
-	if ! status >/dev/null; then return 0; fi
-	$DAEMON -rx "$1"
-}
-
-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 0
-	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 0
-		fi
-		start-stop-daemon --start --group $GROUP --pidfile "$PIDFILE" \
-			--exec $REALDAEMON -- $PARAMS
-	else
-		start-stop-daemon --start --group $GROUP --make-pidfile \
-			--pidfile "$ASTSAFE_PIDFILE" \
-			--exec $REALDAEMON -- $PARAMS
-	fi
-		
-	
-	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 --pidfile $ASTSAFE_PIDFILE --oknodo \
-			--stop
-	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 $DAEMON
-	echo "."
-	;;
-  reload)
-	echo "Reloading $DESC configuration files."
-	asterisk_rx 'reload'
-	;;
-  logger-reload)
-	asterisk_rx 'logger reload'
-	;;
-  extensions-reload)
-	echo "Reloading $DESC configuration files."
-	asterisk_rx 'extensions reload'
-	;;
-  restart|force-reload)
-	$0 stop
-	$0 start
-	;;
-  status)
-	status
-	exit $?
-	;;
-  zaptel-fix) 	 
-	echo "Unloading and reloading loading Asterisk and Zaptel:" 	 
-	$0 stop 	 
-	/etc/init.d/zaptel unload 	 
-	# load modules from /etc/modules. This will break if you count on 	 
-	# discover/hotplug 	 
-	/etc/init.d/module-init-tools 	 
-	/etc/init.d/zaptel start 	 
-	$0 start 	 
-	;; 	 
-  *)
-	N=/etc/init.d/$NAME
-	echo "Usage: $N {start|stop|restart|reload|status|debug|logger-reload|extensions-reload|force-reload}" >&2
-	exit 1
-	;;
-esac
-
-exit 0

Deleted: asterisk1.2/trunk/debian/asterisk1.2_fix
===================================================================
--- asterisk1.2/trunk/debian/asterisk1.2_fix	2007-08-09 22:05:15 UTC (rev 3968)
+++ asterisk1.2/trunk/debian/asterisk1.2_fix	2007-08-09 23:29:48 UTC (rev 3969)
@@ -1,116 +0,0 @@
-#! /bin/sh
-
-if getent passwd asterisk >/dev/null ;then
-	# Some halfbaked Sarge versions needed their home dir fixed:
-        if [ "`getent passwd asterisk|awk -F: '{print $6}'`" = \
-		"/var/run/asterisk" ];then
-		usermod -d /var/lib/asterisk asterisk
-        fi
-else
-	adduser_extra_opts=""
-	# Cosmetic noise reduction
-	if [ -d "/var/lib/asterisk" ]; then
-    		adduser_extra_opts="--no-create-home"
-	fi
-	adduser --system --group --home /var/lib/asterisk \
-	    $adduser_extra_opts \
-        	--gecos "Asterisk PBX daemon" asterisk		
-fi
-
-for group in dialout audio; do
-	if groups asterisk | grep -w -q -v $group; then
-        	adduser asterisk $group
-	fi
-done
-
-# Update from /usr/share/asterisk/sounds/priv-callerintros to 
-#             /var/lib/asterisk/sounds/priv-callerintros
-if [ -d /usr/share/asterisk/sounds/priv-callerintros ];then
-	if [ -L /usr/share/asterisk/sounds/priv-callerintros ];then
-		# if this is a fresh install just try to move the symlink.
-		userprovided=0
-		if [ ! -L /var/lib/asterisk/sounds/priv-callerintros ];then
-			if [ `find /var/lib/asterisk/sounds/priv-callerintros -mindepth 1|wc -l` -gt 0 ];then
-				rmdir /var/lib/asterisk/sounds/priv-callerintros
-				echo -n "Updating private callerintros location to /var/lib/asterisk/sounds/priv-callerintros"
-				ln -s `readlink /usr/share/asterisk/sounds/priv-callerintros` /var/lib/asterisk/sounds/priv-callerintros
-				rm /usr/share/asterisk/sounds/priv-callerintros
-				echo '.'
-			else
-				userprovided=1
-			fi
-		else
-			userprovided=1
-		fi
-		if [ "$userprovided" = "1" ];then
-			echo 'Found user installed private callerintros. Not updating private callerintros'
-			echo 'directory to new directory. Please adjust symlink manually to new location'
-			echo '/var/lib/asterisk/sounds/priv-callerintros.'
-		fi
-	else
-		echo -n "Updating private callerintros location to /var/lib/asterisk/sounds/priv-callerintros"
-		find /usr/share/asterisk/sounds/priv-callerintros -mindepth 1 -maxdepth 1 -exec mv '{}' /var/lib/asterisk/sounds/priv-callerintros \;
-		rmdir /usr/share/asterisk/sounds/priv-callerintros
-		echo "."
-	fi
-fi
-
-# Make sure all (possibly) used dirs exist and is owned by asterisk
-
-# /var/run/asterisk is not yet handled by init.d :-(
-# (/var/run/asterisk is handled in sysV script /etc/init.d/asterisk)
-
-dirs="
-        /var/log/asterisk
-        /var/spool/asterisk
-        /var/lib/asterisk
-	/var/run/asterisk
-        /etc/asterisk
-"
-
-subdirs="
-	/var/lib/asterisk/sounds/priv-callerintros
-        /var/log/asterisk/cdr-csv
-        /var/log/asterisk/cdr-custom
-        /var/spool/asterisk/dictate
-        /var/spool/asterisk/meetme
-        /var/spool/asterisk/monitor
-        /var/spool/asterisk/monitor
-        /var/spool/asterisk/system
-        /var/spool/asterisk/tmp
-        /var/spool/asterisk/voicemail
-"
-
-for dir in $subdirs $dirs; do
-        mkdir -p "$dir"
-done
-
-for dir in $dirs; do
-        chown -R asterisk: "$dir"
-done
-
-
-###################################
-# this part should be reviewed, but it's basically trial and error
-# code i wrote to make freepbx work. better solutions are welcomed.
-
-# files need to be RW by the group
-# dirs need to a+rx
-chmod -R 0660 /etc/asterisk/
-find /etc/asterisk/ -type d | xargs chmod ug+rx
-
-#chmod g+s /etc/asterisk/
-
-# this is needed because othewise sqlite cannot write to the DB
-#chmod -R 0660 /var/lib/asterisk/
-
-####################################
-# If asterisk in running, reload it
-# otherwise start it
-if [ -x "/etc/init.d/asterisk" ];then
-	if [ -f /var/run/asterisk/asterisk.pid ];then
-	    invoke-rc.d asterisk reload || exit $?
-	else
-	    invoke-rc.d asterisk restart || exit $?
-	fi
-fi

Copied: asterisk1.2/trunk/debian/asterisk_fix (from rev 3962, asterisk1.2/trunk/debian/asterisk1.2_fix)
===================================================================
--- asterisk1.2/trunk/debian/asterisk_fix	                        (rev 0)
+++ asterisk1.2/trunk/debian/asterisk_fix	2007-08-09 23:29:48 UTC (rev 3969)
@@ -0,0 +1,116 @@
+#! /bin/sh
+
+if getent passwd asterisk >/dev/null ;then
+	# Some halfbaked Sarge versions needed their home dir fixed:
+        if [ "`getent passwd asterisk|awk -F: '{print $6}'`" = \
+		"/var/run/asterisk" ];then
+		usermod -d /var/lib/asterisk asterisk
+        fi
+else
+	adduser_extra_opts=""
+	# Cosmetic noise reduction
+	if [ -d "/var/lib/asterisk" ]; then
+    		adduser_extra_opts="--no-create-home"
+	fi
+	adduser --system --group --home /var/lib/asterisk \
+	    $adduser_extra_opts \
+        	--gecos "Asterisk PBX daemon" asterisk		
+fi
+
+for group in dialout audio; do
+	if groups asterisk | grep -w -q -v $group; then
+        	adduser asterisk $group
+	fi
+done
+
+# Update from /usr/share/asterisk/sounds/priv-callerintros to 
+#             /var/lib/asterisk/sounds/priv-callerintros
+if [ -d /usr/share/asterisk/sounds/priv-callerintros ];then
+	if [ -L /usr/share/asterisk/sounds/priv-callerintros ];then
+		# if this is a fresh install just try to move the symlink.
+		userprovided=0
+		if [ ! -L /var/lib/asterisk/sounds/priv-callerintros ];then
+			if [ `find /var/lib/asterisk/sounds/priv-callerintros -mindepth 1|wc -l` -gt 0 ];then
+				rmdir /var/lib/asterisk/sounds/priv-callerintros
+				echo -n "Updating private callerintros location to /var/lib/asterisk/sounds/priv-callerintros"
+				ln -s `readlink /usr/share/asterisk/sounds/priv-callerintros` /var/lib/asterisk/sounds/priv-callerintros
+				rm /usr/share/asterisk/sounds/priv-callerintros
+				echo '.'
+			else
+				userprovided=1
+			fi
+		else
+			userprovided=1
+		fi
+		if [ "$userprovided" = "1" ];then
+			echo 'Found user installed private callerintros. Not updating private callerintros'
+			echo 'directory to new directory. Please adjust symlink manually to new location'
+			echo '/var/lib/asterisk/sounds/priv-callerintros.'
+		fi
+	else
+		echo -n "Updating private callerintros location to /var/lib/asterisk/sounds/priv-callerintros"
+		find /usr/share/asterisk/sounds/priv-callerintros -mindepth 1 -maxdepth 1 -exec mv '{}' /var/lib/asterisk/sounds/priv-callerintros \;
+		rmdir /usr/share/asterisk/sounds/priv-callerintros
+		echo "."
+	fi
+fi
+
+# Make sure all (possibly) used dirs exist and is owned by asterisk
+
+# /var/run/asterisk is not yet handled by init.d :-(
+# (/var/run/asterisk is handled in sysV script /etc/init.d/asterisk)
+
+dirs="
+        /var/log/asterisk
+        /var/spool/asterisk
+        /var/lib/asterisk
+	/var/run/asterisk
+        /etc/asterisk
+"
+
+subdirs="
+	/var/lib/asterisk/sounds/priv-callerintros
+        /var/log/asterisk/cdr-csv
+        /var/log/asterisk/cdr-custom
+        /var/spool/asterisk/dictate
+        /var/spool/asterisk/meetme
+        /var/spool/asterisk/monitor
+        /var/spool/asterisk/monitor
+        /var/spool/asterisk/system
+        /var/spool/asterisk/tmp
+        /var/spool/asterisk/voicemail
+"
+
+for dir in $subdirs $dirs; do
+        mkdir -p "$dir"
+done
+
+for dir in $dirs; do
+        chown -R asterisk: "$dir"
+done
+
+
+###################################
+# this part should be reviewed, but it's basically trial and error
+# code i wrote to make freepbx work. better solutions are welcomed.
+
+# files need to be RW by the group
+# dirs need to a+rx
+chmod -R 0660 /etc/asterisk/
+find /etc/asterisk/ -type d | xargs chmod ug+rx
+
+#chmod g+s /etc/asterisk/
+
+# this is needed because othewise sqlite cannot write to the DB
+#chmod -R 0660 /var/lib/asterisk/
+
+####################################
+# If asterisk in running, reload it
+# otherwise start it
+if [ -x "/etc/init.d/asterisk" ];then
+	if [ -f /var/run/asterisk/asterisk.pid ];then
+	    invoke-rc.d asterisk reload || exit $?
+	else
+	    invoke-rc.d asterisk restart || exit $?
+	fi
+fi

Modified: asterisk1.2/trunk/debian/changelog
===================================================================
--- asterisk1.2/trunk/debian/changelog	2007-08-09 22:05:15 UTC (rev 3968)
+++ asterisk1.2/trunk/debian/changelog	2007-08-09 23:29:48 UTC (rev 3969)
@@ -8,12 +8,13 @@
   * Moved asterisk 1.2 series into own namespace
 
   [ Tzafrir Cohen ]
-  * Bristuff 0.3.0-1y-h
+  * Bristuff 0.3.0-1y-j
   * h323_fix_1217.dpatch: fix build of h323 that got broken in 1.2.17 .
   * Fix target of sample h323.conf file.
   * Bumped standards version to 3.7.2 .
   * Fixed location of moh files.
   * Add a -dbg package.
+  * Set compat to 5 for this to work.
   * stereorize.1: fix typos.
 
  -- Mark Purcell <msp at debian.org>  Thu, 09 Aug 2007 22:43:51 +0100

Modified: asterisk1.2/trunk/debian/control
===================================================================
--- asterisk1.2/trunk/debian/control	2007-08-09 22:05:15 UTC (rev 3968)
+++ asterisk1.2/trunk/debian/control	2007-08-09 23:29:48 UTC (rev 3969)
@@ -4,7 +4,7 @@
 Maintainer: Debian VoIP Team <pkg-voip-maintainers at lists.alioth.debian.org>
 Uploaders: Mark Purcell <msp at debian.org>, Kilian Krause <kilian at debian.org>, Jose Carlos Garcia Sogo <jsogo at debian.org>, Santiago Garcia Mantinan <manty at debian.org>, Simon Richter <sjr at debian.org>, Tzafrir Cohen <tzafrir.cohen at xorcom.com>
 Standards-Version: 3.7.2
-Build-Depends: debhelper (>= 4.0.4), sed (>= 3.95), zlib1g-dev, libreadline5-dev, libgsm1-dev, libssl-dev, libtonezone1.2-dev (>= 1:1.2.3-1), bison, libasound2-dev, libpq-dev, unixodbc-dev, libpri1.2-dev (>= 1:1.2.3-1), dpatch (>= 2.0.10), zaptel1.2-source (>= 1:1.2.13-1), autotools-dev, libnewt-dev, libsqlite-dev, libspeex-dev (>= 1.1.12-3), graphviz, libcurl3-dev, doxygen, gsfonts, libpopt-dev, libopenh323-dev (>= 1.17.4-1), dpkg (>= 1.13.19), libogg-dev, libvorbis-dev
+Build-Depends: debhelper (>= 5.0.0), sed (>= 3.95), zlib1g-dev, libreadline5-dev, libgsm1-dev, libssl-dev, libtonezone-dev (>= 1:1.2.3-1), bison, libasound2-dev, libpq-dev, unixodbc-dev, libpri-dev (>= 1.2.3-1), dpatch (>= 2.0.10), zaptel-source (>= 1:1.2.13-1), autotools-dev, libnewt-dev, libsqlite-dev, libspeex-dev (>= 1.1.12-3), graphviz, libcurl3-dev, doxygen, gsfonts, libpopt-dev, libopenh323-dev (>= 1.17.4-1), dpkg (>= 1.13.19), libogg-dev, libvorbis-dev
 XS-Vcs-Svn: svn://svn.debian.org/pkg-voip/
 XS-Vcs-Browser: http://svn.debian.org/wsvn/pkg-voip/
 
@@ -12,8 +12,9 @@
 Architecture: all
 Section: comm
 Depends: asterisk1.2-classic (>= ${source:Version}) | asterisk1.2-bristuff (>= ${source:Version}), adduser (>= 3.63)
-Conflicts: asterisk-oh323 (<= 0.6.6pre3-3), asterisk
+Conflicts: asterisk-oh323 (<= 0.6.6pre3-3), asterisk, asterisk-classic, asterisk-bristuff
 Replaces: asterisk
+Provides: asterisk
 Suggests: ekiga, ohphone, kphone, asterisk1.2-doc, asterisk1.2-dev, asterisk-rate-engine
 Description: Open Source Private Branch Exchange (PBX)
  Asterisk is an Open Source PBX and telephony toolkit.  It is, in a
@@ -41,7 +42,7 @@
 Package: asterisk1.2-classic
 Architecture: any
 Section: comm
-Depends: ${shlibs:Depends}, asterisk1.2 (= ${source:Version}), asterisk1.2-config (= ${source:Version}) | asterisk1.2-config-custom, adduser (>= 3.63), asterisk1.2-sounds-main (>= 1:1.0.2)
+Depends: ${shlibs:Depends}, asterisk1.2 (= ${source:Version}), asterisk1.2-config (= ${source:Version}) | asterisk-config-custom, adduser (>= 3.63), asterisk1.2-sounds-main (>= 1:1.0.2)
 Conflicts: asterisk1.2-bristuff, asterisk-classic
 Replaces: asterisk-classic
 Description: Open Source Private Branch Exchange (PBX) - original Digium version
@@ -70,7 +71,7 @@
 Package: asterisk1.2-bristuff
 Architecture: any
 Section: comm
-Depends: ${shlibs:Depends}, asterisk1.2 (= ${source:Version}), asterisk1.2-config (= ${source:Version}) | asterisk1.2-config-custom, adduser (>= 3.63), asterisk1.2-sounds-main (>= 1:1.0.2)
+Depends: ${shlibs:Depends}, asterisk1.2 (= ${source:Version}), asterisk1.2-config (= ${source:Version}) | asterisk-config-custom, adduser (>= 3.63), asterisk1.2-sounds-main (>= 1:1.0.2)
 Conflicts: asterisk1.2-classic, asterisk-bristuff
 Replaces: asterisk-bristuff
 Description: Open Source Private Branch Exchange (PBX) - BRIstuff-enabled version
@@ -153,6 +154,7 @@
 Recommends: asterisk1.2
 Conflicts: asterisk (<=0.1.12-3), asterisk-sounds (<= 1:1.0.2-1), asterisk-sounds-main
 Replaces: asterisk (<=0.4.0-5), asterisk-sounds (<= 1:1.0.2-1), asterisk-sounds-extra, asterisk-sounds-main
+Provides: asterisk-sounds-main
 Section: comm
 Description: sound files for asterisk
  Asterisk is an Open Source PBX and telephony toolkit.

Modified: asterisk1.2/trunk/debian/patches/bristuff.dpatch
===================================================================
--- asterisk1.2/trunk/debian/patches/bristuff.dpatch	2007-08-09 22:05:15 UTC (rev 3968)
+++ asterisk1.2/trunk/debian/patches/bristuff.dpatch	2007-08-09 23:29:48 UTC (rev 3969)
@@ -2,14 +2,14 @@
 ## bristuff.dpatch by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
 ##
 ## All lines beginning with `## DP:' are a description of the patch.
-## DP: bristuff support: asterisk.patch from bristuff-0.3.0-PRE-1y-h
-## DP: cygdef.h removed ;-)
-## DP: Updated version: 1.2.23
+## DP: bristuff support: asterisk.patch from bristuff-0.3.0-PRE-1y-j
+## DP: cygdef.h removed
+## DP: Updated version: 1.2.24
 
 @DPATCH@
-diff -urN asterisk-1.2.19.orig/agi/Makefile asterisk-1.2.19/agi/Makefile
---- asterisk-1.2.19.orig/agi/Makefile	2006-03-28 22:22:05.000000000 +0200
-+++ asterisk-1.2.19/agi/Makefile	2007-06-25 11:13:51.369615860 +0200
+diff -urN asterisk-1.2.23.orig/agi/Makefile asterisk-1.2.23/agi/Makefile
+--- asterisk-1.2.23.orig/agi/Makefile	2006-03-28 22:22:05.000000000 +0200
++++ asterisk-1.2.23/agi/Makefile	2007-07-25 08:53:52.936330778 +0200
 @@ -11,7 +11,7 @@
  # the GNU General Public License
  #
@@ -28,9 +28,9 @@
  
  %.so : %.o
  	$(CC) -shared -Xlinker -x -o $@ $<
-diff -urN asterisk-1.2.19.orig/agi/xagi-test.c asterisk-1.2.19/agi/xagi-test.c
---- asterisk-1.2.19.orig/agi/xagi-test.c	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.19/agi/xagi-test.c	2007-06-25 11:13:51.393621529 +0200
+diff -urN asterisk-1.2.23.orig/agi/xagi-test.c asterisk-1.2.23/agi/xagi-test.c
+--- asterisk-1.2.23.orig/agi/xagi-test.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.23/agi/xagi-test.c	2007-07-25 08:53:52.960336468 +0200
 @@ -0,0 +1,175 @@
 +/*
 + * Asterisk -- A telephony toolkit for Linux.
@@ -207,9 +207,9 @@
 +		return -1;
 +	exit(0);
 +}
-diff -urN asterisk-1.2.19.orig/apps/app_callingpres.c asterisk-1.2.19/apps/app_callingpres.c
---- asterisk-1.2.19.orig/apps/app_callingpres.c	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.19/apps/app_callingpres.c	2007-06-25 11:13:51.397622474 +0200
+diff -urN asterisk-1.2.23.orig/apps/app_callingpres.c asterisk-1.2.23/apps/app_callingpres.c
+--- asterisk-1.2.23.orig/apps/app_callingpres.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.23/apps/app_callingpres.c	2007-07-25 08:53:52.960336468 +0200
 @@ -0,0 +1,70 @@
 +/*
 + * An application to change the CallingPresentation for an Asterisk channel.
@@ -281,9 +281,9 @@
 +{
 +    return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.19.orig/apps/app_capiCD.c asterisk-1.2.19/apps/app_capiCD.c
---- asterisk-1.2.19.orig/apps/app_capiCD.c	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.19/apps/app_capiCD.c	2007-06-25 11:13:51.397622474 +0200
+diff -urN asterisk-1.2.23.orig/apps/app_capiCD.c asterisk-1.2.23/apps/app_capiCD.c
+--- asterisk-1.2.23.orig/apps/app_capiCD.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.23/apps/app_capiCD.c	2007-07-25 08:53:52.960336468 +0200
 @@ -0,0 +1,172 @@
 +/*
 + * (CAPI*)
@@ -457,9 +457,9 @@
 +{
 +	return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.19.orig/apps/app_capiECT.c asterisk-1.2.19/apps/app_capiECT.c
---- asterisk-1.2.19.orig/apps/app_capiECT.c	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.19/apps/app_capiECT.c	2007-06-25 11:13:51.397622474 +0200
+diff -urN asterisk-1.2.23.orig/apps/app_capiECT.c asterisk-1.2.23/apps/app_capiECT.c
+--- asterisk-1.2.23.orig/apps/app_capiECT.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.23/apps/app_capiECT.c	2007-07-25 08:53:52.960336468 +0200
 @@ -0,0 +1,210 @@
 +/*
 + * (CAPI*)
@@ -671,9 +671,9 @@
 +{
 +	return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.19.orig/apps/app_capiNoES.c asterisk-1.2.19/apps/app_capiNoES.c
---- asterisk-1.2.19.orig/apps/app_capiNoES.c	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.19/apps/app_capiNoES.c	2007-06-25 11:13:51.397622474 +0200
+diff -urN asterisk-1.2.23.orig/apps/app_capiNoES.c asterisk-1.2.23/apps/app_capiNoES.c
+--- asterisk-1.2.23.orig/apps/app_capiNoES.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.23/apps/app_capiNoES.c	2007-07-25 08:53:52.960336468 +0200
 @@ -0,0 +1,96 @@
 +/*
 + * (CAPI*)
@@ -771,9 +771,9 @@
 +{
 +	return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.19.orig/apps/app_chanisavail.c asterisk-1.2.19/apps/app_chanisavail.c
---- asterisk-1.2.19.orig/apps/app_chanisavail.c	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.19/apps/app_chanisavail.c	2007-06-25 11:13:51.401623419 +0200
+diff -urN asterisk-1.2.23.orig/apps/app_chanisavail.c asterisk-1.2.23/apps/app_chanisavail.c
+--- asterisk-1.2.23.orig/apps/app_chanisavail.c	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.23/apps/app_chanisavail.c	2007-07-25 08:53:52.964337416 +0200
 @@ -118,7 +118,7 @@
  				snprintf(trychan, sizeof(trychan), "%s/%s",cur,number);
  				status = inuse = ast_device_state(trychan);
@@ -783,9 +783,9 @@
  					pbx_builtin_setvar_helper(chan, "AVAILCHAN", tempchan->name);
  					/* Store the originally used channel too */
  					snprintf(tmp, sizeof(tmp), "%s/%s", tech, number);
-diff -urN asterisk-1.2.19.orig/apps/app_chanspy.c asterisk-1.2.19/apps/app_chanspy.c
---- asterisk-1.2.19.orig/apps/app_chanspy.c	2007-02-02 00:14:09.000000000 +0100
-+++ asterisk-1.2.19/apps/app_chanspy.c	2007-06-25 11:13:51.401623419 +0200
+diff -urN asterisk-1.2.23.orig/apps/app_chanspy.c asterisk-1.2.23/apps/app_chanspy.c
+--- asterisk-1.2.23.orig/apps/app_chanspy.c	2007-07-13 22:10:39.000000000 +0200
++++ asterisk-1.2.23/apps/app_chanspy.c	2007-07-25 08:53:52.964337416 +0200
 @@ -55,6 +55,7 @@
  
  static const char *synopsis = "Listen to the audio of an active channel";
@@ -814,7 +814,7 @@
  static void *spy_alloc(struct ast_channel *chan, void *data)
  {
  	/* just store the data pointer in the channel structure */
-@@ -548,11 +562,87 @@
+@@ -551,11 +565,87 @@
  	ALL_DONE(u, res);
  }
  
@@ -903,7 +903,7 @@
  
  	STANDARD_HANGUP_LOCALUSERS;
  
-@@ -561,7 +651,8 @@
+@@ -564,7 +654,8 @@
  
  int load_module(void)
  {
@@ -913,9 +913,9 @@
  }
  
  char *description(void)
-diff -urN asterisk-1.2.19.orig/apps/app_devstate.c asterisk-1.2.19/apps/app_devstate.c
---- asterisk-1.2.19.orig/apps/app_devstate.c	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.19/apps/app_devstate.c	2007-06-25 11:13:51.401623419 +0200
+diff -urN asterisk-1.2.23.orig/apps/app_devstate.c asterisk-1.2.23/apps/app_devstate.c
+--- asterisk-1.2.23.orig/apps/app_devstate.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.23/apps/app_devstate.c	2007-07-25 08:53:52.964337416 +0200
 @@ -0,0 +1,225 @@
 +/*
 + * Devstate application
@@ -1142,9 +1142,9 @@
 +{
 +    return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.19.orig/apps/app_dial.c asterisk-1.2.19/apps/app_dial.c
---- asterisk-1.2.19.orig/apps/app_dial.c	2007-06-07 16:19:40.000000000 +0200
-+++ asterisk-1.2.19/apps/app_dial.c	2007-06-25 11:13:51.409625309 +0200
+diff -urN asterisk-1.2.23.orig/apps/app_dial.c asterisk-1.2.23/apps/app_dial.c
+--- asterisk-1.2.23.orig/apps/app_dial.c	2007-07-03 14:34:14.000000000 +0200
++++ asterisk-1.2.23/apps/app_dial.c	2007-07-25 08:53:52.968338365 +0200
 @@ -11,6 +11,10 @@
   * the project provides a web site, mailing lists and IRC
   * channels for your use.
@@ -1464,9 +1464,9 @@
  		if (res != AST_PBX_NO_HANGUP_PEER) {
  			if (!chan->_softhangup)
  				chan->hangupcause = peer->hangupcause;
-diff -urN asterisk-1.2.19.orig/apps/app_directed_pickup.c asterisk-1.2.19/apps/app_directed_pickup.c
---- asterisk-1.2.19.orig/apps/app_directed_pickup.c	2006-04-06 19:00:10.000000000 +0200
-+++ asterisk-1.2.19/apps/app_directed_pickup.c	2007-06-25 11:13:51.409625309 +0200
+diff -urN asterisk-1.2.23.orig/apps/app_directed_pickup.c asterisk-1.2.23/apps/app_directed_pickup.c
+--- asterisk-1.2.23.orig/apps/app_directed_pickup.c	2006-04-06 19:00:10.000000000 +0200
++++ asterisk-1.2.23/apps/app_directed_pickup.c	2007-07-25 08:53:52.968338365 +0200
 @@ -41,7 +41,7 @@
  #include "asterisk/app.h"
  
@@ -1476,9 +1476,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.19.orig/apps/app_meetme.c asterisk-1.2.19/apps/app_meetme.c
---- asterisk-1.2.19.orig/apps/app_meetme.c	2007-03-29 19:33:58.000000000 +0200
-+++ asterisk-1.2.19/apps/app_meetme.c	2007-06-25 11:13:51.413626254 +0200
+diff -urN asterisk-1.2.23.orig/apps/app_meetme.c asterisk-1.2.23/apps/app_meetme.c
+--- asterisk-1.2.23.orig/apps/app_meetme.c	2007-06-19 15:54:03.000000000 +0200
++++ asterisk-1.2.23/apps/app_meetme.c	2007-07-25 08:53:52.968338365 +0200
 @@ -460,7 +460,7 @@
  			ast_copy_string(cnf->pin, pin, sizeof(cnf->pin));
  			ast_copy_string(cnf->pinadmin, pinadmin, sizeof(cnf->pinadmin));
@@ -1508,7 +1508,7 @@
  		bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
  		bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
  		bi.numbufs = audio_buffers;
-@@ -1311,6 +1312,14 @@
+@@ -1315,6 +1316,14 @@
  				f = ast_read(c);
  				if (!f)
  					break;
@@ -1523,7 +1523,7 @@
  				if ((f->frametype == AST_FRAME_VOICE) && (f->subclass == AST_FORMAT_SLINEAR)) {
  					if (user->talk.actual)
  						ast_frame_adjust_volume(f, user->talk.actual);
-@@ -1545,7 +1554,7 @@
+@@ -1549,7 +1558,7 @@
  				}
  				ast_frfree(f);
  			} else if (outfd > -1) {
@@ -1532,9 +1532,9 @@
  				if (res > 0) {
  					memset(&fr, 0, sizeof(fr));
  					fr.frametype = AST_FRAME_VOICE;
-diff -urN asterisk-1.2.19.orig/apps/app_milliwatt.c asterisk-1.2.19/apps/app_milliwatt.c
---- asterisk-1.2.19.orig/apps/app_milliwatt.c	2006-01-19 05:17:45.000000000 +0100
-+++ asterisk-1.2.19/apps/app_milliwatt.c	2007-06-25 11:13:51.413626254 +0200
+diff -urN asterisk-1.2.23.orig/apps/app_milliwatt.c asterisk-1.2.23/apps/app_milliwatt.c
+--- asterisk-1.2.23.orig/apps/app_milliwatt.c	2006-01-19 05:17:45.000000000 +0100
++++ asterisk-1.2.23/apps/app_milliwatt.c	2007-07-25 08:53:52.972339313 +0200
 @@ -74,20 +74,28 @@
  {
  	struct ast_frame wf;
@@ -1570,9 +1570,9 @@
  	wf.src = "app_milliwatt";
  	wf.delivery.tv_sec = 0;
  	wf.delivery.tv_usec = 0;
-diff -urN asterisk-1.2.19.orig/apps/app_page.c asterisk-1.2.19/apps/app_page.c
---- asterisk-1.2.19.orig/apps/app_page.c	2007-02-20 20:49:50.000000000 +0100
-+++ asterisk-1.2.19/apps/app_page.c	2007-06-25 11:13:51.413626254 +0200
+diff -urN asterisk-1.2.23.orig/apps/app_page.c asterisk-1.2.23/apps/app_page.c
+--- asterisk-1.2.23.orig/apps/app_page.c	2007-02-20 20:49:50.000000000 +0100
++++ asterisk-1.2.23/apps/app_page.c	2007-07-25 08:53:52.972339313 +0200
 @@ -85,7 +85,7 @@
  {
  	struct calloutdata *cd = data;
@@ -1582,9 +1582,9 @@
  	free(cd);
  	return NULL;
  }
-diff -urN asterisk-1.2.19.orig/apps/app_parkandannounce.c asterisk-1.2.19/apps/app_parkandannounce.c
---- asterisk-1.2.19.orig/apps/app_parkandannounce.c	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.19/apps/app_parkandannounce.c	2007-06-25 11:13:51.413626254 +0200
+diff -urN asterisk-1.2.23.orig/apps/app_parkandannounce.c asterisk-1.2.23/apps/app_parkandannounce.c
+--- asterisk-1.2.23.orig/apps/app_parkandannounce.c	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.23/apps/app_parkandannounce.c	2007-07-25 08:53:52.972339313 +0200
 @@ -183,7 +183,7 @@
  
  	memset(&oh, 0, sizeof(oh));
@@ -1594,10 +1594,10 @@
  
  	if(dchan) {
  		if(dchan->_state == AST_STATE_UP) {
-diff -urN asterisk-1.2.19.orig/apps/app_pickup.c asterisk-1.2.19/apps/app_pickup.c
---- asterisk-1.2.19.orig/apps/app_pickup.c	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.19/apps/app_pickup.c	2007-06-25 16:03:48.878931207 +0200
-@@ -0,0 +1,319 @@
+diff -urN asterisk-1.2.23.orig/apps/app_pickup.c asterisk-1.2.23/apps/app_pickup.c
+--- asterisk-1.2.23.orig/apps/app_pickup.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.23/apps/app_pickup.c	2007-07-25 08:53:52.972339313 +0200
+@@ -0,0 +1,438 @@
 +/*
 + * Asterisk -- A telephony toolkit for Linux.
 + *
@@ -1664,16 +1664,37 @@
 +
 +static char *app5 = "StealChan";
 +
-+static char *synopsis5 = "Channel independent call stealing. Just like pickup but for answered channels.";
++static char *synopsis5 = "Channel independent call stealing. Just like pickup but for answered channels that are bridged.";
 +
 +static char *descrip5 = 
-+"  StealChan(Technology/resource[&Technology2/resource2...]):  Tries to steal the first ringing channel in the parameter list.\n";
++"  StealChan(Technology/resource[&Technology2/resource2...]):  Tries to steal the first bridged channel in the parameter list.\n";
 +
++static char *app6 = "GrabChan";
++
++static char *synopsis6 = "Channel independent call grabbing. Just like pickup but for answered channels that are not bridged.";
++
++static char *descrip6 = 
++"  GrabChan(Technology/resource[&Technology2/resource2...]):  Tries to grab the first not bridged channel in the parameter list.\n";
++
++static char *app7 = "GrabUniqueID";
++
++static char *synopsis7 = "Channel independent call grabbing. Just like pickup but for answered channels that are not bridged.";
++
++static char *descrip7 = 
++"  GrabUniqueID(uniqueid):  Tries to grab the channel with UniqueID 'uniqueid'.\n";
++
++static char *app8 = "StealUniqueID";
++
++static char *synopsis8 = "Channel independent call stealing. Just like pickup but for answered channels that are bridged.";
++
++static char *descrip8 = 
++"  GrabUniqueID(uniqueid):  Tries to steal the channel with UniqueID 'uniqueid'.\n";
++
 +STANDARD_LOCAL_USER;
 +
 +LOCAL_USER_DECL;
 +
-+static int my_pickup_call(struct ast_channel *chan, unsigned int pickupgroup, int chanstate, int bridge) {
++static int my_pickup_call(struct ast_channel *chan, unsigned int pickupgroup, int chanstate, int chanbridged, int bridge) {
 +	struct ast_channel *cur;
 +	int res = -1;
 +	cur = ast_channel_walk_locked(NULL);
@@ -1719,17 +1740,22 @@
 +	return res;
 +}
 +
-+static int my_pickup_channel(struct ast_channel *chan, void *data, int chanstate, int bridge) {
-+       struct ast_channel *cur;
-+       char channels[256];
-+       char evalchan[256];
-+       char *endptr;
-+       int res = -1;
++static int my_pickup_channel(struct ast_channel *chan, void *data, char *uniqueid, int chanstate, int chanbridged, int bridge) {
++    struct ast_channel *cur;
++    char channels[256];
++    char evalchan[256];
++    char *endptr;
++    int res = -1;
++    int isbridged = 0;
++    struct ast_bridge_config config;
++
++    if (!ast_strlen_zero(uniqueid)) {
++       cur = ast_get_channel_by_uniqueid_locked(uniqueid);
++    } else {
 +       cur = ast_channel_walk_locked(NULL);
 +       strncpy(channels, (char *)data, sizeof(channels) - 1);
 +       while(cur) {
-+               if ((cur != chan) &&
-+                        (cur->_state == chanstate)) {
++               if (cur != chan) {
 +                               /* This call is a candidate (correct ringstate and not ourselves), now check if the channel is in our list */
 +                               strncpy(evalchan, (char *)cur->name, sizeof(evalchan) - 1);                             
 +                               /* strip the subchannel tag */
@@ -1737,20 +1763,25 @@
 +                               if(endptr) {
 +                                       *endptr = '\0';
 +                               }
-+/*                               endptr = strrchr(evalchan, '/');
-+                               if(endptr) {
-+                                       *endptr = '\0';
-+                               } */
 +                               /* check for each of the members if they match (probably a stristr will do ?) */
 +                               /* if we match the code, break */
 +                               if(strstr(channels, evalchan) != NULL) {
++				    if (chanstate == -1) {
++					if (ast_bridged_channel(cur)) { isbridged = 1; }
++					if (isbridged == chanbridged) {
++                                          ast_verbose(VERBOSE_PREFIX_1 "Nice channel, I'll take it: %s (isbridged = %d)\n",evalchan, isbridged);
++                                          break;
++					}
++				    } else if (cur->_state == chanstate) {
 +                                       ast_verbose(VERBOSE_PREFIX_1 "Nice channel, I'll take it: %s\n",evalchan);
 +                                       break;
++				    }
 +                               }
 +               }
 +               ast_mutex_unlock(&cur->lock);
 +               cur = ast_channel_walk_locked(cur);
 +       }
++    }
 +       if (cur) {
 +               if(option_verbose > 2) {
 +                   if (chanstate == AST_STATE_RINGING) {
@@ -1764,14 +1795,37 @@
 +                   }
 +               }
 +               if (bridge == 1) {
-+	    	   if (chan->_state != AST_STATE_UP) {
-+		       ast_answer(chan);
++		   if (isbridged) {
++	    	      if (chan->_state != AST_STATE_UP) {
++		        ast_answer(chan);
++		      }
++                      if (ast_channel_masquerade(cur, chan)) {
++                        ast_log(LOG_ERROR, "unable to masquerade\n");
++                      }
++                      ast_mutex_unlock(&cur->lock);
++                      ast_mutex_unlock(&chan->lock);
++		   } else {
++
++		    res = ast_channel_make_compatible(chan, cur);
++		    if (res < 0) {
++			ast_log(LOG_WARNING, "Could not make channels %s and %s compatible for bridge\n", chan->name, cur->name);
++			ast_hangup(cur);
++			return -1;
++		    }
++
++		    memset(&config,0,sizeof(struct ast_bridge_config));
++		    ast_set_flag(&(config.features_callee), AST_FEATURE_REDIRECT);
++		    ast_set_flag(&(config.features_caller), AST_FEATURE_REDIRECT);
++		    config.timelimit = 0;
++		    config.play_warning = 0;
++		    config.warning_freq = 0;
++		    config.warning_sound=NULL;
++		    if (cur->pbx) {
++			ast_softhangup_nolock(cur, AST_SOFTHANGUP_UNBRIDGE);
++		    }
++                    ast_mutex_unlock(&cur->lock);
++		    res = ast_bridge_call(chan,cur,&config);
 +		   }
-+                   if (ast_channel_masquerade(cur, chan)) {
-+                       ast_log(LOG_ERROR, "unable to masquerade\n");
-+                   }
-+                   ast_mutex_unlock(&cur->lock);
-+                   ast_mutex_unlock(&chan->lock);
 +               } else {
 +                   cur->_softhangup = AST_SOFTHANGUP_DEV;
 +                   ast_mutex_unlock(&cur->lock);
@@ -1797,7 +1851,7 @@
 +	}
 +	LOCAL_USER_ADD(u);
 +	if (!res) {
-+		res = my_pickup_call(chan, pickupgroup, AST_STATE_RINGING, 1);
++		res = my_pickup_call(chan, pickupgroup, AST_STATE_RINGING, 0, 1);
 +	}
 +	if (res > 0)
 +		res = 0;
@@ -1817,7 +1871,7 @@
 +	}
 +	LOCAL_USER_ADD(u);
 +	if (!res) {
-+		res = my_pickup_call(chan, pickupgroup, AST_STATE_UP, 1);
++		res = my_pickup_call(chan, pickupgroup, AST_STATE_UP, 1, 1);
 +	}
 +	if (res > 0)
 +		res = 0;
@@ -1837,7 +1891,7 @@
 +	}
 +	LOCAL_USER_ADD(u);
 +	if (!res) {
-+		res = my_pickup_call(chan, pickupgroup, AST_STATE_RINGING, 0);
++		res = my_pickup_call(chan, pickupgroup, AST_STATE_RINGING, 0, 0);
 +	}
 +	if (res > 0)
 +		res = 0;
@@ -1854,7 +1908,7 @@
 +        }
 +       LOCAL_USER_ADD(u);
 +       if (!res) {
-+               res = my_pickup_channel(chan, data, AST_STATE_RINGING, 1);
++               res = my_pickup_channel(chan, data, NULL,AST_STATE_RINGING, 0, 1);
 +       }
 +       if (res > 0)
 +               res = 0;
@@ -1873,7 +1927,7 @@
 +
 +	LOCAL_USER_ADD(u);
 +	if (!res) {
-+		res = my_pickup_channel(chan, data, AST_STATE_UP, 1);
++		res = my_pickup_channel(chan, data, NULL, AST_STATE_UP, 1, 1);
 +	}
 +	if (res > 0)
 +		res = 0;
@@ -1881,10 +1935,72 @@
 +	return res;
 +}
 +
++static int stealuniqueid_exec(struct ast_channel *chan, void *data)
++{
++	int res=0;
++	struct localuser *u;
++	char *uniqueid = NULL;
++        if (!data) {
++                ast_log(LOG_WARNING, "StealUniqueID requires an argument (uniqueid)\n");
++                return -1;
++        }
++	uniqueid = (char *)data;
++	LOCAL_USER_ADD(u);
++	if (!res) {
++		res = my_pickup_channel(chan, NULL, uniqueid, AST_STATE_UP, 1, 1);
++	}
++	if (res > 0)
++		res = 0;
++	LOCAL_USER_REMOVE(u);
++	return res;
++}
 +
++static int grabchan_exec(struct ast_channel *chan, void *data)
++{
++	int res=0;
++	struct localuser *u;
++        if (!data) {
++                ast_log(LOG_WARNING, "GrabChan requires an argument (technology1/number1&technology2/number2...)\n");
++                return -1;
++        }
++
++	LOCAL_USER_ADD(u);
++	if (!res) {
++		res = my_pickup_channel(chan, data, NULL, -1, 0, 1);
++	}
++	if (res > 0)
++		res = 0;
++	LOCAL_USER_REMOVE(u);
++	return res;
++}
++
++static int grabuniqueid_exec(struct ast_channel *chan, void *data)
++{
++	int res=0;
++	struct localuser *u;
++	char *uniqueid = NULL;
++        if (!data) {
++                ast_log(LOG_WARNING, "GrabUniqueID requires an argument (uniqueid)\n");
++                return -1;
++        }
++	uniqueid = (char *)data;
++	LOCAL_USER_ADD(u);
++	if (!res) {
++		res = my_pickup_channel(chan, NULL, uniqueid, -1, 0, 1);
++	}
++	if (res > 0)
++		res = 0;
++	LOCAL_USER_REMOVE(u);
++	return res;
++}
++
++
 +int unload_module(void)
 +{
 +	STANDARD_HANGUP_LOCALUSERS;
++	ast_unregister_application(app8);
++	ast_unregister_application(app7);
++	ast_unregister_application(app6);
 +	ast_unregister_application(app5);
 +	ast_unregister_application(app4);
 +	ast_unregister_application(app3);
@@ -1894,6 +2010,9 @@
 +
 +int load_module(void)
 +{
++	ast_register_application(app8, stealuniqueid_exec, synopsis8, descrip8);
++	ast_register_application(app7, grabuniqueid_exec, synopsis7, descrip7);
++	ast_register_application(app6, grabchan_exec, synopsis6, descrip6);
 +	ast_register_application(app5, stealchan_exec, synopsis5, descrip5);
 +	ast_register_application(app4, pickupchan_exec, synopsis4, descrip4);
 +	ast_register_application(app3, pickdown_exec, synopsis3, descrip3);
@@ -1917,9 +2036,9 @@
 +{
 +	return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.19.orig/apps/app_queue.c asterisk-1.2.19/apps/app_queue.c
---- asterisk-1.2.19.orig/apps/app_queue.c	2007-05-22 15:07:03.000000000 +0200
-+++ asterisk-1.2.19/apps/app_queue.c	2007-06-25 11:13:51.421628144 +0200
+diff -urN asterisk-1.2.23.orig/apps/app_queue.c asterisk-1.2.23/apps/app_queue.c
+--- asterisk-1.2.23.orig/apps/app_queue.c	2007-07-18 19:48:33.000000000 +0200
++++ asterisk-1.2.23/apps/app_queue.c	2007-07-25 08:53:52.976340261 +0200
 @@ -545,7 +545,7 @@
  	return NULL;
  }
@@ -1929,7 +2048,7 @@
  {
  	/* Avoid potential for deadlocks by spawning a new thread to handle
  	   the event */
-@@ -1529,7 +1529,7 @@
+@@ -1525,7 +1525,7 @@
  		location = "";
  
  	/* Request the peer */
@@ -1938,7 +2057,7 @@
  	if (!tmp->chan) {			/* If we can't, just go on to the next call */
  #if 0
  		ast_log(LOG_NOTICE, "Unable to create channel of type '%s' for Queue\n", cur->tech);
-@@ -1841,7 +1841,7 @@
+@@ -1837,7 +1837,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 */
@@ -1947,7 +2066,7 @@
  					if (status != o->oldstatus) 
  						update_dial_status(qe->parent, o->member, status);						
  					if (!o->chan) {
-@@ -2385,14 +2385,14 @@
+@@ -2390,14 +2390,14 @@
  			else
  				which = peer;
  			if (monitorfilename)
@@ -1965,9 +2084,9 @@
  			}
  			if (qe->parent->monjoin)
  				ast_monitor_setjoinfiles(which, 1);
-diff -urN asterisk-1.2.19.orig/apps/app_readfile.c asterisk-1.2.19/apps/app_readfile.c
---- asterisk-1.2.19.orig/apps/app_readfile.c	2006-03-23 21:13:48.000000000 +0100
-+++ asterisk-1.2.19/apps/app_readfile.c	2007-06-25 11:13:51.421628144 +0200
+diff -urN asterisk-1.2.23.orig/apps/app_readfile.c asterisk-1.2.23/apps/app_readfile.c
+--- asterisk-1.2.23.orig/apps/app_readfile.c	2006-03-23 21:13:48.000000000 +0100
++++ asterisk-1.2.23/apps/app_readfile.c	2007-07-25 08:53:52.976340261 +0200
 @@ -40,7 +40,7 @@
  #include "asterisk/app.h"
  #include "asterisk/module.h"
@@ -1977,9 +2096,9 @@
  
  static char *app_readfile = "ReadFile";
  
-diff -urN asterisk-1.2.19.orig/apps/app_segfault.c asterisk-1.2.19/apps/app_segfault.c
---- asterisk-1.2.19.orig/apps/app_segfault.c	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.19/apps/app_segfault.c	2007-06-25 11:13:51.421628144 +0200
+diff -urN asterisk-1.2.23.orig/apps/app_segfault.c asterisk-1.2.23/apps/app_segfault.c
+--- asterisk-1.2.23.orig/apps/app_segfault.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.23/apps/app_segfault.c	2007-07-25 08:53:52.976340261 +0200
 @@ -0,0 +1,75 @@
 +/*
 + * Segfault application
@@ -2056,9 +2175,9 @@
 +{
 +    return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.19.orig/apps/app_sendtext.c asterisk-1.2.19/apps/app_sendtext.c
---- asterisk-1.2.19.orig/apps/app_sendtext.c	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.19/apps/app_sendtext.c	2007-06-25 11:13:51.425629089 +0200
+diff -urN asterisk-1.2.23.orig/apps/app_sendtext.c asterisk-1.2.23/apps/app_sendtext.c
+--- asterisk-1.2.23.orig/apps/app_sendtext.c	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.23/apps/app_sendtext.c	2007-07-25 08:53:52.980341210 +0200
 @@ -112,7 +112,7 @@
  	}
  	status = "FAILURE";
@@ -2068,9 +2187,9 @@
  	if (!res)
  		status = "SUCCESS";
  	pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
-diff -urN asterisk-1.2.19.orig/apps/app_zapras.c asterisk-1.2.19/apps/app_zapras.c
---- asterisk-1.2.19.orig/apps/app_zapras.c	2006-12-11 01:33:59.000000000 +0100
-+++ asterisk-1.2.19/apps/app_zapras.c	2007-06-25 11:13:51.425629089 +0200
+diff -urN asterisk-1.2.23.orig/apps/app_zapras.c asterisk-1.2.23/apps/app_zapras.c
+--- asterisk-1.2.23.orig/apps/app_zapras.c	2006-12-11 01:33:59.000000000 +0100
++++ asterisk-1.2.23/apps/app_zapras.c	2007-07-25 08:53:52.980341210 +0200
 @@ -188,7 +188,7 @@
  				}
  			}
@@ -2080,9 +2199,9 @@
  			ioctl(chan->fds[0], ZT_AUDIOMODE, &x);
  
  			/* Restore saved values */
-diff -urN asterisk-1.2.19.orig/apps/Makefile asterisk-1.2.19/apps/Makefile
---- asterisk-1.2.19.orig/apps/Makefile	2006-04-30 15:38:22.000000000 +0200
-+++ asterisk-1.2.19/apps/Makefile	2007-06-25 11:13:51.425629089 +0200
+diff -urN asterisk-1.2.23.orig/apps/Makefile asterisk-1.2.23/apps/Makefile
+--- asterisk-1.2.23.orig/apps/Makefile	2006-04-30 15:38:22.000000000 +0200
++++ asterisk-1.2.23/apps/Makefile	2007-07-25 08:53:52.980341210 +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 \
@@ -2100,9 +2219,9 @@
  
  #
  # Obsolete things...
-diff -urN asterisk-1.2.19.orig/asterisk.c asterisk-1.2.19/asterisk.c
---- asterisk-1.2.19.orig/asterisk.c	2007-04-30 16:34:07.000000000 +0200
-+++ asterisk-1.2.19/asterisk.c	2007-06-25 11:13:51.429630034 +0200
+diff -urN asterisk-1.2.23.orig/asterisk.c asterisk-1.2.23/asterisk.c
+--- asterisk-1.2.23.orig/asterisk.c	2007-06-28 01:22:13.000000000 +0200
++++ asterisk-1.2.23/asterisk.c	2007-07-25 08:53:52.980341210 +0200
 @@ -169,7 +169,7 @@
  int option_maxcalls = 0;			/*!< */
  double option_maxload = 0.0;			/*!< Max load avg on system */
@@ -2120,7 +2239,7 @@
  
  static char *_argv[256];
  static int shuttingdown = 0;
-@@ -1890,6 +1891,7 @@
+@@ -1893,6 +1894,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));
@@ -2128,7 +2247,7 @@
  
  	/* no asterisk.conf? no problem, use buildtime config! */
  	if (!cfg) {
-@@ -2004,6 +2006,8 @@
+@@ -2007,6 +2009,8 @@
  		/* What group to run as */
  		} else if (!strcasecmp(v->name, "rungroup")) {
  			ast_copy_string(ast_config_AST_RUN_GROUP, v->value, sizeof(ast_config_AST_RUN_GROUP));
@@ -2137,9 +2256,9 @@
  		}
  		v = v->next;
  	}
-diff -urN asterisk-1.2.19.orig/build_tools/make_defaults_h asterisk-1.2.19/build_tools/make_defaults_h
---- asterisk-1.2.19.orig/build_tools/make_defaults_h	2005-06-20 19:26:08.000000000 +0200
-+++ asterisk-1.2.19/build_tools/make_defaults_h	2007-06-25 11:13:51.429630034 +0200
+diff -urN asterisk-1.2.23.orig/build_tools/make_defaults_h asterisk-1.2.23/build_tools/make_defaults_h
+--- asterisk-1.2.23.orig/build_tools/make_defaults_h	2005-06-20 19:26:08.000000000 +0200
++++ asterisk-1.2.23/build_tools/make_defaults_h	2007-07-25 08:53:52.984342158 +0200
 @@ -16,6 +16,7 @@
  #define AST_KEY_DIR    "${INSTALL_PATH}${ASTVARLIBDIR}/keys"
  #define AST_DB         "${INSTALL_PATH}${ASTVARLIBDIR}/astdb"
@@ -2148,9 +2267,9 @@
  
  #define AST_CONFIG_FILE "${INSTALL_PATH}${ASTCONFPATH}"
  
-diff -urN asterisk-1.2.19.orig/channel.c asterisk-1.2.19/channel.c
---- asterisk-1.2.19.orig/channel.c	2007-06-14 22:56:19.000000000 +0200
-+++ asterisk-1.2.19/channel.c	2007-06-25 11:13:51.433630978 +0200
+diff -urN asterisk-1.2.23.orig/channel.c asterisk-1.2.23/channel.c
+--- asterisk-1.2.23.orig/channel.c	2007-07-05 16:19:14.000000000 +0200
++++ asterisk-1.2.23/channel.c	2007-07-25 08:53:52.988343106 +0200
 @@ -94,8 +94,8 @@
   */
  static int shutting_down = 0;
@@ -2291,7 +2410,7 @@
  }
  
  int ast_channel_spy_add(struct ast_channel *chan, struct ast_channel_spy *spy)
-@@ -2161,7 +2191,7 @@
+@@ -2164,7 +2194,7 @@
  	return buf;
  }
  
@@ -2300,7 +2419,7 @@
  {
  	int res = 0;
  	/* Stop if we're a zombie or need a soft hangup */
-@@ -2169,7 +2199,7 @@
+@@ -2172,7 +2202,7 @@
  		return -1;
  	CHECK_BLOCKING(chan);
  	if (chan->tech->send_text)
@@ -2309,7 +2428,7 @@
  	ast_clear_flag(chan, AST_FLAG_BLOCKING);
  	return res;
  }
-@@ -2299,7 +2329,7 @@
+@@ -2302,7 +2332,7 @@
  		break;
  	case AST_FRAME_TEXT:
  		if (chan->tech->send_text)
@@ -2318,7 +2437,7 @@
  		else
  			res = 0;
  		break;
-@@ -2443,7 +2473,7 @@
+@@ -2446,7 +2476,7 @@
  			  &chan->writetrans, 1);
  }
  
@@ -2327,7 +2446,7 @@
  {
  	int state = 0;
  	int cause = 0;
-@@ -2451,7 +2481,7 @@
+@@ -2454,7 +2484,7 @@
  	struct ast_frame *f;
  	int res = 0;
  	
@@ -2336,7 +2455,7 @@
  	if (chan) {
  		if (oh) {
  			if (oh->vars)	
-@@ -2465,6 +2495,7 @@
+@@ -2468,6 +2498,7 @@
  		}
  		ast_set_callerid(chan, cid_num, cid_name, cid_num);
  
@@ -2344,7 +2463,7 @@
  		if (!ast_call(chan, data, 0)) {
  			res = 1;	/* in case chan->_state is already AST_STATE_UP */
  			while (timeout && (chan->_state != AST_STATE_UP)) {
-@@ -2488,6 +2519,7 @@
+@@ -2491,6 +2522,7 @@
  					if (f->subclass == AST_CONTROL_RINGING)
  						state = AST_CONTROL_RINGING;
  					else if ((f->subclass == AST_CONTROL_BUSY) || (f->subclass == AST_CONTROL_CONGESTION)) {
@@ -2352,7 +2471,7 @@
  						state = f->subclass;
  						ast_frfree(f);
  						break;
-@@ -2557,12 +2589,12 @@
+@@ -2560,12 +2592,12 @@
  	return chan;
  }
  
@@ -2368,7 +2487,7 @@
  {
  	struct chanlist *chan;
  	struct ast_channel *c;
-@@ -2599,6 +2631,7 @@
+@@ -2602,6 +2634,7 @@
  		if (!(c = chan->tech->requester(type, capabilities, data, cause)))
  			return NULL;
  
@@ -2376,7 +2495,7 @@
  		if (c->_state == AST_STATE_DOWN) {
  			manager_event(EVENT_FLAG_CALL, "Newchannel",
  				      "Channel: %s\r\n"
-@@ -2880,6 +2913,29 @@
+@@ -2883,6 +2916,29 @@
  	return res;
  }
  
@@ -2406,7 +2525,7 @@
  void ast_change_name(struct ast_channel *chan, char *newname)
  {
  	char tmp[256];
-@@ -3005,7 +3061,7 @@
+@@ -3018,7 +3074,7 @@
  	ast_copy_string(clone->name, masqn, sizeof(clone->name));
  	
  	/* Notify any managers of the change, first the masq then the other */
@@ -2415,7 +2534,7 @@
  	manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", orig, newn, original->uniqueid);
  
  	/* Swap the technlogies */	
-@@ -3255,15 +3311,14 @@
+@@ -3267,15 +3323,14 @@
  				);
  }
  
@@ -2433,7 +2552,7 @@
  	manager_event(EVENT_FLAG_CALL,
  		      (oldstate == AST_STATE_DOWN && !ast_test_flag(chan, AST_FLAG_NOTNEW)) ? "Newchannel" : "Newstate",
  		      "Channel: %s\r\n"
-@@ -3279,6 +3334,10 @@
+@@ -3291,6 +3346,10 @@
  	return 0;
  }
  
@@ -2444,7 +2563,7 @@
  /*--- Find bridged channel */
  struct ast_channel *ast_bridged_channel(struct ast_channel *chan)
  {
-@@ -3458,6 +3517,7 @@
+@@ -3470,6 +3529,7 @@
  	char caller_warning = 0;
  	char callee_warning = 0;
  
@@ -2452,7 +2571,7 @@
  	if (c0->_bridge) {
  		ast_log(LOG_WARNING, "%s is already in a bridge with %s\n", 
  			c0->name, c0->_bridge->name);
-@@ -3468,6 +3528,10 @@
+@@ -3480,6 +3540,10 @@
  			c1->name, c1->_bridge->name);
  		return -1;
  	}
@@ -2463,7 +2582,7 @@
  	
  	/* Stop if we're a zombie or need a soft hangup */
  	if (ast_test_flag(c0, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) ||
-@@ -4191,3 +4255,22 @@
+@@ -4209,3 +4273,22 @@
  
  	free(state);
  }
@@ -2486,9 +2605,9 @@
 +
 +	return res;
 +}
-diff -urN asterisk-1.2.19.orig/channels/chan_agent.c asterisk-1.2.19/channels/chan_agent.c
---- asterisk-1.2.19.orig/channels/chan_agent.c	2007-02-28 19:55:45.000000000 +0100
-+++ asterisk-1.2.19/channels/chan_agent.c	2007-06-25 11:13:51.437631923 +0200
+diff -urN asterisk-1.2.23.orig/channels/chan_agent.c asterisk-1.2.23/channels/chan_agent.c
+--- asterisk-1.2.23.orig/channels/chan_agent.c	2007-07-23 20:28:13.000000000 +0200
++++ asterisk-1.2.23/channels/chan_agent.c	2007-07-25 08:53:52.988343106 +0200
 @@ -248,7 +248,7 @@
  static struct ast_frame *agent_read(struct ast_channel *ast);
  static int agent_write(struct ast_channel *ast, struct ast_frame *f);
@@ -2523,7 +2642,7 @@
  	ast_mutex_unlock(&p->lock);
  	return res;
  }
-@@ -1348,7 +1348,7 @@
+@@ -1350,7 +1350,7 @@
  						chan = agent_new(p, AST_STATE_DOWN);
  					} else if (!p->owner && !ast_strlen_zero(p->loginchan)) {
  						/* Adjustable agent */
@@ -2532,9 +2651,9 @@
  						if (p->chan)
  							chan = agent_new(p, AST_STATE_DOWN);
  					}
-diff -urN asterisk-1.2.19.orig/channels/chan_alsa.c asterisk-1.2.19/channels/chan_alsa.c
---- asterisk-1.2.19.orig/channels/chan_alsa.c	2005-12-21 21:01:16.000000000 +0100
-+++ asterisk-1.2.19/channels/chan_alsa.c	2007-06-25 11:13:51.437631923 +0200
+diff -urN asterisk-1.2.23.orig/channels/chan_alsa.c asterisk-1.2.23/channels/chan_alsa.c
+--- asterisk-1.2.23.orig/channels/chan_alsa.c	2005-12-21 21:01:16.000000000 +0100
++++ asterisk-1.2.23/channels/chan_alsa.c	2007-07-25 08:53:52.992344055 +0200
 @@ -172,7 +172,7 @@
  /* ZZ */
  static struct ast_channel *alsa_request(const char *type, int format, void *data, int *cause);
@@ -2553,9 +2672,9 @@
  {
  	ast_mutex_lock(&alsalock);
  	ast_verbose( " << Console Received text %s >> \n", text);
-diff -urN asterisk-1.2.19.orig/channels/chan_capi.c asterisk-1.2.19/channels/chan_capi.c
---- asterisk-1.2.19.orig/channels/chan_capi.c	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.19/channels/chan_capi.c	2007-06-25 11:13:51.445633813 +0200
+diff -urN asterisk-1.2.23.orig/channels/chan_capi.c asterisk-1.2.23/channels/chan_capi.c
+--- asterisk-1.2.23.orig/channels/chan_capi.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.23/channels/chan_capi.c	2007-07-25 08:53:52.996345003 +0200
 @@ -0,0 +1,2888 @@
 +/*
 + * (CAPI*)
@@ -5445,9 +5564,9 @@
 +{
 +	return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.19.orig/channels/chan_features.c asterisk-1.2.19/channels/chan_features.c
---- asterisk-1.2.19.orig/channels/chan_features.c	2006-08-30 20:59:44.000000000 +0200
-+++ asterisk-1.2.19/channels/chan_features.c	2007-06-25 11:13:51.445633813 +0200
+diff -urN asterisk-1.2.23.orig/channels/chan_features.c asterisk-1.2.23/channels/chan_features.c
+--- asterisk-1.2.23.orig/channels/chan_features.c	2006-08-30 20:59:44.000000000 +0200
++++ asterisk-1.2.23/channels/chan_features.c	2007-07-25 08:53:52.996345003 +0200
 @@ -427,7 +427,7 @@
  	}
  	ast_mutex_unlock(&featurelock);
@@ -5457,9 +5576,9 @@
  		if (!chan) {
  			ast_log(LOG_NOTICE, "Unable to allocate subchannel '%s/%s'\n", tech, dest);
  			return NULL;
-diff -urN asterisk-1.2.19.orig/channels/chan_iax2.c asterisk-1.2.19/channels/chan_iax2.c
---- asterisk-1.2.19.orig/channels/chan_iax2.c	2007-05-23 22:06:13.000000000 +0200
-+++ asterisk-1.2.19/channels/chan_iax2.c	2007-06-25 11:13:51.457636648 +0200
+diff -urN asterisk-1.2.23.orig/channels/chan_iax2.c asterisk-1.2.23/channels/chan_iax2.c
+--- asterisk-1.2.23.orig/channels/chan_iax2.c	2007-07-24 18:32:04.000000000 +0200
++++ asterisk-1.2.23/channels/chan_iax2.c	2007-07-25 08:53:53.008347848 +0200
 @@ -11,6 +11,9 @@
   * the project provides a web site, mailing lists and IRC
   * channels for your use.
@@ -5470,7 +5589,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.
-@@ -747,7 +750,7 @@
+@@ -754,7 +757,7 @@
  static struct ast_channel *iax2_request(const char *type, int format, void *data, int *cause);
  static int iax2_devicestate(void *data);
  static int iax2_digit(struct ast_channel *c, char digit);
@@ -5479,7 +5598,7 @@
  static int iax2_sendimage(struct ast_channel *c, struct ast_frame *img);
  static int iax2_sendhtml(struct ast_channel *c, int subclass, const char *data, int datalen);
  static int iax2_call(struct ast_channel *c, char *dest, int timeout);
-@@ -2575,7 +2578,7 @@
+@@ -2582,7 +2585,7 @@
  	return send_command_locked(PTR_TO_CALLNO(c->tech_pvt), AST_FRAME_DTMF, digit, 0, NULL, 0, -1);
  }
  
@@ -5488,7 +5607,7 @@
  {
  	
  	return send_command_locked(PTR_TO_CALLNO(c->tech_pvt), AST_FRAME_TEXT,
-@@ -3114,7 +3117,7 @@
+@@ -3121,7 +3124,7 @@
   	memset(&ied, 0, sizeof(ied));
  	ast_mutex_lock(&iaxsl[callno]);
  	if (callno && iaxs[callno]) {
@@ -5497,9 +5616,9 @@
  		alreadygone = ast_test_flag(iaxs[callno], IAX_ALREADYGONE);
  		/* Send the hangup unless we have had a transmission error or are already gone */
   		iax_ie_append_byte(&ied, IAX_IE_CAUSECODE, (unsigned char)c->hangupcause);
-diff -urN asterisk-1.2.19.orig/channels/chan_oss.c asterisk-1.2.19/channels/chan_oss.c
---- asterisk-1.2.19.orig/channels/chan_oss.c	2006-07-05 17:31:01.000000000 +0200
-+++ asterisk-1.2.19/channels/chan_oss.c	2007-06-25 11:13:51.457636648 +0200
+diff -urN asterisk-1.2.23.orig/channels/chan_oss.c asterisk-1.2.23/channels/chan_oss.c
+--- asterisk-1.2.23.orig/channels/chan_oss.c	2006-07-05 17:31:01.000000000 +0200
++++ asterisk-1.2.23/channels/chan_oss.c	2007-07-25 08:53:53.008347848 +0200
 @@ -318,7 +318,7 @@
  static struct ast_channel *oss_request(const char *type, int format, void *data
  , int *cause);
@@ -5518,9 +5637,9 @@
  {
  	/* print received messages */
  	ast_verbose( " << Console Received text %s >> \n", text);
-diff -urN asterisk-1.2.19.orig/channels/chan_oss_old.c asterisk-1.2.19/channels/chan_oss_old.c
---- asterisk-1.2.19.orig/channels/chan_oss_old.c	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.19/channels/chan_oss_old.c	2007-06-25 11:13:51.461637593 +0200
+diff -urN asterisk-1.2.23.orig/channels/chan_oss_old.c asterisk-1.2.23/channels/chan_oss_old.c
+--- asterisk-1.2.23.orig/channels/chan_oss_old.c	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.23/channels/chan_oss_old.c	2007-07-25 08:53:53.008347848 +0200
 @@ -136,7 +136,7 @@
  
  static struct ast_channel *oss_request(const char *type, int format, void *data, int *cause);
@@ -5539,10 +5658,10 @@
  {
  	ast_verbose( " << Console Received text %s >> \n", text);
  	return 0;
-diff -urN asterisk-1.2.19.orig/channels/chan_phone.c asterisk-1.2.19/channels/chan_phone.c
---- asterisk-1.2.19.orig/channels/chan_phone.c	2007-04-24 20:20:31.000000000 +0200
-+++ asterisk-1.2.19/channels/chan_phone.c	2007-06-25 11:13:51.461637593 +0200
-@@ -153,7 +153,7 @@
+diff -urN asterisk-1.2.23.orig/channels/chan_phone.c asterisk-1.2.23/channels/chan_phone.c
+--- asterisk-1.2.23.orig/channels/chan_phone.c	2007-07-11 19:15:11.000000000 +0200
++++ asterisk-1.2.23/channels/chan_phone.c	2007-07-25 08:53:53.012348796 +0200
+@@ -156,7 +156,7 @@
  static struct ast_frame *phone_read(struct ast_channel *ast);
  static int phone_write(struct ast_channel *ast, struct ast_frame *frame);
  static struct ast_frame *phone_exception(struct ast_channel *ast);
@@ -5551,7 +5670,7 @@
  static int phone_fixup(struct ast_channel *old, struct ast_channel *new);
  
  static const struct ast_channel_tech phone_tech = {
-@@ -596,7 +596,7 @@
+@@ -599,7 +599,7 @@
  	return len;
  }
  
@@ -5560,9 +5679,9 @@
  {
      int length = strlen(text);
      return phone_write_buf(ast->tech_pvt, text, length, length, 0) == 
-diff -urN asterisk-1.2.19.orig/channels/chan_sip.c asterisk-1.2.19/channels/chan_sip.c
---- asterisk-1.2.19.orig/channels/chan_sip.c	2007-06-07 02:09:13.000000000 +0200
-+++ asterisk-1.2.19/channels/chan_sip.c	2007-06-25 11:21:49.290502680 +0200
+diff -urN asterisk-1.2.23.orig/channels/chan_sip.c asterisk-1.2.23/channels/chan_sip.c
+--- asterisk-1.2.23.orig/channels/chan_sip.c	2007-07-23 16:32:07.000000000 +0200
++++ asterisk-1.2.23/channels/chan_sip.c	2007-07-25 08:53:53.028352590 +0200
 @@ -604,6 +604,7 @@
  	unsigned int flags;			/*!< SIP_ flags */	
  	int timer_t1;				/*!< SIP timer T1, ms rtt */
@@ -5682,7 +5801,7 @@
  
  /*! \brief  realtime_update_peer: Update peer object in realtime storage ---*/
  static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, const char *username, const char *fullcontact, int expirey)
-@@ -3197,16 +3199,30 @@
+@@ -3199,16 +3201,30 @@
  
  /*! \brief  find_call: Connect incoming SIP message to current dialog or create new dialog structure */
  /*               Called by handle_request, sipsock_read */
@@ -5714,7 +5833,7 @@
  	if (pedanticsipchecking) {
  		/* In principle Call-ID's uniquely identify a call, but with a forking SIP proxy
  		   we need more to identify a branch - so we have to check branch, from
-@@ -4224,6 +4240,7 @@
+@@ -4226,6 +4242,7 @@
  	if (sipmethod == SIP_CANCEL) {
  		c = p->initreq.rlPart2;	/* Use original URI */
  	} else if (sipmethod == SIP_ACK) {
@@ -5722,7 +5841,7 @@
  		/* Use URI from Contact: in 200 OK (if INVITE) 
  		(we only have the contacturi on INVITEs) */
  		if (!ast_strlen_zero(p->okcontacturi))
-@@ -4572,6 +4589,10 @@
+@@ -4577,6 +4594,10 @@
  		dest.sin_addr = p->redirip.sin_addr;
  		if (p->redircodecs)
  			capability = p->redircodecs;
@@ -5733,7 +5852,7 @@
  	} else {
  		dest.sin_addr = p->ourip;
  		dest.sin_port = sin.sin_port;
-@@ -5034,13 +5055,15 @@
+@@ -5039,13 +5060,15 @@
  		ast_build_string(&invite, &invite_max, ";%s", p->options->uri_options);
  
  	ast_copy_string(p->uri, invite_buf, sizeof(p->uri));
@@ -5750,7 +5869,7 @@
  	} else {
  		snprintf(to, sizeof(to), "<%s>", p->uri);
  	}
-@@ -5072,6 +5095,45 @@
+@@ -5077,6 +5100,45 @@
  		add_header(req, "Remote-Party-ID", p->rpid);
  }
  
@@ -5796,7 +5915,7 @@
  /*! \brief  transmit_invite: Build REFER/INVITE/OPTIONS message and transmit it ---*/
  static int transmit_invite(struct sip_pvt *p, int sipmethod, int sdp, int init)
  {
-@@ -5098,6 +5160,11 @@
+@@ -5103,6 +5165,11 @@
  		if (!ast_strlen_zero(p->referred_by))
  			add_header(&req, "Referred-By", p->referred_by);
  	}
@@ -5808,7 +5927,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);
-@@ -5172,7 +5239,7 @@
+@@ -5177,7 +5244,7 @@
  }
  
  /*! \brief  transmit_state_notify: Used in the SUBSCRIBE notification subsystem ----*/
@@ -5817,7 +5936,7 @@
  {
  	char tmp[4000], from[256], to[256];
  	char *t = tmp, *c, *a, *mfrom, *mto;
-@@ -5320,10 +5387,19 @@
+@@ -5325,10 +5392,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);
@@ -5840,7 +5959,7 @@
  		ast_build_string(&t, &maxbytes, "<state>%s</state>\n", statestring);
  		ast_build_string(&t, &maxbytes, "</dialog>\n</dialog-info>\n");
  		break;
-@@ -6161,8 +6237,10 @@
+@@ -6164,8 +6240,10 @@
  		p->expire = -1;
  	pvt->expiry = expiry;
  	snprintf(data, sizeof(data), "%s:%d:%d:%s:%s", ast_inet_ntoa(iabuf, sizeof(iabuf), p->addr.sin_addr), ntohs(p->addr.sin_port), expiry, p->username, p->fullcontact);
@@ -5852,7 +5971,7 @@
  	manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: SIP/%s\r\nPeerStatus: Registered\r\n", p->name);
  	if (inaddrcmp(&p->addr, &oldsin)) {
  		sip_poke_peer(p);
-@@ -6553,7 +6631,7 @@
+@@ -6556,7 +6634,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 */
@@ -5861,7 +5980,7 @@
  {
  	struct sip_pvt *p = data;
  
-@@ -6572,7 +6650,7 @@
+@@ -6577,7 +6655,7 @@
  		p->laststate = state;
  		break;
  	}
@@ -5870,7 +5989,7 @@
  
  	if (option_verbose > 1)
  		ast_verbose(VERBOSE_PREFIX_1 "Extension Changed %s new state %s for Notify User %s\n", exten, ast_extension_state2str(state), p->username);
-@@ -6598,7 +6676,13 @@
+@@ -6606,7 +6684,13 @@
  	char *name, *c;
  	char *t;
  	char *domain;
@@ -5885,7 +6004,7 @@
  	/* Terminate URI */
  	t = uri;
  	while(*t && (*t > 32) && (*t != ';'))
-@@ -6651,9 +6735,68 @@
+@@ -6659,9 +6743,68 @@
  			ast_log(LOG_ERROR, "Peer '%s' is trying to register, but not configured as host=dynamic\n", peer->name);
  			res = -5;
  		} else {
@@ -5955,7 +6074,7 @@
  				sip_cancel_destroy(p);
  
  				switch (parse_register_contact(p, peer, req)) {
-@@ -6674,6 +6817,7 @@
+@@ -6682,6 +6825,7 @@
  					transmit_response_with_date(p, "200 OK", req);
  					peer->lastmsgssent = -1;
  					res = 0;
@@ -5963,7 +6082,7 @@
  					break;
  				}
  			} 
-@@ -7019,6 +7163,11 @@
+@@ -7027,6 +7171,11 @@
  			/* XXX The refer_to could contain a call on an entirely different machine, requiring an 
  	    		  INVITE with a replaces header -anthm XXX */
  			/* The only way to find out is to use the dialplan - oej */
@@ -5975,7 +6094,7 @@
  		}
  	} else if (ast_exists_extension(NULL, *transfercontext, refer_to, 1, NULL) || !strcmp(refer_to, ast_parking_ext())) {
  		/* This is an unsupervised transfer (blind transfer) */
-@@ -7744,6 +7893,8 @@
+@@ -7757,6 +7906,8 @@
  	int peers_offline = 0;
  	char *id;
  	char idtext[256] = "";
@@ -5984,7 +6103,7 @@
  
  	if (s) {	/* Manager - get ActionID */
  		id = astman_get_header(m,"ActionID");
-@@ -7786,6 +7937,7 @@
+@@ -7799,6 +7950,7 @@
  		else
  			ast_copy_string(name, iterator->name, sizeof(name));
  
@@ -5992,7 +6111,7 @@
  		pstatus = peer_status(iterator, status, sizeof(status));
  		if (pstatus) 	
  			peers_online++;
-@@ -7802,14 +7954,24 @@
+@@ -7815,14 +7967,24 @@
  			}
  		}			
  		
@@ -6018,7 +6137,7 @@
  			ast_cli(fd, FORMAT, name, 
  			iterator->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), iterator->addr.sin_addr) : "(Unspecified)",
  			ast_test_flag(&iterator->flags_page2, SIP_PAGE2_DYNAMIC) ? " D " : "   ",  /* Dynamic or not? */
-@@ -7817,6 +7979,7 @@
+@@ -7830,6 +7992,7 @@
  			iterator->ha ? " A " : "   ",       /* permit/deny */
  			
  			ntohs(iterator->addr.sin_port), status);
@@ -6026,7 +6145,7 @@
  		} else {	/* Manager format */
  			/* The names here need to be the same as other channels */
  			ast_cli(fd, 
-@@ -7842,7 +8005,9 @@
+@@ -7855,7 +8018,9 @@
  
  		ASTOBJ_UNLOCK(iterator);
  
@@ -6037,7 +6156,7 @@
  	} while(0) );
  
  	if (!s) {
-@@ -8878,6 +9043,7 @@
+@@ -8891,6 +9056,7 @@
  	char buf[1024];
  	unsigned int event;
  	char *c;
@@ -6045,7 +6164,7 @@
  	
  	/* Need to check the media/type */
  	if (!strcasecmp(get_header(req, "Content-Type"), "application/dtmf-relay") ||
-@@ -8941,6 +9107,19 @@
+@@ -8954,6 +9120,19 @@
  			ast_queue_control(p->owner, AST_CONTROL_VIDUPDATE);
  		transmit_response(p, "200 OK", req);
  		return;
@@ -6065,7 +6184,7 @@
  	} else if ((c = get_header(req, "X-ClientCode"))) {
  		/* Client code (from SNOM phone) */
  		if (ast_test_flag(p, SIP_USECLIENTCODE)) {
-@@ -9040,12 +9219,63 @@
+@@ -9053,12 +9232,63 @@
  	return RESULT_SUCCESS;
  }
  
@@ -6130,7 +6249,7 @@
  	if (argc < 4)
  		return RESULT_SHOWUSAGE;
  
-@@ -9062,41 +9292,13 @@
+@@ -9075,41 +9305,13 @@
  	}
  
  	for (i = 3; i < argc; i++) {
@@ -6177,7 +6296,7 @@
  /*! \brief  sip_do_history: Enable SIP History logging (CLI) ---*/
  static int sip_do_history(int fd, int argc, char *argv[])
  {
-@@ -9762,7 +9964,7 @@
+@@ -9777,7 +9979,7 @@
  		if (!ignore && p->owner) {
  			ast_queue_control(p->owner, AST_CONTROL_RINGING);
  			if (p->owner->_state != AST_STATE_UP)
@@ -6186,7 +6305,7 @@
  		}
  		if (find_sdp(req)) {
  			process_sdp(p, req);
-@@ -10472,6 +10674,8 @@
+@@ -10487,6 +10689,8 @@
  static int attempt_transfer(struct sip_pvt *p1, struct sip_pvt *p2)
  {
  	int res = 0;
@@ -6195,7 +6314,7 @@
  	struct ast_channel 
  		*chana = NULL,
  		*chanb = NULL,
-@@ -10481,6 +10685,9 @@
+@@ -10496,6 +10700,9 @@
  		*peerb = NULL,
  		*peerc = NULL,
  		*peerd = NULL;
@@ -6205,7 +6324,7 @@
  
  	if (!p1->owner || !p2->owner) {
  		ast_log(LOG_WARNING, "Transfer attempted without dual ownership?\n");
-@@ -10509,6 +10716,12 @@
+@@ -10524,6 +10731,12 @@
  		ast_quiet_chan(peerc);
  		ast_quiet_chan(peerd);
  
@@ -6218,7 +6337,7 @@
  		if (peera->cdr && peerb->cdr) {
  			peerb->cdr = ast_cdr_append(peerb->cdr, peera->cdr);
  		} else if (peera->cdr) {
-@@ -10527,6 +10740,13 @@
+@@ -10542,6 +10755,13 @@
  			ast_log(LOG_WARNING, "Failed to masquerade %s into %s\n", peerb->name, peerc->name);
  			res = -1;
  		}
@@ -6232,7 +6351,7 @@
  		return res;
  	} else {
  		ast_log(LOG_NOTICE, "Transfer attempted with no appropriate bridged calls to transfer\n");
-@@ -10538,7 +10758,6 @@
+@@ -10553,7 +10773,6 @@
  	}
  	return 0;
  }
@@ -6240,7 +6359,7 @@
  /*! \brief  gettag: Get tag from packet */
  static char *gettag(struct sip_request *req, char *header, char *tagbuf, int tagbufsize) 
  {
-@@ -10841,6 +11060,7 @@
+@@ -10856,6 +11075,7 @@
  	int res;
  	struct ast_channel *transfer_to;
  	char *transfercontext = NULL;
@@ -6248,7 +6367,7 @@
  
  	if (option_debug > 2)
  		ast_log(LOG_DEBUG, "SIP call transfer received for call %s (REFER)!\n", p->callid);
-@@ -10851,9 +11071,73 @@
+@@ -10866,9 +11086,73 @@
  		transfercontext = p->context;
  	if (res < 0)
  		transmit_response(p, "603 Declined", req);
@@ -6324,7 +6443,7 @@
  		int nobye = 0;
  		if (!ignore) {
  			if (p->refer_call) {
-@@ -11213,7 +11497,7 @@
+@@ -11231,7 +11515,7 @@
  			struct sip_pvt *p_old;
  
  			transmit_response(p, "200 OK", req);
@@ -6333,7 +6452,7 @@
  			append_history(p, "Subscribestatus", ast_extension_state2str(firststate));
  
  			/* remove any old subscription from this peer for the same exten/context,
-@@ -11425,6 +11709,8 @@
+@@ -11443,6 +11727,8 @@
  		res = handle_request_options(p, req, debug);
  		break;
  	case SIP_INVITE:
@@ -6342,7 +6461,7 @@
  		res = handle_request_invite(p, req, debug, ignore, seqno, sin, recount, e);
  		break;
  	case SIP_REFER:
-@@ -11542,7 +11828,7 @@
+@@ -11560,7 +11846,7 @@
  	/* Process request, with netlock held */
  retrylock:
  	ast_mutex_lock(&netlock);
@@ -6351,7 +6470,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)) {
-@@ -11890,6 +12176,52 @@
+@@ -11912,6 +12198,52 @@
  	return 0;
  }
  
@@ -6404,7 +6523,7 @@
  /*! \brief  sip_devicestate: Part of PBX channel interface ---*/
  
  /* Return values:---
-@@ -11961,9 +12293,13 @@
+@@ -11983,9 +12315,13 @@
  {
  	int oldformat;
  	struct sip_pvt *p;
@@ -6418,7 +6537,7 @@
  	char *dest = data;
  
  	oldformat = format;
-@@ -12026,6 +12362,56 @@
+@@ -12048,6 +12384,56 @@
  	if (ext) {
  		ast_copy_string(p->username, ext, sizeof(p->username));
  		p->fullcontact[0] = 0;	
@@ -6433,16 +6552,16 @@
 +			    if (number == p->username) {
 +				strip += strlen(peer->internationalprefix);
 +				if (option_verbose > 4) ast_log(LOG_NOTICE, "found int prefix, rest is %s\n",number+strip); 
++				ton = 2;
 +			    }
-+			    ton = 2;
 +			}
 +			if (!ton && (!ast_strlen_zero(peer->nationalprefix))) {
 +			    number = strstr(p->username, peer->nationalprefix);
 +			    if (number == p->username) {
 +				strip += strlen(peer->nationalprefix);
 +			        if (option_verbose > 4) ast_log(LOG_NOTICE, "found national prefix, rest is %s\n",number+strip); 
++				ton = 1;
 +			    }
-+			    ton = 1;
 +			}
 +			if (peer->dialplan == SIP_DIALPLAN_INTERNATIONAL) {
 +			    if (ton == 1) {
@@ -6475,7 +6594,7 @@
  	}
  #if 0
  	printf("Setting up to call extension '%s' at '%s'\n", ext ? ext : "<none>", host);
-@@ -12424,6 +12810,7 @@
+@@ -12446,6 +12832,7 @@
  
  	peer->expire = -1;
  	peer->pokeexpire = -1;
@@ -6483,7 +6602,7 @@
  	ast_copy_string(peer->name, name, sizeof(peer->name));
  	ast_copy_flags(peer, &global_flags, SIP_FLAGS_TO_COPY);
  	strcpy(peer->context, default_context);
-@@ -12452,6 +12839,8 @@
+@@ -12474,6 +12861,8 @@
  	int obproxyfound=0;
  	int found=0;
  	int format=0;		/* Ama flags */
@@ -6492,7 +6611,7 @@
  	time_t regseconds;
  	char *varname = NULL, *varval = NULL;
  	struct ast_variable *tmpvar = NULL;
-@@ -12469,7 +12858,9 @@
+@@ -12491,7 +12880,9 @@
  
  	if (peer) {
  		/* Already in the list, remove it and it will be added back (or FREE'd)  */
@@ -6503,7 +6622,7 @@
   	} else {
  		peer = malloc(sizeof(*peer));
  		if (peer) {
-@@ -12481,6 +12872,7 @@
+@@ -12503,6 +12894,7 @@
  			ASTOBJ_INIT(peer);
  			peer->expire = -1;
  			peer->pokeexpire = -1;
@@ -6511,7 +6630,7 @@
  		} else {
  			ast_log(LOG_WARNING, "Can't allocate SIP peer memory\n");
  		}
-@@ -12626,6 +13018,10 @@
+@@ -12651,6 +13043,10 @@
  			peer->call_limit = atoi(v->value);
  			if (peer->call_limit < 0)
  				peer->call_limit = 0;
@@ -6522,7 +6641,7 @@
  		} else if (!strcasecmp(v->name, "amaflags")) {
  			format = ast_cdr_amaflags2int(v->value);
  			if (format < 0) {
-@@ -12684,6 +13080,26 @@
+@@ -12709,6 +13105,26 @@
  				ast_log(LOG_WARNING, "Qualification of peer '%s' should be 'yes', 'no', or a number of milliseconds at line %d of sip.conf\n", peer->name, v->lineno);
  				peer->maxms = 0;
  			}
@@ -6549,7 +6668,7 @@
  		}
  		v = v->next;
  	}
-@@ -13016,6 +13432,22 @@
+@@ -13042,6 +13458,22 @@
  					peer = build_peer(cat, ast_variable_browse(cfg, cat), 0);
  					if (peer) {
  						ast_device_state_changed("SIP/%s", peer->name);
@@ -6572,7 +6691,7 @@
  						ASTOBJ_CONTAINER_LINK(&peerl,peer);
  						ASTOBJ_UNREF(peer, sip_destroy_peer);
  					}
-@@ -13619,6 +14051,8 @@
+@@ -13645,6 +14077,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);
@@ -6581,7 +6700,7 @@
  
  	sip_poke_all_peers();	
  	sip_send_all_registers();
-@@ -13649,6 +14083,7 @@
+@@ -13675,6 +14109,7 @@
  
  	ast_rtp_proto_unregister(&sip_rtp);
  
@@ -6589,9 +6708,9 @@
  	ast_manager_unregister("SIPpeers");
  	ast_manager_unregister("SIPshowpeer");
  
-diff -urN asterisk-1.2.19.orig/channels/chan_zap.c asterisk-1.2.19/channels/chan_zap.c
---- asterisk-1.2.19.orig/channels/chan_zap.c	2007-05-23 15:06:17.000000000 +0200
-+++ asterisk-1.2.19/channels/chan_zap.c	2007-06-25 15:44:42.863171289 +0200
+diff -urN asterisk-1.2.23.orig/channels/chan_zap.c asterisk-1.2.23/channels/chan_zap.c
+--- asterisk-1.2.23.orig/channels/chan_zap.c	2007-07-13 21:10:00.000000000 +0200
++++ asterisk-1.2.23/channels/chan_zap.c	2007-07-25 08:53:53.044356383 +0200
 @@ -11,6 +11,10 @@
   * the project provides a web site, mailing lists and IRC
   * channels for your use.
@@ -7042,7 +7161,7 @@
  		x = p->echotraining;
  		res = ioctl(p->subs[SUB_REAL].zfd, ZT_ECHOTRAIN, &x);
  		if (res) 
-@@ -1741,7 +1942,7 @@
+@@ -1750,7 +1951,7 @@
  {
  	int x, y, res;
  	x = muted;
@@ -7051,7 +7170,7 @@
  		y = 1;
  		res = ioctl(p->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &y);
  		if (res)
-@@ -1923,7 +2124,12 @@
+@@ -1932,7 +2133,12 @@
  		ast_log(LOG_WARNING, "Unable to flush input on channel %d\n", p->channel);
  	p->outgoing = 1;
  
@@ -7065,7 +7184,7 @@
  
  	switch(p->sig) {
  	case SIG_FXOLS:
-@@ -2147,6 +2353,26 @@
+@@ -2156,6 +2362,26 @@
  	case SIG_PRI:
  		/* We'll get it in a moment -- but use dialdest to store pre-setup_ack digits */
  		p->dialdest[0] = '\0';
@@ -7092,7 +7211,7 @@
  		break;
  	default:
  		ast_log(LOG_DEBUG, "not yet implemented\n");
-@@ -2165,6 +2391,12 @@
+@@ -2174,6 +2400,12 @@
  		int ldp_strip;
  		int exclusive;
  
@@ -7105,7 +7224,7 @@
  		c = strchr(dest, '/');
  		if (c)
  			c++;
-@@ -2182,6 +2414,7 @@
+@@ -2191,6 +2423,7 @@
  			ast_mutex_unlock(&p->lock);
  			return -1;
  		}
@@ -7113,7 +7232,7 @@
  		if (p->sig != SIG_FXSKS) {
  			p->dop.op = ZT_DIAL_OP_REPLACE;
  			s = strchr(c + p->stripmsd, 'w');
-@@ -2205,6 +2438,8 @@
+@@ -2214,6 +2447,8 @@
  			pri_rel(p->pri);
  			ast_mutex_unlock(&p->lock);
  			return -1;
@@ -7122,7 +7241,7 @@
  		}
  		if (!(sr = pri_sr_new())) {
  			ast_log(LOG_WARNING, "Failed to allocate setup request channel %d\n", p->channel);
-@@ -2234,7 +2469,7 @@
+@@ -2243,7 +2478,7 @@
  		pri_sr_set_channel(sr, p->bearer ? PVT_TO_CHANNEL(p->bearer) : PVT_TO_CHANNEL(p), exclusive, 1);
  		pri_sr_set_bearer(sr, p->digital ? PRI_TRANS_CAP_DIGITAL : ast->transfercapability, 
  					(p->digital ? -1 : 
@@ -7131,7 +7250,7 @@
  		if (p->pri->facilityenable)
  			pri_facility_enable(p->pri->pri);
  
-@@ -2435,8 +2670,10 @@
+@@ -2444,8 +2679,10 @@
  	}
  	if (newslot < 0) {
  		newslot = 0;
@@ -7143,7 +7262,7 @@
  	}
  	if (old && (oldslot != newslot))
  		ast_log(LOG_NOTICE, "Switching from from d-channel %d to channel %d!\n",
-@@ -2492,8 +2729,7 @@
+@@ -2501,8 +2738,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);
@@ -7153,7 +7272,7 @@
  	if (index > -1) {
  		/* Real channel, do some fixup */
  		p->subs[index].owner = NULL;
-@@ -2590,6 +2826,7 @@
+@@ -2599,6 +2835,7 @@
  
  
  	if (!p->subs[SUB_REAL].owner && !p->subs[SUB_CALLWAIT].owner && !p->subs[SUB_THREEWAY].owner) {
@@ -7161,7 +7280,7 @@
  		p->owner = NULL;
  		p->ringt = 0;
  		p->distinctivering = 0;
-@@ -2626,19 +2863,61 @@
+@@ -2635,19 +2872,61 @@
  			if (p->call && (!p->bearer || (p->bearer->call == p->call))) {
  				if (!pri_grab(p, p->pri)) {
  					if (p->alreadyhungup) {
@@ -7224,7 +7343,7 @@
  						ast_log(LOG_DEBUG, "Not yet hungup...  Calling hangup once with icause, and clearing call\n");
  
  #ifdef SUPPORT_USERUSER
-@@ -2652,7 +2931,28 @@
+@@ -2661,7 +2940,28 @@
  							if (atoi(cause))
  								icause = atoi(cause);
  						}
@@ -7254,7 +7373,7 @@
  					}
  					if (res < 0) 
  						ast_log(LOG_WARNING, "pri_disconnect failed\n");
-@@ -2680,7 +2980,13 @@
+@@ -2689,7 +2989,13 @@
  
  		}
  #endif
@@ -7269,7 +7388,7 @@
  			res = zt_set_hook(p->subs[SUB_REAL].zfd, ZT_ONHOOK);
  		if (res < 0) {
  			ast_log(LOG_WARNING, "Unable to hangup line %s\n", ast->name);
-@@ -2849,10 +3155,14 @@
+@@ -2858,10 +3164,14 @@
  			p->proceeding = 1;
  			res = pri_answer(p->pri->pri, p->call, 0, !p->digital);
  			pri_rel(p->pri);
@@ -7284,7 +7403,7 @@
  		break;
  #endif
  #ifdef ZAPATA_R2
-@@ -2862,6 +3172,13 @@
+@@ -2871,6 +3181,13 @@
  			ast_log(LOG_WARNING, "R2 Answer call failed :( on %s\n", ast->name);
  		break;
  #endif			
@@ -7298,7 +7417,7 @@
  	case 0:
  		ast_mutex_unlock(&p->lock);
  		return 0;
-@@ -3428,6 +3745,15 @@
+@@ -3437,6 +3754,15 @@
  {
  	struct zt_pvt *p = newchan->tech_pvt;
  	int x;
@@ -7314,7 +7433,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) {
-@@ -3700,7 +4026,7 @@
+@@ -3709,7 +4035,7 @@
  					if (ast_async_goto(ast, target_context, "fax", 1))
  						ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", ast->name, target_context);
  				} else
@@ -7323,7 +7442,7 @@
  			} else
  				ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n");
  		} else
-@@ -3855,7 +4181,7 @@
+@@ -3864,7 +4190,7 @@
  			if (p->call) {
  				if (p->pri && p->pri->pri) {
  					if (!pri_grab(p, p->pri)) {
@@ -7332,7 +7451,7 @@
  						pri_destroycall(p->pri->pri, p->call);
  						p->call = NULL;
  						pri_rel(p->pri);
-@@ -4821,7 +5147,7 @@
+@@ -4830,7 +5156,7 @@
  		p->subs[index].f.data = NULL;
  		p->subs[index].f.datalen= 0;
  	}
@@ -7341,7 +7460,7 @@
  		/* Perform busy detection. etc on the zap line */
  		f = ast_dsp_process(ast, p->dsp, &p->subs[index].f);
  		if (f) {
-@@ -4833,8 +5159,9 @@
+@@ -4842,8 +5168,9 @@
  				}
  			} else if (f->frametype == AST_FRAME_DTMF) {
  #ifdef ZAPATA_PRI
@@ -7353,7 +7472,7 @@
  					f->frametype = AST_FRAME_NULL;
  					f->subclass = 0;
  				}
-@@ -4909,7 +5236,9 @@
+@@ -4918,7 +5245,9 @@
  #endif
  	/* Write a frame of (presumably voice) data */
  	if (frame->frametype != AST_FRAME_VOICE) {
@@ -7364,7 +7483,7 @@
  			ast_log(LOG_WARNING, "Don't know what to do with frame type '%d'\n", frame->frametype);
  		return 0;
  	}
-@@ -4980,7 +5309,7 @@
+@@ -4989,7 +5318,7 @@
  		switch(condition) {
  		case AST_CONTROL_BUSY:
  #ifdef ZAPATA_PRI
@@ -7373,7 +7492,7 @@
  				chan->hangupcause = AST_CAUSE_USER_BUSY;
  				chan->_softhangup |= AST_SOFTHANGUP_DEV;
  				res = 0;
-@@ -5024,7 +5353,7 @@
+@@ -5033,7 +5362,7 @@
  		case AST_CONTROL_PROCEEDING:
  			ast_log(LOG_DEBUG,"Received AST_CONTROL_PROCEEDING on %s\n",chan->name);
  #ifdef ZAPATA_PRI
@@ -7382,7 +7501,7 @@
  				if (p->pri->pri) {		
  					if (!pri_grab(p, p->pri)) {
  						pri_proceeding(p->pri->pri,p->call, PVT_TO_CHANNEL(p), !p->digital);
-@@ -5043,7 +5372,7 @@
+@@ -5052,7 +5381,7 @@
  			ast_log(LOG_DEBUG,"Received AST_CONTROL_PROGRESS on %s\n",chan->name);
  #ifdef ZAPATA_PRI
  			p->digital = 0;	/* Digital-only calls isn't allows any inband progress messages */
@@ -7391,7 +7510,7 @@
  				if (p->pri->pri) {		
  					if (!pri_grab(p, p->pri)) {
  						pri_progress(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1);
-@@ -5061,7 +5390,7 @@
+@@ -5070,7 +5399,7 @@
  		case AST_CONTROL_CONGESTION:
  			chan->hangupcause = AST_CAUSE_CONGESTION;
  #ifdef ZAPATA_PRI
@@ -7400,7 +7519,7 @@
  				chan->hangupcause = AST_CAUSE_SWITCH_CONGESTION;
  				chan->_softhangup |= AST_SOFTHANGUP_DEV;
  				res = 0;
-@@ -5248,8 +5577,12 @@
+@@ -5257,8 +5586,12 @@
  		if (state == AST_STATE_RING)
  			tmp->rings = 1;
  		tmp->tech_pvt = i;
@@ -7415,7 +7534,7 @@
  			tmp->callgroup = i->callgroup;
  			tmp->pickupgroup = i->pickupgroup;
  		}
-@@ -5391,6 +5724,7 @@
+@@ -5400,6 +5733,7 @@
  	int len = 0;
  	int res;
  	int index;
@@ -7423,7 +7542,7 @@
  
  	/* in the bizarre case where the channel has become a zombie before we
  	   even get started here, abort safely
-@@ -5419,10 +5753,17 @@
+@@ -5428,10 +5762,17 @@
  		len = strlen(exten);
  		res = 0;
  		while((len < AST_MAX_EXTENSION-1) && ast_matchmore_extension(chan, chan->context, exten, 1, p->cid_num)) {
@@ -7444,7 +7563,7 @@
  			if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num))
  				timeout = matchdigittimeout;
  			else
-@@ -6519,18 +6860,44 @@
+@@ -6528,18 +6869,44 @@
  		break;
  	case ZT_EVENT_NOALARM:
  		i->inalarm = 0;
@@ -7489,7 +7608,7 @@
  		/* fall thru intentionally */
  	case ZT_EVENT_ONHOOK:
  		if (i->radio) break;
-@@ -6570,8 +6937,10 @@
+@@ -6579,8 +6946,10 @@
  			zt_set_hook(i->subs[SUB_REAL].zfd, ZT_ONHOOK);
  			break;
  		case SIG_PRI:
@@ -7502,7 +7621,7 @@
  			break;
  		default:
  			ast_log(LOG_WARNING, "Don't know how to handle on hook with signalling %s on channel %d\n", sig2str(i->sig), i->channel);
-@@ -6891,6 +7260,8 @@
+@@ -6900,6 +7269,8 @@
  		} else {
  			if (si->totalchans == 31) { /* if it's an E1 */
  				pris[*span].dchannels[0] = 16 + offset;
@@ -7511,7 +7630,7 @@
  			} else {
  				pris[*span].dchannels[0] = 24 + offset;
  			}
-@@ -6978,6 +7349,10 @@
+@@ -6987,6 +7358,10 @@
  
  #endif
  
@@ -7522,7 +7641,7 @@
  static struct zt_pvt *mkintf(int channel, struct zt_chan_conf chan_conf, struct zt_pri *pri, int reloading)
  {
  	/* Make a zt_pvt structure for this interface (or CRV if "pri" is specified) */
-@@ -7141,6 +7516,11 @@
+@@ -7150,6 +7525,11 @@
  							destroy_zt_pvt(&tmp);
  							return NULL;
  						}
@@ -7534,7 +7653,7 @@
  						if (!ast_strlen_zero(pris[span].idleext) && strcmp(pris[span].idleext, chan_conf.pri.idleext)) {
  							ast_log(LOG_ERROR, "Span %d already has idleext '%s'.\n", span + 1, chan_conf.pri.idleext);
  							destroy_zt_pvt(&tmp);
-@@ -7163,6 +7543,17 @@
+@@ -7172,6 +7552,17 @@
  							return NULL;
  						}
  						pris[span].nodetype = pritype;
@@ -7552,7 +7671,7 @@
  						pris[span].switchtype = myswitchtype;
  						pris[span].nsf = nsf;
  						pris[span].dialplan = dialplan;
-@@ -7171,9 +7562,14 @@
+@@ -7180,9 +7571,14 @@
  						pris[span].minunused = chan_conf.pri.minunused;
  						pris[span].minidle = chan_conf.pri.minidle;
  						pris[span].overlapdial = chan_conf.pri.overlapdial;
@@ -7567,7 +7686,7 @@
  						ast_copy_string(pris[span].internationalprefix, chan_conf.pri.internationalprefix, sizeof(pris[span].internationalprefix));
  						ast_copy_string(pris[span].nationalprefix, chan_conf.pri.nationalprefix, sizeof(pris[span].nationalprefix));
  						ast_copy_string(pris[span].localprefix, chan_conf.pri.localprefix, sizeof(pris[span].localprefix));
-@@ -7194,6 +7590,37 @@
+@@ -7203,6 +7599,37 @@
  				tmp->prioffset = 0;
  			}
  #endif
@@ -7605,7 +7724,7 @@
  #ifdef ZAPATA_R2
  			if (chan_conf.signalling == SIG_R2) {
  				if (r2prot < 0) {
-@@ -7327,6 +7754,7 @@
+@@ -7336,6 +7763,7 @@
  		tmp->restrictcid = chan_conf.restrictcid;
  		tmp->use_callingpres = chan_conf.use_callingpres;
  		tmp->priindication_oob = chan_conf.priindication_oob;
@@ -7613,7 +7732,7 @@
  		tmp->priexclusive = chan_conf.priexclusive;
  		if (tmp->usedistinctiveringdetection) {
  			if (!tmp->use_callerid) {
-@@ -7479,6 +7907,12 @@
+@@ -7488,6 +7916,12 @@
  				return 1;
  		}
  #endif
@@ -7626,7 +7745,7 @@
  #ifdef ZAPATA_R2
  		/* Trust R2 as well */
  		if (p->r2) {
-@@ -7600,7 +8034,7 @@
+@@ -7609,7 +8043,7 @@
  			break;
  		if (!backwards && (x >= pri->numchans))
  			break;
@@ -7635,7 +7754,7 @@
  			ast_log(LOG_DEBUG, "Found empty available channel %d/%d\n", 
  				pri->pvts[x]->logicalspan, pri->pvts[x]->prioffset);
  			return x;
-@@ -7647,7 +8081,7 @@
+@@ -7656,7 +8090,7 @@
  	end = ifend;
  	/* We do signed linear */
  	oldformat = format;
@@ -7644,7 +7763,7 @@
  	if (!format) {
  		ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", oldformat);
  		return NULL;
-@@ -7807,6 +8241,11 @@
+@@ -7816,6 +8250,11 @@
  					p->digital = 1;
  					if (tmp)
  						tmp->transfercapability = AST_TRANS_CAP_DIGITAL;
@@ -7656,7 +7775,7 @@
  				} else {
  					ast_log(LOG_WARNING, "Unknown option '%c' in '%s'\n", opt, (char *)data);
  				}
-@@ -7840,12 +8279,242 @@
+@@ -7849,12 +8288,242 @@
  				*cause = AST_CAUSE_BUSY;
  		} else if (groupmatched) {
  			*cause = AST_CAUSE_CONGESTION;
@@ -7899,7 +8018,7 @@
  
  #ifdef ZAPATA_PRI
  static struct zt_pvt *pri_find_crv(struct zt_pri *pri, int crv)
-@@ -7860,11 +8529,62 @@
+@@ -7869,11 +8538,62 @@
  	return NULL;
  }
  
@@ -7966,7 +8085,7 @@
  	int spanfd;
  	ZT_PARAMS param;
  	int principle = -1;
-@@ -7892,7 +8612,9 @@
+@@ -7901,7 +8621,9 @@
  static int pri_fixup_principle(struct zt_pri *pri, int principle, q931_call *c)
  {
  	int x;
@@ -7976,7 +8095,7 @@
  	if (!c) {
  		if (principle < 0)
  			return -1;
-@@ -7906,6 +8628,7 @@
+@@ -7915,6 +8637,7 @@
  	/* First, check for other bearers */
  	for (x=0;x<pri->numchans;x++) {
  		if (!pri->pvts[x]) continue;
@@ -7984,7 +8103,7 @@
  		if (pri->pvts[x]->call == c) {
  			/* Found our call */
  			if (principle != x) {
-@@ -7919,19 +8642,56 @@
+@@ -7928,19 +8651,56 @@
  				}
  				/* Fix it all up now */
  				pri->pvts[principle]->owner = pri->pvts[x]->owner;
@@ -8042,7 +8161,7 @@
  			}
  			return principle;
  		}
-@@ -7960,7 +8720,9 @@
+@@ -7969,7 +8729,9 @@
  		}
  		crv = crv->next;
  	}
@@ -8053,7 +8172,7 @@
  	return -1;
  }
  
-@@ -8019,86 +8781,33 @@
+@@ -8028,86 +8790,33 @@
  #ifndef PRI_RESTART
  #error "Upgrade your libpri"
  #endif
@@ -8157,7 +8276,7 @@
  	do {
  		pri->resetpos++;
  	} while((pri->resetpos < pri->numchans) &&
-@@ -8181,6 +8890,32 @@
+@@ -8190,6 +8899,32 @@
  	}
  }
  
@@ -8190,7 +8309,7 @@
  static void *pri_dchannel(void *vpri)
  {
  	struct zt_pri *pri = vpri;
-@@ -8358,15 +9093,44 @@
+@@ -8367,15 +9102,44 @@
  					/* Check for an event */
  					x = 0;
  					res = ioctl(pri->fds[which], ZT_GETEVENT, &x);
@@ -8238,7 +8357,7 @@
  					}
  				
  					if (option_debug)
-@@ -8378,8 +9142,7 @@
+@@ -8387,8 +9151,7 @@
  					break;
  			}
  		} else if (errno != EINTR)
@@ -8248,7 +8367,7 @@
  		if (e) {
  			if (pri->debug)
  				pri_dump_event(pri->dchans[which], e);
-@@ -8392,32 +9155,102 @@
+@@ -8401,32 +9164,102 @@
  
  			switch(e->e) {
  			case PRI_EVENT_DCHAN_UP:
@@ -8375,7 +8494,7 @@
  					pri->resetting = 0;
  					/* Hangup active channels and put them in alarm mode */
  					for (i=0; i<pri->numchans; i++) {
-@@ -8425,19 +9258,29 @@
+@@ -8434,19 +9267,29 @@
  						if (p) {
  							if (p->call) {
  								if (p->pri && p->pri->pri) {
@@ -8412,7 +8531,7 @@
  				}
  				break;
  			case PRI_EVENT_RESTART:
-@@ -8472,8 +9315,8 @@
+@@ -8481,8 +9324,8 @@
  								pri_destroycall(pri->pri, pri->pvts[x]->call);
  								pri->pvts[x]->call = NULL;
  							}
@@ -8423,7 +8542,7 @@
   							else if (pri->pvts[x]->owner)
  								pri->pvts[x]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
  							ast_mutex_unlock(&pri->pvts[x]->lock);
-@@ -8507,7 +9350,6 @@
+@@ -8516,7 +9359,6 @@
  					}
  				}
  				break;
@@ -8431,7 +8550,7 @@
  			case PRI_EVENT_INFO_RECEIVED:
  				chanpos = pri_find_principle(pri, e->ring.channel);
  				if (chanpos < 0) {
-@@ -8516,9 +9358,11 @@
+@@ -8525,9 +9367,11 @@
  				} else {
  					chanpos = pri_fixup_principle(pri, chanpos, e->ring.call);
  					if (chanpos > -1) {
@@ -8444,7 +8563,7 @@
  							/* how to do that */
  							int digitlen = strlen(e->ring.callednum);
  							char digit;
-@@ -8530,6 +9374,14 @@
+@@ -8539,6 +9383,14 @@
  									zap_queue_frame(pri->pvts[chanpos], &f, pri);
  								}
  							}
@@ -8459,7 +8578,7 @@
  						}
  						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
  					}
-@@ -8537,36 +9389,59 @@
+@@ -8546,36 +9398,59 @@
  				break;
  			case PRI_EVENT_RING:
  				crv = NULL;
@@ -8535,7 +8654,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));
-@@ -8580,13 +9455,14 @@
+@@ -8589,13 +9464,14 @@
  								ast_log(LOG_WARNING, "Call received for busy CRV %d on span %d\n", pri_get_crv(pri->pri, e->ring.call, NULL), pri->span);
  							} else
  								ast_log(LOG_NOTICE, "Call received for unconfigured CRV %d on span %d\n", pri_get_crv(pri->pri, e->ring.call, NULL), pri->span);
@@ -8551,7 +8670,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) {
-@@ -8611,29 +9487,78 @@
+@@ -8620,29 +9496,78 @@
  					}
  					apply_plan_to_number(pri->pvts[chanpos]->rdnis, sizeof(pri->pvts[chanpos]->rdnis), pri,
  							     e->ring.redirectingnum, e->ring.callingplanrdnis);
@@ -8643,7 +8762,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)) {
-@@ -8652,19 +9577,36 @@
+@@ -8661,19 +9586,36 @@
  						res = zt_setlaw(pri->pvts[chanpos]->subs[SUB_REAL].zfd, law);
  						if (res < 0) 
  							ast_log(LOG_WARNING, "Unable to set law on channel %d\n", pri->pvts[chanpos]->channel);
@@ -8684,7 +8803,7 @@
  						/* Get the use_callingpres state */
  						pri->pvts[chanpos]->callingpres = e->ring.callingpres;
  					
-@@ -8676,14 +9618,31 @@
+@@ -8685,14 +9627,31 @@
  								/* Set bearer and such */
  								pri_assign_bearer(crv, pri, pri->pvts[chanpos]);
  								c = zt_new(crv, AST_STATE_RESERVED, 0, SUB_REAL, law, e->ring.ctype);
@@ -8716,7 +8835,7 @@
  							if(e->ring.ani2 >= 0) {
  								snprintf(ani2str, 5, "%.2d", e->ring.ani2);
  								pbx_builtin_setvar_helper(c, "ANI2", ani2str);
-@@ -8705,8 +9664,8 @@
+@@ -8714,8 +9673,8 @@
  							pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
  							if (c && !ast_pthread_create(&threadid, &attr, ss_thread, c)) {
  								if (option_verbose > 2)
@@ -8727,7 +8846,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", 
-@@ -8714,15 +9673,19 @@
+@@ -8723,15 +9682,19 @@
  								if (c)
  									ast_hangup(c);
  								else {
@@ -8748,7 +8867,7 @@
  							ast_mutex_lock(&pri->lock);
  							if (c) {
  								char calledtonstr[10];
-@@ -8743,23 +9706,40 @@
+@@ -8752,23 +9715,40 @@
  								snprintf(calledtonstr, sizeof(calledtonstr)-1, "%d", e->ring.calledplan);
  								pbx_builtin_setvar_helper(c, "CALLEDTON", calledtonstr);
  								if (option_verbose > 2)
@@ -8793,7 +8912,7 @@
  						pri->pvts[chanpos]->call = NULL;
  						pri->pvts[chanpos]->exten[0] = '\0';
  					}
-@@ -8768,9 +9748,9 @@
+@@ -8777,9 +9757,9 @@
  					ast_mutex_unlock(&pri->pvts[chanpos]->lock);
  				} else {
  					if (e->ring.flexible)
@@ -8805,7 +8924,7 @@
  				}
  				break;
  			case PRI_EVENT_RINGING:
-@@ -8789,7 +9769,7 @@
+@@ -8798,7 +9778,7 @@
  					} else {
  						ast_mutex_lock(&pri->pvts[chanpos]->lock);
  						if (ast_strlen_zero(pri->pvts[chanpos]->dop.dialstr)) {
@@ -8814,7 +8933,7 @@
  							pri->pvts[chanpos]->subs[SUB_REAL].needringing = 1;
  							pri->pvts[chanpos]->alerting = 1;
  						} else
-@@ -8818,9 +9798,16 @@
+@@ -8827,9 +9807,16 @@
  				}
  				break;
  			case PRI_EVENT_PROGRESS:
@@ -8832,7 +8951,7 @@
  #ifdef PRI_PROGRESS_MASK
  					if ((!pri->pvts[chanpos]->progress) || (e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE)) {
  #else
-@@ -8867,6 +9854,12 @@
+@@ -8876,6 +9863,12 @@
  			case PRI_EVENT_PROCEEDING:
  				chanpos = pri_find_principle(pri, e->proceeding.channel);
  				if (chanpos > -1) {
@@ -8845,7 +8964,7 @@
  					if (!pri->pvts[chanpos]->proceeding) {
  						struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_PROCEEDING, };
  						
-@@ -8917,6 +9910,295 @@
+@@ -8926,6 +9919,295 @@
  					}
  				}
  				break;				
@@ -9141,7 +9260,7 @@
  			case PRI_EVENT_ANSWER:
  				chanpos = pri_find_principle(pri, e->answer.channel);
  				if (chanpos < 0) {
-@@ -8932,6 +10214,7 @@
+@@ -8941,6 +10223,7 @@
  						chanpos = -1;
  					} else {
  						ast_mutex_lock(&pri->pvts[chanpos]->lock);
@@ -9149,7 +9268,7 @@
  						/* Now we can do call progress detection */
  
  						/* We changed this so it turns on the DSP no matter what... progress or no progress.
-@@ -8961,11 +10244,16 @@
+@@ -8970,11 +10253,16 @@
  								ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", pri->pvts[chanpos]->dop.dialstr);
  							pri->pvts[chanpos]->dop.dialstr[0] = '\0';
  						} else if (pri->pvts[chanpos]->confirmanswer) {
@@ -9167,14 +9286,9 @@
  						}
  
  #ifdef SUPPORT_USERUSER
-@@ -9014,23 +10302,32 @@
- 								}
- 							}
- 							if (option_verbose > 2) 
--								ast_verbose(VERBOSE_PREFIX_3 "Channel %d/%d, span %d got hangup, cause %d\n", 
--									pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span, e->hangup.cause);
-+								ast_verbose(VERBOSE_PREFIX_3 "Channel %d/%d, span %d got hangup, cause %d\n", 
-+									pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span, e->hangup.cause);
+@@ -9030,21 +10318,30 @@
+ 								ast_verbose(VERBOSE_PREFIX_3 "Channel %d/%d, span %d got hangup, cause %d\n", 
+ 									pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span, e->hangup.cause);
  						} else {
 -							pri_hangup(pri->pri, pri->pvts[chanpos]->call, e->hangup.cause);
 +							pri_hangup(pri->pri, pri->pvts[chanpos]->call, e->hangup.cause, -1);
@@ -9194,7 +9308,7 @@
 +							}
  						}
 -						if (e->hangup.aoc_units > -1)
-+    						if (e->hangup.aoc_units > -1) {
++						if (e->hangup.aoc_units > -1) {
 +							if (pri->pvts[chanpos]->owner) {
 +							    char tmpstr[256];
 +							    snprintf(tmpstr, sizeof(tmpstr), "%d", (int)e->hangup.aoc_units);
@@ -9203,11 +9317,12 @@
  							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");
-+						}		
  
++						}
  #ifdef SUPPORT_USERUSER
  						if (!ast_strlen_zero(e->hangup.useruserinfo)) {
-@@ -9040,8 +10337,20 @@
+ 							pbx_builtin_setvar_helper(pri->pvts[chanpos]->owner, "USERUSERINFO", e->hangup.useruserinfo);
+@@ -9053,8 +10350,20 @@
  
  						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
  					} else {
@@ -9230,7 +9345,7 @@
  					}
  				} 
  				break;
-@@ -9051,17 +10360,25 @@
+@@ -9064,17 +10373,25 @@
  			case PRI_EVENT_HANGUP_REQ:
  				chanpos = pri_find_principle(pri, e->hangup.channel);
  				if (chanpos < 0) {
@@ -9257,9 +9372,9 @@
 +							snprintf(tmpstr, sizeof(tmpstr), "%d", e->hangup.cause);
 +							pbx_builtin_setvar_helper(pri->pvts[chanpos]->owner, "PRI_CAUSE", tmpstr);
  							pri->pvts[chanpos]->owner->hangupcause = e->hangup.cause;
- 							switch(e->hangup.cause) {
- 							case PRI_CAUSE_USER_BUSY:
-@@ -9080,20 +10397,87 @@
+ 							if (pri->pvts[chanpos]->owner->_state == AST_STATE_UP)
+ 								pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+@@ -9097,20 +10414,86 @@
  							}
  							if (option_verbose > 2) 
  								ast_verbose(VERBOSE_PREFIX_3 "Channel %d/%d, span %d got hangup request, cause %d\n", PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span, e->hangup.cause);
@@ -9274,7 +9389,7 @@
 +								pbx_builtin_setvar_helper(pri->pvts[chanpos]->owner, "AOCEUNITS", tmpstr);
 +							    }
 +							    if (option_verbose > 2)
-+							    	ast_verbose(VERBOSE_PREFIX_3 "Channel %d/%d, span %d received AOC-E charging %d unit%s\n",
++								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");
 +							}
 + 							if (pri->nodetype == BRI_NETWORK_PTMP) {
@@ -9327,37 +9442,34 @@
 +								    }
 + 								    ast_mutex_unlock(&pri->pvts[chanpos]->lock);
 + 								    break;
-+                                                               } else {
-+                                                                       pri_hangup(pri->pri, pri->pvts[chanpos]->call, e->hangup.cause, -1);
-+                                                                       pri->pvts[chanpos]->call = NULL;
-+                                                                       pri->pvts[chanpos]->tei = -1;
-+                                                               }
-+ 							    }
-+ 							}
++                                                            } else {
++                                                                    pri_hangup(pri->pri, pri->pvts[chanpos]->call, e->hangup.cause, -1);
++                                                                    pri->pvts[chanpos]->call = NULL;
++                                                                    pri->pvts[chanpos]->tei = -1;
++                                                            }
++  							}
++						    }
  						} else {
 -							pri_hangup(pri->pri, pri->pvts[chanpos]->call, e->hangup.cause);
 +							pri_hangup(pri->pri, pri->pvts[chanpos]->call, e->hangup.cause, -1);
  							pri->pvts[chanpos]->call = NULL;
-+ 							pri->pvts[chanpos]->tei = -1;
++							pri->pvts[chanpos]->tei = -1;
  						}
  						if (e->hangup.cause == PRI_CAUSE_REQUESTED_CHAN_UNAVAIL) {
 -							if (option_verbose > 2)
--								ast_verbose(VERBOSE_PREFIX_3 "Forcing restart of channel %d/%d span %d since channel reported in use\n", 
--									PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span);
++ 							if ((pri->nodetype != BRI_CPE_PTMP) && (pri->nodetype != BRI_NETWORK_PTMP)) {
++							    if (option_verbose > 2)
+ 								ast_verbose(VERBOSE_PREFIX_3 "Forcing restart of channel %d/%d span %d since channel reported in use\n", 
+ 									PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span);
 -							pri_reset(pri->pri, PVT_TO_CHANNEL(pri->pvts[chanpos]));
 -							pri->pvts[chanpos]->resetting = 1;
-+ 							if ((pri->nodetype != BRI_CPE_PTMP) && (pri->nodetype != BRI_NETWORK_PTMP)) {
-+ 							    if (option_verbose > 2)
-+  								ast_verbose(VERBOSE_PREFIX_3 "Forcing restart of channel %d/%d span %d since channel reported in use\n", 
-+  									PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span);
 +							    pri_reset(pri->pri, PVT_TO_CHANNEL(pri->pvts[chanpos]));
 +							    pri->pvts[chanpos]->resetting = 1;
 +							}
-+
  						}
  
  #ifdef SUPPORT_USERUSER
-@@ -9104,9 +10488,39 @@
+@@ -9121,9 +10504,39 @@
  
  						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
  					} else {
@@ -9398,7 +9510,7 @@
  				break;
  			case PRI_EVENT_HANGUP_ACK:
  				chanpos = pri_find_principle(pri, e->hangup.channel);
-@@ -9120,6 +10534,7 @@
+@@ -9137,6 +10550,7 @@
  					if (chanpos > -1) {
  						ast_mutex_lock(&pri->pvts[chanpos]->lock);
  						pri->pvts[chanpos]->call = NULL;
@@ -9406,7 +9518,7 @@
  						pri->pvts[chanpos]->resetting = 0;
  						if (pri->pvts[chanpos]->owner) {
  							if (option_verbose > 2) 
-@@ -9133,7 +10548,9 @@
+@@ -9150,7 +10564,9 @@
  #endif
  
  						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
@@ -9416,7 +9528,7 @@
  				}
  				break;
  			case PRI_EVENT_CONFIG_ERR:
-@@ -9225,10 +10642,22 @@
+@@ -9242,10 +10658,22 @@
  					ast_mutex_lock(&pri->pvts[chanpos]->lock);
  					switch(e->notify.info) {
  					case PRI_NOTIFY_REMOTE_HOLD:
@@ -9439,7 +9551,7 @@
  						f.subclass = AST_CONTROL_UNHOLD;
  						zap_queue_frame(pri->pvts[chanpos], &f, pri);
  						break;
-@@ -9236,6 +10665,77 @@
+@@ -9253,6 +10681,77 @@
  					ast_mutex_unlock(&pri->pvts[chanpos]->lock);
  				}
  				break;
@@ -9517,7 +9629,7 @@
  			default:
  				ast_log(LOG_DEBUG, "Event: %d\n", e->e);
  			}
-@@ -9297,7 +10797,7 @@
+@@ -9314,7 +10813,7 @@
  			pri->fds[i] = -1;
  			return -1;
  		}
@@ -9526,7 +9638,7 @@
  		/* Force overlap dial if we're doing GR-303! */
  		if (pri->switchtype == PRI_SWITCH_GR303_TMC)
  			pri->overlapdial = 1;
-@@ -9366,39 +10866,77 @@
+@@ -9383,39 +10882,77 @@
  
  static int handle_pri_set_debug_file(int fd, int argc, char **argv)
  {
@@ -9626,7 +9738,7 @@
  	}
  
  	return RESULT_SUCCESS;
-@@ -9430,6 +10968,7 @@
+@@ -9447,6 +10984,7 @@
  
  
  
@@ -9634,7 +9746,7 @@
  static int handle_pri_no_debug(int fd, int argc, char *argv[])
  {
  	int span;
-@@ -9536,36 +11075,6 @@
+@@ -9553,36 +11091,6 @@
  	return RESULT_SUCCESS;
  }
  
@@ -9671,7 +9783,7 @@
  static char pri_debug_help[] = 
  	"Usage: pri debug span <span>\n"
  	"       Enables debugging on a given PRI span\n";
-@@ -9582,6 +11091,18 @@
+@@ -9599,6 +11107,18 @@
  	"Usage: pri show span <span>\n"
  	"       Displays PRI Information\n";
  
@@ -9690,7 +9802,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 },
-@@ -9589,18 +11110,327 @@
+@@ -9606,18 +11126,327 @@
  	  "Disables PRI debugging on a span", pri_no_debug_help, complete_span_5 },
  	{ { "pri", "intense", "debug", "span", NULL }, handle_pri_really_debug,
  	  "Enables REALLY INTENSE PRI debugging", pri_really_debug_help, complete_span_5 },
@@ -10021,7 +10133,7 @@
  
  #ifdef ZAPATA_R2
  static int handle_r2_no_debug(int fd, int argc, char *argv[])
-@@ -10213,6 +12043,14 @@
+@@ -10230,6 +12059,14 @@
  			pthread_cancel(pris[i].master);
  	}
  	ast_cli_unregister_multiple(zap_pri_cli, sizeof(zap_pri_cli) / sizeof(zap_pri_cli[0]));
@@ -10036,7 +10148,7 @@
  #endif
  #ifdef ZAPATA_R2
  	ast_cli_unregister_multiple(zap_r2_cli, sizeof(zap_r2_cli) / sizeof(zap_r2_cli[0]));
-@@ -10224,6 +12062,7 @@
+@@ -10241,6 +12078,7 @@
  	ast_manager_unregister( "ZapDNDoff" );
  	ast_manager_unregister( "ZapDNDon" );
  	ast_manager_unregister("ZapShowChannels");
@@ -10044,7 +10156,7 @@
  	ast_channel_unregister(&zap_tech);
  	if (!ast_mutex_lock(&iflock)) {
  		/* Hangup all interfaces if they have an owner */
-@@ -10582,8 +12421,8 @@
+@@ -10599,8 +12437,8 @@
  			}
  		} else if (!strcasecmp(v->name, "echotraining")) {
  			if (sscanf(v->value, "%d", &y) == 1) {
@@ -10055,7 +10167,7 @@
  				} else {
  					chan_conf.echotraining = y;
  				}
-@@ -10769,12 +12608,33 @@
+@@ -10794,12 +12632,33 @@
  					chan_conf.signalling = SIG_GR303FXSKS;
  					chan_conf.radio = 0;
  					pritype = PRI_CPE;
@@ -10089,7 +10201,7 @@
  				} else {
  					ast_log(LOG_ERROR, "Unknown signalling method '%s'\n", v->value);
  				}
-@@ -10857,9 +12717,21 @@
+@@ -10882,9 +12741,21 @@
  					chan_conf.priindication_oob = 1;
  				else if (!strcasecmp(v->value, "inband"))
  					chan_conf.priindication_oob = 0;
@@ -10112,7 +10224,7 @@
  			} else if (!strcasecmp(v->name, "priexclusive")) {
  				chan_conf.priexclusive = ast_true(v->value);
  			} else if (!strcasecmp(v->name, "internationalprefix")) {
-@@ -10872,6 +12744,14 @@
+@@ -10897,6 +12768,14 @@
  				ast_copy_string(chan_conf.pri.privateprefix, v->value, sizeof(chan_conf.pri.privateprefix));
  			} else if (!strcasecmp(v->name, "unknownprefix")) {
  				ast_copy_string(chan_conf.pri.unknownprefix, v->value, sizeof(chan_conf.pri.unknownprefix));
@@ -10127,7 +10239,7 @@
  			} else if (!strcasecmp(v->name, "resetinterval")) {
  				if (!strcasecmp(v->value, "never"))
  					chan_conf.pri.resetinterval = -1;
-@@ -10888,6 +12768,8 @@
+@@ -10913,6 +12792,8 @@
  				ast_copy_string(chan_conf.pri.idleext, v->value, sizeof(chan_conf.pri.idleext));
  			} else if (!strcasecmp(v->name, "idledial")) {
  				ast_copy_string(chan_conf.pri.idledial, v->value, sizeof(chan_conf.pri.idledial));
@@ -10136,7 +10248,7 @@
  			} else if (!strcasecmp(v->name, "overlapdial")) {
  				chan_conf.pri.overlapdial = ast_true(v->value);
  			} else if (!strcasecmp(v->name, "pritimer")) {
-@@ -11073,6 +12955,7 @@
+@@ -11090,6 +12971,7 @@
  #ifdef ZAPATA_PRI
  	if (!reload) {
  		for (x=0;x<NUM_SPANS;x++) {
@@ -10144,7 +10256,7 @@
  			if (pris[x].pvts[0]) {
  				if (start_pri(pris + x)) {
  					ast_log(LOG_ERROR, "Unable to start D-channel on span %d\n", x + 1);
-@@ -11105,6 +12988,10 @@
+@@ -11122,6 +13004,10 @@
  	pri_set_error(zt_pri_error);
  	pri_set_message(zt_pri_message);
  #endif
@@ -10155,7 +10267,7 @@
  	res = setup_zap(0);
  	/* Make sure we can register our Zap channel type */
  	if(res) {
-@@ -11122,6 +13009,12 @@
+@@ -11139,6 +13025,12 @@
  	ast_cli_register_multiple(zap_r2_cli, sizeof(zap_r2_cli) / sizeof(zap_r2_cli[0]));
  #endif	
  	ast_cli_register_multiple(zap_cli, sizeof(zap_cli) / sizeof(zap_cli[0]));
@@ -10168,7 +10280,7 @@
  	
  	memset(round_robin, 0, sizeof(round_robin));
  	ast_manager_register( "ZapTransfer", 0, action_transfer, "Transfer Zap Channel" );
-@@ -11130,11 +13023,56 @@
+@@ -11147,11 +13039,56 @@
  	ast_manager_register( "ZapDNDon", 0, action_zapdndon, "Toggle Zap channel Do Not Disturb status ON" );
  	ast_manager_register( "ZapDNDoff", 0, action_zapdndoff, "Toggle Zap channel Do Not Disturb status OFF" );
  	ast_manager_register("ZapShowChannels", 0, action_zapshowchannels, "Show status zapata channels");
@@ -10227,7 +10339,7 @@
  {
  #define	END_SILENCE_LEN 400
  #define	HEADER_MS 50
-@@ -11153,6 +13091,7 @@
+@@ -11170,6 +13107,7 @@
  	float scont = 0.0;
  	int index;
  
@@ -10235,10 +10347,10 @@
  	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.19.orig/channels/Makefile asterisk-1.2.19/channels/Makefile
---- asterisk-1.2.19.orig/channels/Makefile	2007-03-26 12:21:56.000000000 +0200
-+++ asterisk-1.2.19/channels/Makefile	2007-06-25 16:07:37.549148740 +0200
-@@ -108,8 +108,16 @@
+diff -urN asterisk-1.2.23.orig/channels/Makefile asterisk-1.2.23/channels/Makefile
+--- asterisk-1.2.23.orig/channels/Makefile	2007-07-11 19:15:11.000000000 +0200
++++ asterisk-1.2.23/channels/Makefile	2007-07-25 08:53:53.056359228 +0200
+@@ -112,8 +112,16 @@
    ZAPR2=-lmfcr2
  endif
  
@@ -10250,12 +10362,12 @@
  ALSA_SRC=chan_alsa.c
  
 +# uncomment this if you want to try out the zaptel device state support 
-+#CFLAGS+=-DZAPATA_DEVICE_STATES
++CFLAGS+=-DZAPATA_DEVICE_STATES
 +
  ifneq ($(wildcard alsa-monitor.h),)
    CFLAGS+=-DALSA_MONITOR
    ALSA_SRC+=alsa-monitor.h
-@@ -128,6 +136,35 @@
+@@ -132,6 +140,35 @@
  endif
  endif # WITHOUT_ZAPTEL
  
@@ -10291,7 +10403,7 @@
  ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/vpbapi.h),)
    CHANNEL_LIBS+=chan_vpb.so
    CFLAGS+=-DLINUX
-@@ -211,7 +248,7 @@
+@@ -215,7 +252,7 @@
  	$(CC) -c $(CFLAGS) -o chan_zap.o chan_zap.c
  
  chan_zap.so: chan_zap.o
@@ -10300,7 +10412,7 @@
  
  chan_sip.so: chan_sip.o
  	$(CC) $(SOLINK) -o $@ ${CYGSOLINK} chan_sip.o ${CYGSOLIB}
-@@ -227,6 +264,9 @@
+@@ -231,6 +268,9 @@
  chan_nbs.so: chan_nbs.o
  	$(CC) $(SOLINK) -o $@ $< -lnbs
  
@@ -10310,9 +10422,9 @@
  chan_vpb.o: chan_vpb.c
  	$(CXX) -c $(CFLAGS) -o $@ chan_vpb.c
  
-diff -urN asterisk-1.2.19.orig/codecs/codec_ilbc.c asterisk-1.2.19/codecs/codec_ilbc.c
---- asterisk-1.2.19.orig/codecs/codec_ilbc.c	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.19/codecs/codec_ilbc.c	2007-06-25 11:13:51.517650822 +0200
+diff -urN asterisk-1.2.23.orig/codecs/codec_ilbc.c asterisk-1.2.23/codecs/codec_ilbc.c
+--- asterisk-1.2.23.orig/codecs/codec_ilbc.c	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.23/codecs/codec_ilbc.c	2007-07-25 08:53:53.056359228 +0200
 @@ -49,7 +49,7 @@
  #include "slin_ilbc_ex.h"
  #include "ilbc_slin_ex.h"
@@ -10322,9 +10434,9 @@
  #define ILBC_MS 			30
  /* #define ILBC_MS			20 */
  
-diff -urN asterisk-1.2.19.orig/configs/capi.conf.sample asterisk-1.2.19/configs/capi.conf.sample
---- asterisk-1.2.19.orig/configs/capi.conf.sample	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.19/configs/capi.conf.sample	2007-06-25 11:13:51.517650822 +0200
+diff -urN asterisk-1.2.23.orig/configs/capi.conf.sample asterisk-1.2.23/configs/capi.conf.sample
+--- asterisk-1.2.23.orig/configs/capi.conf.sample	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.23/configs/capi.conf.sample	2007-07-25 08:53:53.056359228 +0200
 @@ -0,0 +1,44 @@
 +;
 +; CAPI config
@@ -10370,9 +10482,9 @@
 +;msn=55512
 +;controller=2
 +;devices => 30
-diff -urN asterisk-1.2.19.orig/configs/esel.conf.sample asterisk-1.2.19/configs/esel.conf.sample
---- asterisk-1.2.19.orig/configs/esel.conf.sample	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.19/configs/esel.conf.sample	2007-06-25 11:13:51.517650822 +0200
+diff -urN asterisk-1.2.23.orig/configs/esel.conf.sample asterisk-1.2.23/configs/esel.conf.sample
+--- asterisk-1.2.23.orig/configs/esel.conf.sample	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.23/configs/esel.conf.sample	2007-07-25 08:53:53.060360177 +0200
 @@ -0,0 +1,12 @@
 +;
 +; Configuration file for res_esel
@@ -10386,9 +10498,9 @@
 +
 +; export the extension snom in context phones to DS/100 on asterisk-2
 +;export => snom at phones,100
-diff -urN asterisk-1.2.19.orig/configs/modules.conf.sample asterisk-1.2.19/configs/modules.conf.sample
---- asterisk-1.2.19.orig/configs/modules.conf.sample	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.19/configs/modules.conf.sample	2007-06-25 11:13:51.537655547 +0200
+diff -urN asterisk-1.2.23.orig/configs/modules.conf.sample asterisk-1.2.23/configs/modules.conf.sample
+--- asterisk-1.2.23.orig/configs/modules.conf.sample	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.23/configs/modules.conf.sample	2007-07-25 08:53:53.060360177 +0200
 @@ -46,8 +46,12 @@
  ;
  noload => chan_alsa.so
@@ -10402,9 +10514,9 @@
  ;
  [global]
 +chan_capi.so=yes
-diff -urN asterisk-1.2.19.orig/configs/sip.conf.sample asterisk-1.2.19/configs/sip.conf.sample
---- asterisk-1.2.19.orig/configs/sip.conf.sample	2006-11-30 18:55:23.000000000 +0100
-+++ asterisk-1.2.19/configs/sip.conf.sample	2007-06-25 11:13:51.537655547 +0200
+diff -urN asterisk-1.2.23.orig/configs/sip.conf.sample asterisk-1.2.23/configs/sip.conf.sample
+--- asterisk-1.2.23.orig/configs/sip.conf.sample	2006-11-30 18:55:23.000000000 +0100
++++ asterisk-1.2.23/configs/sip.conf.sample	2007-07-25 08:53:53.060360177 +0200
 @@ -329,7 +329,16 @@
  ;call-limit=5				; permit only 5 simultaneous outgoing calls to this peer
  ;outboundproxy=proxy.provider.domain	; send outbound signaling to this proxy, not directly to the peer
@@ -10423,9 +10535,9 @@
  ;------------------------------------------------------------------------------
  ; Definitions of locally connected SIP phones
  ;
-diff -urN asterisk-1.2.19.orig/configs/watchdog.conf.sample asterisk-1.2.19/configs/watchdog.conf.sample
---- asterisk-1.2.19.orig/configs/watchdog.conf.sample	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.19/configs/watchdog.conf.sample	2007-06-25 11:13:51.537655547 +0200
+diff -urN asterisk-1.2.23.orig/configs/watchdog.conf.sample asterisk-1.2.23/configs/watchdog.conf.sample
+--- asterisk-1.2.23.orig/configs/watchdog.conf.sample	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.23/configs/watchdog.conf.sample	2007-07-25 08:53:53.060360177 +0200
 @@ -0,0 +1,22 @@
 +;
 +; Configuration file for res_watchdog
@@ -10449,9 +10561,9 @@
 +;device = /dev/watchdog
 +;interval = 100
 +
-diff -urN asterisk-1.2.19.orig/configs/zapata.conf.sample asterisk-1.2.19/configs/zapata.conf.sample
---- asterisk-1.2.19.orig/configs/zapata.conf.sample	2006-09-18 17:05:56.000000000 +0200
-+++ asterisk-1.2.19/configs/zapata.conf.sample	2007-06-25 11:13:51.537655547 +0200
+diff -urN asterisk-1.2.23.orig/configs/zapata.conf.sample asterisk-1.2.23/configs/zapata.conf.sample
+--- asterisk-1.2.23.orig/configs/zapata.conf.sample	2006-09-18 17:05:56.000000000 +0200
++++ asterisk-1.2.23/configs/zapata.conf.sample	2007-07-25 08:53:53.164384833 +0200
 @@ -123,9 +123,20 @@
  ; 
  ; outofband:      Signal Busy/Congestion out of band with RELEASE/DISCONNECT
@@ -10473,9 +10585,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.19.orig/db.c asterisk-1.2.19/db.c
---- asterisk-1.2.19.orig/db.c	2006-01-09 19:09:53.000000000 +0100
-+++ asterisk-1.2.19/db.c	2007-06-25 11:13:51.537655547 +0200
+diff -urN asterisk-1.2.23.orig/db.c asterisk-1.2.23/db.c
+--- asterisk-1.2.23.orig/db.c	2007-06-24 19:32:21.000000000 +0200
++++ asterisk-1.2.23/db.c	2007-07-25 08:53:53.164384833 +0200
 @@ -516,11 +516,18 @@
  struct ast_cli_entry cli_database_deltree =
  { { "database", "deltree", NULL }, database_deltree, "Removes database keytree/values", database_deltree_usage };
@@ -10496,7 +10608,7 @@
  	int res;
  
  	if (!strlen(family)) {
-@@ -545,6 +552,12 @@
+@@ -541,6 +548,12 @@
  	return 0;
  }
  
@@ -10509,7 +10621,7 @@
  static int manager_dbget(struct mansession *s, struct message *m)
  {
  	char *id = astman_get_header(m,"ActionID");
-@@ -574,7 +587,7 @@
+@@ -570,7 +583,7 @@
  		ast_cli(s->fd, "Event: DBGetResponse\r\n"
  				"Family: %s\r\n"
  				"Key: %s\r\n"
@@ -10518,7 +10630,7 @@
  				"%s"
  				"\r\n",
  				family, key, tmp, idText);
-@@ -582,6 +595,39 @@
+@@ -578,6 +591,39 @@
  	return 0;
  }
  
@@ -10558,7 +10670,7 @@
  int astdb_init(void)
  {
  	dbinit();
-@@ -591,7 +637,8 @@
+@@ -587,7 +633,8 @@
  	ast_cli_register(&cli_database_put);
  	ast_cli_register(&cli_database_del);
  	ast_cli_register(&cli_database_deltree);
@@ -10569,9 +10681,9 @@
 +	ast_manager_register("DBdel", EVENT_FLAG_SYSTEM, manager_dbdel, mandescr_dbdel);
  	return 0;
  }
-diff -urN asterisk-1.2.19.orig/devicestate.c asterisk-1.2.19/devicestate.c
---- asterisk-1.2.19.orig/devicestate.c	2007-06-06 14:18:36.000000000 +0200
-+++ asterisk-1.2.19/devicestate.c	2007-06-25 11:13:51.541656492 +0200
+diff -urN asterisk-1.2.23.orig/devicestate.c asterisk-1.2.23/devicestate.c
+--- asterisk-1.2.23.orig/devicestate.c	2007-06-06 14:18:36.000000000 +0200
++++ asterisk-1.2.23/devicestate.c	2007-07-25 08:53:53.168385782 +0200
 @@ -62,6 +62,8 @@
  
  struct state_change {
@@ -10663,9 +10775,9 @@
  			free(cur);
  			AST_LIST_LOCK(&state_changes);
  		} else {
-diff -urN asterisk-1.2.19.orig/doc/README.asterisk.conf asterisk-1.2.19/doc/README.asterisk.conf
---- asterisk-1.2.19.orig/doc/README.asterisk.conf	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.19/doc/README.asterisk.conf	2007-06-25 11:13:51.541656492 +0200
+diff -urN asterisk-1.2.23.orig/doc/README.asterisk.conf asterisk-1.2.23/doc/README.asterisk.conf
+--- asterisk-1.2.23.orig/doc/README.asterisk.conf	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.23/doc/README.asterisk.conf	2007-07-25 08:53:53.168385782 +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
@@ -10674,9 +10786,24 @@
  
  [files]
  ; Changing the following lines may compromise your security
-diff -urN asterisk-1.2.19.orig/HARDWARE asterisk-1.2.19/HARDWARE
---- asterisk-1.2.19.orig/HARDWARE	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.19/HARDWARE	2007-06-25 11:13:51.541656492 +0200
+diff -urN asterisk-1.2.23.orig/editline/cygdef.h asterisk-1.2.23/editline/cygdef.h
+--- asterisk-1.2.23.orig/editline/cygdef.h	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.23/editline/cygdef.h	2007-07-25 08:53:53.168385782 +0200
+@@ -0,0 +1,11 @@
++/* cygdef.h. Generated automatically by configure. */ 
++#ifndef _CYGDEF_H_
++#define _CYGDEF_H_ 1
++#include <sys/ioctl.h>
++#define __linux__ 1
++ 
++
++typedef void (*sig_t)(int);
++ 
++
++#endif /* _CYGDEF_H_ */
+diff -urN asterisk-1.2.23.orig/HARDWARE asterisk-1.2.23/HARDWARE
+--- asterisk-1.2.23.orig/HARDWARE	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.23/HARDWARE	2007-07-25 08:53:53.168385782 +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.
@@ -10697,9 +10824,9 @@
  Non-zaptel compatible hardware
  ==============================
  
-diff -urN asterisk-1.2.19.orig/include/asterisk/agi.h asterisk-1.2.19/include/asterisk/agi.h
---- asterisk-1.2.19.orig/include/asterisk/agi.h	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.19/include/asterisk/agi.h	2007-06-25 11:13:51.541656492 +0200
+diff -urN asterisk-1.2.23.orig/include/asterisk/agi.h asterisk-1.2.23/include/asterisk/agi.h
+--- asterisk-1.2.23.orig/include/asterisk/agi.h	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.23/include/asterisk/agi.h	2007-07-25 08:53:53.168385782 +0200
 @@ -29,7 +29,8 @@
  
  typedef struct agi_state {
@@ -10710,9 +10837,9 @@
  	int ctrl;	/* FD for input control */
  } AGI;
  
-diff -urN asterisk-1.2.19.orig/include/asterisk/chan_capi_app.h asterisk-1.2.19/include/asterisk/chan_capi_app.h
---- asterisk-1.2.19.orig/include/asterisk/chan_capi_app.h	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.19/include/asterisk/chan_capi_app.h	2007-06-25 11:13:51.541656492 +0200
+diff -urN asterisk-1.2.23.orig/include/asterisk/chan_capi_app.h asterisk-1.2.23/include/asterisk/chan_capi_app.h
+--- asterisk-1.2.23.orig/include/asterisk/chan_capi_app.h	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.23/include/asterisk/chan_capi_app.h	2007-07-25 08:53:53.168385782 +0200
 @@ -0,0 +1,30 @@
 +/*
 + * (CAPI*)
@@ -10744,9 +10871,9 @@
 +extern MESSAGE_EXCHANGE_ERROR _capi_put_cmsg(_cmsg *CMSG);
 +
 +#endif
-diff -urN asterisk-1.2.19.orig/include/asterisk/chan_capi.h asterisk-1.2.19/include/asterisk/chan_capi.h
---- asterisk-1.2.19.orig/include/asterisk/chan_capi.h	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.19/include/asterisk/chan_capi.h	2007-06-25 11:13:51.541656492 +0200
+diff -urN asterisk-1.2.23.orig/include/asterisk/chan_capi.h asterisk-1.2.23/include/asterisk/chan_capi.h
+--- asterisk-1.2.23.orig/include/asterisk/chan_capi.h	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.23/include/asterisk/chan_capi.h	2007-07-25 08:53:53.172386730 +0200
 @@ -0,0 +1,276 @@
 +/*
 + * (CAPI*)
@@ -11024,9 +11151,9 @@
 +#define CAPI_ETSI_NPLAN_INTERNAT	0x10
 +
 +#endif
-diff -urN asterisk-1.2.19.orig/include/asterisk/channel.h asterisk-1.2.19/include/asterisk/channel.h
---- asterisk-1.2.19.orig/include/asterisk/channel.h	2006-11-07 19:22:01.000000000 +0100
-+++ asterisk-1.2.19/include/asterisk/channel.h	2007-06-25 11:13:51.545657437 +0200
+diff -urN asterisk-1.2.23.orig/include/asterisk/channel.h asterisk-1.2.23/include/asterisk/channel.h
+--- asterisk-1.2.23.orig/include/asterisk/channel.h	2006-11-07 19:22:01.000000000 +0100
++++ asterisk-1.2.23/include/asterisk/channel.h	2007-07-25 08:53:53.172386730 +0200
 @@ -86,6 +86,9 @@
  #ifndef _ASTERISK_CHANNEL_H
  #define _ASTERISK_CHANNEL_H
@@ -11147,9 +11274,9 @@
  
  /*! Gives the string form of a given cause code */
  /*! 
-diff -urN asterisk-1.2.19.orig/include/asterisk/devicestate.h asterisk-1.2.19/include/asterisk/devicestate.h
---- asterisk-1.2.19.orig/include/asterisk/devicestate.h	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.19/include/asterisk/devicestate.h	2007-06-25 11:13:51.545657437 +0200
+diff -urN asterisk-1.2.23.orig/include/asterisk/devicestate.h asterisk-1.2.23/include/asterisk/devicestate.h
+--- asterisk-1.2.23.orig/include/asterisk/devicestate.h	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.23/include/asterisk/devicestate.h	2007-07-25 08:53:53.172386730 +0200
 @@ -42,7 +42,7 @@
  /*! Device is ringing */
  #define AST_DEVICE_RINGING	6
@@ -11168,9 +11295,9 @@
  
  /*! \brief Registers a device state change callback 
   * \param callback Callback
-diff -urN asterisk-1.2.19.orig/include/asterisk/features.h asterisk-1.2.19/include/asterisk/features.h
---- asterisk-1.2.19.orig/include/asterisk/features.h	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.19/include/asterisk/features.h	2007-06-25 11:13:51.545657437 +0200
+diff -urN asterisk-1.2.23.orig/include/asterisk/features.h asterisk-1.2.23/include/asterisk/features.h
+--- asterisk-1.2.23.orig/include/asterisk/features.h	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.23/include/asterisk/features.h	2007-07-25 08:53:53.172386730 +0200
 @@ -45,6 +45,8 @@
  };
  
@@ -11213,9 +11340,9 @@
 +extern struct ast_call_feature *ast_find_builtin_feature(char *name);
 +
  #endif /* _AST_FEATURES_H */
-diff -urN asterisk-1.2.19.orig/include/asterisk/manager.h asterisk-1.2.19/include/asterisk/manager.h
---- asterisk-1.2.19.orig/include/asterisk/manager.h	2006-02-11 19:15:00.000000000 +0100
-+++ asterisk-1.2.19/include/asterisk/manager.h	2007-06-25 11:13:51.545657437 +0200
+diff -urN asterisk-1.2.23.orig/include/asterisk/manager.h asterisk-1.2.23/include/asterisk/manager.h
+--- asterisk-1.2.23.orig/include/asterisk/manager.h	2006-02-11 19:15:00.000000000 +0100
++++ asterisk-1.2.23/include/asterisk/manager.h	2007-07-25 08:53:53.176387678 +0200
 @@ -54,6 +54,7 @@
  #define EVENT_FLAG_COMMAND		(1 << 4) /* Ability to read/set commands */
  #define EVENT_FLAG_AGENT		(1 << 5) /* Ability to read/set agent info */
@@ -11224,9 +11351,9 @@
  
  /* Export manager structures */
  #define AST_MAX_MANHEADERS 80
-diff -urN asterisk-1.2.19.orig/include/asterisk/monitor.h asterisk-1.2.19/include/asterisk/monitor.h
---- asterisk-1.2.19.orig/include/asterisk/monitor.h	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.19/include/asterisk/monitor.h	2007-06-25 11:13:51.545657437 +0200
+diff -urN asterisk-1.2.23.orig/include/asterisk/monitor.h asterisk-1.2.23/include/asterisk/monitor.h
+--- asterisk-1.2.23.orig/include/asterisk/monitor.h	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.23/include/asterisk/monitor.h	2007-07-25 08:53:53.176387678 +0200
 @@ -35,6 +35,8 @@
  	char write_filename[FILENAME_MAX];
  	char filename_base[FILENAME_MAX];
@@ -11245,9 +11372,9 @@
  
  /* Stop monitoring a channel */
  int ast_monitor_stop(struct ast_channel *chan, int need_lock);
-diff -urN asterisk-1.2.19.orig/include/asterisk/pbx.h asterisk-1.2.19/include/asterisk/pbx.h
---- asterisk-1.2.19.orig/include/asterisk/pbx.h	2006-03-29 21:11:18.000000000 +0200
-+++ asterisk-1.2.19/include/asterisk/pbx.h	2007-06-25 11:13:51.545657437 +0200
+diff -urN asterisk-1.2.23.orig/include/asterisk/pbx.h asterisk-1.2.23/include/asterisk/pbx.h
+--- asterisk-1.2.23.orig/include/asterisk/pbx.h	2006-03-29 21:11:18.000000000 +0200
++++ asterisk-1.2.23/include/asterisk/pbx.h	2007-07-25 08:53:53.176387678 +0200
 @@ -57,7 +57,7 @@
  	AST_EXTENSION_BUSY = 1 << 1,
  	/*! All devices UNAVAILABLE/UNREGISTERED */
@@ -11298,9 +11425,9 @@
  
  #if defined(__cplusplus) || defined(c_plusplus)
  }
-diff -urN asterisk-1.2.19.orig/include/asterisk/xlaw.h asterisk-1.2.19/include/asterisk/xlaw.h
---- asterisk-1.2.19.orig/include/asterisk/xlaw.h	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.19/include/asterisk/xlaw.h	2007-06-25 11:13:51.549658382 +0200
+diff -urN asterisk-1.2.23.orig/include/asterisk/xlaw.h asterisk-1.2.23/include/asterisk/xlaw.h
+--- asterisk-1.2.23.orig/include/asterisk/xlaw.h	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.23/include/asterisk/xlaw.h	2007-07-25 08:53:53.180388627 +0200
 @@ -0,0 +1,1665 @@
 +#ifndef _ASTERISK_XLAW_H
 +#define _ASTERISK_XLAW_H
@@ -12967,9 +13094,9 @@
 +#endif // CAPI_ULAW
 +#endif
 +
-diff -urN asterisk-1.2.19.orig/include/asterisk.h asterisk-1.2.19/include/asterisk.h
---- asterisk-1.2.19.orig/include/asterisk.h	2007-04-09 04:49:06.000000000 +0200
-+++ asterisk-1.2.19/include/asterisk.h	2007-06-25 11:13:51.549658382 +0200
+diff -urN asterisk-1.2.23.orig/include/asterisk.h asterisk-1.2.23/include/asterisk.h
+--- asterisk-1.2.23.orig/include/asterisk.h	2007-04-09 04:49:06.000000000 +0200
++++ asterisk-1.2.23/include/asterisk.h	2007-07-25 08:53:53.184389575 +0200
 @@ -38,6 +38,7 @@
  extern char ast_config_AST_PID[AST_CONFIG_MAX_PATH];
  extern char ast_config_AST_SOCKET[AST_CONFIG_MAX_PATH];
@@ -12978,9 +13105,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.19.orig/LICENSE asterisk-1.2.19/LICENSE
---- asterisk-1.2.19.orig/LICENSE	2006-10-17 19:22:01.000000000 +0200
-+++ asterisk-1.2.19/LICENSE	2007-06-25 11:13:51.549658382 +0200
+diff -urN asterisk-1.2.23.orig/LICENSE asterisk-1.2.23/LICENSE
+--- asterisk-1.2.23.orig/LICENSE	2006-10-17 19:22:01.000000000 +0200
++++ asterisk-1.2.23/LICENSE	2007-07-25 08:53:53.184389575 +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
@@ -12993,9 +13120,9 @@
  except as defined below. The GPL (version 2) is included in this
  source tree in the file COPYING.
  
-diff -urN asterisk-1.2.19.orig/Makefile asterisk-1.2.19/Makefile
---- asterisk-1.2.19.orig/Makefile	2007-05-11 18:31:03.000000000 +0200
-+++ asterisk-1.2.19/Makefile	2007-06-25 11:13:51.549658382 +0200
+diff -urN asterisk-1.2.23.orig/Makefile asterisk-1.2.23/Makefile
+--- asterisk-1.2.23.orig/Makefile	2007-07-16 20:33:02.000000000 +0200
++++ asterisk-1.2.23/Makefile	2007-07-25 08:53:53.184389575 +0200
 @@ -781,6 +781,9 @@
  		echo ";astctlowner = root" ; \
  		echo ";astctlgroup = apache" ; \
@@ -13006,9 +13133,9 @@
  		) > $(DESTDIR)$(ASTCONFPATH) ; \
  	else \
  		echo "Skipping asterisk.conf creation"; \
-diff -urN asterisk-1.2.19.orig/manager.c asterisk-1.2.19/manager.c
---- asterisk-1.2.19.orig/manager.c	2007-04-24 23:33:59.000000000 +0200
-+++ asterisk-1.2.19/manager.c	2007-06-25 11:13:51.553659327 +0200
+diff -urN asterisk-1.2.23.orig/manager.c asterisk-1.2.23/manager.c
+--- asterisk-1.2.23.orig/manager.c	2007-06-24 19:32:21.000000000 +0200
++++ asterisk-1.2.23/manager.c	2007-07-25 08:53:53.188390523 +0200
 @@ -11,6 +11,9 @@
   * the project provides a web site, mailing lists and IRC
   * channels for your use.
@@ -13115,7 +13242,7 @@
  static char mandescr_setvar[] = 
  "Description: Set a global or local channel variable.\n"
  "Variables: (Names marked with * are required)\n"
-@@ -761,6 +817,7 @@
+@@ -756,6 +812,7 @@
  }
  
  
@@ -13123,7 +13250,7 @@
  /*! \brief  action_status: Manager "status" command to show channels */
  /* Needs documentation... */
  static int action_status(struct mansession *s, struct message *m)
-@@ -867,19 +924,29 @@
+@@ -862,19 +919,29 @@
  	char *exten = astman_get_header(m, "Exten");
  	char *context = astman_get_header(m, "Context");
  	char *priority = astman_get_header(m, "Priority");
@@ -13156,7 +13283,7 @@
  	if (!chan) {
  		char buf[BUFSIZ];
  		snprintf(buf, sizeof(buf), "Channel does not exist: %s", name);
-@@ -901,19 +968,27 @@
+@@ -896,19 +963,27 @@
  	}
  	res = ast_async_goto(chan, context, exten, pi);
  	if (!res) {
@@ -13196,7 +13323,7 @@
  	if (chan)
  		ast_mutex_unlock(&chan->lock);
  	if (chan2)
-@@ -949,15 +1024,15 @@
+@@ -944,15 +1019,15 @@
  	struct ast_channel *chan = NULL;
  
  	if (!ast_strlen_zero(in->app)) {
@@ -13216,7 +13343,7 @@
  	}   
  	if (!res)
  		manager_event(EVENT_FLAG_CALL,
-@@ -968,7 +1043,7 @@
+@@ -963,7 +1038,7 @@
  			"Exten: %s\r\n"
  			"Reason: %d\r\n"
  			"Uniqueid: %s\r\n",
@@ -13225,7 +13352,7 @@
  	else
  		manager_event(EVENT_FLAG_CALL,
  			"OriginateFailure",
-@@ -978,7 +1053,7 @@
+@@ -973,7 +1048,7 @@
  			"Exten: %s\r\n"
  			"Reason: %d\r\n"
  			"Uniqueid: %s\r\n",
@@ -13234,7 +13361,7 @@
  
  	/* Locked by ast_pbx_outgoing_exten or ast_pbx_outgoing_app */
  	if (chan)
-@@ -1011,6 +1086,7 @@
+@@ -1006,6 +1081,7 @@
  	char *priority = astman_get_header(m, "Priority");
  	char *timeout = astman_get_header(m, "Timeout");
  	char *callerid = astman_get_header(m, "CallerID");
@@ -13242,7 +13369,7 @@
  	char *account = astman_get_header(m, "Account");
  	char *app = astman_get_header(m, "Application");
  	char *appdata = astman_get_header(m, "Data");
-@@ -1019,12 +1095,15 @@
+@@ -1014,12 +1090,15 @@
  	struct ast_variable *vars = astman_get_variables(m);
  	char *tech, *data;
  	char *l=NULL, *n=NULL;
@@ -13258,7 +13385,7 @@
  	
  	pthread_t th;
  	pthread_attr_t attr;
-@@ -1040,6 +1119,10 @@
+@@ -1035,6 +1114,10 @@
  		astman_send_error(s, m, "Invalid timeout\n");
  		return 0;
  	}
@@ -13269,7 +13396,7 @@
  	ast_copy_string(tmp, name, sizeof(tmp));
  	tech = tmp;
  	data = strchr(tmp, '/');
-@@ -1060,6 +1143,7 @@
+@@ -1055,6 +1138,7 @@
  		if (ast_strlen_zero(l))
  			l = NULL;
  	}
@@ -13277,7 +13404,7 @@
  	if (ast_true(async)) {
  		struct fast_originate_helper *fast = malloc(sizeof(struct fast_originate_helper));
  		if (!fast) {
-@@ -1080,8 +1164,10 @@
+@@ -1075,8 +1159,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));
@@ -13288,7 +13415,7 @@
  			pthread_attr_init(&attr);
  			pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
  			if (ast_pthread_create(&th, &attr, fast_originate, fast)) {
-@@ -1092,19 +1178,28 @@
+@@ -1087,19 +1173,28 @@
  			pthread_attr_destroy(&attr);
  		}
  	} else if (!ast_strlen_zero(app)) {
@@ -13322,7 +13449,7 @@
  	return 0;
  }
  
-@@ -1578,10 +1673,12 @@
+@@ -1573,10 +1668,12 @@
  	return 0;
  }
  
@@ -13337,7 +13464,7 @@
  	return 0;
  }
  
-@@ -1666,6 +1763,7 @@
+@@ -1661,6 +1758,7 @@
  		ast_manager_register2("Events", 0, action_events, "Control Event Flow", mandescr_events);
  		ast_manager_register2("Logoff", 0, action_logoff, "Logoff Manager", mandescr_logoff);
  		ast_manager_register2("Hangup", EVENT_FLAG_CALL, action_hangup, "Hangup Channel", mandescr_hangup);
@@ -13345,9 +13472,9 @@
  		ast_manager_register("Status", EVENT_FLAG_CALL, action_status, "Lists channel status" );
  		ast_manager_register2("Setvar", EVENT_FLAG_CALL, action_setvar, "Set Channel Variable", mandescr_setvar );
  		ast_manager_register2("Getvar", EVENT_FLAG_CALL, action_getvar, "Gets a Channel Variable", mandescr_getvar );
-diff -urN asterisk-1.2.19.orig/pbx/pbx_spool.c asterisk-1.2.19/pbx/pbx_spool.c
---- asterisk-1.2.19.orig/pbx/pbx_spool.c	2007-01-31 22:25:11.000000000 +0100
-+++ asterisk-1.2.19/pbx/pbx_spool.c	2007-06-25 11:13:51.553659327 +0200
+diff -urN asterisk-1.2.23.orig/pbx/pbx_spool.c asterisk-1.2.23/pbx/pbx_spool.c
+--- asterisk-1.2.23.orig/pbx/pbx_spool.c	2007-07-02 01:51:34.000000000 +0200
++++ asterisk-1.2.23/pbx/pbx_spool.c	2007-07-25 08:53:53.188390523 +0200
 @@ -77,6 +77,10 @@
  	char app[256];
  	char data[256];
@@ -13419,9 +13546,9 @@
  	}
  	free_outgoing(o);
  	return NULL;
-diff -urN asterisk-1.2.19.orig/pbx.c asterisk-1.2.19/pbx.c
---- asterisk-1.2.19.orig/pbx.c	2007-05-02 22:10:32.000000000 +0200
-+++ asterisk-1.2.19/pbx.c	2007-06-25 11:13:51.557660272 +0200
+diff -urN asterisk-1.2.23.orig/pbx.c asterisk-1.2.23/pbx.c
+--- asterisk-1.2.23.orig/pbx.c	2007-05-02 22:10:32.000000000 +0200
++++ asterisk-1.2.23/pbx.c	2007-07-25 08:53:53.196392420 +0200
 @@ -374,7 +374,8 @@
  	
  	{ "Hangup", pbx_builtin_hangup,
@@ -13491,7 +13618,15 @@
  		if (channel) {
  			*channel = chan;
  			if (chan)
-@@ -5116,7 +5117,7 @@
+@@ -5104,6 +5105,7 @@
+ 					ast_set_variables(chan, vars);
+ 					if (account)
+ 						ast_cdr_setaccount(chan, account);
++					ast_cdr_setuserfield(chan, (char*)data);
+ 					ast_pbx_run(chan);	
+ 				} else 
+ 					ast_log(LOG_WARNING, "Can't allocate the channel structure, skipping execution of extension 'failed'\n");
+@@ -5116,7 +5118,7 @@
  			goto outgoing_exten_cleanup;
  		}	
  		memset(as, 0, sizeof(struct async_stat));
@@ -13500,7 +13635,15 @@
  		if (channel) {
  			*channel = chan;
  			if (chan)
-@@ -5164,7 +5165,7 @@
+@@ -5135,6 +5137,7 @@
+ 		ast_set_variables(chan, vars);
+ 		if (account)
+ 			ast_cdr_setaccount(chan, account);
++		ast_cdr_setuserfield(chan, (char*)data);
+ 		pthread_attr_init(&attr);
+ 		pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ 		if (ast_pthread_create(&as->p, &attr, async_wait, as)) {
+@@ -5164,7 +5167,7 @@
  	pthread_t t;
  };
  
@@ -13509,7 +13652,7 @@
  {
  	struct app_tmp *tmp = data;
  	struct ast_app *app;
-@@ -5180,7 +5181,7 @@
+@@ -5180,7 +5183,7 @@
  	return NULL;
  }
  
@@ -13518,7 +13661,7 @@
  {
  	struct ast_channel *chan;
  	struct async_stat *as;
-@@ -5200,7 +5201,7 @@
+@@ -5200,7 +5203,7 @@
  		goto outgoing_app_cleanup;	
  	}
  	if (sync) {
@@ -13527,7 +13670,15 @@
  		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);
-@@ -5288,7 +5289,8 @@
+@@ -5220,6 +5223,7 @@
+ 			ast_set_variables(chan, vars);
+ 			if (account)
+ 				ast_cdr_setaccount(chan, account);
++			ast_cdr_setuserfield(chan, (char*)data);
+ 			if (chan->_state == AST_STATE_UP) {
+ 				res = 0;
+ 				if (option_verbose > 3)
+@@ -5288,7 +5292,8 @@
  			goto outgoing_app_cleanup;
  		}
  		memset(as, 0, sizeof(struct async_stat));
@@ -13537,7 +13688,7 @@
  		if (!chan) {
  			free(as);
  			res = -1;
-@@ -5579,6 +5581,9 @@
+@@ -5579,6 +5584,9 @@
   */
  static int pbx_builtin_hangup(struct ast_channel *chan, void *data)
  {
@@ -13547,7 +13698,7 @@
  	/* Just return non-zero and it will hang up */
  	if (!chan->hangupcause)
  		chan->hangupcause = AST_CAUSE_NORMAL_CLEARING;
-@@ -6233,6 +6238,9 @@
+@@ -6233,6 +6241,9 @@
  			return -1;
  		}
  	}
@@ -13557,7 +13708,7 @@
  	return res = ast_say_number(chan, atoi((char *) tmp), "", chan->language, options);
  }
  
-@@ -6240,8 +6248,12 @@
+@@ -6240,8 +6251,12 @@
  {
  	int res = 0;
  
@@ -13571,7 +13722,7 @@
  	return res;
  }
  	
-@@ -6249,8 +6261,12 @@
+@@ -6249,8 +6264,12 @@
  {
  	int res = 0;
  
@@ -13585,7 +13736,7 @@
  	return res;
  }
  	
-@@ -6258,8 +6274,12 @@
+@@ -6258,8 +6277,12 @@
  {
  	int res = 0;
  
@@ -13599,9 +13750,9 @@
  	return res;
  }
  	
-diff -urN asterisk-1.2.19.orig/README asterisk-1.2.19/README
---- asterisk-1.2.19.orig/README	2006-03-03 09:12:33.000000000 +0100
-+++ asterisk-1.2.19/README	2007-06-25 11:13:51.557660272 +0200
+diff -urN asterisk-1.2.23.orig/README asterisk-1.2.23/README
+--- asterisk-1.2.23.orig/README	2006-03-03 09:12:33.000000000 +0100
++++ asterisk-1.2.23/README	2007-07-25 08:53:53.196392420 +0200
 @@ -4,6 +4,8 @@
  
  Copyright (C) 2001-2005 Digium, Inc.
@@ -13611,9 +13762,9 @@
  ================================================================
  
  * SECURITY
-diff -urN asterisk-1.2.19.orig/README.chan_capi asterisk-1.2.19/README.chan_capi
---- asterisk-1.2.19.orig/README.chan_capi	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.19/README.chan_capi	2007-06-25 11:13:51.557660272 +0200
+diff -urN asterisk-1.2.23.orig/README.chan_capi asterisk-1.2.23/README.chan_capi
+--- asterisk-1.2.23.orig/README.chan_capi	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.23/README.chan_capi	2007-07-25 08:53:53.196392420 +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 
@@ -13761,9 +13912,9 @@
 +	
 +
 +
-diff -urN asterisk-1.2.19.orig/res/Makefile asterisk-1.2.19/res/Makefile
---- asterisk-1.2.19.orig/res/Makefile	2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.19/res/Makefile	2007-06-25 11:13:51.557660272 +0200
+diff -urN asterisk-1.2.23.orig/res/Makefile asterisk-1.2.23/res/Makefile
+--- asterisk-1.2.23.orig/res/Makefile	2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.23/res/Makefile	2007-07-25 08:53:53.196392420 +0200
 @@ -11,7 +11,7 @@
  # the GNU General Public License
  #
@@ -13773,9 +13924,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.19.orig/res/res_agi.c asterisk-1.2.19/res/res_agi.c
---- asterisk-1.2.19.orig/res/res_agi.c	2007-02-16 12:38:03.000000000 +0100
-+++ asterisk-1.2.19/res/res_agi.c	2007-06-25 11:13:51.561661216 +0200
+diff -urN asterisk-1.2.23.orig/res/res_agi.c asterisk-1.2.23/res/res_agi.c
+--- asterisk-1.2.23.orig/res/res_agi.c	2007-06-25 20:12:37.000000000 +0200
++++ asterisk-1.2.23/res/res_agi.c	2007-07-25 08:53:53.200393368 +0200
 @@ -11,6 +11,9 @@
   * the project provides a web site, mailing lists and IRC
   * channels for your use.
@@ -13935,7 +14086,7 @@
  	fdprintf(agi->fd, "200 result=%d\n", res);
  	if (res >= 0)
  		return RESULT_SUCCESS;
-@@ -577,7 +625,7 @@
+@@ -570,7 +618,7 @@
  	ast_seekstream(fs, sample_offset, SEEK_SET);
  	res = ast_applystream(chan, fs);
  	ast_playstream(fs);
@@ -13944,16 +14095,16 @@
  	/* this is to check for if ast_waitstream closed the stream, we probably are at
  	 * the end of the stream, return that amount, else check for the amount */
  	sample_offset = (chan->stream) ? ast_tellstream(fs) : max_length;
-@@ -637,7 +685,7 @@
+@@ -623,7 +671,7 @@
          ast_seekstream(fs, sample_offset, SEEK_SET);
          res = ast_applystream(chan, fs);
          ast_playstream(fs);
 -        res = ast_waitstream_full(chan, argv[3], agi->audio, agi->ctrl);
-+	res = ast_waitstream_full(chan, argv[3], agi->audio_out, agi->ctrl);
++        res = ast_waitstream_full(chan, argv[3], agi->audio_out, agi->ctrl);
          /* this is to check for if ast_waitstream closed the stream, we probably are at
           * the end of the stream, return that amount, else check for the amount */
          sample_offset = (chan->stream)?ast_tellstream(fs):max_length;
-@@ -649,7 +697,7 @@
+@@ -635,7 +683,7 @@
  
  	/* If the user didnt press a key, wait for digitTimeout*/
  	if (res == 0 ) {
@@ -13962,7 +14113,7 @@
  		/* Make sure the new result is in the escape digits of the GET OPTION */
  		if ( !strchr(edigits,res) )
                  	res=0;
-@@ -676,7 +724,7 @@
+@@ -662,7 +710,7 @@
  		return RESULT_SHOWUSAGE;
  	if (sscanf(argv[2], "%d", &num) != 1)
  		return RESULT_SHOWUSAGE;
@@ -13971,7 +14122,7 @@
  	if (res == 1)
  		return RESULT_SUCCESS;
  	fdprintf(agi->fd, "200 result=%d\n", res);
-@@ -696,7 +744,7 @@
+@@ -682,7 +730,7 @@
  	if (sscanf(argv[2], "%d", &num) != 1)
  		return RESULT_SHOWUSAGE;
  
@@ -13980,7 +14131,7 @@
  	if (res == 1) /* New command */
  		return RESULT_SUCCESS;
  	fdprintf(agi->fd, "200 result=%d\n", res);
-@@ -713,7 +761,7 @@
+@@ -699,7 +747,7 @@
  	if (argc != 4)
  		return RESULT_SHOWUSAGE;
  
@@ -13989,7 +14140,7 @@
  	if (res == 1) /* New command */
  		return RESULT_SUCCESS;
  	fdprintf(agi->fd, "200 result=%d\n", res);
-@@ -803,7 +851,7 @@
+@@ -789,7 +837,7 @@
  	if (argc != 4)
  		return RESULT_SHOWUSAGE;
  
@@ -13998,7 +14149,7 @@
  	if (res == 1) /* New command */
  		return RESULT_SUCCESS;
  	fdprintf(agi->fd, "200 result=%d\n", res);
-@@ -830,7 +878,7 @@
+@@ -816,7 +864,7 @@
  		max = atoi(argv[4]); 
  	else
  		max = 1024;
@@ -14007,7 +14158,7 @@
  	if (res == 2)			/* New command */
  		return RESULT_SUCCESS;
  	else if (res == 1)
-@@ -1868,7 +1916,12 @@
+@@ -1854,7 +1902,12 @@
  	int ms;
  	int returnstatus = 0;
  	struct ast_frame *f;
@@ -14020,7 +14171,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) */
-@@ -1882,10 +1935,22 @@
+@@ -1868,10 +1921,22 @@
  		return -1;
  	}
  	setlinebuf(readf);
@@ -14045,7 +14196,7 @@
  		if (c) {
  			retry = RETRY;
  			/* Idle the channel until we get a command */
-@@ -1896,13 +1961,24 @@
+@@ -1882,13 +1947,24 @@
  				break;
  			} else {
  				/* If it's voice, write it to the audio pipe */
@@ -14072,7 +14223,7 @@
  			retry = RETRY;
  			if (!fgets(buf, sizeof(buf), readf)) {
  				/* Program terminated */
-@@ -1924,6 +2000,7 @@
+@@ -1910,6 +1986,7 @@
  			if ((returnstatus < 0) || (returnstatus == AST_PBX_KEEPALIVE)) {
  				break;
  			}
@@ -14080,7 +14231,7 @@
  		} else {
  			if (--retry <= 0) {
  				ast_log(LOG_WARNING, "No channel, no fd?\n");
-@@ -2030,6 +2107,7 @@
+@@ -2016,6 +2093,7 @@
  	int argc = 0;
  	int fds[2];
  	int efd = -1;
@@ -14088,7 +14239,7 @@
  	int pid;
          char *stringp;
  	AGI agi;
-@@ -2055,16 +2133,19 @@
+@@ -2041,16 +2119,19 @@
  		}
  	}
  #endif
@@ -14110,7 +14261,7 @@
  	}
  	LOCAL_USER_REMOVE(u);
  	return res;
-@@ -2098,6 +2179,35 @@
+@@ -2084,6 +2165,35 @@
  	return res;
  }
  
@@ -14146,7 +14297,7 @@
  static int deadagi_exec(struct ast_channel *chan, void *data)
  {
  	return agi_exec_full(chan, data, 0, 1);
-@@ -2127,6 +2237,7 @@
+@@ -2113,6 +2223,7 @@
  	ast_cli_unregister(&dumpagihtml);
  	ast_cli_unregister(&cli_debug);
  	ast_cli_unregister(&cli_no_debug);
@@ -14154,7 +14305,7 @@
  	ast_unregister_application(eapp);
  	ast_unregister_application(deadapp);
  	return ast_unregister_application(app);
-@@ -2140,6 +2251,7 @@
+@@ -2126,6 +2237,7 @@
  	ast_cli_register(&cli_no_debug);
  	ast_register_application(deadapp, deadagi_exec, deadsynopsis, descrip);
  	ast_register_application(eapp, eagi_exec, esynopsis, descrip);
@@ -14162,9 +14313,9 @@
  	return ast_register_application(app, agi_exec, synopsis, descrip);
  }
  
-diff -urN asterisk-1.2.19.orig/res/res_esel.c asterisk-1.2.19/res/res_esel.c
---- asterisk-1.2.19.orig/res/res_esel.c	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.19/res/res_esel.c	2007-06-25 11:13:51.561661216 +0200
+diff -urN asterisk-1.2.23.orig/res/res_esel.c asterisk-1.2.23/res/res_esel.c
+--- asterisk-1.2.23.orig/res/res_esel.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.23/res/res_esel.c	2007-07-25 08:53:53.200393368 +0200
 @@ -0,0 +1,399 @@
 +/*
 + * Asterisk -- A telephony toolkit for Linux.
@@ -14565,9 +14716,9 @@
 +{
 +	return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.19.orig/res/res_features.c asterisk-1.2.19/res/res_features.c
---- asterisk-1.2.19.orig/res/res_features.c	2007-05-01 23:55:19.000000000 +0200
-+++ asterisk-1.2.19/res/res_features.c	2007-06-25 11:13:51.561661216 +0200
+diff -urN asterisk-1.2.23.orig/res/res_features.c asterisk-1.2.23/res/res_features.c
+--- asterisk-1.2.23.orig/res/res_features.c	2007-06-22 18:02:40.000000000 +0200
++++ asterisk-1.2.23/res/res_features.c	2007-07-25 08:53:53.204394317 +0200
 @@ -11,6 +11,10 @@
   * the project provides a web site, mailing lists and IRC
   * channels for your use.
@@ -14704,7 +14855,7 @@
  		/* Make the masq execute */
  		f = ast_read(chan);
  		if (f)
-@@ -909,7 +976,7 @@
+@@ -910,7 +977,7 @@
  }
  
  /* find a feature by name */
@@ -14713,7 +14864,7 @@
  {
  	struct ast_call_feature *tmp;
  
-@@ -919,10 +986,21 @@
+@@ -920,10 +987,21 @@
  			break;
  	}
  	AST_LIST_UNLOCK(&feature_list);
@@ -14736,7 +14887,7 @@
  /* exec an app by feature */
  static int feature_exec_app(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, char *code, int sense)
  {
-@@ -1021,7 +1099,7 @@
+@@ -1022,7 +1100,7 @@
  			return res;
  		
  		while ((tok = strsep(&tmp, "#")) != NULL) {
@@ -14745,7 +14896,7 @@
  			
  			if (feature) {
  				/* Feature is up for consideration */
-@@ -1074,7 +1152,7 @@
+@@ -1075,7 +1153,7 @@
  
  			/* while we have a feature */
  			while (NULL != (tok = strsep(&tmp, "#"))) {
@@ -14754,7 +14905,7 @@
  					if (ast_test_flag(feature, AST_FEATURE_FLAG_NEEDSDTMF)) {
  						if (ast_test_flag(feature, AST_FEATURE_FLAG_CALLER))
  							ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_0);
-@@ -1099,7 +1177,7 @@
+@@ -1100,7 +1178,7 @@
  	struct ast_frame *f = NULL;
  	int res = 0, ready = 0;
  	
@@ -14763,7 +14914,7 @@
  		ast_set_callerid(chan, cid_num, cid_name, cid_num);
  		ast_channel_inherit_variables(caller, chan);	
  		if (!ast_call(chan, data, timeout)) {
-@@ -1554,9 +1632,10 @@
+@@ -1555,9 +1633,10 @@
  					"Channel: %s\r\n"
  					"CallerID: %s\r\n"
  					"CallerIDName: %s\r\n"
@@ -14775,7 +14926,7 @@
  					);
  
  				if (option_verbose > 1) 
-@@ -1599,9 +1678,10 @@
+@@ -1600,9 +1679,10 @@
  								"Channel: %s\r\n"
  								"CallerID: %s\r\n"
  								"CallerIDName: %s\r\n"
@@ -14787,7 +14938,7 @@
  								);
  
  							/* There's a problem, hang them up*/
-@@ -1688,6 +1768,282 @@
+@@ -1689,6 +1769,282 @@
  	return res;
  }
  
@@ -15070,7 +15221,7 @@
  static int park_exec(struct ast_channel *chan, void *data)
  {
  	int res=0;
-@@ -1736,9 +2092,10 @@
+@@ -1737,9 +2093,10 @@
  			"From: %s\r\n"
  			"CallerID: %s\r\n"
  			"CallerIDName: %s\r\n"
@@ -15082,7 +15233,7 @@
  			);
  
  		free(pu);
-@@ -1902,12 +2259,13 @@
+@@ -1903,12 +2260,13 @@
  			"Timeout: %ld\r\n"
  			"CallerID: %s\r\n"
  			"CallerIDName: %s\r\n"
@@ -15097,7 +15248,7 @@
  			,idText);
  
              cur = cur->next;
-@@ -1923,6 +2281,416 @@
+@@ -1924,6 +2282,416 @@
          return RESULT_SUCCESS;
  }
  
@@ -15514,7 +15665,7 @@
  
  int ast_pickup_call(struct ast_channel *chan)
  {
-@@ -2078,7 +2846,7 @@
+@@ -2079,7 +2847,7 @@
  			}
  
  			{
@@ -15523,7 +15674,7 @@
  				int mallocd=0;
  				
  				if (!feature) {
-@@ -2141,6 +2909,7 @@
+@@ -2142,6 +2910,7 @@
  }
  
  int reload(void) {
@@ -15531,7 +15682,7 @@
  	return load_config();
  }
  
-@@ -2154,14 +2923,22 @@
+@@ -2155,14 +2924,22 @@
  	if ((res = load_config()))
  		return res;
  	ast_cli_register(&showparked);
@@ -15554,7 +15705,7 @@
  	return res;
  }
  
-@@ -2172,7 +2949,11 @@
+@@ -2173,7 +2950,11 @@
  
  	ast_manager_unregister("ParkedCalls");
  	ast_cli_unregister(&showfeatures);
@@ -15566,9 +15717,9 @@
  	ast_unregister_application(parkcall);
  	return ast_unregister_application(parkedcall);
  }
-diff -urN asterisk-1.2.19.orig/res/res_monitor.c asterisk-1.2.19/res/res_monitor.c
---- asterisk-1.2.19.orig/res/res_monitor.c	2007-03-21 19:03:20.000000000 +0100
-+++ asterisk-1.2.19/res/res_monitor.c	2007-06-25 11:13:51.565662161 +0200
+diff -urN asterisk-1.2.23.orig/res/res_monitor.c asterisk-1.2.23/res/res_monitor.c
+--- asterisk-1.2.23.orig/res/res_monitor.c	2007-03-21 19:03:20.000000000 +0100
++++ asterisk-1.2.23/res/res_monitor.c	2007-07-25 08:53:53.208395265 +0200
 @@ -90,7 +90,7 @@
  
  /* Start monitoring a channel */
@@ -15705,9 +15856,9 @@
  	res = ast_monitor_stop(c, 1);
  	ast_mutex_unlock(&c->lock);
  	if (res) {
-diff -urN asterisk-1.2.19.orig/res/res_watchdog.c asterisk-1.2.19/res/res_watchdog.c
---- asterisk-1.2.19.orig/res/res_watchdog.c	1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.19/res/res_watchdog.c	2007-06-25 11:13:51.565662161 +0200
+diff -urN asterisk-1.2.23.orig/res/res_watchdog.c asterisk-1.2.23/res/res_watchdog.c
+--- asterisk-1.2.23.orig/res/res_watchdog.c	1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.23/res/res_watchdog.c	2007-07-25 08:53:53.208395265 +0200
 @@ -0,0 +1,149 @@
 +/*
 + * Asterisk -- A telephony toolkit for Linux.
@@ -15858,10 +16009,10 @@
 +{
 +	return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.19.orig/rtp.c asterisk-1.2.19/rtp.c
---- asterisk-1.2.19.orig/rtp.c	2007-06-12 16:18:57.000000000 +0200
-+++ asterisk-1.2.19/rtp.c	2007-06-25 11:13:51.565662161 +0200
-@@ -447,6 +447,11 @@
+diff -urN asterisk-1.2.23.orig/rtp.c asterisk-1.2.23/rtp.c
+--- asterisk-1.2.23.orig/rtp.c	2007-06-19 19:00:58.000000000 +0200
++++ asterisk-1.2.23/rtp.c	2007-07-25 08:53:53.208395265 +0200
+@@ -448,6 +448,11 @@
  	struct rtpPayloadType rtpPT;
  	
  	len = sizeof(sin);
@@ -15873,9 +16024,9 @@
  	
  	/* Cache where the header will go */
  	res = recvfrom(rtp->s, rtp->rawdata + AST_FRIENDLY_OFFSET, sizeof(rtp->rawdata) - AST_FRIENDLY_OFFSET,
-diff -urN asterisk-1.2.19.orig/.version asterisk-1.2.19/.version
---- asterisk-1.2.19.orig/.version	2007-06-15 23:00:17.000000000 +0200
-+++ asterisk-1.2.19/.version	2007-06-25 11:13:51.565662161 +0200
+diff -urN asterisk-1.2.23.orig/.version asterisk-1.2.23/.version
+--- asterisk-1.2.23.orig/.version	2007-07-24 19:46:34.000000000 +0200
++++ asterisk-1.2.23/.version	2007-07-25 08:54:35.282368090 +0200
 @@ -1 +1 @@
--1.2.23
-+1.2.23-BRIstuffed-0.3.0-PRE-1y-h
+-1.2.24
++1.2.24-BRIstuffed-0.3.0-PRE-1y-j

Modified: asterisk1.2/trunk/debian/rules
===================================================================
--- asterisk1.2/trunk/debian/rules	2007-08-09 22:05:15 UTC (rev 3968)
+++ asterisk1.2/trunk/debian/rules	2007-08-09 23:29:48 UTC (rev 3969)
@@ -6,7 +6,7 @@
 #export DH_VERBOSE=1
 
 # This is the debhelper compatibility version to use.
-export DH_COMPAT=4
+export DH_COMPAT=5
 
 export DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
 export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
@@ -156,8 +156,8 @@
 	cp -a debian/ast_config/* $(CURDIR)/debian/tmp/etc/asterisk
 	
 	mkdir -p $(CURDIR)/debian/asterisk1.2/usr/share/asterisk/bin
-	cp debian/asterisk1.2_fix $(CURDIR)/debian/asterisk1.2/usr/share/asterisk/bin
-	chmod +x $(CURDIR)/debian/asterisk1.2/usr/share/asterisk/bin/asterisk1.2_fix
+	cp debian/asterisk_fix $(CURDIR)/debian/asterisk1.2/usr/share/asterisk/bin
+	chmod +x $(CURDIR)/debian/asterisk1.2/usr/share/asterisk/bin/asterisk_fix
 	
 	mkdir -p $(CURDIR)/debian/tmp/usr/share/asterisk/firmware/iax
 	
@@ -172,7 +172,7 @@
 	dh_testdir -i
 	dh_testroot -i
 	dh_installlogrotate -i 
-	dh_installinit -i -- defaults 21
+	dh_installinit -i --init-script=asterisk -- defaults 21
 	dh_installdocs -i -XREADME.cygwin
 	dh_installexamples -i -XCVS
 	dh_installcron -i




More information about the Pkg-voip-commits mailing list