]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/commitdiff
Hinzugefügt:
authorms <ms@ea5c0bd1-69bd-2848-81d8-4f18e57aeed8>
Fri, 14 Jul 2006 15:53:44 +0000 (15:53 +0000)
committerms <ms@ea5c0bd1-69bd-2848-81d8-4f18e57aeed8>
Fri, 14 Jul 2006 15:53:44 +0000 (15:53 +0000)
  * Unzip in die ISO gebaut.
  * QoS-Kontroll-Binary.
Geändert:
  * Asterisk in seine Einzelteile gespalten, damit das Paket kleiner und einfach zu updaten wird.
  * Neuer Asterisk, LibPRI, Bristuff usw...
  * QoS-Scripts aktualisiert.

git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@207 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8

23 files changed:
config/qos/makeqosscripts.pl
html/cgi-bin/qos.cgi
lfs/asterisk
lfs/bristuff [new file with mode: 0644]
lfs/libpri [new file with mode: 0644]
lfs/zaptel [new file with mode: 0644]
make.sh
src/ROOTFILES.i386
src/misc-progs/Makefile
src/misc-progs/qosctrl.c [new file with mode: 0644]
src/paks/bristuff/ROOTFILES [new file with mode: 0644]
src/paks/bristuff/install.sh [new file with mode: 0644]
src/paks/bristuff/uninstall.sh [new file with mode: 0644]
src/paks/libpri/ROOTFILES [new file with mode: 0644]
src/paks/libpri/install.sh [new file with mode: 0644]
src/paks/libpri/uninstall.sh [new file with mode: 0644]
src/paks/zaptel/ROOTFILES [new file with mode: 0644]
src/paks/zaptel/install.sh [new file with mode: 0644]
src/paks/zaptel/uninstall.sh [new file with mode: 0644]
src/patches/asterisk.patch
src/patches/libpri.patch
src/patches/zaptel.patch
src/scripts/packager

index e7546527db23bf687aa9e1f5f08a080844242b57..334bebe95a7931d48cc9e85eddf9ff9b71bf9bb3 100644 (file)
@@ -146,7 +146,7 @@ foreach $classentry (sort @classes)
                if ($qossettings{'BURST'} > 0) {
                        print "burst $qossettings{'BURST'}k ";
                }
-               if (($qossettings{'CBURST'} ne '') || ($qossettings{'CBURST'} ne 0)) {
+               if (($qossettings{'CBURST'} ne '') && ($qossettings{'CBURST'} ne 0)) {
                        print "cburst $qossettings{'CBURST'}k";
                }
                print "\n";
@@ -166,7 +166,7 @@ foreach $subclassentry (sort @subclasses) {
        if ($qossettings{'SBURST'} > 0) {
                print "burst $qossettings{'SBURST'}k ";
        }
-       if (($qossettings{'SCBURST'} ne '') || ($qossettings{'SCBURST'} ne 0)) {
+       if (($qossettings{'SCBURST'} ne '') && ($qossettings{'SCBURST'} ne 0)) {
                print "cburst $qossettings{'CBURST'}k";
        }
        print "\n";
@@ -268,6 +268,14 @@ END
                                print "-d $qossettings{'DIP'} ";
                        }
                        print "-m layer7 --l7dir /etc/l7-protocols/protocols --l7proto $qossettings{'L7PROT'} -j MARK --set-mark $qossettings{'CLASS'}\n";
+                       print "\tiptables -t mangle -A QOS-OUT -o $qossettings{'DEVICE'} ";
+                       if ($qossettings{'QIP'} ne ''){
+                               print "-s $qossettings{'QIP'} ";
+                       }
+                       if ($qossettings{'DIP'} ne ''){
+                               print "-d $qossettings{'DIP'} ";
+                       }
+                       print "-m layer7 --l7dir /etc/l7-protocols/protocols --l7proto $qossettings{'L7PROT'} -j RETURN\n";
                }
        }
 
@@ -326,13 +334,17 @@ print "\n\t### SET PORT-RULES\n";
 print <<END
 
        ### REDUNDANT: SET ALL NONMARKED PACKETS TO DEFAULT CLASS
-       iptables -t mangle -A QOS-OUT -m mark --mark 0 -j MARK --set-mark $qossettings{'DEFCLASS_OUT'}
+       iptables -t mangle -A QOS-OUT -o $qossettings{'RED_DEV'} -m mark --mark 0 -j MARK --set-mark $qossettings{'DEFCLASS_OUT'}
 
        ###
        ### $qossettings{'IMQ_DEV'}
        ###
 
        ### BRING UP $qossettings{'IMQ_DEV'}
+       if [ `lsmod | grep -q ipt_IMQ` ]; then
+               insmod ipt_IMQ
+               sleep 2
+       fi
        modprobe imq numdevs=1
        ip link set $qossettings{'IMQ_DEV'} up
 
@@ -433,7 +445,9 @@ print <<END
 
        ### ADD QOS-OUT CHAIN TO THE MANGLE TABLE IN IPTABLES
        iptables -t mangle -N QOS-INC
-       iptables -t mangle -I POSTROUTING -o $qossettings{'IMQ_DEV'} -j QOS-INC
+       iptables -t mangle -A PREROUTING -i $qossettings{'RED_DEV'} -j IMQ --todev 0
+       iptables -t mangle -I PREROUTING -i $qossettings{'RED_DEV'} -j QOS-INC
+
 
        ### SET LEVEL7-RULES
 END
@@ -448,7 +462,7 @@ END
                        $qossettings{'L7PROT'} = $l7ruleline[2];
                        $qossettings{'QIP'} = $l7ruleline[3];
                        $qossettings{'DIP'} = $l7ruleline[4];
-                       print "\tiptables -t mangle -A QOS-INC -o $qossettings{'DEVICE'} ";
+                       print "\tiptables -t mangle -A QOS-INC -i $qossettings{'DEVICE'} ";
                        if ($qossettings{'QIP'} ne ''){
                                print "-s $qossettings{'QIP'} ";
                        }
@@ -456,6 +470,14 @@ END
                                print "-d $qossettings{'DIP'} ";
                        }
                        print "-m layer7 --l7dir /etc/l7-protocols/protocols --l7proto $qossettings{'L7PROT'} -j MARK --set-mark $qossettings{'CLASS'}\n";
+                       print "\tiptables -t mangle -A QOS-INC -i $qossettings{'DEVICE'} ";
+                       if ($qossettings{'QIP'} ne ''){
+                               print "-s $qossettings{'QIP'} ";
+                       }
+                       if ($qossettings{'DIP'} ne ''){
+                               print "-d $qossettings{'DIP'} ";
+                       }
+                       print "-m layer7 --l7dir /etc/l7-protocols/protocols --l7proto $qossettings{'L7PROT'} -j RETURN\n";
                }
        }
 
@@ -472,7 +494,7 @@ print "\n\t### SET PORT-RULES\n";
                        $qossettings{'QPORT'} = $portruleline[4];
                        $qossettings{'DIP'} = $portruleline[5];
                        $qossettings{'DPORT'} = $portruleline[6];
-                       print "\tiptables -t mangle -A QOS-INC -o $qossettings{'DEVICE'} ";
+                       print "\tiptables -t mangle -A QOS-INC -i $qossettings{'DEVICE'} ";
                        if ($qossettings{'QIP'} ne ''){
                                print "-s $qossettings{'QIP'} ";
                        }
@@ -490,7 +512,7 @@ print "\n\t### SET PORT-RULES\n";
                                print "--dport $qossettings{'DPORT'} ";
                        }
                        print "-j MARK --set-mark $qossettings{'CLASS'}\n";
-                       print "\tiptables -t mangle -A QOS-INC -o $qossettings{'DEVICE'} ";
+                       print "\tiptables -t mangle -A QOS-INC -i $qossettings{'DEVICE'} ";
                        if ($qossettings{'QIP'} ne ''){
                                print "-s $qossettings{'QIP'} ";
                        }
@@ -514,7 +536,7 @@ print "\n\t### SET PORT-RULES\n";
 print <<END
 
        ### REDUNDANT: SET ALL NONMARKED PACKETS TO DEFAULT CLASS
-       iptables -t mangle -A QOS-INC -m mark --mark 0 -j MARK --set-mark $qossettings{'DEFCLASS_INC'}
+       iptables -t mangle -A QOS-INC -i $qossettings{'IMQ_DEV'} -m mark --mark 0 -j MARK --set-mark $qossettings{'DEFCLASS_INC'}
 
        echo "Quality of Service was successfully started!"
        exit 0
@@ -522,21 +544,29 @@ print <<END
   clear)
        ### RESET EVERYTHING TO A KNOWN STATE
        # DELETE QDISCS
-       tc qdisc del dev $qossettings{'RED_DEV'} root &> /dev/null
-       tc qdisc del dev $qossettings{'IMQ_DEV'} root &> /dev/null
+       tc qdisc del dev $qossettings{'RED_DEV'} root
+       tc qdisc del dev $qossettings{'IMQ_DEV'} root
        # REMOVE & FLUSH CHAINS
-       iptables -t mangle -D POSTROURING -o $qossettings{'RED_DEV'} -j QOS-OUT &> /dev/null
-       iptables -t mangle -F QOS-OUT &> /dev/null
-       iptables -t mangle -X QOS-OUT &> /dev/null
-       iptables -t mangle -D POSTROURING -o $qossettings{'IMQ_DEV'} -j QOS-INC &> /dev/null
-       iptables -t mangle -F QOS-INC &> /dev/null
-       iptables -t mangle -X QOS-INC &> /dev/null
+       iptables -t mangle --delete POSTROUTING -o $qossettings{'RED_DEV'} -j QOS-OUT
+       iptables -t mangle --flush  QOS-OUT
+       iptables -t mangle --delete-chain QOS-OUT
+       iptables -t mangle --delete PREROUTING -i $qossettings{'IMQ_DEV'} -j QOS-INC
+       iptables -t mangle --flush  QOS-INC
+       iptables -t mangle --delete-chain QOS-INC
        # STOP IMQ-DEVICE
-       ip link set $qossettings{'IMQ_DEV'} down &> /dev/null
-       rmmod imq &> /dev/null
-       rmmod sch_htb &> /dev/null
+       ip link set $qossettings{'IMQ_DEV'} down
+       iptables -t mangle --delete PREROUTING -i $qossettings{'RED_DEV'} -j IMQ --todev 0
+       rmmod imq
+       rmmod sch_htb
+       ## rmmod ipt_IMQ # Doesn't work :(
        echo "Quality of Service was successfully cleared!"
   ;;
+  gen)
+       echo -n "Generateing the QoS-Scripts..."
+       /usr/bin/perl /var/ipfire/qos/bin/makeqosscripts.pl > /var/ipfire/qos/bin/qos.sh
+       echo ".Done!"
+       exit 0
+       ;;
 esac
 ### EOF
 END
index 06b397314a3377552a7d80cfa231d44d88d8eb65..094cd87351a048fc9ed4bc6c73e23d5e4c19e6e1 100644 (file)
@@ -57,6 +57,7 @@ $qossettings{'DEFCLASS_INC'} = '';
 $qossettings{'DEFCLASS_OUT'} = '';
 $qossettings{'ACK'} = '';
 $qossettings{'MTU'} = '1492';
+$qossettings{'SFQ_PERTUB'} = '10';
 $qossettings{'QLENGTH'} = '30';
 $qossettings{'RED_DEV'} = `cat /var/ipfire/red/iface`;
 $qossettings{'IMQ_DEV'} = 'imq0';
index 8e9feeb2ded92e85c54fd87b912e5a1092748b17..1f0d2f1c7d81ec0708dd15498a53caefd41212de 100644 (file)
@@ -26,7 +26,7 @@
 
 include Config
 
-VER        = 1.2.7.1
+VER        = 1.2.9.1
 
 THISAPP    = asterisk-$(VER)
 DL_FILE    = $(THISAPP).tar.gz
@@ -36,43 +36,24 @@ TARGET     = $(DIR_INFO)/$(THISAPP)
 PROG       = asterisk
 PAK_VER    = ipfire-beta1
 
-ASTERISK   = $(THISAPP)
-ZAPTEL     = zaptel-1.2.5
-BRISTUFF   = bristuff-0.3.0-PRE-1o
-LIBPRI     = libpri-1.2.2
-SPANDSP    = spandsp-0.0.2pre25
-OH323      = asterisk-oh323-0.7.3
-
 ###############################################################################
 # Top-level Rules
 ###############################################################################
 
 objects = $(DL_FILE) \
-          $(ZAPTEL).tar.gz \
-          $(BRISTUFF).tar.gz \
-          $(LIBPRI).tar.gz \
-          $(OH323).tar.gz \
           app_rxfax.c \
           app_txfax.c \
           apps_Makefile.patch
 
 $(DL_FILE) = $(DL_FROM)/$(DL_FILE)
-$(ZAPTEL).tar.gz = $(URL_IPFIRE)/$(ZAPTEL).tar.gz
-$(BRISTUFF).tar.gz = $(URL_IPFIRE)/$(BRISTUFF).tar.gz
-$(LIBPRI).tar.gz = $(URL_IPFIRE)/$(LIBPRI).tar.gz
 app_rxfax.c = $(URL_IPFIRE)/app_rxfax.c
 app_txfax.c = $(URL_IPFIRE)/app_txfax.c
 apps_Makefile.patch = $(URL_IPFIRE)/apps_Makefile.patch
-$(OH323).tar.gz = $(URL_IPFIRE)/$(OH323).tar.gz
 
-$(DL_FILE)_MD5 = 5c4b473eee2fbc2cb9e346f0564ef970
-$(ZAPTEL).tar.gz_MD5 = 8c8561259d29a314aa5a076050124697
-$(BRISTUFF).tar.gz_MD5 = 93bb8a5661aaf3022cf4a102ea061f83
-$(LIBPRI).tar.gz_MD5 = efce9c3699110588df5e4cf09eae01d9
+$(DL_FILE)_MD5 = d98fc3dc5ee8df691ca2b0bd309bb251
 app_rxfax.c_MD5 = ab6983b51c412883545b36993d704999
 app_txfax.c_MD5 = 8c8fcb263b76897022b4c28052a7b439
 apps_Makefile.patch_MD5 = 6b0faa7a7cf8613962b17c23ee5a1583
-$(OH323).tar.gz_MD5 = 66dc098a20ac11f098edbbaed307c085
 
 install : $(TARGET)
 
@@ -104,92 +85,14 @@ $(subst %,%_MD5,$(objects)) :
 
 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        @$(PREBUILD)
-       @rm -rf $(DIR_SRC)/$(BRISTUFF)
-       # Decompress the source-code
-       cd $(DIR_SRC) && \
-       tar zxf $(DIR_DL)/$(BRISTUFF).tar.gz -C $(DIR_SRC) && \
-       cd $(DIR_SRC)/$(BRISTUFF) && \
-       tar xfz $(DIR_DL)/$(ZAPTEL).tar.gz && \
-       tar xfz $(DIR_DL)/$(LIBPRI).tar.gz && \
-       tar xfz $(DIR_DL)/$(ASTERISK).tar.gz && \
-       tar xfz $(DIR_DL)/$(OH323).tar.gz
-
-       # Build Zaptel
-       cd $(DIR_SRC)/$(BRISTUFF)/$(ZAPTEL) && \
-       patch -Np1 < $(DIR_SRC)/src/patches/zaptel.patch && \
-       make clean && \
-       make all KVERS=$(KVER)-smp && \
-       make install KVERS=$(KVER)-smp && \
-       make clean && \
-       make all KVERS=$(KVER) && \
-       make install KVERS=$(KVER)
-       cd $(DIR_SRC)/$(BRISTUFF)/$(ZAPTEL) && install -D -m 644 zaptel.h /usr/include/linux/zaptel.h
-       cd $(DIR_SRC)/$(BRISTUFF)/$(ZAPTEL) && install -D -m 644 zconfig.h /usr/include/linux/zconfig.h
-       cd $(DIR_SRC)/$(BRISTUFF)/$(ZAPTEL) && install -D -m 644 ecdis.h /usr/include/linux/ecdis.h
-       cd $(DIR_SRC)/$(BRISTUFF)/$(ZAPTEL) && install -D -m 644 fasthdlc.h /usr/include/linux/fasthdlc.h
-       cd $(DIR_SRC)/$(BRISTUFF)/$(ZAPTEL) && install -D -m 644 kb1ec.h /usr/include/linux/kb1ec.h
-       cd $(DIR_SRC)/$(BRISTUFF)/$(ZAPTEL) && install -D -m 644 kb1ec_const.h /usr/include/linux/kb1ec_const.h
-       cd $(DIR_SRC)/$(BRISTUFF)/$(ZAPTEL) && install -D -m 644 biquad.h /usr/include/linux/biquad.h
-       cd $(DIR_SRC)/$(BRISTUFF)/$(ZAPTEL) && install -D -m 644 arith.h /usr/include/linux/arith.h
-       ln -nf -v /usr/include/linux/zaptel.h /usr/include/zaptel.h
-       ln -nf -v /usr/include/linux/zconfig.h /usr/include/zconfig.h
-       ln -nf -v /usr/include/linux/ecdis.h /usr/include/ecdis.h
-       ln -nf -v /usr/include/linux/fasthdlc.h /usr/include/fasthdlc.h
-       ln -nf -v /usr/include/linux/kb1ec.h /usr/include/kb1ec.h
-       ln -nf -v /usr/include/linux/kb1ec_const.h /usr/include/kb1ec_const.h
-       ln -nf -v /usr/include/linux/biquad.h /usr/include/biquad.h
-       ln -nf -v /usr/include/linux/arith.h /usr/include/arith.h
-
-       # Build Libpri
-       cd $(DIR_SRC)/$(BRISTUFF)/$(LIBPRI) && \
-       patch -Np1 < $(DIR_SRC)/src/patches/libpri.patch && \
-       make clean all KVERS=$(KVER) && \
-       make install KVERS=$(KVER)
-
-       # Build libgsmat
-       cd $(DIR_SRC)/$(BRISTUFF)/libgsmat-0.0.1 && \
-       make clean all && \
-       make install
-
-       # Build uno/duo/quad GSM PCI driver
-       cd $(DIR_SRC)/$(BRISTUFF)/ztgsm && \
-       make clean linux24 && \
-       install -D -m 644 ztgsm.o /lib/modules/$(KVER)/misc/ztgsm.o
-
-       # Build qozap
-       cd $(DIR_SRC)/$(BRISTUFF)/qozap && \
-       make clean linux24 && \
-       install -D -m 644 qozap.o /lib/modules/$(KVER)/misc/qozap.o
-
-       # Build cwain
-       cd $(DIR_SRC)/$(BRISTUFF)/cwain && \
-       make clean linux24 && \
-       install -D -m 644 cwain.o /lib/modules/$(KVER)/misc/cwain.o
-
-       # Build zaphfc
-       cd $(DIR_SRC)/$(BRISTUFF)/zaphfc && \
-       patch -Np1 < $(DIR_SRC)/src/patches/zaphfc_0.3.0-PRE-1o_florz-12.diff && \
-       cd $(DIR_SRC)/$(BRISTUFF)/zaphfc && make clean linux24 && \
-       install -D -m 644 zaphfc.o /lib/modules/$(KVER)/misc/zaphfc.o
-
-       # Compress the Kernelmodules
-       find /lib/modules/$(KVER)/misc/ -name '*.o' -a -type f | xargs gzip -f9
-       find /lib/modules/$(KVER)-smp/misc/ -name '*.o' -a -type f | xargs gzip -f9
-
-       # Build Asterisk
-       cd $(DIR_SRC)/$(BRISTUFF)/$(ASTERISK) &&        patch -Np1 < $(DIR_SRC)/src/patches/asterisk.patch
-       ### FAX geht noch nicht mit Asterisk 1.2.7.1
-       # cp -fv $(DIR_DL)/app_{r,t}xfax.c $(DIR_SRC)/$(BRISTUFF)/$(ASTERISK)/apps && \
-       # cd $(DIR_SRC)/$(BRISTUFF)/$(ASTERISK)/apps && patch < $(DIR_DL)/apps_Makefile.patch
-       cd $(DIR_SRC)/$(BRISTUFF)/$(ASTERISK) &&        make clean
-       cd $(DIR_SRC)/$(BRISTUFF)/$(ASTERISK) &&        make all ASTETCDIR=/var/ipfire/asterisk
-       cd $(DIR_SRC)/$(BRISTUFF)/$(ASTERISK) &&        make install ASTETCDIR=/var/ipfire/asterisk
-       cd $(DIR_SRC)/$(BRISTUFF)/$(ASTERISK) &&        make samples ASTETCDIR=/var/ipfire/asterisk
-
-       # Build OH323
-       cd $(DIR_SRC)/$(BRISTUFF)/$(OH323) && \
-       make ASTERISKINCDIR=$(DIR_SRC)/$(BRISTUFF)/$(ASTERISK)/include OH323WRAPLIBDIR=/usr/lib && \
-       make install ASTERISKINCDIR=$(DIR_SRC)/$(BRISTUFF)/$(ASTERISK)/include OH323WRAPLIBDIR=/usr/lib
-       @rm -rf $(DIR_SRC)/$(BRISTUFF) ## Do not delete any more cause to save time on a recompile: $(DIR_SRC)/{pwlib,openh323}
+       @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE)
+       cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/asterisk.patch
+       ### FAX geht noch nicht mit Asterisk 1.2.9.1
+       # cp -fv $(DIR_DL)/app_{r,t}xfax.c $(DIR_APP)/apps && \
+       # cd $(DIR_APP)/apps && patch < $(DIR_DL)/apps_Makefile.patch
+       cd $(DIR_APP) && make clean
+       cd $(DIR_APP) && make all ASTETCDIR=/var/ipfire/asterisk
+       cd $(DIR_APP) && make install ASTETCDIR=/var/ipfire/asterisk
+       cd $(DIR_APP) && make samples ASTETCDIR=/var/ipfire/asterisk
+       @rm -rf $(DIR_APP)
        @$(POSTBUILD)
-
diff --git a/lfs/bristuff b/lfs/bristuff
new file mode 100644 (file)
index 0000000..96ea511
--- /dev/null
@@ -0,0 +1,110 @@
+###############################################################################
+# This file is part of the IPCop Firewall.                                    #
+#                                                                             #
+# IPCop is free software; you can redistribute it and/or modify               #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation; either version 2 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# IPCop is distributed in the hope that it will be useful,                    #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with IPCop; if not, write to the Free Software                        #
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA    #
+#                                                                             #
+# Makefiles are based on LFSMake, which is                                    #
+# Copyright (C) 2002 Rod Roard <rod@sunsetsystems.com>                        #
+#                                                                             #
+###############################################################################
+
+###############################################################################
+# Definitions
+###############################################################################
+
+include Config
+
+VER        = 0.3.0-PRE-1q
+
+THISAPP    = bristuff-$(VER)
+DL_FILE    = $(THISAPP).tar.gz
+DL_FROM    = $(URL_IPFIRE)
+DIR_APP    = $(DIR_SRC)/$(THISAPP)
+TARGET     = $(DIR_INFO)/$(THISAPP)
+PROG       = bristuff
+PAK_VER    = ipfire-beta1
+
+###############################################################################
+# Top-level Rules
+###############################################################################
+
+objects = $(DL_FILE)
+
+$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
+
+$(DL_FILE)_MD5 = 9b3ef09eca7166b7277e8519a11844bf
+
+install : $(TARGET)
+
+check : $(patsubst %,$(DIR_CHK)/%,$(objects))
+
+download :$(patsubst %,$(DIR_DL)/%,$(objects))
+
+md5 : $(subst %,%_MD5,$(objects))
+
+dist: 
+       @$(PAK)
+
+###############################################################################
+# Downloading, checking, md5sum
+###############################################################################
+
+$(patsubst %,$(DIR_CHK)/%,$(objects)) :
+       @$(CHECK)
+
+$(patsubst %,$(DIR_DL)/%,$(objects)) :
+       @$(LOAD)
+
+$(subst %,%_MD5,$(objects)) :
+       @$(MD5)
+
+###############################################################################
+# Installation Details
+###############################################################################
+
+$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
+       @$(PREBUILD)
+       @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE)
+       # Build libgsmat
+       cd $(DIR_APP)/libgsmat-0.0.1 && \
+       make clean all && \
+       make install
+
+       # Build uno/duo/quad GSM PCI driver
+       cd $(DIR_APP)/ztgsm && \
+       make clean linux24 && \
+       install -D -m 644 ztgsm.o /lib/modules/$(KVER)/misc/ztgsm.o
+
+       # Build qozap
+       cd $(DIR_APP)/qozap && \
+       make clean linux24 && \
+       install -D -m 644 qozap.o /lib/modules/$(KVER)/misc/qozap.o
+
+       # Build cwain
+       cd $(DIR_APP)/cwain && \
+       make clean linux24 && \
+       install -D -m 644 cwain.o /lib/modules/$(KVER)/misc/cwain.o
+
+       # Build zaphfc
+       cd $(DIR_APP)/zaphfc && \
+       patch -Np1 < $(DIR_SRC)/src/patches/zaphfc_0.3.0-PRE-1o_florz-12.diff && \
+       cd $(DIR_APP)/zaphfc && make clean linux24 && \
+       install -D -m 644 zaphfc.o /lib/modules/$(KVER)/misc/zaphfc.o
+
+       # Compress the Kernelmodules
+       find /lib/modules/$(KVER)/misc/ -name '*.o' -a -type f | xargs gzip -f9
+       find /lib/modules/$(KVER)-smp/misc/ -name '*.o' -a -type f | xargs gzip -f9
+       @rm -rf $(DIR_APP)
+       @$(POSTBUILD)
diff --git a/lfs/libpri b/lfs/libpri
new file mode 100644 (file)
index 0000000..16df896
--- /dev/null
@@ -0,0 +1,87 @@
+###############################################################################
+# This file is part of the IPCop Firewall.                                    #
+#                                                                             #
+# IPCop is free software; you can redistribute it and/or modify               #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation; either version 2 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# IPCop is distributed in the hope that it will be useful,                    #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with IPCop; if not, write to the Free Software                        #
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA    #
+#                                                                             #
+# Makefiles are based on LFSMake, which is                                    #
+# Copyright (C) 2002 Rod Roard <rod@sunsetsystems.com>                        #
+#                                                                             #
+###############################################################################
+
+###############################################################################
+# Definitions
+###############################################################################
+
+include Config
+
+VER        = 1.2.3
+
+THISAPP    = libpri-$(VER)
+DL_FILE    = $(THISAPP).tar.gz
+DL_FROM    = $(URL_IPFIRE)
+DIR_APP    = $(DIR_SRC)/$(THISAPP)
+TARGET     = $(DIR_INFO)/$(THISAPP)
+PROG       = libpri
+PAK_VER    = ipfire-beta1
+
+###############################################################################
+# Top-level Rules
+###############################################################################
+
+objects = $(DL_FILE)
+
+$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
+
+$(DL_FILE)_MD5 = f365d9ee29a7253d605729a6d07ebfff
+
+install : $(TARGET)
+
+check : $(patsubst %,$(DIR_CHK)/%,$(objects))
+
+download :$(patsubst %,$(DIR_DL)/%,$(objects))
+
+md5 : $(subst %,%_MD5,$(objects))
+
+dist: 
+       @$(PAK)
+
+###############################################################################
+# Downloading, checking, md5sum
+###############################################################################
+
+$(patsubst %,$(DIR_CHK)/%,$(objects)) :
+       @$(CHECK)
+
+$(patsubst %,$(DIR_DL)/%,$(objects)) :
+       @$(LOAD)
+
+$(subst %,%_MD5,$(objects)) :
+       @$(MD5)
+
+###############################################################################
+# Installation Details
+###############################################################################
+
+$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
+       @$(PREBUILD)
+       @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE)
+       # Build Libpri
+       cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/libpri.patch
+       cd $(DIR_APP) && make clean all KVERS=$(KVER)
+       cd $(DIR_APP) && make install KVERS=$(KVER)
+       find /lib/modules/$(KVER)/misc/ -name '*.o' -a -type f | xargs gzip -f9
+       find /lib/modules/$(KVER)-smp/misc/ -name '*.o' -a -type f | xargs gzip -f9
+       @rm -rf $(DIR_APP)
+       @$(POSTBUILD)
diff --git a/lfs/zaptel b/lfs/zaptel
new file mode 100644 (file)
index 0000000..6b3b31b
--- /dev/null
@@ -0,0 +1,107 @@
+###############################################################################
+# This file is part of the IPCop Firewall.                                    #
+#                                                                             #
+# IPCop is free software; you can redistribute it and/or modify               #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation; either version 2 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# IPCop is distributed in the hope that it will be useful,                    #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with IPCop; if not, write to the Free Software                        #
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA    #
+#                                                                             #
+# Makefiles are based on LFSMake, which is                                    #
+# Copyright (C) 2002 Rod Roard <rod@sunsetsystems.com>                        #
+#                                                                             #
+###############################################################################
+
+###############################################################################
+# Definitions
+###############################################################################
+
+include Config
+
+VER        = 1.2.6
+
+THISAPP    = zaptel-$(VER)
+DL_FILE    = $(THISAPP).tar.gz
+DL_FROM    = $(URL_IPFIRE)
+DIR_APP    = $(DIR_SRC)/$(THISAPP)
+TARGET     = $(DIR_INFO)/$(THISAPP)
+PROG       = zaptel
+PAK_VER    = ipfire-beta1
+
+###############################################################################
+# Top-level Rules
+###############################################################################
+
+objects = $(DL_FILE)
+
+$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
+
+$(DL_FILE)_MD5 = c6058b74f43ae12a29e486cf1e919562
+
+install : $(TARGET)
+
+check : $(patsubst %,$(DIR_CHK)/%,$(objects))
+
+download :$(patsubst %,$(DIR_DL)/%,$(objects))
+
+md5 : $(subst %,%_MD5,$(objects))
+
+dist: 
+       @$(PAK)
+
+###############################################################################
+# Downloading, checking, md5sum
+###############################################################################
+
+$(patsubst %,$(DIR_CHK)/%,$(objects)) :
+       @$(CHECK)
+
+$(patsubst %,$(DIR_DL)/%,$(objects)) :
+       @$(LOAD)
+
+$(subst %,%_MD5,$(objects)) :
+       @$(MD5)
+
+###############################################################################
+# Installation Details
+###############################################################################
+
+$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
+       @$(PREBUILD)
+       @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE)
+       # Build Zaptel
+       cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/zaptel.patch
+       cd $(DIR_APP) && make clean
+       cd $(DIR_APP) && make all KVERS=$(KVER)-smp
+       cd $(DIR_APP) && make install KVERS=$(KVER)-smp
+       cd $(DIR_APP) && make clean
+       cd $(DIR_APP) && make all KVERS=$(KVER)
+       cd $(DIR_APP) && make install KVERS=$(KVER)
+       cd $(DIR_APP) && install -D -m 644 zaptel.h /usr/include/linux/zaptel.h
+       cd $(DIR_APP) && install -D -m 644 zconfig.h /usr/include/linux/zconfig.h
+       cd $(DIR_APP) && install -D -m 644 ecdis.h /usr/include/linux/ecdis.h
+       cd $(DIR_APP) && install -D -m 644 fasthdlc.h /usr/include/linux/fasthdlc.h
+       cd $(DIR_APP) && install -D -m 644 kb1ec.h /usr/include/linux/kb1ec.h
+       cd $(DIR_APP) && install -D -m 644 kb1ec_const.h /usr/include/linux/kb1ec_const.h
+       cd $(DIR_APP) && install -D -m 644 biquad.h /usr/include/linux/biquad.h
+       cd $(DIR_APP) && install -D -m 644 arith.h /usr/include/linux/arith.h
+       ln -nf -v /usr/include/linux/zaptel.h /usr/include/zaptel.h
+       ln -nf -v /usr/include/linux/zconfig.h /usr/include/zconfig.h
+       ln -nf -v /usr/include/linux/ecdis.h /usr/include/ecdis.h
+       ln -nf -v /usr/include/linux/fasthdlc.h /usr/include/fasthdlc.h
+       ln -nf -v /usr/include/linux/kb1ec.h /usr/include/kb1ec.h
+       ln -nf -v /usr/include/linux/kb1ec_const.h /usr/include/kb1ec_const.h
+       ln -nf -v /usr/include/linux/biquad.h /usr/include/biquad.h
+       ln -nf -v /usr/include/linux/arith.h /usr/include/arith.h
+       find /lib/modules/$(KVER)/misc/ -name '*.o' -a -type f | xargs gzip -f9
+       find /lib/modules/$(KVER)-smp/misc/ -name '*.o' -a -type f | xargs gzip -f9
+       @rm -rf $(DIR_APP)
+       @$(POSTBUILD)
diff --git a/make.sh b/make.sh
index 39648a6e37cbaca2bf9848c1d8eb2bf061c57904..1dc85f45104af469e5e6c11365aa98f9b4d8290a 100644 (file)
--- a/make.sh
+++ b/make.sh
@@ -722,7 +722,10 @@ buildipcop() {
 #  ipcopmake amavisd
   echo -ne "`date -u '+%b %e %T'`: Building ### VoIP-Server ### \n" | tee -a $LOGFILE
   ipcopmake stund
-  ipcopmake asterisk
+  ipcopmake zaptel
+  ipcopmake libpri
+  ipcopmake bristuff
+#  ipcopmake asterisk
   ipcopmake mpg123
   echo -ne "`date -u '+%b %e %T'`: Building ### MP3-Server ### \n" | tee -a $LOGFILE
   ipcopmake lame
@@ -856,7 +859,7 @@ ipfirepackages() {
   fi
   ipfiredist amavisd
   ipfiredist applejuice
-  ipfiredist asterisk
+  ipfiredist asterisk
   ipfiredist clamav
   ipfiredist cups
   ipfiredist cyrusimap
index 45ad3a253ec6f702d00440a649720fda10c07bb0..7e8742985592c6cf7cb31d4c67abe33063cc067e 100644 (file)
@@ -24384,11 +24384,11 @@ lib/modules/2.4.31-smp/extra/unicorn_pci_atm.o.gz
 ##
 ## unzip552
 ##
-#usr/bin/funzip
-#usr/bin/unzip
-#usr/bin/unzipsfx
-#usr/bin/zipgrep
-#usr/bin/zipinfo
+usr/bin/funzip
+usr/bin/unzip
+usr/bin/unzipsfx
+usr/bin/zipgrep
+usr/bin/zipinfo
 #usr/share/man/man1/funzip.1
 #usr/share/man/man1/unzip.1
 #usr/share/man/man1/unzipsfx.1
index 828dafabeb2a338bae8a3128f69296b725c2d861..9938b5c0298749617a3a201dd348ac742e1ef956 100644 (file)
@@ -10,7 +10,7 @@ SUID_PROGS = setdmzholes setportfw setfilters setxtaccess restartdhcp restartsno
        setaliases ipfirebackup restartntpd \
        restartapplejuice setdate rebuildhosts \
        restartsyslogd logwatch openvpnctrl timecheckctrl \
-       restartwireless getipstat
+       restartwireless getipstat qosctrl
 
 install : all
        install -m 755  $(PROGS) /usr/local/bin
@@ -39,6 +39,9 @@ logwatch: logwatch.c setuid.o ../install+setup/libsmooth/varval.o
 openvpnctrl: openvpnctrl.c setuid.o ../install+setup/libsmooth/varval.o
        $(COMPILE) -I../install+setup/libsmooth/ openvpnctrl.c setuid.o ../install+setup/libsmooth/varval.o -o $@
 
+qosctrl: qosctrl.c setuid.o ../install+setup/libsmooth/varval.o
+       $(COMPILE) -I../install+setup/libsmooth/ qosctrl.c setuid.o ../install+setup/libsmooth/varval.o -o $@
+
 setaliases: setaliases.c setuid.o ../install+setup/libsmooth/varval.o
        $(COMPILE) -I../install+setup/libsmooth/ setaliases.c setuid.o ../install+setup/libsmooth/varval.o -o $@
 
diff --git a/src/misc-progs/qosctrl.c b/src/misc-progs/qosctrl.c
new file mode 100644 (file)
index 0000000..ee64502
--- /dev/null
@@ -0,0 +1,51 @@
+/* This file is part of the IPFire Firewall.
+ *
+ * This program is distributed under the terms of the GNU General Public
+ * Licence.  See the file COPYING for details.
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include "setuid.h"
+
+int main(int argc, char *argv[]) {
+
+       int fd = -1;
+       int enable = 0;
+
+       if (!(initsetuid()))
+               exit(1);
+
+       if (argc < 2) {
+               fprintf(stderr, "\nNo argument given.\n\nqosctrl (start|clear|status)\n\n");
+               exit(1);
+       }
+
+
+               if (strcmp(argv[1], "start") == 0) {
+                        if ((fd = open("/var/ipfire/qos/enable", O_RDONLY)) != -1)
+                       {
+                               close(fd);
+                               enable = 1;
+                       }
+
+                       if (enable)
+                       {
+                               safe_system("/var/ipfire/qos/bin/qos.sh start");
+                       }       
+               } else if (strcmp(argv[1], "clear") == 0) {
+                       safe_system("/var/ipfire/qos/bin/qos.sh clear");
+               } else if (strcmp(argv[1], "status") == 0) {
+                       safe_system("/var/ipfire/qos/bin/qos.sh status");
+               } else {
+                       fprintf(stderr, "\nBad argument given.\n\nqosctrl (start|clear|status)\n\n");
+                       exit(1);
+               }
+
+       return 0;
+}
diff --git a/src/paks/bristuff/ROOTFILES b/src/paks/bristuff/ROOTFILES
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/paks/bristuff/install.sh b/src/paks/bristuff/install.sh
new file mode 100644 (file)
index 0000000..3a9ce55
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+#
+#################################################################
+#                                                               #
+# This file belongs to IPFire Firewall - GPLv2 - www.ipfire.org #
+#                                                               #
+#################################################################
+#
+# Extract the files
+tar xfz files.tgz -C /
+cp -f ROOTFILES /opt/pakfire/installed/ROOTFILES.$2
diff --git a/src/paks/bristuff/uninstall.sh b/src/paks/bristuff/uninstall.sh
new file mode 100644 (file)
index 0000000..ad61226
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/bash
+#################################################################
+#                                                               #
+# This file belongs to IPFire Firewall - GPLv2 - www.ipfire.org #
+#                                                               #
+#################################################################
+#
+# Delete the files
+## Befehl fehlt noch
+rm -f /opt/pakfire/installed/ROOTFILES.$2
diff --git a/src/paks/libpri/ROOTFILES b/src/paks/libpri/ROOTFILES
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/paks/libpri/install.sh b/src/paks/libpri/install.sh
new file mode 100644 (file)
index 0000000..3a9ce55
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+#
+#################################################################
+#                                                               #
+# This file belongs to IPFire Firewall - GPLv2 - www.ipfire.org #
+#                                                               #
+#################################################################
+#
+# Extract the files
+tar xfz files.tgz -C /
+cp -f ROOTFILES /opt/pakfire/installed/ROOTFILES.$2
diff --git a/src/paks/libpri/uninstall.sh b/src/paks/libpri/uninstall.sh
new file mode 100644 (file)
index 0000000..ad61226
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/bash
+#################################################################
+#                                                               #
+# This file belongs to IPFire Firewall - GPLv2 - www.ipfire.org #
+#                                                               #
+#################################################################
+#
+# Delete the files
+## Befehl fehlt noch
+rm -f /opt/pakfire/installed/ROOTFILES.$2
diff --git a/src/paks/zaptel/ROOTFILES b/src/paks/zaptel/ROOTFILES
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/paks/zaptel/install.sh b/src/paks/zaptel/install.sh
new file mode 100644 (file)
index 0000000..3a9ce55
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+#
+#################################################################
+#                                                               #
+# This file belongs to IPFire Firewall - GPLv2 - www.ipfire.org #
+#                                                               #
+#################################################################
+#
+# Extract the files
+tar xfz files.tgz -C /
+cp -f ROOTFILES /opt/pakfire/installed/ROOTFILES.$2
diff --git a/src/paks/zaptel/uninstall.sh b/src/paks/zaptel/uninstall.sh
new file mode 100644 (file)
index 0000000..ad61226
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/bash
+#################################################################
+#                                                               #
+# This file belongs to IPFire Firewall - GPLv2 - www.ipfire.org #
+#                                                               #
+#################################################################
+#
+# Delete the files
+## Befehl fehlt noch
+rm -f /opt/pakfire/installed/ROOTFILES.$2
index afc998e214ed6775ee690f48c8aa5df5ed73eba9..d9983662f4c2a54b61766f8447ae07df7b8bb6bb 100644 (file)
@@ -1,12 +1,12 @@
-diff -urN asterisk-1.2.7.1.orig/.version asterisk-1.2.7.1/.version
---- asterisk-1.2.7.1.orig/.version     2006-04-13 19:50:06.000000000 +0200
-+++ asterisk-1.2.7.1/.version  2006-04-18 14:39:46.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/.version asterisk-1.2.9.1/.version
+--- asterisk-1.2.9.1.orig/.version     2006-06-06 18:19:31.000000000 +0200
++++ asterisk-1.2.9.1/.version  2006-06-09 10:25:16.000000000 +0200
 @@ -1 +1 @@
--1.2.7.1
-+1.2.7.1-BRIstuffed-0.3.0-PRE-1o-with-florz-patch-for-ipfire
-diff -urN asterisk-1.2.7.1.orig/HARDWARE asterisk-1.2.7.1/HARDWARE
---- asterisk-1.2.7.1.orig/HARDWARE     2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.7.1/HARDWARE  2006-04-18 14:39:28.000000000 +0200
+-1.2.9.1
++1.2.9.1-BRIstuffed-0.3.0-PRE-1q
+diff -urN asterisk-1.2.9.1.orig/HARDWARE asterisk-1.2.9.1/HARDWARE
+--- asterisk-1.2.9.1.orig/HARDWARE     2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.9.1/HARDWARE  2006-06-09 10:25:04.000000000 +0200
 @@ -37,6 +37,19 @@
     * Wildcard TE410P - Quad T1/E1 switchable interface.  Supports PRI and 
       RBS signalling, as well as PPP, FR, and HDLC data modes.
@@ -27,9 +27,9 @@ diff -urN asterisk-1.2.7.1.orig/HARDWARE asterisk-1.2.7.1/HARDWARE
  Non-zaptel compatible hardware
  ==============================
  
-diff -urN asterisk-1.2.7.1.orig/LICENSE asterisk-1.2.7.1/LICENSE
---- asterisk-1.2.7.1.orig/LICENSE      2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.7.1/LICENSE   2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/LICENSE asterisk-1.2.9.1/LICENSE
+--- asterisk-1.2.9.1.orig/LICENSE      2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.9.1/LICENSE   2006-06-09 10:25:04.000000000 +0200
 @@ -1,7 +1,7 @@
 -Asterisk is distributed under the GNU General Public License version 2
 -and is also available under alternative licenses negotiated directly
@@ -42,10 +42,10 @@ diff -urN asterisk-1.2.7.1.orig/LICENSE asterisk-1.2.7.1/LICENSE
  except as defined below. The GPL (version 2) is included in this
  source tree in the file COPYING.
  
-diff -urN asterisk-1.2.7.1.orig/Makefile asterisk-1.2.7.1/Makefile
---- asterisk-1.2.7.1.orig/Makefile     2006-04-11 23:58:47.000000000 +0200
-+++ asterisk-1.2.7.1/Makefile  2006-04-18 14:39:28.000000000 +0200
-@@ -760,6 +760,9 @@
+diff -urN asterisk-1.2.9.1.orig/Makefile asterisk-1.2.9.1/Makefile
+--- asterisk-1.2.9.1.orig/Makefile     2006-04-30 16:27:56.000000000 +0200
++++ asterisk-1.2.9.1/Makefile  2006-06-09 10:25:04.000000000 +0200
+@@ -761,6 +761,9 @@
                echo ";astctlowner = root" ; \
                echo ";astctlgroup = apache" ; \
                echo ";astctl = asterisk.ctl" ; \
@@ -55,9 +55,9 @@ diff -urN asterisk-1.2.7.1.orig/Makefile asterisk-1.2.7.1/Makefile
                ) > $(DESTDIR)$(ASTCONFPATH) ; \
        else \
                echo "Skipping asterisk.conf creation"; \
-diff -urN asterisk-1.2.7.1.orig/README asterisk-1.2.7.1/README
---- asterisk-1.2.7.1.orig/README       2006-03-03 09:12:33.000000000 +0100
-+++ asterisk-1.2.7.1/README    2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/README asterisk-1.2.9.1/README
+--- asterisk-1.2.9.1.orig/README       2006-03-03 09:12:33.000000000 +0100
++++ asterisk-1.2.9.1/README    2006-06-09 10:25:04.000000000 +0200
 @@ -4,6 +4,8 @@
  
  Copyright (C) 2001-2005 Digium, Inc.
@@ -67,9 +67,9 @@ diff -urN asterisk-1.2.7.1.orig/README asterisk-1.2.7.1/README
  ================================================================
  
  * SECURITY
-diff -urN asterisk-1.2.7.1.orig/README.chan_capi asterisk-1.2.7.1/README.chan_capi
---- asterisk-1.2.7.1.orig/README.chan_capi     1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.7.1/README.chan_capi  2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/README.chan_capi asterisk-1.2.9.1/README.chan_capi
+--- asterisk-1.2.9.1.orig/README.chan_capi     1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.9.1/README.chan_capi  2006-06-09 10:25:04.000000000 +0200
 @@ -0,0 +1,146 @@
 +(CAPI*) chan_capi a Common ISDN API 2.0 implementation for Asterisk
 +(C) 2002, 2003, 2004, 2005 Junghanns.NET GmbH 
@@ -217,9 +217,9 @@ diff -urN asterisk-1.2.7.1.orig/README.chan_capi asterisk-1.2.7.1/README.chan_ca
 +      
 +
 +
-diff -urN asterisk-1.2.7.1.orig/agi/Makefile asterisk-1.2.7.1/agi/Makefile
---- asterisk-1.2.7.1.orig/agi/Makefile 2006-03-28 22:22:05.000000000 +0200
-+++ asterisk-1.2.7.1/agi/Makefile      2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/agi/Makefile asterisk-1.2.9.1/agi/Makefile
+--- asterisk-1.2.9.1.orig/agi/Makefile 2006-03-28 22:22:05.000000000 +0200
++++ asterisk-1.2.9.1/agi/Makefile      2006-06-09 10:25:04.000000000 +0200
 @@ -11,7 +11,7 @@
  # the GNU General Public License
  #
@@ -238,9 +238,9 @@ diff -urN asterisk-1.2.7.1.orig/agi/Makefile asterisk-1.2.7.1/agi/Makefile
  
  %.so : %.o
        $(CC) -shared -Xlinker -x -o $@ $<
-diff -urN asterisk-1.2.7.1.orig/agi/xagi-test.c asterisk-1.2.7.1/agi/xagi-test.c
---- asterisk-1.2.7.1.orig/agi/xagi-test.c      1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.7.1/agi/xagi-test.c   2006-04-24 09:55:45.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/agi/xagi-test.c asterisk-1.2.9.1/agi/xagi-test.c
+--- asterisk-1.2.9.1.orig/agi/xagi-test.c      1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.9.1/agi/xagi-test.c   2006-06-09 10:25:04.000000000 +0200
 @@ -0,0 +1,175 @@
 +/*
 + * Asterisk -- A telephony toolkit for Linux.
@@ -417,9 +417,9 @@ diff -urN asterisk-1.2.7.1.orig/agi/xagi-test.c asterisk-1.2.7.1/agi/xagi-test.c
 +              return -1;
 +      exit(0);
 +}
-diff -urN asterisk-1.2.7.1.orig/apps/Makefile asterisk-1.2.7.1/apps/Makefile
---- asterisk-1.2.7.1.orig/apps/Makefile        2006-02-09 03:31:21.000000000 +0100
-+++ asterisk-1.2.7.1/apps/Makefile     2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/apps/Makefile asterisk-1.2.9.1/apps/Makefile
+--- asterisk-1.2.9.1.orig/apps/Makefile        2006-04-30 15:38:22.000000000 +0200
++++ asterisk-1.2.9.1/apps/Makefile     2006-06-09 10:25:04.000000000 +0200
 @@ -28,8 +28,15 @@
       app_test.so app_forkcdr.so app_math.so app_realtime.so \
       app_dumpchan.so app_waitforsilence.so app_while.so app_setrdnis.so \
@@ -437,9 +437,9 @@ diff -urN asterisk-1.2.7.1.orig/apps/Makefile asterisk-1.2.7.1/apps/Makefile
  
  #
  # Obsolete things...
-diff -urN asterisk-1.2.7.1.orig/apps/app_callingpres.c asterisk-1.2.7.1/apps/app_callingpres.c
---- asterisk-1.2.7.1.orig/apps/app_callingpres.c       1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.7.1/apps/app_callingpres.c    2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/apps/app_callingpres.c asterisk-1.2.9.1/apps/app_callingpres.c
+--- asterisk-1.2.9.1.orig/apps/app_callingpres.c       1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.9.1/apps/app_callingpres.c    2006-06-09 10:25:04.000000000 +0200
 @@ -0,0 +1,70 @@
 +/*
 + * An application to change the CallingPresentation for an Asterisk channel.
@@ -511,9 +511,9 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_callingpres.c asterisk-1.2.7.1/apps/app
 +{
 +    return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.7.1.orig/apps/app_capiCD.c asterisk-1.2.7.1/apps/app_capiCD.c
---- asterisk-1.2.7.1.orig/apps/app_capiCD.c    1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.7.1/apps/app_capiCD.c 2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/apps/app_capiCD.c asterisk-1.2.9.1/apps/app_capiCD.c
+--- asterisk-1.2.9.1.orig/apps/app_capiCD.c    1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.9.1/apps/app_capiCD.c 2006-06-09 10:25:04.000000000 +0200
 @@ -0,0 +1,172 @@
 +/*
 + * (CAPI*)
@@ -687,9 +687,9 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_capiCD.c asterisk-1.2.7.1/apps/app_capi
 +{
 +      return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.7.1.orig/apps/app_capiECT.c asterisk-1.2.7.1/apps/app_capiECT.c
---- asterisk-1.2.7.1.orig/apps/app_capiECT.c   1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.7.1/apps/app_capiECT.c        2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/apps/app_capiECT.c asterisk-1.2.9.1/apps/app_capiECT.c
+--- asterisk-1.2.9.1.orig/apps/app_capiECT.c   1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.9.1/apps/app_capiECT.c        2006-06-09 10:25:04.000000000 +0200
 @@ -0,0 +1,210 @@
 +/*
 + * (CAPI*)
@@ -901,9 +901,9 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_capiECT.c asterisk-1.2.7.1/apps/app_cap
 +{
 +      return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.7.1.orig/apps/app_capiNoES.c asterisk-1.2.7.1/apps/app_capiNoES.c
---- asterisk-1.2.7.1.orig/apps/app_capiNoES.c  1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.7.1/apps/app_capiNoES.c       2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/apps/app_capiNoES.c asterisk-1.2.9.1/apps/app_capiNoES.c
+--- asterisk-1.2.9.1.orig/apps/app_capiNoES.c  1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.9.1/apps/app_capiNoES.c       2006-06-09 10:25:04.000000000 +0200
 @@ -0,0 +1,96 @@
 +/*
 + * (CAPI*)
@@ -1001,9 +1001,9 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_capiNoES.c asterisk-1.2.7.1/apps/app_ca
 +{
 +      return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.7.1.orig/apps/app_chanisavail.c asterisk-1.2.7.1/apps/app_chanisavail.c
---- asterisk-1.2.7.1.orig/apps/app_chanisavail.c       2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.7.1/apps/app_chanisavail.c    2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/apps/app_chanisavail.c asterisk-1.2.9.1/apps/app_chanisavail.c
+--- asterisk-1.2.9.1.orig/apps/app_chanisavail.c       2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.9.1/apps/app_chanisavail.c    2006-06-09 10:25:04.000000000 +0200
 @@ -118,7 +118,7 @@
                                snprintf(trychan, sizeof(trychan), "%s/%s",cur,number);
                                status = inuse = ast_device_state(trychan);
@@ -1013,10 +1013,140 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_chanisavail.c asterisk-1.2.7.1/apps/app
                                        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.7.1.orig/apps/app_devstate.c asterisk-1.2.7.1/apps/app_devstate.c
---- asterisk-1.2.7.1.orig/apps/app_devstate.c  1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.7.1/apps/app_devstate.c       2006-04-18 14:39:28.000000000 +0200
-@@ -0,0 +1,219 @@
+diff -urN asterisk-1.2.9.1.orig/apps/app_chanspy.c asterisk-1.2.9.1/apps/app_chanspy.c
+--- asterisk-1.2.9.1.orig/apps/app_chanspy.c   2006-01-03 18:24:56.000000000 +0100
++++ asterisk-1.2.9.1/apps/app_chanspy.c        2006-06-09 10:25:04.000000000 +0200
+@@ -54,6 +54,7 @@
+ static const char *synopsis = "Listen to the audio of an active channel\n";
+ static const char *app = "ChanSpy";
++static const char *app2 = "ChanSpyChan";
+ static const char *desc = 
+ "  ChanSpy([chanprefix][|options]): This application is used to listen to the\n"
+ "audio from an active Asterisk channel. This includes the audio coming in and\n"
+@@ -141,6 +142,19 @@
+       return ret;
+ }
++static struct ast_channel *local_get_channel_uniqueid(char *uniqueid) 
++{
++      struct ast_channel *chan = NULL;
++      if (uniqueid) {
++          ast_mutex_lock(&modlock);
++          if ((chan = ast_get_channel_by_uniqueid_locked(uniqueid))) {
++              ast_mutex_unlock(&chan->lock);
++          }
++          ast_mutex_unlock(&modlock);
++      }       
++      return chan;
++}
++
+ static void *spy_alloc(struct ast_channel *chan, void *data)
+ {
+       /* just store the data pointer in the channel structure */
+@@ -553,11 +567,87 @@
+       ALL_DONE(u, res);
+ }
++static int chanspychan_exec(struct ast_channel *chan, void *data)
++{
++      struct localuser *u;
++      struct ast_channel *peer=NULL;
++      char    *args,
++              *uniqueid = NULL,
++              *argv[5];
++      int res = -1,
++              volfactor = 0,
++              argc = 0,
++              oldrf = 0,
++              oldwf = 0,
++              fd = 0;
++      signed char zero_volume = 0;
++
++      if (!(args = ast_strdupa((char *)data))) {
++              ast_log(LOG_ERROR, "Out of memory!\n");
++              return -1;
++      }
++
++      LOCAL_USER_ADD(u);
++
++      oldrf = chan->readformat;
++      oldwf = chan->writeformat;
++      if (ast_set_read_format(chan, AST_FORMAT_SLINEAR) < 0) {
++              ast_log(LOG_ERROR, "Could Not Set Read Format.\n");
++              LOCAL_USER_REMOVE(u);
++              return -1;
++      }
++      
++      if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) {
++              ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
++              LOCAL_USER_REMOVE(u);
++              return -1;
++      }
++
++
++      if ((argc = ast_app_separate_args(args, '|', argv, sizeof(argv) / sizeof(argv[0])))) {
++              uniqueid = argv[0];
++              if (ast_strlen_zero(uniqueid)) {
++                  LOCAL_USER_REMOVE(u);
++                  return -1;
++              }
++      }
++      
++      ast_answer(chan);
++
++      ast_set_flag(chan, AST_FLAG_SPYING); /* so nobody can spy on us while we are spying */
++
++      peer = local_get_channel_uniqueid(uniqueid);
++      if (peer && (peer != chan) && !ast_check_hangup(peer) && !ast_test_flag(peer, AST_FLAG_SPYING)) {
++          res = channel_spy(chan, peer, &volfactor, fd);
++      } else {
++          ast_log(LOG_NOTICE, "no channel found with uniqueid %s\n", uniqueid);
++      }
++
++      if (fd > 0) {
++              close(fd);
++      }
++
++      if (oldrf && ast_set_read_format(chan, oldrf) < 0) {
++              ast_log(LOG_ERROR, "Could Not Set Read Format.\n");
++      }
++      
++      if (oldwf && ast_set_write_format(chan, oldwf) < 0) {
++              ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
++      }
++
++      ast_clear_flag(chan, AST_FLAG_SPYING);
++
++      ast_channel_setoption(chan, AST_OPTION_TXGAIN, &zero_volume, sizeof(zero_volume), 0);
++
++      ALL_DONE(u, res);
++}
++
+ int unload_module(void)
+ {
+       int res;
+-      res = ast_unregister_application(app);
++      ast_unregister_application(app);
++      res = ast_unregister_application(app2);
+       STANDARD_HANGUP_LOCALUSERS;
+@@ -566,7 +656,8 @@
+ int load_module(void)
+ {
+-      return ast_register_application(app, chanspy_exec, synopsis, desc);
++      ast_register_application(app, chanspy_exec, synopsis, desc);
++      return ast_register_application(app2, chanspychan_exec, synopsis, desc);
+ }
+ char *description(void)
+diff -urN asterisk-1.2.9.1.orig/apps/app_devstate.c asterisk-1.2.9.1/apps/app_devstate.c
+--- asterisk-1.2.9.1.orig/apps/app_devstate.c  1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.9.1/apps/app_devstate.c       2006-06-09 10:25:04.000000000 +0200
+@@ -0,0 +1,225 @@
 +/*
 + * Devstate application
 + * 
@@ -1071,7 +1201,7 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_devstate.c asterisk-1.2.7.1/apps/app_de
 +static int devstate_cli(int fd, int argc, char *argv[])
 +{
 +    char devName[128];
-+    if ((argc != 3) && (argc != 4))
++    if ((argc != 3) && (argc != 4) && (argc != 5))
 +        return RESULT_SHOWUSAGE;
 +
 +    if (ast_db_put("DEVSTATES", argv[1], argv[2]))
@@ -1082,6 +1212,9 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_devstate.c asterisk-1.2.7.1/apps/app_de
 +    if (argc == 4) {
 +        ast_log(LOG_NOTICE, "devname %s cid %s\n", devName, argv[3]);
 +      ast_device_state_changed_literal(devName, argv[3], NULL);
++    } else if (argc == 5) {
++        ast_log(LOG_NOTICE, "devname %s cid %s cidname %s\n", devName, argv[3], argv[4]);
++      ast_device_state_changed_literal(devName, argv[3], argv[4]);
 +    } else {
 +      ast_device_state_changed_literal(devName, NULL, NULL);
 +    }
@@ -1173,6 +1306,8 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_devstate.c asterisk-1.2.7.1/apps/app_de
 +        char *devstate = astman_get_header(m, "Devstate");
 +        char *value = astman_get_header(m, "Value");
 +      char *id = astman_get_header(m,"ActionID");
++        char *cid_num = astman_get_header(m, "CallerID");
++        char *cid_name = astman_get_header(m, "CallerIDName");
 +      char devName[128];
 +
 +      if (!strlen(devstate)) {
@@ -1186,7 +1321,8 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_devstate.c asterisk-1.2.7.1/apps/app_de
 +
 +        if (!ast_db_put("DEVSTATES", devstate, value)) {
 +          snprintf(devName, sizeof(devName), "DS/%s", devstate);
-+          ast_device_state_changed(devName);
++//        ast_device_state_changed(devName);
++          ast_device_state_changed_literal(devName, cid_num, cid_name);
 +          ast_cli(s->fd, "Response: Success\r\n");
 +      } else {
 +          ast_log(LOG_DEBUG, "ast_db_put failed\n");
@@ -1236,9 +1372,9 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_devstate.c asterisk-1.2.7.1/apps/app_de
 +{
 +    return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.7.1.orig/apps/app_dial.c asterisk-1.2.7.1/apps/app_dial.c
---- asterisk-1.2.7.1.orig/apps/app_dial.c      2006-04-12 00:39:59.000000000 +0200
-+++ asterisk-1.2.7.1/apps/app_dial.c   2006-04-18 14:40:13.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/apps/app_dial.c asterisk-1.2.9.1/apps/app_dial.c
+--- asterisk-1.2.9.1.orig/apps/app_dial.c      2006-05-24 21:44:26.000000000 +0200
++++ asterisk-1.2.9.1/apps/app_dial.c   2006-06-09 10:25:04.000000000 +0200
 @@ -11,6 +11,10 @@
   * the project provides a web site, mailing lists and IRC
   * channels for your use.
@@ -1250,8 +1386,8 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_dial.c asterisk-1.2.7.1/apps/app_dial.c
   * 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.
-@@ -114,7 +118,8 @@
- "           Otherwise, the current extension is used.\n"
+@@ -115,7 +119,8 @@
+ "           action post answer options in conjunction with this option.\n" 
  "    h    - Allow the called party to hang up by sending the '*' DTMF digit.\n"
  "    H    - Allow the calling party to hang up by hitting the '*' DTMF digit.\n"
 -"    j    - Jump to priority n+101 if all of the requested channels were busy.\n"
@@ -1260,7 +1396,7 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_dial.c asterisk-1.2.7.1/apps/app_dial.c
  "    L(x[:y][:z]) - Limit the call to 'x' ms. Play a warning when 'y' ms are\n"
  "           left. Repeat the warning every 'z' ms. The following special\n"
  "           variables can be used with this option:\n"
-@@ -159,8 +164,11 @@
+@@ -162,8 +167,11 @@
  "           family/key is not specified.\n"
  "    r    - Indicate ringing to the calling party. Pass no audio to the calling\n"
  "           party until the called channel has answered.\n"
@@ -1273,7 +1409,7 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_dial.c asterisk-1.2.7.1/apps/app_dial.c
  "    t    - Allow the called party to transfer the calling party by sending the\n"
  "           DTMF sequence defined in features.conf.\n"
  "    T    - Allow the calling party to transfer the called party by sending the\n"
-@@ -211,6 +219,8 @@
+@@ -214,6 +222,8 @@
        OPT_CALLEE_MONITOR = (1 << 21),
        OPT_CALLER_MONITOR = (1 << 22),
        OPT_GOTO = (1 << 23),
@@ -1282,7 +1418,7 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_dial.c asterisk-1.2.7.1/apps/app_dial.c
  } dial_exec_option_flags;
  
  #define DIAL_STILLGOING                       (1 << 30)
-@@ -249,6 +259,8 @@
+@@ -252,6 +262,8 @@
        AST_APP_OPTION('p', OPT_SCREENING),
        AST_APP_OPTION_ARG('P', OPT_PRIVACY, OPT_ARG_PRIVACY),
        AST_APP_OPTION('r', OPT_RINGBACK),
@@ -1291,7 +1427,7 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_dial.c asterisk-1.2.7.1/apps/app_dial.c
        AST_APP_OPTION_ARG('S', OPT_DURATION_STOP, OPT_ARG_DURATION_STOP),
        AST_APP_OPTION('t', OPT_CALLEE_TRANSFER),
        AST_APP_OPTION('T', OPT_CALLER_TRANSFER),
-@@ -386,7 +398,7 @@
+@@ -389,7 +401,7 @@
        char *context = NULL;
        char cidname[AST_MAX_EXTENSION];
  
@@ -1300,7 +1436,7 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_dial.c asterisk-1.2.7.1/apps/app_dial.c
        
        if (single) {
                /* Turn off hold music, etc */
-@@ -465,7 +477,7 @@
+@@ -468,7 +480,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 */
@@ -1308,8 +1444,8 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_dial.c asterisk-1.2.7.1/apps/app_dial.c
 +                                              o->chan = ast_request(tech, in->nativeformats, stuff, &cause, NULL);
                                                if (!o->chan)
                                                        ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause);
-                                       } else {
-@@ -581,12 +593,18 @@
+                                               else
+@@ -586,12 +598,18 @@
                                                        HANDLE_CAUSE(AST_CAUSE_CONGESTION, in);
                                                        break;
                                                case AST_CONTROL_RINGING:
@@ -1334,42 +1470,40 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_dial.c asterisk-1.2.7.1/apps/app_dial.c
                                                        break;
                                                case AST_CONTROL_PROGRESS:
                                                        if (option_verbose > 2)
-@@ -761,6 +779,7 @@
+@@ -766,6 +784,7 @@
        int digit = 0, result = 0;
        time_t start_time, answer_time, end_time;
        struct ast_app *app = NULL;
-+      char *aoceunits;
++/*    char *aoceunits; */
  
        char *parse;
        AST_DECLARE_APP_ARGS(args,
-@@ -934,17 +953,24 @@
+@@ -939,13 +958,13 @@
                }
                
                if( privdb_val == AST_PRIVACY_DENY ) {
+-                      strcpy(status, "NOANSWER");
 +                      ast_copy_string(status, "NOANSWER", sizeof(status));
                        ast_verbose( VERBOSE_PREFIX_3  "Privacy DB reports PRIVACY_DENY for this callerid. Dial reports unavailable\n");
                        res=0;
                        goto out;
                }
                else if( privdb_val == AST_PRIVACY_KILL ) {
--                      ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 201);
+-                      strcpy(status, "DONTCALL");
 +                      ast_copy_string(status, "DONTCALL", sizeof(status));
-+                      if (option_priority_jumping || ast_test_flag(&opts, OPT_PRIORITY_JUMP)) {
-+                              ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 201);
-+                      }
-                       res = 0;
+                       if (option_priority_jumping || ast_test_flag(&opts, OPT_PRIORITY_JUMP)) {
+                               ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 201);
+                       }
+@@ -953,7 +972,7 @@
                        goto out; /* Is this right? */
                }
                else if( privdb_val == AST_PRIVACY_TORTURE ) {
--                      ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 301);
+-                      strcpy(status, "TORTURE");
 +                      ast_copy_string(status, "TORTURE", sizeof(status));
-+                      if (option_priority_jumping || ast_test_flag(&opts, OPT_PRIORITY_JUMP)) {
-+                              ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 301);
-+                      }
-                       res = 0;
-                       goto out; /* is this right??? */
-@@ -981,7 +1007,7 @@
+                       if (option_priority_jumping || ast_test_flag(&opts, OPT_PRIORITY_JUMP)) {
+                               ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 301);
+                       }
+@@ -992,7 +1011,7 @@
        /* If a channel group has been specified, get it for use when we create peer channels */
        outbound_group = pbx_builtin_getvar_helper(chan, "OUTBOUND_GROUP");
  
@@ -1378,7 +1512,7 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_dial.c asterisk-1.2.7.1/apps/app_dial.c
        cur = args.peers;
        do {
                /* Remember where to start next time */
-@@ -1023,7 +1049,7 @@
+@@ -1034,7 +1053,7 @@
                                ast_log(LOG_DEBUG, "Dialing by extension %s\n", numsubst);
                }
                /* Request the peer */
@@ -1387,7 +1521,7 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_dial.c asterisk-1.2.7.1/apps/app_dial.c
                if (!tmp->chan) {
                        /* If we can't, just go on to the next call */
                        ast_log(LOG_NOTICE, "Unable to create channel of type '%s' (cause %d - %s)\n", tech, cause, ast_cause2str(cause));
-@@ -1054,7 +1080,7 @@
+@@ -1065,7 +1084,7 @@
                                        ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", chan->name, tech, stuff, tmp->chan->name);
                                ast_hangup(tmp->chan);
                                /* Setup parameters */
@@ -1395,50 +1529,50 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_dial.c asterisk-1.2.7.1/apps/app_dial.c
 +                              tmp->chan = ast_request(tech, chan->nativeformats, stuff, &cause, NULL);
                                if (!tmp->chan)
                                        ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause);
-                       } else {
-@@ -1173,8 +1199,11 @@
+                               else
+@@ -1178,7 +1197,7 @@
+       if (outgoing) {
+               /* Our status will at least be NOANSWER */
+-              strcpy(status, "NOANSWER");
++              ast_copy_string(status, "NOANSWER", sizeof(status));
+               if (ast_test_flag(outgoing, OPT_MUSICBACK)) {
+                       moh=1;
+                       ast_moh_start(chan, opt_args[OPT_ARG_MUSICBACK]);
+@@ -1186,8 +1205,11 @@
                        ast_indicate(chan, AST_CONTROL_RINGING);
                        sentringing++;
                }
 -      } else
+-              strcpy(status, "CHANUNAVAIL");
 +      } else {
-               strcpy(status, "CHANUNAVAIL");
++              ast_copy_string(status, "CHANUNAVAIL", sizeof(status));
 +              /* See if there is a special message */
 +              ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 201);
 +      }
  
        time(&start_time);
        peer = wait_for_answer(chan, outgoing, &to, peerflags, &sentringing, status, sizeof(status), numbusy, numnochan, numcongestion, ast_test_flag(&opts, OPT_PRIORITY_JUMP), &result);
-@@ -1303,6 +1332,8 @@
-                                                                    opt_args[OPT_ARG_PRIVACY], privcid);
-                                               ast_privacy_set(opt_args[OPT_ARG_PRIVACY], privcid, AST_PRIVACY_DENY);
-                                       }
-+                                      ast_copy_string(status, "NOANSWER", sizeof(status));
-+
-                                       if (ast_test_flag(&opts, OPT_MUSICBACK)) {
-                                               ast_moh_stop(chan);
-                                       } else if (ast_test_flag(&opts, OPT_RINGBACK)) {
-@@ -1585,7 +1616,16 @@
+@@ -1599,7 +1621,15 @@
                }
                snprintf(toast, sizeof(toast), "%ld", (long)(end_time - start_time));
                pbx_builtin_setvar_helper(chan, "DIALEDTIME", toast);
 -              
 +
 +              /* forward AOC-E units from peer, if possible */
-+              aoceunits = pbx_builtin_getvar_helper(peer, "AOCEUNITS");
++/*            aoceunits = pbx_builtin_getvar_helper(peer, "AOCEUNITS");
 +
 +              if (aoceunits) {
 +                  snprintf(toast, sizeof(toast), "%d", atoi(aoceunits));
-+              //    ast_log(LOG_NOTICE, "AOCEUNITS %s\n" , toast);
 +                  pbx_builtin_setvar_helper(chan, "AOCEUNITS", toast);
-+              } 
++              }  */
 +
                if (res != AST_PBX_NO_HANGUP_PEER) {
                        if (!chan->_softhangup)
                                chan->hangupcause = peer->hangupcause;
-diff -urN asterisk-1.2.7.1.orig/apps/app_directed_pickup.c asterisk-1.2.7.1/apps/app_directed_pickup.c
---- asterisk-1.2.7.1.orig/apps/app_directed_pickup.c   2006-04-06 19:00:10.000000000 +0200
-+++ asterisk-1.2.7.1/apps/app_directed_pickup.c        2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/apps/app_directed_pickup.c asterisk-1.2.9.1/apps/app_directed_pickup.c
+--- asterisk-1.2.9.1.orig/apps/app_directed_pickup.c   2006-04-06 19:00:10.000000000 +0200
++++ asterisk-1.2.9.1/apps/app_directed_pickup.c        2006-06-09 10:25:04.000000000 +0200
 @@ -41,7 +41,7 @@
  #include "asterisk/app.h"
  
@@ -1448,10 +1582,10 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_directed_pickup.c asterisk-1.2.7.1/apps
  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.7.1.orig/apps/app_meetme.c asterisk-1.2.7.1/apps/app_meetme.c
---- asterisk-1.2.7.1.orig/apps/app_meetme.c    2006-04-07 00:15:20.000000000 +0200
-+++ asterisk-1.2.7.1/apps/app_meetme.c 2006-04-18 14:39:28.000000000 +0200
-@@ -455,7 +455,7 @@
+diff -urN asterisk-1.2.9.1.orig/apps/app_meetme.c asterisk-1.2.9.1/apps/app_meetme.c
+--- asterisk-1.2.9.1.orig/apps/app_meetme.c    2006-05-25 22:03:11.000000000 +0200
++++ asterisk-1.2.9.1/apps/app_meetme.c 2006-06-09 10:25:04.000000000 +0200
+@@ -453,7 +453,7 @@
                        ast_copy_string(cnf->pin, pin, sizeof(cnf->pin));
                        ast_copy_string(cnf->pinadmin, pinadmin, sizeof(cnf->pinadmin));
                        cnf->markedusers = 0;
@@ -1460,7 +1594,7 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_meetme.c asterisk-1.2.7.1/apps/app_meet
                        if (cnf->chan) {
                                cnf->fd = cnf->chan->fds[0];    /* for use by conf_play() */
                        } else {
-@@ -825,8 +825,9 @@
+@@ -823,8 +823,9 @@
        char exitcontext[AST_MAX_CONTEXT] = "";
        char recordingtmp[AST_MAX_EXTENSION] = "";
        int dtmf;
@@ -1471,7 +1605,7 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_meetme.c asterisk-1.2.7.1/apps/app_meet
        char *buf = __buf + AST_FRIENDLY_OFFSET;
        
        if (!user) {
-@@ -992,7 +993,7 @@
+@@ -990,7 +991,7 @@
                }
                /* Setup buffering information */
                memset(&bi, 0, sizeof(bi));
@@ -1480,7 +1614,7 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_meetme.c asterisk-1.2.7.1/apps/app_meet
                bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
                bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
                bi.numbufs = audio_buffers;
-@@ -1277,6 +1278,14 @@
+@@ -1275,6 +1276,14 @@
                                f = ast_read(c);
                                if (!f)
                                        break;
@@ -1495,7 +1629,7 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_meetme.c asterisk-1.2.7.1/apps/app_meet
                                if ((f->frametype == AST_FRAME_VOICE) && (f->subclass == AST_FORMAT_SLINEAR)) {
                                        if (user->talk.actual)
                                                ast_frame_adjust_volume(f, user->talk.actual);
-@@ -1508,7 +1517,7 @@
+@@ -1506,7 +1515,7 @@
                                }
                                ast_frfree(f);
                        } else if (outfd > -1) {
@@ -1504,9 +1638,9 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_meetme.c asterisk-1.2.7.1/apps/app_meet
                                if (res > 0) {
                                        memset(&fr, 0, sizeof(fr));
                                        fr.frametype = AST_FRAME_VOICE;
-diff -urN asterisk-1.2.7.1.orig/apps/app_milliwatt.c asterisk-1.2.7.1/apps/app_milliwatt.c
---- asterisk-1.2.7.1.orig/apps/app_milliwatt.c 2006-01-19 05:17:45.000000000 +0100
-+++ asterisk-1.2.7.1/apps/app_milliwatt.c      2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/apps/app_milliwatt.c asterisk-1.2.9.1/apps/app_milliwatt.c
+--- asterisk-1.2.9.1.orig/apps/app_milliwatt.c 2006-01-19 05:17:45.000000000 +0100
++++ asterisk-1.2.9.1/apps/app_milliwatt.c      2006-06-09 10:25:04.000000000 +0200
 @@ -74,20 +74,28 @@
  {
        struct ast_frame wf;
@@ -1542,9 +1676,9 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_milliwatt.c asterisk-1.2.7.1/apps/app_m
        wf.src = "app_milliwatt";
        wf.delivery.tv_sec = 0;
        wf.delivery.tv_usec = 0;
-diff -urN asterisk-1.2.7.1.orig/apps/app_page.c asterisk-1.2.7.1/apps/app_page.c
---- asterisk-1.2.7.1.orig/apps/app_page.c      2006-04-13 19:40:21.000000000 +0200
-+++ asterisk-1.2.7.1/apps/app_page.c   2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/apps/app_page.c asterisk-1.2.9.1/apps/app_page.c
+--- asterisk-1.2.9.1.orig/apps/app_page.c      2006-04-13 19:40:21.000000000 +0200
++++ asterisk-1.2.9.1/apps/app_page.c   2006-06-09 10:25:04.000000000 +0200
 @@ -85,7 +85,7 @@
  {
        struct calloutdata *cd = data;
@@ -1554,9 +1688,9 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_page.c asterisk-1.2.7.1/apps/app_page.c
        free(cd);
        return NULL;
  }
-diff -urN asterisk-1.2.7.1.orig/apps/app_parkandannounce.c asterisk-1.2.7.1/apps/app_parkandannounce.c
---- asterisk-1.2.7.1.orig/apps/app_parkandannounce.c   2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.7.1/apps/app_parkandannounce.c        2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/apps/app_parkandannounce.c asterisk-1.2.9.1/apps/app_parkandannounce.c
+--- asterisk-1.2.9.1.orig/apps/app_parkandannounce.c   2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.9.1/apps/app_parkandannounce.c        2006-06-09 10:25:04.000000000 +0200
 @@ -183,7 +183,7 @@
  
        memset(&oh, 0, sizeof(oh));
@@ -1566,9 +1700,9 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_parkandannounce.c asterisk-1.2.7.1/apps
  
        if(dchan) {
                if(dchan->_state == AST_STATE_UP) {
-diff -urN asterisk-1.2.7.1.orig/apps/app_pickup.c asterisk-1.2.7.1/apps/app_pickup.c
---- asterisk-1.2.7.1.orig/apps/app_pickup.c    1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.7.1/apps/app_pickup.c 2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/apps/app_pickup.c asterisk-1.2.9.1/apps/app_pickup.c
+--- asterisk-1.2.9.1.orig/apps/app_pickup.c    1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.9.1/apps/app_pickup.c 2006-06-09 10:25:04.000000000 +0200
 @@ -0,0 +1,319 @@
 +/*
 + * Asterisk -- A telephony toolkit for Linux.
@@ -1889,10 +2023,10 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_pickup.c asterisk-1.2.7.1/apps/app_pick
 +{
 +      return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.7.1.orig/apps/app_queue.c asterisk-1.2.7.1/apps/app_queue.c
---- asterisk-1.2.7.1.orig/apps/app_queue.c     2006-04-04 19:59:18.000000000 +0200
-+++ asterisk-1.2.7.1/apps/app_queue.c  2006-04-18 14:39:28.000000000 +0200
-@@ -501,7 +501,7 @@
+diff -urN asterisk-1.2.9.1.orig/apps/app_queue.c asterisk-1.2.9.1/apps/app_queue.c
+--- asterisk-1.2.9.1.orig/apps/app_queue.c     2006-06-04 05:43:35.000000000 +0200
++++ asterisk-1.2.9.1/apps/app_queue.c  2006-06-09 10:25:04.000000000 +0200
+@@ -526,7 +526,7 @@
        return NULL;
  }
  
@@ -1901,7 +2035,7 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_queue.c asterisk-1.2.7.1/apps/app_queue
  {
        /* Avoid potential for deadlocks by spawning a new thread to handle
           the event */
-@@ -1386,7 +1386,7 @@
+@@ -1512,7 +1512,7 @@
                location = "";
  
        /* Request the peer */
@@ -1910,7 +2044,7 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_queue.c asterisk-1.2.7.1/apps/app_queue
        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);
-@@ -1692,7 +1692,7 @@
+@@ -1819,7 +1819,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 */
@@ -1919,9 +2053,27 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_queue.c asterisk-1.2.7.1/apps/app_queue
                                        if (status != o->oldstatus) 
                                                update_dial_status(qe->parent, o->member, status);                                              
                                        if (!o->chan) {
-diff -urN asterisk-1.2.7.1.orig/apps/app_readfile.c asterisk-1.2.7.1/apps/app_readfile.c
---- asterisk-1.2.7.1.orig/apps/app_readfile.c  2006-03-23 21:13:48.000000000 +0100
-+++ asterisk-1.2.7.1/apps/app_readfile.c       2006-04-18 14:39:28.000000000 +0200
+@@ -2363,14 +2363,14 @@
+                       else
+                               which = peer;
+                       if (monitorfilename)
+-                              ast_monitor_start(which, qe->parent->monfmt, monitorfilename, 1 );
++                              ast_monitor_start(which, qe->parent->monfmt, monitorfilename, NULL, NULL, 1 );
+                       else if (qe->chan->cdr) 
+-                              ast_monitor_start(which, qe->parent->monfmt, qe->chan->cdr->uniqueid, 1 );
++                              ast_monitor_start(which, qe->parent->monfmt, qe->chan->cdr->uniqueid, NULL, NULL, 1 );
+                       else {
+                               /* Last ditch effort -- no CDR, make up something */
+                               char tmpid[256];
+                               snprintf(tmpid, sizeof(tmpid), "chan-%x", rand());
+-                              ast_monitor_start(which, qe->parent->monfmt, tmpid, 1 );
++                              ast_monitor_start(which, qe->parent->monfmt, tmpid, NULL, NULL, 1 );
+                       }
+                       if (qe->parent->monjoin)
+                               ast_monitor_setjoinfiles(which, 1);
+diff -urN asterisk-1.2.9.1.orig/apps/app_readfile.c asterisk-1.2.9.1/apps/app_readfile.c
+--- asterisk-1.2.9.1.orig/apps/app_readfile.c  2006-03-23 21:13:48.000000000 +0100
++++ asterisk-1.2.9.1/apps/app_readfile.c       2006-06-09 10:25:04.000000000 +0200
 @@ -40,7 +40,7 @@
  #include "asterisk/app.h"
  #include "asterisk/module.h"
@@ -1931,9 +2083,9 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_readfile.c asterisk-1.2.7.1/apps/app_re
  
  static char *app_readfile = "ReadFile";
  
-diff -urN asterisk-1.2.7.1.orig/apps/app_segfault.c asterisk-1.2.7.1/apps/app_segfault.c
---- asterisk-1.2.7.1.orig/apps/app_segfault.c  1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.7.1/apps/app_segfault.c       2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/apps/app_segfault.c asterisk-1.2.9.1/apps/app_segfault.c
+--- asterisk-1.2.9.1.orig/apps/app_segfault.c  1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.9.1/apps/app_segfault.c       2006-06-09 10:25:04.000000000 +0200
 @@ -0,0 +1,75 @@
 +/*
 + * Segfault application
@@ -2010,67 +2162,10 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_segfault.c asterisk-1.2.7.1/apps/app_se
 +{
 +    return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.7.1.orig/apps/app_sms.c asterisk-1.2.7.1/apps/app_sms.c
---- asterisk-1.2.7.1.orig/apps/app_sms.c       2005-12-26 19:19:12.000000000 +0100
-+++ asterisk-1.2.7.1/apps/app_sms.c    2006-04-18 14:39:28.000000000 +0200
-@@ -1179,32 +1179,31 @@
- {
-       struct ast_frame f = { 0 };
-       unsigned char waste[AST_FRIENDLY_OFFSET];
-+#define MAXSAMPLES (800)
- #ifdef OUTALAW
--      unsigned char buf[800];
-+      unsigned char buf[MAXSAMPLES];
- #else
--      signed short buf[800];
-+      signed short buf[MAXSAMPLES];
- #endif
-+#define SAMPLE2LEN (sizeof (buf[0]))
-       sms_t *h = data;
-       int i;
--      if (len > sizeof (buf)) {
--              ast_log (LOG_WARNING, "Only doing %d bytes (%d bytes requested)\n", (int)(sizeof (buf) / sizeof (signed short)), len);
--              len = sizeof (buf);
--#ifdef OUTALAW
--              samples = len;
--#else
--              samples = len / 2;
--#endif
-+      if (samples > MAXSAMPLES) {
-+              ast_log (LOG_WARNING, "Only doing %d samples (%d requested)\n",
-+                       MAXSAMPLES, samples);
-+              samples = MAXSAMPLES;
-       }
--      waste[0] = 0;                                    /* make compiler happy */
-+      len = samples * SAMPLE2LEN;
-+
-+      waste[0] = 0;                            /* make compiler happy */
-       f.frametype = AST_FRAME_VOICE;
- #ifdef OUTALAW
-       f.subclass = AST_FORMAT_ALAW;
--      f.datalen = samples;
- #else
-       f.subclass = AST_FORMAT_SLINEAR;
--      f.datalen = samples * 2;
- #endif
-+      f.datalen = len;
-       f.offset = AST_FRIENDLY_OFFSET;
-       f.mallocd = 0;
-       f.data = buf;
-@@ -1256,6 +1255,8 @@
-               return -1;
-       }
-       return 0;
-+#undef SAMPLE2LEN
-+#undef MAXSAMPLES
- }
- static void sms_process (sms_t * h, int samples, signed short *data)
-diff -urN asterisk-1.2.7.1.orig/apps/app_zapras.c asterisk-1.2.7.1/apps/app_zapras.c
---- asterisk-1.2.7.1.orig/apps/app_zapras.c    2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.7.1/apps/app_zapras.c 2006-04-18 14:39:28.000000000 +0200
-@@ -182,7 +182,7 @@
+diff -urN asterisk-1.2.9.1.orig/apps/app_zapras.c asterisk-1.2.9.1/apps/app_zapras.c
+--- asterisk-1.2.9.1.orig/apps/app_zapras.c    2006-05-01 22:44:24.000000000 +0200
++++ asterisk-1.2.9.1/apps/app_zapras.c 2006-06-09 10:25:04.000000000 +0200
+@@ -186,7 +186,7 @@
                                }
                        }
                        /* Throw back into audio mode */
@@ -2079,9 +2174,9 @@ diff -urN asterisk-1.2.7.1.orig/apps/app_zapras.c asterisk-1.2.7.1/apps/app_zapr
                        ioctl(chan->fds[0], ZT_AUDIOMODE, &x);
  
                        /* Restore saved values */
-diff -urN asterisk-1.2.7.1.orig/asterisk.c asterisk-1.2.7.1/asterisk.c
---- asterisk-1.2.7.1.orig/asterisk.c   2006-04-11 23:55:51.000000000 +0200
-+++ asterisk-1.2.7.1/asterisk.c        2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/asterisk.c asterisk-1.2.9.1/asterisk.c
+--- asterisk-1.2.9.1.orig/asterisk.c   2006-05-19 21:01:17.000000000 +0200
++++ asterisk-1.2.9.1/asterisk.c        2006-06-13 10:10:50.000000000 +0200
 @@ -228,6 +228,7 @@
  char ast_config_AST_CTL_OWNER[AST_CONFIG_MAX_PATH] = "\0";
  char ast_config_AST_CTL_GROUP[AST_CONFIG_MAX_PATH] = "\0";
@@ -2090,7 +2185,7 @@ diff -urN asterisk-1.2.7.1.orig/asterisk.c asterisk-1.2.7.1/asterisk.c
  
  static char *_argv[256];
  static int shuttingdown = 0;
-@@ -1887,6 +1888,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));
@@ -2098,18 +2193,18 @@ diff -urN asterisk-1.2.7.1.orig/asterisk.c asterisk-1.2.7.1/asterisk.c
  
        /* no asterisk.conf? no problem, use buildtime config! */
        if (!cfg) {
-@@ -1926,6 +1928,8 @@
-                       ast_copy_string(ast_config_AST_RUN_DIR, v->value, sizeof(ast_config_AST_RUN_DIR));
-               } else if (!strcasecmp(v->name, "astmoddir")) {
-                       ast_copy_string(ast_config_AST_MODULE_DIR, v->value, sizeof(ast_config_AST_MODULE_DIR));
+@@ -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));
 +              } else if (!strcasecmp(v->name, "uniquename")) {
 +                      strncpy(ast_config_AST_SYMBOLIC_NAME,v->value,sizeof(ast_config_AST_SYMBOLIC_NAME));
                }
                v = v->next;
        }
-diff -urN asterisk-1.2.7.1.orig/build_tools/make_defaults_h asterisk-1.2.7.1/build_tools/make_defaults_h
---- asterisk-1.2.7.1.orig/build_tools/make_defaults_h  2005-06-20 19:26:08.000000000 +0200
-+++ asterisk-1.2.7.1/build_tools/make_defaults_h       2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/build_tools/make_defaults_h asterisk-1.2.9.1/build_tools/make_defaults_h
+--- asterisk-1.2.9.1.orig/build_tools/make_defaults_h  2005-06-20 19:26:08.000000000 +0200
++++ asterisk-1.2.9.1/build_tools/make_defaults_h       2006-06-09 10:25:04.000000000 +0200
 @@ -16,6 +16,7 @@
  #define AST_KEY_DIR    "${INSTALL_PATH}${ASTVARLIBDIR}/keys"
  #define AST_DB         "${INSTALL_PATH}${ASTVARLIBDIR}/astdb"
@@ -2118,9 +2213,9 @@ diff -urN asterisk-1.2.7.1.orig/build_tools/make_defaults_h asterisk-1.2.7.1/bui
  
  #define AST_CONFIG_FILE "${INSTALL_PATH}${ASTCONFPATH}"
  
-diff -urN asterisk-1.2.7.1.orig/channel.c asterisk-1.2.7.1/channel.c
---- asterisk-1.2.7.1.orig/channel.c    2006-04-11 23:35:52.000000000 +0200
-+++ asterisk-1.2.7.1/channel.c 2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/channel.c asterisk-1.2.9.1/channel.c
+--- asterisk-1.2.9.1.orig/channel.c    2006-06-01 22:27:50.000000000 +0200
++++ asterisk-1.2.9.1/channel.c 2006-06-09 10:25:04.000000000 +0200
 @@ -94,8 +94,8 @@
   */
  static int shutting_down = 0;
@@ -2270,7 +2365,7 @@ diff -urN asterisk-1.2.7.1.orig/channel.c asterisk-1.2.7.1/channel.c
  }
  
  int ast_channel_spy_add(struct ast_channel *chan, struct ast_channel_spy *spy)
-@@ -2362,7 +2391,7 @@
+@@ -2364,7 +2393,7 @@
                          &chan->writetrans, 1);
  }
  
@@ -2279,7 +2374,7 @@ diff -urN asterisk-1.2.7.1.orig/channel.c asterisk-1.2.7.1/channel.c
  {
        int state = 0;
        int cause = 0;
-@@ -2370,7 +2399,7 @@
+@@ -2372,7 +2401,7 @@
        struct ast_frame *f;
        int res = 0;
        
@@ -2288,7 +2383,7 @@ diff -urN asterisk-1.2.7.1.orig/channel.c asterisk-1.2.7.1/channel.c
        if (chan) {
                if (oh) {
                        if (oh->vars)   
-@@ -2384,6 +2413,7 @@
+@@ -2386,6 +2415,7 @@
                }
                ast_set_callerid(chan, cid_num, cid_name, cid_num);
  
@@ -2296,7 +2391,7 @@ diff -urN asterisk-1.2.7.1.orig/channel.c asterisk-1.2.7.1/channel.c
                if (!ast_call(chan, data, 0)) {
                        res = 1;        /* in case chan->_state is already AST_STATE_UP */
                        while (timeout && (chan->_state != AST_STATE_UP)) {
-@@ -2407,6 +2437,7 @@
+@@ -2409,6 +2439,7 @@
                                        if (f->subclass == AST_CONTROL_RINGING)
                                                state = AST_CONTROL_RINGING;
                                        else if ((f->subclass == AST_CONTROL_BUSY) || (f->subclass == AST_CONTROL_CONGESTION)) {
@@ -2304,7 +2399,7 @@ diff -urN asterisk-1.2.7.1.orig/channel.c asterisk-1.2.7.1/channel.c
                                                state = f->subclass;
                                                ast_frfree(f);
                                                break;
-@@ -2476,12 +2507,12 @@
+@@ -2478,12 +2509,12 @@
        return chan;
  }
  
@@ -2320,7 +2415,7 @@ diff -urN asterisk-1.2.7.1.orig/channel.c asterisk-1.2.7.1/channel.c
  {
        struct chanlist *chan;
        struct ast_channel *c;
-@@ -2518,6 +2549,7 @@
+@@ -2520,6 +2551,7 @@
                if (!(c = chan->tech->requester(type, capabilities, data, cause)))
                        return NULL;
  
@@ -2328,7 +2423,7 @@ diff -urN asterisk-1.2.7.1.orig/channel.c asterisk-1.2.7.1/channel.c
                if (c->_state == AST_STATE_DOWN) {
                        manager_event(EVENT_FLAG_CALL, "Newchannel",
                                      "Channel: %s\r\n"
-@@ -2765,6 +2797,29 @@
+@@ -2775,6 +2807,29 @@
        return res;
  }
  
@@ -2358,7 +2453,16 @@ diff -urN asterisk-1.2.7.1.orig/channel.c asterisk-1.2.7.1/channel.c
  void ast_change_name(struct ast_channel *chan, char *newname)
  {
        char tmp[256];
-@@ -3131,15 +3186,14 @@
+@@ -2914,7 +2969,7 @@
+       ast_copy_string(clone->name, masqn, sizeof(clone->name));
+       
+       /* Notify any managers of the change, first the masq then the other */
+-      manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", newn, masqn, clone->uniqueid);
++      manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\nNewUniqueid: %s\r\n", newn, masqn, clone->uniqueid, original->uniqueid);
+       manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", orig, newn, original->uniqueid);
+       /* Swap the technlogies */      
+@@ -3141,15 +3196,14 @@
                                );
  }
  
@@ -2376,7 +2480,7 @@ diff -urN asterisk-1.2.7.1.orig/channel.c asterisk-1.2.7.1/channel.c
        manager_event(EVENT_FLAG_CALL,
                      (oldstate == AST_STATE_DOWN) ? "Newchannel" : "Newstate",
                      "Channel: %s\r\n"
-@@ -3155,6 +3209,10 @@
+@@ -3165,6 +3219,10 @@
        return 0;
  }
  
@@ -2387,7 +2491,7 @@ diff -urN asterisk-1.2.7.1.orig/channel.c asterisk-1.2.7.1/channel.c
  /*--- Find bridged channel */
  struct ast_channel *ast_bridged_channel(struct ast_channel *chan)
  {
-@@ -3332,6 +3390,7 @@
+@@ -3342,6 +3400,7 @@
        char callee_warning = 0;
        int to;
  
@@ -2395,7 +2499,7 @@ diff -urN asterisk-1.2.7.1.orig/channel.c asterisk-1.2.7.1/channel.c
        if (c0->_bridge) {
                ast_log(LOG_WARNING, "%s is already in a bridge with %s\n", 
                        c0->name, c0->_bridge->name);
-@@ -3342,6 +3401,10 @@
+@@ -3352,6 +3411,10 @@
                        c1->name, c1->_bridge->name);
                return -1;
        }
@@ -2406,9 +2510,9 @@ diff -urN asterisk-1.2.7.1.orig/channel.c asterisk-1.2.7.1/channel.c
        
        /* Stop if we're a zombie or need a soft hangup */
        if (ast_test_flag(c0, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) ||
-diff -urN asterisk-1.2.7.1.orig/channels/Makefile asterisk-1.2.7.1/channels/Makefile
---- asterisk-1.2.7.1.orig/channels/Makefile    2005-12-15 11:52:30.000000000 +0100
-+++ asterisk-1.2.7.1/channels/Makefile 2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/channels/Makefile asterisk-1.2.9.1/channels/Makefile
+--- asterisk-1.2.9.1.orig/channels/Makefile    2006-04-30 16:27:56.000000000 +0200
++++ asterisk-1.2.9.1/channels/Makefile 2006-06-09 10:25:04.000000000 +0200
 @@ -102,6 +102,11 @@
    ZAPR2=-lmfcr2
  endif
@@ -2476,9 +2580,18 @@ diff -urN asterisk-1.2.7.1.orig/channels/Makefile asterisk-1.2.7.1/channels/Make
  chan_vpb.o: chan_vpb.c
        $(CXX) -c $(CFLAGS) -o $@ chan_vpb.c
  
-diff -urN asterisk-1.2.7.1.orig/channels/chan_agent.c asterisk-1.2.7.1/channels/chan_agent.c
---- asterisk-1.2.7.1.orig/channels/chan_agent.c        2006-02-15 02:21:33.000000000 +0100
-+++ asterisk-1.2.7.1/channels/chan_agent.c     2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/channels/chan_agent.c asterisk-1.2.9.1/channels/chan_agent.c
+--- asterisk-1.2.9.1.orig/channels/chan_agent.c        2006-05-08 16:12:20.000000000 +0200
++++ asterisk-1.2.9.1/channels/chan_agent.c     2006-06-09 10:25:04.000000000 +0200
+@@ -440,7 +440,7 @@
+               if ((pointer = strchr(filename, '.')))
+                       *pointer = '-';
+               snprintf(tmp, sizeof(tmp), "%s%s",savecallsin ? savecallsin : "", filename);
+-              ast_monitor_start(ast, recordformat, tmp, needlock);
++              ast_monitor_start(ast, recordformat, tmp, NULL, NULL, needlock);
+               ast_monitor_setjoinfiles(ast, 1);
+               snprintf(tmp2, sizeof(tmp2), "%s%s.%s", urlprefix ? urlprefix : "", filename, recordformatext);
+ #if 0
 @@ -1331,7 +1331,7 @@
                                                chan = agent_new(p, AST_STATE_DOWN);
                                        } else if (!p->owner && !ast_strlen_zero(p->loginchan)) {
@@ -2488,9 +2601,9 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_agent.c asterisk-1.2.7.1/channels/
                                                if (p->chan)
                                                        chan = agent_new(p, AST_STATE_DOWN);
                                        }
-diff -urN asterisk-1.2.7.1.orig/channels/chan_capi.c asterisk-1.2.7.1/channels/chan_capi.c
---- asterisk-1.2.7.1.orig/channels/chan_capi.c 1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.7.1/channels/chan_capi.c      2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/channels/chan_capi.c asterisk-1.2.9.1/channels/chan_capi.c
+--- asterisk-1.2.9.1.orig/channels/chan_capi.c 1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.9.1/channels/chan_capi.c      2006-06-09 10:25:04.000000000 +0200
 @@ -0,0 +1,2888 @@
 +/*
 + * (CAPI*)
@@ -5380,9 +5493,9 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_capi.c asterisk-1.2.7.1/channels/c
 +{
 +      return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.7.1.orig/channels/chan_features.c asterisk-1.2.7.1/channels/chan_features.c
---- asterisk-1.2.7.1.orig/channels/chan_features.c     2006-01-25 19:39:44.000000000 +0100
-+++ asterisk-1.2.7.1/channels/chan_features.c  2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/channels/chan_features.c asterisk-1.2.9.1/channels/chan_features.c
+--- asterisk-1.2.9.1.orig/channels/chan_features.c     2006-01-25 19:39:44.000000000 +0100
++++ asterisk-1.2.9.1/channels/chan_features.c  2006-06-09 10:25:04.000000000 +0200
 @@ -438,7 +438,7 @@
        }
        ast_mutex_unlock(&featurelock);
@@ -5392,9 +5505,9 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_features.c asterisk-1.2.7.1/channe
                if (!chan) {
                        ast_log(LOG_NOTICE, "Unable to allocate subchannel '%s/%s'\n", tech, dest);
                        return NULL;
-diff -urN asterisk-1.2.7.1.orig/channels/chan_iax2.c asterisk-1.2.7.1/channels/chan_iax2.c
---- asterisk-1.2.7.1.orig/channels/chan_iax2.c 2006-03-31 21:11:26.000000000 +0200
-+++ asterisk-1.2.7.1/channels/chan_iax2.c      2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/channels/chan_iax2.c asterisk-1.2.9.1/channels/chan_iax2.c
+--- asterisk-1.2.9.1.orig/channels/chan_iax2.c 2006-06-06 17:48:00.000000000 +0200
++++ asterisk-1.2.9.1/channels/chan_iax2.c      2006-06-09 10:25:04.000000000 +0200
 @@ -11,6 +11,9 @@
   * the project provides a web site, mailing lists and IRC
   * channels for your use.
@@ -5405,7 +5518,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_iax2.c asterisk-1.2.7.1/channels/c
   * 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.
-@@ -3065,7 +3068,7 @@
+@@ -3068,7 +3071,7 @@
        memset(&ied, 0, sizeof(ied));
        ast_mutex_lock(&iaxsl[callno]);
        if (callno && iaxs[callno]) {
@@ -5414,7 +5527,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_iax2.c asterisk-1.2.7.1/channels/c
                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);
-@@ -3117,7 +3120,8 @@
+@@ -3120,7 +3123,8 @@
  static struct ast_frame *iax2_read(struct ast_channel *c) 
  {
        static struct ast_frame f = { AST_FRAME_NULL, };
@@ -5424,19 +5537,10 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_iax2.c asterisk-1.2.7.1/channels/c
        return &f;
  }
  
-@@ -6702,7 +6706,7 @@
-               }
-               if (f.frametype == AST_FRAME_IAX) {
-                       if (iaxs[fr.callno]->initid > -1) {
--                              /* Don't auto congest anymore since we've gotten something usefulb ack */
-+                              /* Don't auto congest anymore since we've gotten something useful back */
-                               ast_sched_del(sched, iaxs[fr.callno]->initid);
-                               iaxs[fr.callno]->initid = -1;
-                       }
-diff -urN asterisk-1.2.7.1.orig/channels/chan_sip.c asterisk-1.2.7.1/channels/chan_sip.c
---- asterisk-1.2.7.1.orig/channels/chan_sip.c  2006-04-07 16:16:41.000000000 +0200
-+++ asterisk-1.2.7.1/channels/chan_sip.c       2006-04-25 13:23:13.000000000 +0200
-@@ -596,6 +596,7 @@
+diff -urN asterisk-1.2.9.1.orig/channels/chan_sip.c asterisk-1.2.9.1/channels/chan_sip.c
+--- asterisk-1.2.9.1.orig/channels/chan_sip.c  2006-05-25 19:18:01.000000000 +0200
++++ asterisk-1.2.9.1/channels/chan_sip.c       2006-06-09 10:25:04.000000000 +0200
+@@ -603,6 +603,7 @@
        unsigned int flags;                     /*!< SIP_ flags */      
        int timer_t1;                           /*!< SIP timer T1, ms rtt */
        unsigned int sipoptions;                /*!< Supported SIP sipoptions on the other end */
@@ -5444,23 +5548,33 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_sip.c asterisk-1.2.7.1/channels/ch
        int capability;                         /*!< Special capability (codec) */
        int jointcapability;                    /*!< Supported capability at both ends (codecs ) */
        int peercapability;                     /*!< Supported peer capability */
-@@ -619,6 +620,7 @@
+@@ -626,6 +627,7 @@
        char refer_to[AST_MAX_EXTENSION];       /*!< Place to store REFER-TO extension */
        char referred_by[AST_MAX_EXTENSION];    /*!< Place to store REFERRED-BY extension */
-       char refer_contact[AST_MAX_EXTENSION];  /*!< Place to store Contact info from a REFER extension */
+       char refer_contact[SIP_LEN_CONTACT];    /*!< Place to store Contact info from a REFER extension */
 +      char refer_replaces[AST_MAX_EXTENSION]; /*!< Place to store Replaces header of REFER-TO header */
        struct sip_pvt *refer_call;             /*!< Call we are referring */
        struct sip_route *route;                /*!< Head of linked list of routing steps (fm Record-Route) */
        int route_persistant;                   /*!< Is this the "real" route? */
-@@ -638,6 +640,7 @@
+@@ -645,6 +647,7 @@
        char peername[256];                     /*!< [peer] name, not set if [user] */
        char authname[256];                     /*!< Who we use for authentication */
        char uri[256];                          /*!< Original requested URI */
-+      char origuri[256];                      /*!< REAL! Original requested URI */
-       char okcontacturi[256];                 /*!< URI from the 200 OK on INVITE */
++      char origuri[SIP_LEN_CONTACT];                  /*!< REAL! Original requested URI */
+       char okcontacturi[SIP_LEN_CONTACT];     /*!< URI from the 200 OK on INVITE */
        char peersecret[256];                   /*!< Password */
        char peermd5secret[256];
-@@ -921,7 +924,7 @@
+@@ -768,6 +771,9 @@
+       int callingpres;                /*!< Calling id presentation */
+       int inUse;                      /*!< Number of calls in use */
+       int call_limit;                 /*!< Limit of concurrent calls */
++      int max_regs;                   /*!< Limit of concurrent registrations */
++      int subpeer;                    /*!< Peer entry used for multiple registrations */
++      char reg_callid[80];            /*!< Call-ID used for registration */
+       char vmexten[AST_MAX_EXTENSION]; /*!< Dialplan extension for MWI notify message*/
+       char mailbox[AST_MAX_EXTENSION]; /*!< Mailbox setting for MWI checks */
+       char language[MAX_LANGUAGE];    /*!<  Default language for prompts */
+@@ -928,7 +934,7 @@
  static int determine_firstline_parts(struct sip_request *req);
  static void sip_dump_history(struct sip_pvt *dialog); /* Dump history to LOG_DEBUG at end of dialog, before destroying data */
  static const struct cfsubscription_types *find_subscription_type(enum subscriptiontype subtype);
@@ -5469,7 +5583,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_sip.c asterisk-1.2.7.1/channels/ch
  static char *gettag(struct sip_request *req, char *header, char *tagbuf, int tagbufsize);
  
  /*! \brief Definition of this channel for PBX channel registration */
-@@ -1304,7 +1307,7 @@
+@@ -1311,7 +1317,7 @@
        /* If this is a subscription, tell the phone that we got a timeout */
        if (p->subscribed) {
                p->subscribed = TIMEOUT;
@@ -5478,7 +5592,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_sip.c asterisk-1.2.7.1/channels/ch
                p->subscribed = NONE;
                append_history(p, "Subscribestatus", "timeout");
                return 10000;   /* Reschedule this destruction so that we know that it's gone */
-@@ -3124,16 +3127,30 @@
+@@ -3150,16 +3156,30 @@
  
  /*! \brief  find_call: Connect incoming SIP message to current dialog or create new dialog structure */
  /*               Called by handle_request, sipsock_read */
@@ -5510,7 +5624,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_sip.c asterisk-1.2.7.1/channels/ch
        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
-@@ -4058,6 +4075,7 @@
+@@ -4141,6 +4161,7 @@
        if (sipmethod == SIP_CANCEL) {
                c = p->initreq.rlPart2; /* Use original URI */
        } else if (sipmethod == SIP_ACK) {
@@ -5518,7 +5632,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_sip.c asterisk-1.2.7.1/channels/ch
                /* Use URI from Contact: in 200 OK (if INVITE) 
                (we only have the contacturi on INVITEs) */
                if (!ast_strlen_zero(p->okcontacturi))
-@@ -4824,13 +4842,15 @@
+@@ -4907,13 +4928,15 @@
                ast_build_string(&invite, &invite_max, ";%s", p->options->uri_options);
  
        ast_copy_string(p->uri, invite_buf, sizeof(p->uri));
@@ -5535,7 +5649,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_sip.c asterisk-1.2.7.1/channels/ch
        } else {
                snprintf(to, sizeof(to), "<%s>", p->uri);
        }
-@@ -4887,6 +4907,11 @@
+@@ -4970,6 +4993,11 @@
                if (!ast_strlen_zero(p->referred_by))
                        add_header(&req, "Referred-By", p->referred_by);
        }
@@ -5547,7 +5661,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_sip.c asterisk-1.2.7.1/channels/ch
  #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);
-@@ -4961,8 +4986,7 @@
+@@ -5044,8 +5072,7 @@
  }
  
  /*! \brief  transmit_state_notify: Used in the SUBSCRIBE notification subsystem ----*/
@@ -5557,7 +5671,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_sip.c asterisk-1.2.7.1/channels/ch
        char tmp[4000], from[256], to[256];
        char *t = tmp, *c, *a, *mfrom, *mto;
        size_t maxbytes = sizeof(tmp);
-@@ -5106,10 +5130,19 @@
+@@ -5189,10 +5216,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);
@@ -5580,7 +5694,19 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_sip.c asterisk-1.2.7.1/channels/ch
                ast_build_string(&t, &maxbytes, "<state>%s</state>\n", statestring);
                ast_build_string(&t, &maxbytes, "</dialog>\n</dialog-info>\n");
                break;
-@@ -6321,7 +6354,7 @@
+@@ -6019,8 +6055,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);
+-      if (!ast_test_flag((&p->flags_page2), SIP_PAGE2_RT_FROMCONTACT)) 
++      if (!ast_test_flag((&p->flags_page2), SIP_PAGE2_RT_FROMCONTACT)) {
++      //      ast_log(LOG_NOTICE, "updating SIP/Registry for peer %s with data %s\n", p->name, data);
+               ast_db_put("SIP/Registry", p->name, data);
++      }
+       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);
+@@ -6411,7 +6449,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 */
@@ -5589,7 +5715,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_sip.c asterisk-1.2.7.1/channels/ch
  {
        struct sip_pvt *p = data;
  
-@@ -6340,7 +6373,7 @@
+@@ -6430,7 +6468,7 @@
                p->laststate = state;
                break;
        }
@@ -5598,7 +5724,174 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_sip.c asterisk-1.2.7.1/channels/ch
  
        if (option_debug > 1)
                ast_verbose(VERBOSE_PREFIX_1 "Extension Changed %s new state %s for Notify User %s\n", exten, ast_extension_state2str(state), p->username);
-@@ -8607,6 +8640,7 @@
+@@ -6456,7 +6494,13 @@
+       char *name, *c;
+       char *t;
+       char *domain;
+-
++      char *callid;
++      struct sip_peer *clone;
++      char clone_name[256];
++      int found = 0;
++      struct sip_peer *recycle_peer = NULL;
++      char peer_name[256];
++      
+       /* Terminate URI */
+       t = uri;
+       while(*t && (*t > 32) && (*t != ';'))
+@@ -6505,9 +6549,68 @@
+               if (!ast_test_flag(&peer->flags_page2, SIP_PAGE2_DYNAMIC)) {
+                       ast_log(LOG_ERROR, "Peer '%s' is trying to register, but not configured as host=dynamic\n", peer->name);
+               } else {
++                      callid = get_header(req, "Call-ID");
++                      ast_copy_string(peer_name, peer->name, sizeof(peer_name));
++                      if (peer->max_regs > 1) {
++                          int i = 0;
++                          /* check if peer matches callid */
++                          if ((peer->expire > -1) && (!strncmp(peer->reg_callid, callid, strlen(callid)))) {
++                      //      ast_log(LOG_NOTICE, "peer->reg_callid %s, req->callid %s found in peer\n", peer->reg_callid, callid);
++                              found++;
++                          } else {
++                              /* otherwise check subpeers for callid */
++                              for (i=0; i<peer->max_regs - 1; i++) {
++                                  snprintf(clone_name, sizeof(clone_name), "%s@%d", peer->name, i);
++                              //    ast_log(LOG_NOTICE, "checking subpeer %s\n", clone_name);
++                                  clone = find_peer(clone_name, NULL, 1);
++                                  if (clone && (clone->expire > -1)) {
++                                      if (!strncmp(clone->reg_callid, callid, strlen(callid))) {
++                                      //    ast_log(LOG_NOTICE, "clone->reg_callid %s, req->callid %s found in subpeer\n", clone->reg_callid, callid);
++                                          found++;
++                                          peer = clone;
++                                          break;
++                                      }
++                                  }
++                              }
++                          }
++                          if (!found) {
++                      //      ast_log(LOG_NOTICE, "did not find callid in peer or subpeer\n");
++                              /* choose the next best peer or subpeer (that means: find the peer with the smalles expiry time */
++                              if (peer->expire == -1) {
++                                  recycle_peer = peer;
++                      //          ast_log(LOG_NOTICE, "peer %s expiry %d\n", peer->name, peer->expire);
++                              } else {
++                                  for (i=0; i<peer->max_regs - 1; i++) {
++                                      snprintf(clone_name, sizeof(clone_name), "%s@%d", peer->name, i);
++                                      clone = find_peer(clone_name, NULL, 1);
++                                      if (clone) {
++                                          if (clone->expire == -1) {
++                                              recycle_peer = clone;
++                                              break;
++                                          }
++                      //              ast_log(LOG_NOTICE, "clone %s expiry %d\n", clone->name, clone->expire);
++                                      }
++                                  }   
++                              }
++                              if (recycle_peer) {
++                                  peer = recycle_peer;
++                                  ast_copy_string(peer_name, peer->name, sizeof(peer_name));
++                              //    ast_log(LOG_NOTICE, "recycling peer %s\n", peer->name);
++                                  if (peer->subpeer) {
++                                      i = strchr(peer_name, '@') - peer_name;
++                                      if (i < sizeof(peer_name))
++                                          peer_name[i] = '\0';
++                              //      ast_log(LOG_NOTICE, "i = %d\n", i);
++                                  }
++                              } else {
++                                  /* deny registration */
++                                  peer_name[0] = '\0';
++                              }
++                          }
++                      }
+                       ast_copy_flags(p, peer, SIP_NAT);
+                       transmit_response(p, "100 Trying", req);
+-                      if (!(res = check_auth(p, req, p->randdata, sizeof(p->randdata), peer->name, peer->secret, peer->md5secret, SIP_REGISTER, uri, 0, ignore))) {
++                      if (!(res = check_auth(p, req, p->randdata, sizeof(p->randdata), peer_name, peer->secret, peer->md5secret, SIP_REGISTER, uri, 0, ignore))) {
+                               sip_cancel_destroy(p);
+                               switch (parse_register_contact(p, peer, req)) {
+                               case PARSE_REGISTER_FAILED:
+@@ -6527,6 +6630,7 @@
+                                       transmit_response_with_date(p, "200 OK", req);
+                                       peer->lastmsgssent = -1;
+                                       res = 0;
++                                      ast_copy_string(peer->reg_callid, callid, sizeof(peer->reg_callid));
+                                       break;
+                               }
+                       } 
+@@ -6872,6 +6976,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 */
++                      ast_copy_string(sip_pvt->refer_to, refer_to, sizeof(sip_pvt->refer_to));
++                      ast_copy_string(sip_pvt->referred_by, referred_by, sizeof(sip_pvt->referred_by));
++                      ast_copy_string(sip_pvt->refer_contact, h_contact, sizeof(sip_pvt->refer_contact));
++                      ast_copy_string(sip_pvt->refer_replaces, replace_callid, sizeof(sip_pvt->referred_by));
++                      return 2;
+               }
+       } else if (ast_exists_extension(NULL, transfercontext, refer_to, 1, NULL) || !strcmp(refer_to, ast_parking_ext())) {
+               /* This is an unsupervised transfer (blind transfer) */
+@@ -7592,6 +7701,8 @@
+       int peers_offline = 0;
+       char *id;
+       char idtext[256] = "";
++      char *tmp;
++      int i = 0;
+       if (s) {        /* Manager - get ActionID */
+               id = astman_get_header(m,"ActionID");
+@@ -7634,6 +7745,7 @@
+               else
+                       ast_copy_string(name, iterator->name, sizeof(name));
++      if ((iterator->expire != -1) || (iterator->subpeer != 1)) {
+               pstatus = peer_status(iterator, status, sizeof(status));
+               if (pstatus)    
+                       peers_online++;
+@@ -7650,14 +7762,24 @@
+                       }
+               }                       
+               
+-              snprintf(srch, sizeof(srch), FORMAT, name,
++      }       
++              /* multiple registration, peer used ? */
++              if ((iterator->expire != -1) || (iterator->subpeer != 1)) {
++                  snprintf(srch, sizeof(srch), 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? */
+                       (ast_test_flag(iterator, SIP_NAT) & SIP_NAT_ROUTE) ? " N " : "   ",     /* NAT=yes? */
+                       iterator->ha ? " A " : "   ",   /* permit/deny */
+                       ntohs(iterator->addr.sin_port), status);
++              }
+               if (!s)  {/* Normal CLI list */
++                  if ((iterator->expire != -1) || (iterator->subpeer != 1)) {
++                      if (iterator->subpeer == 1) {
++                          tmp = strchr(name, '@');
++                          i = tmp - name;
++                          name[i] = '\0';
++                      }
+                       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? */
+@@ -7665,6 +7787,7 @@
+                       iterator->ha ? " A " : "   ",       /* permit/deny */
+                       
+                       ntohs(iterator->addr.sin_port), status);
++                  }
+               } else {        /* Manager format */
+                       /* The names here need to be the same as other channels */
+                       ast_cli(fd, 
+@@ -7690,7 +7813,9 @@
+               ASTOBJ_UNLOCK(iterator);
+-              total_peers++;
++              if ((iterator->expire != -1) || (iterator->subpeer != 1)) {
++                  total_peers++;
++              }
+       } while(0) );
+       if (!s) {
+@@ -8725,6 +8850,7 @@
        char buf[1024];
        unsigned int event;
        char *c;
@@ -5606,7 +5899,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_sip.c asterisk-1.2.7.1/channels/ch
        
        /* Need to check the media/type */
        if (!strcasecmp(get_header(req, "Content-Type"), "application/dtmf-relay") ||
-@@ -8670,6 +8704,19 @@
+@@ -8788,6 +8914,19 @@
                        ast_queue_control(p->owner, AST_CONTROL_VIDUPDATE);
                transmit_response(p, "200 OK", req);
                return;
@@ -5626,7 +5919,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_sip.c asterisk-1.2.7.1/channels/ch
        } else if ((c = get_header(req, "X-ClientCode"))) {
                /* Client code (from SNOM phone) */
                if (ast_test_flag(p, SIP_USECLIENTCODE)) {
-@@ -8769,12 +8816,63 @@
+@@ -8887,12 +9026,63 @@
        return RESULT_SUCCESS;
  }
  
@@ -5691,7 +5984,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_sip.c asterisk-1.2.7.1/channels/ch
        if (argc < 4)
                return RESULT_SHOWUSAGE;
  
-@@ -8791,41 +8889,13 @@
+@@ -8909,41 +9099,13 @@
        }
  
        for (i = 3; i < argc; i++) {
@@ -5738,9 +6031,9 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_sip.c asterisk-1.2.7.1/channels/ch
  /*! \brief  sip_do_history: Enable SIP History logging (CLI) ---*/
  static int sip_do_history(int fd, int argc, char *argv[])
  {
-@@ -9468,12 +9538,13 @@
-       case 100:       /* Trying */
-               sip_cancel_destroy(p);
+@@ -9597,12 +9759,13 @@
+               check_pendings(p);
+               ast_set_flag(p, SIP_CAN_BYE);
                break;
 +      case 183:
        case 180:       /* 180 Ringing */
@@ -5751,39 +6044,138 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_sip.c asterisk-1.2.7.1/channels/ch
 -                              ast_setstate(p->owner, AST_STATE_RINGING);
 +                              ast_setstate_and_cid(p->owner, AST_STATE_RINGING, p->owner->cid.cid_num, p->owner->cid.cid_name);
                }
-               if (!strcasecmp(get_header(req, "Content-Type"), "application/sdp")) {
+               if (find_sdp(req)) {
                        process_sdp(p, req);
-@@ -9483,17 +9554,17 @@
-                       }
-               }
+@@ -9616,21 +9779,6 @@
+               check_pendings(p);
+               ast_set_flag(p, SIP_CAN_BYE);
                break;
 -      case 183:       /* Session progress */
-+/*    case 183:       // Session progress
-               sip_cancel_destroy(p);
+-              sip_cancel_destroy(p);
 -              /* Ignore 183 Session progress without SDP */
-+              // Ignore 183 Session progress without SDP
-               if (!strcasecmp(get_header(req, "Content-Type"), "application/sdp")) {
-                       process_sdp(p, req);
-                       if (!ignore && p->owner) {
+-              if (find_sdp(req)) {
+-                      process_sdp(p, req);
+-                      if (!ignore && p->owner) {
 -                              /* Queue a progress frame */
-+                              // Queue a progress frame
-                               ast_queue_control(p->owner, AST_CONTROL_PROGRESS);
-                       }
-               }
+-                              ast_queue_control(p->owner, AST_CONTROL_PROGRESS);
+-                      }
+-              }
+-              /* must call check_pendings before setting CAN_BYE, so that
+-                 if PENDINGBYE is set it will know to send CANCEL instead */
+-              check_pendings(p);
+-              ast_set_flag(p, SIP_CAN_BYE);
 -              break;
-+              break; */
        case 200:       /* 200 OK on invite - someone's answering our call */
                sip_cancel_destroy(p);
                p->authtries = 0;
-@@ -10287,6 +10358,7 @@
+@@ -10424,9 +10572,18 @@
                /* This is a call to ourself.  Send ourselves an error code and stop
                   processing immediately, as SIP really has no good mechanism for
                   being able to call yourself */
-+ast_log(LOG_NOTICE, "to: %s uri: %s\n", get_header(req, "To"), p->origuri);
-               transmit_response(p, "482 Loop Detected", req);
-               /* We do NOT destroy p here, so that our response will be accepted */
-               return 0;
-@@ -10836,7 +10908,7 @@
+-              transmit_response(p, "482 Loop Detected", req);
+-              /* We do NOT destroy p here, so that our response will be accepted */
+-              return 0;
++/*            char tmp[256] = "", *uri;
++              if (req->rlPart2)
++                  ast_copy_string(tmp, req->rlPart2, sizeof(tmp));
++              uri = get_in_brackets(tmp);
++              if (strcmp(p->uri, uri)) {
++                  ast_log(LOG_NOTICE, "SPIRAL DETECTED p->uri: %s uri: %s\n", p->uri, uri);
++              } else {
++                  ast_log(LOG_NOTICE, "LOOP DETECTED p->uri: %s uri: %s\n", p->uri, uri);*/
++                  transmit_response(p, "482 Loop Detected", req);
++                  /* We do NOT destroy p here, so that our response will be accepted */
++                  return 0;
++/*            }*/
+       }
+       if (!ignore) {
+               /* Use this as the basis */
+@@ -10658,6 +10815,7 @@
+       struct ast_channel *c=NULL;
+       int res;
+       struct ast_channel *transfer_to;
++      struct sip_pvt *rp; /* replace call */
+       if (option_debug > 2)
+               ast_log(LOG_DEBUG, "SIP call transfer received for call %s (REFER)!\n", p->callid);
+@@ -10666,9 +10824,74 @@
+       res = get_refer_info(p, req);
+       if (res < 0)
+               transmit_response_with_allow(p, "404 Not Found", req, 1);
+-      else if (res > 0)
++      else if (res == 1)
+               transmit_response_with_allow(p, "484 Address Incomplete", req, 1);
+-      else {
++      else if (res == 2) {
++                      transmit_response(p, "202 Accepted", req);
++                      rp = sip_alloc(NULL, NULL, 0, SIP_INVITE);
++                      if (!rp) {
++                          return -1;
++                      }
++                      rp->capability = global_capability;
++
++                      build_route(rp, req, 0);
++              if (option_verbose > 3)
++                  ast_log(LOG_NOTICE, "got REFER for callid %s TO %s CONTACT %s replacing callid %s (tohost %s, p->route %s, rp->route %s)\n", p->callid, p->refer_to, p->refer_contact, p->refer_replaces, p->tohost, p->route->hop, rp->route->hop);
++                      if (create_addr(rp, p->tohost)) {
++                          sip_destroy(rp);
++                          return -1;
++                      }
++
++                      if (ast_sip_ouraddrfor(&rp->sa.sin_addr,&rp->ourip)) {
++                          memcpy(&rp->ourip, &__ourip, sizeof(rp->ourip));
++                      }
++                      build_via(rp, rp->via, sizeof(rp->via));
++                      build_callid(rp->callid, sizeof(rp->callid) - 1, rp->ourip, rp->fromdomain);
++      
++          ast_log(LOG_NOTICE, "1\n");
++                      rp->prefcodec = p->prefcodec;
++                      rp->jointcapability = rp->capability;
++                      rp->rtp = p->rtp;
++                      p->rtp = NULL;
++                      if (!ast_strlen_zero(p->refer_to)) {
++                          ast_copy_string(rp->username, p->refer_to, sizeof(rp->username));
++                          rp->fullcontact[0] = '\0';
++                      }
++                      if (!ast_strlen_zero(p->refer_replaces)) {
++                          ast_copy_string(rp->refer_replaces, p->refer_replaces, sizeof(rp->refer_replaces));
++                      }
++          ast_log(LOG_NOTICE, "2\n");
++                      ast_set_flag(rp, SIP_OUTGOING);
++                      
++          ast_log(LOG_NOTICE, "3\n");
++
++                      if (p->owner) {
++                          c = p->owner;
++//                        ast_copy_string(rp->cid_num, c->cid.cid_num, sizeof(rp->cid_num));
++//                        ast_copy_string(rp->cid_name, c->cid.cid_name, sizeof(rp->cid_name));
++          ast_log(LOG_NOTICE, "4\n");
++                          c->tech_pvt = rp;
++                          rp->owner = c;
++          ast_log(LOG_NOTICE, "5\n");
++                          ast_mutex_unlock(&c->lock);
++                      }
++                      p->owner = NULL;
++          ast_log(LOG_NOTICE, "6\n");
++
++                      transmit_invite(rp, SIP_INVITE, 1, 2);
++                      if (rp->maxtime) {
++                          /* Initialize auto-congest time */
++                          rp->initid = ast_sched_add(sched, rp->maxtime * 4, auto_congest, rp);
++                      }
++
++                      transmit_notify_with_sipfrag(p, seqno);
++
++                      /* Always increment on a BYE */
++                      transmit_request_with_auth(p, SIP_BYE, 0, 1, 1);
++                      ast_set_flag(p, SIP_ALREADYGONE);
++                      return 0;
++      
++      } else {  /* res == 0 */
+               int nobye = 0;
+               if (!ignore) {
+                       if (p->refer_call) {
+@@ -10993,7 +11216,7 @@
                        struct sip_pvt *p_old;
  
                        transmit_response(p, "200 OK", req);
@@ -5792,7 +6184,16 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_sip.c asterisk-1.2.7.1/channels/ch
                        append_history(p, "Subscribestatus", ast_extension_state2str(firststate));
  
                        /* remove any old subscription from this peer for the same exten/context,
-@@ -11148,7 +11220,7 @@
+@@ -11187,6 +11410,8 @@
+               res = handle_request_options(p, req, debug);
+               break;
+       case SIP_INVITE:
++              /* XXX quick fix for xfers */
++              ast_copy_string(p->tohost, ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), sizeof(p->tohost));
+               res = handle_request_invite(p, req, debug, ignore, seqno, sin, recount, e);
+               break;
+       case SIP_REFER:
+@@ -11307,7 +11532,7 @@
        /* Process request, with netlock held */
  retrylock:
        ast_mutex_lock(&netlock);
@@ -5801,7 +6202,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_sip.c asterisk-1.2.7.1/channels/ch
        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)) {
-@@ -11468,6 +11540,52 @@
+@@ -11634,6 +11859,52 @@
        return 0;
  }
  
@@ -5854,7 +6255,72 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_sip.c asterisk-1.2.7.1/channels/ch
  /*! \brief  sip_devicestate: Part of PBX channel interface ---*/
  
  /* Return values:---
-@@ -13167,6 +13285,8 @@
+@@ -12171,6 +12442,7 @@
+       peer->expire = -1;
+       peer->pokeexpire = -1;
++      peer->max_regs = 1;
+       ast_copy_string(peer->name, name, sizeof(peer->name));
+       ast_copy_flags(peer, &global_flags, SIP_FLAGS_TO_COPY);
+       strcpy(peer->context, default_context);
+@@ -12216,7 +12488,9 @@
+       if (peer) {
+               /* Already in the list, remove it and it will be added back (or FREE'd)  */
+-              found++;
++              if (peer->max_regs == 1) {
++                  found++;
++              }
+       } else {
+               peer = malloc(sizeof(*peer));
+               if (peer) {
+@@ -12228,6 +12502,7 @@
+                       ASTOBJ_INIT(peer);
+                       peer->expire = -1;
+                       peer->pokeexpire = -1;
++                      peer->max_regs = 1;
+               } else {
+                       ast_log(LOG_WARNING, "Can't allocate SIP peer memory\n");
+               }
+@@ -12373,6 +12648,10 @@
+                       peer->call_limit = atoi(v->value);
+                       if (peer->call_limit < 0)
+                               peer->call_limit = 0;
++              } else if (!strcasecmp(v->name, "registrations")) {
++                      peer->max_regs = atoi(v->value);
++                      if (peer->max_regs < 0)
++                              peer->max_regs = 0;
+               } else if (!strcasecmp(v->name, "amaflags")) {
+                       format = ast_cdr_amaflags2int(v->value);
+                       if (format < 0) {
+@@ -12768,8 +13047,24 @@
+                               if (!strcasecmp(utype, "peer") || !strcasecmp(utype, "friend")) {
+                                       peer = build_peer(cat, ast_variable_browse(cfg, cat), 0);
+                                       if (peer) {
+-                                              ASTOBJ_CONTAINER_LINK(&peerl,peer);
+-                                              ASTOBJ_UNREF(peer, sip_destroy_peer);
++                                          if (peer->max_regs > 1) {
++                                              int i = 0;
++                                              int clones = peer->max_regs - 1;
++                                              struct sip_peer *clone = NULL;
++                                              char clone_name[sizeof(clone->name)];
++                                              /* clone clone clone */
++                                              for (i=0;i<clones;i++) {
++                                                  snprintf(clone_name, sizeof(clone_name), "%s@%d", cat, i);
++                                                  clone = build_peer(clone_name, ast_variable_browse(cfg, cat), 0);
++                                                  if (clone) {
++                                                      clone->subpeer = 1;
++                                                      ASTOBJ_CONTAINER_LINK(&peerl,clone);
++                                                      ASTOBJ_UNREF(clone, sip_destroy_peer);
++                                                  }
++                                              }
++                                          }
++                                          ASTOBJ_CONTAINER_LINK(&peerl,peer);
++                                          ASTOBJ_UNREF(peer, sip_destroy_peer);
+                                       }
+                               } else if (strcasecmp(utype, "user")) {
+                                       ast_log(LOG_WARNING, "Unknown type '%s' for '%s' in %s\n", utype, cat, "sip.conf");
+@@ -13359,6 +13654,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);
@@ -5863,7 +6329,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_sip.c asterisk-1.2.7.1/channels/ch
  
        sip_poke_all_peers();   
        sip_send_all_registers();
-@@ -13197,6 +13317,7 @@
+@@ -13389,6 +13686,7 @@
  
        ast_rtp_proto_unregister(&sip_rtp);
  
@@ -5871,9 +6337,9 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_sip.c asterisk-1.2.7.1/channels/ch
        ast_manager_unregister("SIPpeers");
        ast_manager_unregister("SIPshowpeer");
  
-diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/chan_zap.c
---- asterisk-1.2.7.1.orig/channels/chan_zap.c  2006-04-04 20:28:14.000000000 +0200
-+++ asterisk-1.2.7.1/channels/chan_zap.c       2006-04-25 14:21:48.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/channels/chan_zap.c asterisk-1.2.9.1/channels/chan_zap.c
+--- asterisk-1.2.9.1.orig/channels/chan_zap.c  2006-05-31 22:26:17.000000000 +0200
++++ asterisk-1.2.9.1/channels/chan_zap.c       2006-06-15 16:09:02.000000000 +0200
 @@ -11,6 +11,10 @@
   * the project provides a web site, mailing lists and IRC
   * channels for your use.
@@ -6311,7 +6777,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
 +                  else
 +                      c = dest;
 +                  ast_mutex_lock(&p->gsm.lock);
-+                  if (gsm_dial(p->gsm.modul, 0, c)) {
++                  if (gsm_dial(p->gsm.modul, p->use_callingpres ? ast->cid.cid_pres : 0, c)) {
 +                      ast_log(LOG_WARNING, "dialing failed on channel %d\n", p->channel);
 +                      ast_mutex_unlock(&p->gsm.lock);
 +                      ast_mutex_unlock(&p->lock);
@@ -6362,7 +6828,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                if (p->pri->facilityenable)
                        pri_facility_enable(p->pri->pri);
  
-@@ -2287,8 +2503,10 @@
+@@ -2286,8 +2502,10 @@
        }
        if (newslot < 0) {
                newslot = 0;
@@ -6374,7 +6840,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
        }
        if (old && (oldslot != newslot))
                ast_log(LOG_NOTICE, "Switching from from d-channel %d to channel %d!\n",
-@@ -2344,8 +2562,7 @@
+@@ -2343,8 +2561,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);
@@ -6384,7 +6850,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
        if (index > -1) {
                /* Real channel, do some fixup */
                p->subs[index].owner = NULL;
-@@ -2442,6 +2659,7 @@
+@@ -2441,6 +2658,7 @@
  
  
        if (!p->subs[SUB_REAL].owner && !p->subs[SUB_CALLWAIT].owner && !p->subs[SUB_THREEWAY].owner) {
@@ -6392,7 +6858,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                p->owner = NULL;
                p->ringt = 0;
                p->distinctivering = 0;
-@@ -2478,19 +2696,61 @@
+@@ -2477,19 +2695,61 @@
                        if (p->call && (!p->bearer || (p->bearer->call == p->call))) {
                                if (!pri_grab(p, p->pri)) {
                                        if (p->alreadyhungup) {
@@ -6455,7 +6921,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                                ast_log(LOG_DEBUG, "Not yet hungup...  Calling hangup once with icause, and clearing call\n");
  
  #ifdef SUPPORT_USERUSER
-@@ -2504,7 +2764,28 @@
+@@ -2503,7 +2763,28 @@
                                                        if (atoi(cause))
                                                                icause = atoi(cause);
                                                }
@@ -6485,7 +6951,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                        }
                                        if (res < 0) 
                                                ast_log(LOG_WARNING, "pri_disconnect failed\n");
-@@ -2532,7 +2813,13 @@
+@@ -2531,7 +2812,13 @@
  
                }
  #endif
@@ -6500,7 +6966,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                        res = zt_set_hook(p->subs[SUB_REAL].zfd, ZT_ONHOOK);
                if (res < 0) {
                        ast_log(LOG_WARNING, "Unable to hangup line %s\n", ast->name);
-@@ -2701,10 +2988,14 @@
+@@ -2700,10 +2987,14 @@
                        p->proceeding = 1;
                        res = pri_answer(p->pri->pri, p->call, 0, !p->digital);
                        pri_rel(p->pri);
@@ -6515,7 +6981,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                break;
  #endif
  #ifdef ZAPATA_R2
-@@ -2714,6 +3005,13 @@
+@@ -2713,6 +3004,13 @@
                        ast_log(LOG_WARNING, "R2 Answer call failed :( on %s\n", ast->name);
                break;
  #endif                        
@@ -6529,7 +6995,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
        case 0:
                ast_mutex_unlock(&p->lock);
                return 0;
-@@ -3274,6 +3572,15 @@
+@@ -3273,6 +3571,15 @@
  {
        struct zt_pvt *p = newchan->tech_pvt;
        int x;
@@ -6545,7 +7011,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
        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) {
-@@ -3637,7 +3944,7 @@
+@@ -3636,7 +3943,7 @@
                        if (p->call) {
                                if (p->pri && p->pri->pri) {
                                        if (!pri_grab(p, p->pri)) {
@@ -6554,7 +7020,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                                pri_destroycall(p->pri->pri, p->call);
                                                p->call = NULL;
                                                pri_rel(p->pri);
-@@ -4600,7 +4907,7 @@
+@@ -4599,7 +4906,7 @@
                p->subs[index].f.data = NULL;
                p->subs[index].f.datalen= 0;
        }
@@ -6563,7 +7029,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                /* Perform busy detection. etc on the zap line */
                f = ast_dsp_process(ast, p->dsp, &p->subs[index].f);
                if (f) {
-@@ -4612,8 +4919,9 @@
+@@ -4611,8 +4918,9 @@
                                }
                        } else if (f->frametype == AST_FRAME_DTMF) {
  #ifdef ZAPATA_PRI
@@ -6575,7 +7041,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                        f->frametype = AST_FRAME_NULL;
                                        f->subclass = 0;
                                }
-@@ -4661,8 +4969,10 @@
+@@ -4660,8 +4968,10 @@
                                                pbx_builtin_setvar_helper(ast, "FAXEXTEN", ast->exten);
                                                if (ast_async_goto(ast, target_context, "fax", 1))
                                                        ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", ast->name, target_context);
@@ -6588,7 +7054,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                } else
                                        ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n");
                        } else
-@@ -4748,7 +5058,9 @@
+@@ -4747,7 +5057,9 @@
  #endif
        /* Write a frame of (presumably voice) data */
        if (frame->frametype != AST_FRAME_VOICE) {
@@ -6599,7 +7065,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                        ast_log(LOG_WARNING, "Don't know what to do with frame type '%d'\n", frame->frametype);
                return 0;
        }
-@@ -4819,7 +5131,7 @@
+@@ -4818,7 +5130,7 @@
                switch(condition) {
                case AST_CONTROL_BUSY:
  #ifdef ZAPATA_PRI
@@ -6608,7 +7074,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                chan->hangupcause = AST_CAUSE_USER_BUSY;
                                chan->_softhangup |= AST_SOFTHANGUP_DEV;
                                res = 0;
-@@ -4901,7 +5213,7 @@
+@@ -4900,7 +5212,7 @@
                case AST_CONTROL_CONGESTION:
                        chan->hangupcause = AST_CAUSE_CONGESTION;
  #ifdef ZAPATA_PRI
@@ -6617,7 +7083,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                chan->hangupcause = AST_CAUSE_SWITCH_CONGESTION;
                                chan->_softhangup |= AST_SOFTHANGUP_DEV;
                                res = 0;
-@@ -5086,8 +5398,12 @@
+@@ -5085,8 +5397,12 @@
                if (state == AST_STATE_RING)
                        tmp->rings = 1;
                tmp->tech_pvt = i;
@@ -6632,7 +7098,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                        tmp->callgroup = i->callgroup;
                        tmp->pickupgroup = i->pickupgroup;
                }
-@@ -5217,6 +5533,7 @@
+@@ -5216,6 +5532,7 @@
        int len = 0;
        int res;
        int index;
@@ -6640,7 +7106,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
        if (option_verbose > 2) 
                ast_verbose( VERBOSE_PREFIX_3 "Starting simple switch on '%s'\n", chan->name);
        index = zt_get_index(chan, p, 1);
-@@ -5235,10 +5552,17 @@
+@@ -5234,10 +5551,17 @@
                len = strlen(exten);
                res = 0;
                while((len < AST_MAX_EXTENSION-1) && ast_matchmore_extension(chan, chan->context, exten, 1, p->cid_num)) {
@@ -6661,7 +7127,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                        if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num))
                                timeout = matchdigittimeout;
                        else
-@@ -6719,6 +7043,8 @@
+@@ -6724,6 +7048,8 @@
                } else {
                        if (si->totalchans == 31) { /* if it's an E1 */
                                pris[*span].dchannels[0] = 16 + offset;
@@ -6670,7 +7136,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                        } else {
                                pris[*span].dchannels[0] = 24 + offset;
                        }
-@@ -6806,6 +7132,10 @@
+@@ -6811,6 +7137,10 @@
  
  #endif
  
@@ -6681,7 +7147,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
  static struct zt_pvt *mkintf(int channel, int signalling, int radio, struct zt_pri *pri, int reloading)
  {
        /* Make a zt_pvt structure for this interface (or CRV if "pri" is specified) */
-@@ -6964,6 +7294,11 @@
+@@ -6969,6 +7299,11 @@
                                                        destroy_zt_pvt(&tmp);
                                                        return NULL;
                                                }
@@ -6693,7 +7159,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                                if (!ast_strlen_zero(pris[span].idledial) && strcmp(pris[span].idledial, idledial)) {
                                                        ast_log(LOG_ERROR, "Span %d already has idledial '%s'.\n", span + 1, idledial);
                                                        destroy_zt_pvt(&tmp);
-@@ -6991,6 +7326,17 @@
+@@ -6996,6 +7331,17 @@
                                                        return NULL;
                                                }
                                                pris[span].nodetype = pritype;
@@ -6711,7 +7177,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                                pris[span].switchtype = myswitchtype;
                                                pris[span].nsf = nsf;
                                                pris[span].dialplan = dialplan;
-@@ -6999,9 +7345,14 @@
+@@ -7004,9 +7350,14 @@
                                                pris[span].minunused = minunused;
                                                pris[span].minidle = minidle;
                                                pris[span].overlapdial = overlapdial;
@@ -6726,7 +7192,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                                ast_copy_string(pris[span].internationalprefix, internationalprefix, sizeof(pris[span].internationalprefix));
                                                ast_copy_string(pris[span].nationalprefix, nationalprefix, sizeof(pris[span].nationalprefix));
                                                ast_copy_string(pris[span].localprefix, localprefix, sizeof(pris[span].localprefix));
-@@ -7022,6 +7373,36 @@
+@@ -7027,6 +7378,36 @@
                                tmp->prioffset = 0;
                        }
  #endif
@@ -6763,7 +7229,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
  #ifdef ZAPATA_R2
                        if (signalling == SIG_R2) {
                                if (r2prot < 0) {
-@@ -7155,6 +7536,7 @@
+@@ -7160,6 +7541,7 @@
                tmp->restrictcid = restrictcid;
                tmp->use_callingpres = use_callingpres;
                tmp->priindication_oob = priindication_oob;
@@ -6771,7 +7237,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                tmp->priexclusive = cur_priexclusive;
                if (tmp->usedistinctiveringdetection) {
                        if (!tmp->use_callerid) {
-@@ -7428,7 +7810,7 @@
+@@ -7433,7 +7815,7 @@
                        break;
                if (!backwards && (x >= pri->numchans))
                        break;
@@ -6780,7 +7246,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                        ast_log(LOG_DEBUG, "Found empty available channel %d/%d\n", 
                                pri->pvts[x]->logicalspan, pri->pvts[x]->prioffset);
                        return x;
-@@ -7475,7 +7857,7 @@
+@@ -7480,7 +7862,7 @@
        end = ifend;
        /* We do signed linear */
        oldformat = format;
@@ -6789,7 +7255,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
        if (!format) {
                ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", oldformat);
                return NULL;
-@@ -7635,6 +8017,11 @@
+@@ -7640,6 +8022,11 @@
                                        p->digital = 1;
                                        if (tmp)
                                                tmp->transfercapability = AST_TRANS_CAP_DIGITAL;
@@ -6801,7 +7267,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                } else {
                                        ast_log(LOG_WARNING, "Unknown option '%c' in '%s'\n", opt, (char *)data);
                                }
-@@ -7674,6 +8061,164 @@
+@@ -7679,6 +8066,164 @@
        return tmp;
  }
  
@@ -6966,7 +7432,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
  
  #ifdef ZAPATA_PRI
  static struct zt_pvt *pri_find_crv(struct zt_pri *pri, int crv)
-@@ -7688,6 +8233,57 @@
+@@ -7693,6 +8238,57 @@
        return NULL;
  }
  
@@ -7024,7 +7490,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
  
  static int pri_find_principle(struct zt_pri *pri, int channel)
  {
-@@ -7720,7 +8316,9 @@
+@@ -7725,7 +8321,9 @@
  static int pri_fixup_principle(struct zt_pri *pri, int principle, q931_call *c)
  {
        int x;
@@ -7034,7 +7500,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
        if (!c) {
                if (principle < 0)
                        return -1;
-@@ -7734,6 +8332,7 @@
+@@ -7739,6 +8337,7 @@
        /* First, check for other bearers */
        for (x=0;x<pri->numchans;x++) {
                if (!pri->pvts[x]) continue;
@@ -7042,7 +7508,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                if (pri->pvts[x]->call == c) {
                        /* Found our call */
                        if (principle != x) {
-@@ -7747,19 +8346,56 @@
+@@ -7752,19 +8351,56 @@
                                }
                                /* Fix it all up now */
                                pri->pvts[principle]->owner = pri->pvts[x]->owner;
@@ -7100,7 +7566,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                        }
                        return principle;
                }
-@@ -7788,7 +8424,9 @@
+@@ -7793,7 +8429,9 @@
                }
                crv = crv->next;
        }
@@ -7111,7 +7577,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
        return -1;
  }
  
-@@ -7850,86 +8488,33 @@
+@@ -7855,86 +8493,33 @@
  #ifndef PRI_RESTART
  #error "Upgrade your libpri"
  #endif
@@ -7209,13 +7675,13 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
  
  static int pri_check_restart(struct zt_pri *pri)
  {
-+      if ((pri->nodetype != PRI_NETWORK) || (pri->nodetype != PRI_CPE)) {
++      if ((pri->nodetype != PRI_NETWORK) && (pri->nodetype != PRI_CPE)) {
 +          return 0;
 +      }
        do {
                pri->resetpos++;
        } while((pri->resetpos < pri->numchans) &&
-@@ -8012,6 +8597,32 @@
+@@ -8017,6 +8602,32 @@
        }
  }
  
@@ -7248,7 +7714,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
  static void *pri_dchannel(void *vpri)
  {
        struct zt_pri *pri = vpri;
-@@ -8103,6 +8714,8 @@
+@@ -8108,6 +8719,8 @@
                                } else if (pri->pvts[x] && pri->pvts[x]->owner && pri->pvts[x]->isidlecall)
                                        activeidles++;
                        }
@@ -7257,7 +7723,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
  #if 0
                        printf("nextidle: %d, haveidles: %d, minunsed: %d\n",
                                nextidle, haveidles, minunused);
-@@ -8204,9 +8817,36 @@
+@@ -8209,9 +8822,36 @@
                                        if (x == ZT_EVENT_ALARM) {
                                                pri->dchanavail[which] &= ~(DCHAN_NOTINALARM | DCHAN_UP);
                                                pri_find_dchan(pri);
@@ -7296,7 +7762,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                        }
                                
                                        if (option_debug)
-@@ -8218,8 +8858,7 @@
+@@ -8223,8 +8863,7 @@
                                        break;
                        }
                } else if (errno != EINTR)
@@ -7306,7 +7772,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                if (e) {
                        if (pri->debug)
                                pri_dump_event(pri->dchans[which], e);
-@@ -8227,32 +8866,102 @@
+@@ -8232,32 +8871,102 @@
                                pri->dchanavail[which] |= DCHAN_UP;
                        switch(e->e) {
                        case PRI_EVENT_DCHAN_UP:
@@ -7433,7 +7899,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                        pri->resetting = 0;
                                        /* Hangup active channels and put them in alarm mode */
                                        for (i=0; i<pri->numchans; i++) {
-@@ -8260,19 +8969,29 @@
+@@ -8265,19 +8974,29 @@
                                                if (p) {
                                                        if (p->call) {
                                                                if (p->pri && p->pri->pri) {
@@ -7470,7 +7936,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                }
                                break;
                        case PRI_EVENT_RESTART:
-@@ -8307,8 +9026,8 @@
+@@ -8312,8 +9031,8 @@
                                                                pri_destroycall(pri->pri, pri->pvts[x]->call);
                                                                pri->pvts[x]->call = NULL;
                                                        }
@@ -7481,7 +7947,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                                        else if (pri->pvts[x]->owner)
                                                                pri->pvts[x]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
                                                        ast_mutex_unlock(&pri->pvts[x]->lock);
-@@ -8342,7 +9061,6 @@
+@@ -8347,7 +9066,6 @@
                                        }
                                }
                                break;
@@ -7489,7 +7955,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                        case PRI_EVENT_INFO_RECEIVED:
                                chanpos = pri_find_principle(pri, e->ring.channel);
                                if (chanpos < 0) {
-@@ -8351,9 +9069,11 @@
+@@ -8356,9 +9074,11 @@
                                } else {
                                        chanpos = pri_fixup_principle(pri, chanpos, e->ring.call);
                                        if (chanpos > -1) {
@@ -7502,7 +7968,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                                        /* how to do that */
                                                        int digitlen = strlen(e->ring.callednum);
                                                        char digit;
-@@ -8365,6 +9085,14 @@
+@@ -8370,6 +9090,14 @@
                                                                        zap_queue_frame(pri->pvts[chanpos], &f, pri);
                                                                }
                                                        }
@@ -7517,7 +7983,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                                }
                                                ast_mutex_unlock(&pri->pvts[chanpos]->lock);
                                        }
-@@ -8372,39 +9100,55 @@
+@@ -8377,39 +9105,58 @@
                                break;
                        case PRI_EVENT_RING:
                                crv = NULL;
@@ -7560,20 +8026,22 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
 -                                                              pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
 -                                                      ast_mutex_unlock(&pri->pvts[chanpos]->lock);
 -                                                      chanpos = -1;
--                                              }
--                                      }
--                                      if (chanpos > -1)
-                                               ast_mutex_unlock(&pri->pvts[chanpos]->lock);
++                                              ast_mutex_unlock(&pri->pvts[chanpos]->lock);
 +                                              chanpos = -1;
 +                                              break;
 +                                          } else {
 +                                              ast_log(LOG_WARNING, "Ring requested on channel %d/%d already in use on span %d. Hanging up owner.\n", 
 +                                              PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), pri->span);
-+                                              if (pri->pvts[chanpos]->realcall) 
++                                              if (pri->pvts[chanpos]->realcall) {
 +                                                      pri_hangup_all(pri->pvts[chanpos]->realcall, pri);
-+                                              else
++                                              } else {
 +                                                      pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
-+                                              ast_mutex_unlock(&pri->pvts[chanpos]->lock);
++                                                      /* XXX destroy the call here, so we can accept the retransmission as a new call */
++                                                      pri_destroycall(pri->pri, e->ring.call);
+                                               }
+-                                      }
+-                                      if (chanpos > -1)
+                                               ast_mutex_unlock(&pri->pvts[chanpos]->lock);
 +                                              chanpos = -1;
 +                                              break;
 +                                          }
@@ -7595,7 +8063,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                        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));
-@@ -8418,13 +9162,14 @@
+@@ -8423,13 +9170,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);
@@ -7611,7 +8079,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                        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) {
-@@ -8449,29 +9194,78 @@
+@@ -8454,29 +9202,78 @@
                                        }
                                        apply_plan_to_number(pri->pvts[chanpos]->rdnis, sizeof(pri->pvts[chanpos]->rdnis), pri,
                                                             e->ring.redirectingnum, e->ring.callingplanrdnis);
@@ -7703,7 +8171,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                        /* 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)) {
-@@ -8490,22 +9284,38 @@
+@@ -8495,22 +9292,38 @@
                                                res = zt_setlaw(pri->pvts[chanpos]->subs[SUB_REAL].zfd, law);
                                                if (res < 0) 
                                                        ast_log(LOG_WARNING, "Unable to set law on channel %d\n", pri->pvts[chanpos]->channel);
@@ -7749,7 +8217,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                                if (pri->overlapdial && ast_matchmore_extension(NULL, pri->pvts[chanpos]->context, pri->pvts[chanpos]->exten, 1, pri->pvts[chanpos]->cid_num)) {
                                                        /* Release the PRI lock while we create the channel */
                                                        ast_mutex_unlock(&pri->lock);
-@@ -8513,14 +9323,31 @@
+@@ -8518,14 +9331,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);
@@ -7781,7 +8249,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                                        if(e->ring.ani2 >= 0) {
                                                                snprintf(ani2str, 5, "%.2d", e->ring.ani2);
                                                                pbx_builtin_setvar_helper(c, "ANI2", ani2str);
-@@ -8540,8 +9367,8 @@
+@@ -8545,8 +9375,8 @@
                                                        ast_mutex_lock(&pri->lock);
                                                        if (c && !ast_pthread_create(&threadid, &attr, ss_thread, c)) {
                                                                if (option_verbose > 2)
@@ -7792,7 +8260,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                                                                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", 
-@@ -8549,14 +9376,18 @@
+@@ -8554,14 +9384,18 @@
                                                                if (c)
                                                                        ast_hangup(c);
                                                                else {
@@ -7812,7 +8280,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                                        ast_mutex_lock(&pri->lock);
                                                        if (c) {
                                                                char calledtonstr[10];
-@@ -8577,23 +9408,40 @@
+@@ -8582,23 +9416,40 @@
                                                                snprintf(calledtonstr, sizeof(calledtonstr)-1, "%d", e->ring.calledplan);
                                                                pbx_builtin_setvar_helper(c, "CALLEDTON", calledtonstr);
                                                                if (option_verbose > 2)
@@ -7857,7 +8325,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                                pri->pvts[chanpos]->call = NULL;
                                                pri->pvts[chanpos]->exten[0] = '\0';
                                        }
-@@ -8601,7 +9449,7 @@
+@@ -8606,7 +9457,7 @@
                                                ast_mutex_unlock(&crv->lock);
                                        ast_mutex_unlock(&pri->pvts[chanpos]->lock);
                                } else 
@@ -7866,7 +8334,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                break;
                        case PRI_EVENT_RINGING:
                                chanpos = pri_find_principle(pri, e->ringing.channel);
-@@ -8619,7 +9467,7 @@
+@@ -8624,7 +9475,7 @@
                                        } else {
                                                ast_mutex_lock(&pri->pvts[chanpos]->lock);
                                                if (ast_strlen_zero(pri->pvts[chanpos]->dop.dialstr)) {
@@ -7875,7 +8343,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                                        pri->pvts[chanpos]->subs[SUB_REAL].needringing = 1;
                                                        pri->pvts[chanpos]->alerting = 1;
                                                } else
-@@ -8648,9 +9496,15 @@
+@@ -8653,9 +9504,15 @@
                                }
                                break;
                        case PRI_EVENT_PROGRESS:
@@ -7892,7 +8360,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
  #ifdef PRI_PROGRESS_MASK
                                        if ((!pri->pvts[chanpos]->progress) || (e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE)) {
  #else
-@@ -8697,6 +9551,12 @@
+@@ -8702,6 +9559,12 @@
                        case PRI_EVENT_PROCEEDING:
                                chanpos = pri_find_principle(pri, e->proceeding.channel);
                                if (chanpos > -1) {
@@ -7905,7 +8373,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                        if (!pri->pvts[chanpos]->proceeding) {
                                                struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_PROCEEDING, };
                                                
-@@ -8747,6 +9607,295 @@
+@@ -8752,6 +9615,295 @@
                                        }
                                }
                                break;                          
@@ -8201,7 +8669,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                        case PRI_EVENT_ANSWER:
                                chanpos = pri_find_principle(pri, e->answer.channel);
                                if (chanpos < 0) {
-@@ -8762,6 +9911,7 @@
+@@ -8767,6 +9919,7 @@
                                                chanpos = -1;
                                        } else {
                                                ast_mutex_lock(&pri->pvts[chanpos]->lock);
@@ -8209,12 +8677,13 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                                /* Now we can do call progress detection */
  
                                                /* We changed this so it turns on the DSP no matter what... progress or no progress.
-@@ -8791,11 +9941,15 @@
+@@ -8796,11 +9949,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) {
 -                                                      ast_log(LOG_DEBUG, "Waiting on answer confirmation on channel %d!\n", pri->pvts[chanpos]->channel);
 +                                                      ast_log(LOG_DEBUG, "Waiting for answer confirmation on channel %d!\n", pri->pvts[chanpos]->channel);
++                                                      enable_dtmf_detect(pri->pvts[chanpos]);
                                                } else {
 +                                                      pri->pvts[chanpos]->dialing = 0;
                                                        pri->pvts[chanpos]->subs[SUB_REAL].needanswer =1;
@@ -8226,7 +8695,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                                }
  
  #ifdef SUPPORT_USERUSER
-@@ -8844,23 +9998,32 @@
+@@ -8849,23 +10007,32 @@
                                                                }
                                                        }
                                                        if (option_verbose > 2) 
@@ -8266,7 +8735,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
  
  #ifdef SUPPORT_USERUSER
                                                if (!ast_strlen_zero(e->hangup.useruserinfo)) {
-@@ -8870,8 +10033,20 @@
+@@ -8875,8 +10042,20 @@
  
                                                ast_mutex_unlock(&pri->pvts[chanpos]->lock);
                                        } else {
@@ -8289,7 +8758,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                        }
                                } 
                                break;
-@@ -8881,17 +10056,25 @@
+@@ -8886,17 +10065,25 @@
                        case PRI_EVENT_HANGUP_REQ:
                                chanpos = pri_find_principle(pri, e->hangup.channel);
                                if (chanpos < 0) {
@@ -8318,7 +8787,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                                        pri->pvts[chanpos]->owner->hangupcause = e->hangup.cause;
                                                        switch(e->hangup.cause) {
                                                        case PRI_CAUSE_USER_BUSY:
-@@ -8910,20 +10093,87 @@
+@@ -8915,20 +10102,87 @@
                                                        }
                                                        if (option_verbose > 2) 
                                                                ast_verbose(VERBOSE_PREFIX_3 "Channel %d/%d, span %d got hangup request\n", PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span);
@@ -8416,7 +8885,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                                }
  
  #ifdef SUPPORT_USERUSER
-@@ -8934,9 +10184,36 @@
+@@ -8939,9 +10193,36 @@
  
                                                ast_mutex_unlock(&pri->pvts[chanpos]->lock);
                                        } else {
@@ -8454,7 +8923,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                break;
                        case PRI_EVENT_HANGUP_ACK:
                                chanpos = pri_find_principle(pri, e->hangup.channel);
-@@ -8950,6 +10227,7 @@
+@@ -8955,6 +10236,7 @@
                                        if (chanpos > -1) {
                                                ast_mutex_lock(&pri->pvts[chanpos]->lock);
                                                pri->pvts[chanpos]->call = NULL;
@@ -8462,7 +8931,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                                pri->pvts[chanpos]->resetting = 0;
                                                if (pri->pvts[chanpos]->owner) {
                                                        if (option_verbose > 2) 
-@@ -8963,7 +10241,9 @@
+@@ -8968,7 +10250,9 @@
  #endif
  
                                                ast_mutex_unlock(&pri->pvts[chanpos]->lock);
@@ -8472,16 +8941,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                }
                                break;
                        case PRI_EVENT_CONFIG_ERR:
-@@ -9030,7 +10310,7 @@
-                                       ast_log(LOG_WARNING, "Received SETUP_ACKNOWLEDGE on unconfigured channel %d/%d span %d\n", 
-                                               PRI_SPAN(e->setup_ack.channel), PRI_CHANNEL(e->setup_ack.channel), pri->span);
-                               } else {
--                                      chanpos = pri_fixup_principle(pri, chanpos, e->ring.call);
-+                                      chanpos = pri_fixup_principle(pri, chanpos, e->setup_ack.call);
-                                       if (chanpos > -1) {
-                                               ast_mutex_lock(&pri->pvts[chanpos]->lock);
-                                               pri->pvts[chanpos]->setup_ack = 1;
-@@ -9055,10 +10335,22 @@
+@@ -9060,10 +10344,22 @@
                                        ast_mutex_lock(&pri->pvts[chanpos]->lock);
                                        switch(e->notify.info) {
                                        case PRI_NOTIFY_REMOTE_HOLD:
@@ -8504,7 +8964,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                                f.subclass = AST_CONTROL_UNHOLD;
                                                zap_queue_frame(pri->pvts[chanpos], &f, pri);
                                                break;
-@@ -9066,6 +10358,77 @@
+@@ -9071,6 +10367,77 @@
                                        ast_mutex_unlock(&pri->pvts[chanpos]->lock);
                                }
                                break;
@@ -8582,7 +9042,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                        default:
                                ast_log(LOG_DEBUG, "Event: %d\n", e->e);
                        }
-@@ -9127,7 +10490,7 @@
+@@ -9132,7 +10499,7 @@
                        pri->fds[i] = -1;
                        return -1;
                }
@@ -8591,7 +9051,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                /* Force overlap dial if we're doing GR-303! */
                if (pri->switchtype == PRI_SWITCH_GR303_TMC)
                        pri->overlapdial = 1;
-@@ -9196,39 +10559,77 @@
+@@ -9201,39 +10568,77 @@
  
  static int handle_pri_set_debug_file(int fd, int argc, char **argv)
  {
@@ -8691,7 +9151,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
        }
  
        return RESULT_SUCCESS;
-@@ -9260,6 +10661,7 @@
+@@ -9265,6 +10670,7 @@
  
  
  
@@ -8699,7 +9159,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
  static int handle_pri_no_debug(int fd, int argc, char *argv[])
  {
        int span;
-@@ -9366,36 +10768,6 @@
+@@ -9371,36 +10777,6 @@
        return RESULT_SUCCESS;
  }
  
@@ -8736,7 +9196,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
  static char pri_debug_help[] = 
        "Usage: pri debug span <span>\n"
        "       Enables debugging on a given PRI span\n";
-@@ -9412,6 +10784,18 @@
+@@ -9417,6 +10793,18 @@
        "Usage: pri show span <span>\n"
        "       Displays PRI Information\n";
  
@@ -8755,7 +9215,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
  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 },
-@@ -9419,19 +10803,207 @@
+@@ -9424,19 +10812,218 @@
          "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 },
@@ -8776,6 +9236,10 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
          "Ends PRI debug output to file" },
  };
  
++static char *zapCD_tdesc = "Call Deflection";
++static char *zapCD_app = "zapCD";
++static char *zapCD_synopsis = "Call Deflection";
++
 +static int app_zapCD(struct ast_channel *chan, void *data)
 +{
 +    struct zt_pvt *p = chan->tech_pvt;
@@ -8787,9 +9251,16 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
 +    return pri_deflect(p->pri->pri, p->call, data);
 +}
 +
-+static char *zapCD_tdesc = "Call Deflection";
-+static char *zapCD_app = "zapCD";
-+static char *zapCD_synopsis = "Call Deflection";
++static char *zapInband_tdesc = "Inband Call Progress (pre-answer)";
++static char *zapInband_app = "zapInband";
++static char *zapInband_synopsis = "Inband Call Progress";
++
++static int app_zapInband(struct ast_channel *chan, void *data)
++{
++    struct zt_pvt *p = chan->tech_pvt;
++
++    return pri_acknowledge(p->pri->pri, p->call, PVT_TO_CHANNEL(p), 1);
++}
  #endif /* ZAPATA_PRI */
  
  
@@ -8966,19 +9437,21 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
  #ifdef ZAPATA_R2
  static int handle_r2_no_debug(int fd, int argc, char *argv[])
  {
-@@ -10044,6 +11616,11 @@
+@@ -10048,6 +11635,13 @@
+                       pthread_cancel(pris[i].master);
        }
        ast_cli_unregister_multiple(zap_pri_cli, sizeof(zap_pri_cli) / sizeof(zap_pri_cli[0]));
- #endif
++      ast_unregister_application(zapCD_app);
++      ast_unregister_application(zapInband_app);
++#endif
 +#ifdef ZAPATA_GSM
 +      ast_cli_unregister(&gsm_send_sms);
 +      ast_cli_unregister(&gsm_send_pdu);
 +      ast_cli_unregister(&gsm_show_status);
-+#endif
+ #endif
  #ifdef ZAPATA_R2
        ast_cli_unregister_multiple(zap_r2_cli, sizeof(zap_r2_cli) / sizeof(zap_r2_cli[0]));
- #endif
-@@ -10054,6 +11631,7 @@
+@@ -10059,6 +11653,7 @@
        ast_manager_unregister( "ZapDNDoff" );
        ast_manager_unregister( "ZapDNDon" );
        ast_manager_unregister("ZapShowChannels");
@@ -8986,7 +9459,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
        ast_channel_unregister(&zap_tech);
        if (!ast_mutex_lock(&iflock)) {
                /* Hangup all interfaces if they have an owner */
-@@ -10412,8 +11990,8 @@
+@@ -10417,8 +12012,8 @@
                        }
                } else if (!strcasecmp(v->name, "echotraining")) {
                        if (sscanf(v->value, "%d", &y) == 1) {
@@ -8997,7 +9470,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                } else {
                                        echotraining = y;
                                }
-@@ -10599,12 +12177,33 @@
+@@ -10604,12 +12199,33 @@
                                        cur_signalling = SIG_GR303FXSKS;
                                        cur_radio = 0;
                                        pritype = PRI_CPE;
@@ -9031,7 +9504,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                } else {
                                        ast_log(LOG_ERROR, "Unknown signalling method '%s'\n", v->value);
                                }
-@@ -10687,8 +12286,20 @@
+@@ -10692,8 +12308,20 @@
                                        priindication_oob = 1;
                                else if (!strcasecmp(v->value, "inband"))
                                        priindication_oob = 0;
@@ -9053,7 +9526,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                                                v->value, v->lineno);
                        } else if (!strcasecmp(v->name, "priexclusive")) {
                                cur_priexclusive = ast_true(v->value);
-@@ -10702,6 +12313,14 @@
+@@ -10707,6 +12335,14 @@
                                ast_copy_string(privateprefix, v->value, sizeof(privateprefix));
                        } else if (!strcasecmp(v->name, "unknownprefix")) {
                                ast_copy_string(unknownprefix, v->value, sizeof(unknownprefix));
@@ -9068,7 +9541,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                        } else if (!strcasecmp(v->name, "resetinterval")) {
                                if (!strcasecmp(v->value, "never"))
                                        resetinterval = -1;
-@@ -10716,6 +12335,8 @@
+@@ -10723,6 +12359,8 @@
                                ast_copy_string(idleext, v->value, sizeof(idleext));
                        } else if (!strcasecmp(v->name, "idledial")) {
                                ast_copy_string(idledial, v->value, sizeof(idledial));
@@ -9077,7 +9550,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                        } else if (!strcasecmp(v->name, "overlapdial")) {
                                overlapdial = ast_true(v->value);
                        } else if (!strcasecmp(v->name, "pritimer")) {
-@@ -10901,6 +12522,7 @@
+@@ -10908,6 +12546,7 @@
  #ifdef ZAPATA_PRI
        if (!reload) {
                for (x=0;x<NUM_SPANS;x++) {
@@ -9085,7 +9558,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
                        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);
-@@ -10933,6 +12555,10 @@
+@@ -10940,6 +12579,10 @@
        pri_set_error(zt_pri_error);
        pri_set_message(zt_pri_message);
  #endif
@@ -9096,7 +9569,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
        res = setup_zap(0);
        /* Make sure we can register our Zap channel type */
        if(res) {
-@@ -10950,6 +12576,11 @@
+@@ -10957,6 +12600,11 @@
        ast_cli_register_multiple(zap_r2_cli, sizeof(zap_r2_cli) / sizeof(zap_r2_cli[0]));
  #endif        
        ast_cli_register_multiple(zap_cli, sizeof(zap_cli) / sizeof(zap_cli[0]));
@@ -9108,7 +9581,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
        
        memset(round_robin, 0, sizeof(round_robin));
        ast_manager_register( "ZapTransfer", 0, action_transfer, "Transfer Zap Channel" );
-@@ -10958,11 +12589,46 @@
+@@ -10965,11 +12613,47 @@
        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");
@@ -9116,6 +9589,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
 +      ast_register_application(zapEC_app, app_zapEC, zapEC_synopsis, zapEC_tdesc);
 +#ifdef ZAPATA_PRI
 +        ast_register_application(zapCD_app, app_zapCD, zapCD_synopsis, zapCD_tdesc);
++        ast_register_application(zapInband_app, app_zapInband, zapInband_synopsis, zapInband_tdesc);
 +#endif
        return res;
  }
@@ -9156,7 +9630,7 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
  {
  #define       END_SILENCE_LEN 400
  #define       HEADER_MS 50
-@@ -10981,6 +12647,7 @@
+@@ -10988,6 +12672,7 @@
        float scont = 0.0;
        int index;
  
@@ -9164,9 +9638,9 @@ diff -urN asterisk-1.2.7.1.orig/channels/chan_zap.c asterisk-1.2.7.1/channels/ch
        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.7.1.orig/codecs/codec_ilbc.c asterisk-1.2.7.1/codecs/codec_ilbc.c
---- asterisk-1.2.7.1.orig/codecs/codec_ilbc.c  2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.7.1/codecs/codec_ilbc.c       2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/codecs/codec_ilbc.c asterisk-1.2.9.1/codecs/codec_ilbc.c
+--- asterisk-1.2.9.1.orig/codecs/codec_ilbc.c  2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.9.1/codecs/codec_ilbc.c       2006-06-09 10:25:04.000000000 +0200
 @@ -49,7 +49,7 @@
  #include "slin_ilbc_ex.h"
  #include "ilbc_slin_ex.h"
@@ -9176,9 +9650,9 @@ diff -urN asterisk-1.2.7.1.orig/codecs/codec_ilbc.c asterisk-1.2.7.1/codecs/code
  #define ILBC_MS                       30
  /* #define ILBC_MS                    20 */
  
-diff -urN asterisk-1.2.7.1.orig/configs/capi.conf.sample asterisk-1.2.7.1/configs/capi.conf.sample
---- asterisk-1.2.7.1.orig/configs/capi.conf.sample     1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.7.1/configs/capi.conf.sample  2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/configs/capi.conf.sample asterisk-1.2.9.1/configs/capi.conf.sample
+--- asterisk-1.2.9.1.orig/configs/capi.conf.sample     1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.9.1/configs/capi.conf.sample  2006-06-09 10:25:04.000000000 +0200
 @@ -0,0 +1,44 @@
 +;
 +; CAPI config
@@ -9224,17 +9698,17 @@ diff -urN asterisk-1.2.7.1.orig/configs/capi.conf.sample asterisk-1.2.7.1/config
 +;msn=55512
 +;controller=2
 +;devices => 30
-diff -urN asterisk-1.2.7.1.orig/configs/modules.conf.sample asterisk-1.2.7.1/configs/modules.conf.sample
---- asterisk-1.2.7.1.orig/configs/modules.conf.sample  2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.7.1/configs/modules.conf.sample       2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/configs/modules.conf.sample asterisk-1.2.9.1/configs/modules.conf.sample
+--- asterisk-1.2.9.1.orig/configs/modules.conf.sample  2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.9.1/configs/modules.conf.sample       2006-06-09 10:25:04.000000000 +0200
 @@ -51,3 +51,4 @@
  ; exported to modules loaded after them.
  ;
  [global]
 +chan_capi.so=yes
-diff -urN asterisk-1.2.7.1.orig/configs/watchdog.conf.sample asterisk-1.2.7.1/configs/watchdog.conf.sample
---- asterisk-1.2.7.1.orig/configs/watchdog.conf.sample 1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.7.1/configs/watchdog.conf.sample      2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/configs/watchdog.conf.sample asterisk-1.2.9.1/configs/watchdog.conf.sample
+--- asterisk-1.2.9.1.orig/configs/watchdog.conf.sample 1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.9.1/configs/watchdog.conf.sample      2006-06-09 10:25:04.000000000 +0200
 @@ -0,0 +1,22 @@
 +;
 +; Configuration file for res_watchdog
@@ -9258,9 +9732,9 @@ diff -urN asterisk-1.2.7.1.orig/configs/watchdog.conf.sample asterisk-1.2.7.1/co
 +;device = /dev/watchdog
 +;interval = 100
 +
-diff -urN asterisk-1.2.7.1.orig/configs/zapata.conf.sample asterisk-1.2.7.1/configs/zapata.conf.sample
---- asterisk-1.2.7.1.orig/configs/zapata.conf.sample   2006-03-06 03:32:35.000000000 +0100
-+++ asterisk-1.2.7.1/configs/zapata.conf.sample        2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/configs/zapata.conf.sample asterisk-1.2.9.1/configs/zapata.conf.sample
+--- asterisk-1.2.9.1.orig/configs/zapata.conf.sample   2006-04-28 18:40:32.000000000 +0200
++++ asterisk-1.2.9.1/configs/zapata.conf.sample        2006-06-09 10:25:04.000000000 +0200
 @@ -121,9 +121,20 @@
  ; 
  ; outofband:      Signal Busy/Congestion out of band with RELEASE/DISCONNECT
@@ -9282,9 +9756,9 @@ diff -urN asterisk-1.2.7.1.orig/configs/zapata.conf.sample asterisk-1.2.7.1/conf
  ; 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.7.1.orig/db.c asterisk-1.2.7.1/db.c
---- asterisk-1.2.7.1.orig/db.c 2006-01-09 19:09:53.000000000 +0100
-+++ asterisk-1.2.7.1/db.c      2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/db.c asterisk-1.2.9.1/db.c
+--- asterisk-1.2.9.1.orig/db.c 2006-01-09 19:09:53.000000000 +0100
++++ asterisk-1.2.9.1/db.c      2006-06-09 10:25:04.000000000 +0200
 @@ -516,11 +516,18 @@
  struct ast_cli_entry cli_database_deltree =
  { { "database", "deltree", NULL }, database_deltree, "Removes database keytree/values", database_deltree_usage };
@@ -9378,9 +9852,9 @@ diff -urN asterisk-1.2.7.1.orig/db.c asterisk-1.2.7.1/db.c
 +      ast_manager_register("DBdel", EVENT_FLAG_SYSTEM, manager_dbdel, mandescr_dbdel);
        return 0;
  }
-diff -urN asterisk-1.2.7.1.orig/devicestate.c asterisk-1.2.7.1/devicestate.c
---- asterisk-1.2.7.1.orig/devicestate.c        2006-02-10 21:38:59.000000000 +0100
-+++ asterisk-1.2.7.1/devicestate.c     2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/devicestate.c asterisk-1.2.9.1/devicestate.c
+--- asterisk-1.2.9.1.orig/devicestate.c        2006-02-10 21:38:59.000000000 +0100
++++ asterisk-1.2.9.1/devicestate.c     2006-06-09 10:25:04.000000000 +0200
 @@ -62,6 +62,8 @@
  
  struct state_change {
@@ -9497,9 +9971,9 @@ diff -urN asterisk-1.2.7.1.orig/devicestate.c asterisk-1.2.7.1/devicestate.c
                        free(cur);
                        AST_LIST_LOCK(&state_changes);
                } else {
-diff -urN asterisk-1.2.7.1.orig/doc/README.asterisk.conf asterisk-1.2.7.1/doc/README.asterisk.conf
---- asterisk-1.2.7.1.orig/doc/README.asterisk.conf     2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.7.1/doc/README.asterisk.conf  2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/doc/README.asterisk.conf asterisk-1.2.9.1/doc/README.asterisk.conf
+--- asterisk-1.2.9.1.orig/doc/README.asterisk.conf     2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.9.1/doc/README.asterisk.conf  2006-06-09 10:25:04.000000000 +0200
 @@ -62,6 +62,7 @@
  maxcalls = 255                                        ; The maximum number of concurrent calls you want to allow 
  execincludes = yes | no                       ; Allow #exec entries in configuration files
@@ -9508,9 +9982,9 @@ diff -urN asterisk-1.2.7.1.orig/doc/README.asterisk.conf asterisk-1.2.7.1/doc/RE
  
  [files]
  ; Changing the following lines may compromise your security
-diff -urN asterisk-1.2.7.1.orig/editline/cygdef.h asterisk-1.2.7.1/editline/cygdef.h
---- asterisk-1.2.7.1.orig/editline/cygdef.h    1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.7.1/editline/cygdef.h 2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/editline/cygdef.h asterisk-1.2.9.1/editline/cygdef.h
+--- asterisk-1.2.9.1.orig/editline/cygdef.h    1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.9.1/editline/cygdef.h 2006-06-09 10:25:04.000000000 +0200
 @@ -0,0 +1,11 @@
 +/* cygdef.h. Generated automatically by configure. */ 
 +#ifndef _CYGDEF_H_
@@ -9523,9 +9997,9 @@ diff -urN asterisk-1.2.7.1.orig/editline/cygdef.h asterisk-1.2.7.1/editline/cygd
 + 
 +
 +#endif /* _CYGDEF_H_ */
-diff -urN asterisk-1.2.7.1.orig/include/asterisk/agi.h asterisk-1.2.7.1/include/asterisk/agi.h
---- asterisk-1.2.7.1.orig/include/asterisk/agi.h       2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.7.1/include/asterisk/agi.h    2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/include/asterisk/agi.h asterisk-1.2.9.1/include/asterisk/agi.h
+--- asterisk-1.2.9.1.orig/include/asterisk/agi.h       2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.9.1/include/asterisk/agi.h    2006-06-09 10:25:04.000000000 +0200
 @@ -29,7 +29,8 @@
  
  typedef struct agi_state {
@@ -9536,9 +10010,9 @@ diff -urN asterisk-1.2.7.1.orig/include/asterisk/agi.h asterisk-1.2.7.1/include/
        int ctrl;       /* FD for input control */
  } AGI;
  
-diff -urN asterisk-1.2.7.1.orig/include/asterisk/chan_capi.h asterisk-1.2.7.1/include/asterisk/chan_capi.h
---- asterisk-1.2.7.1.orig/include/asterisk/chan_capi.h 1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.7.1/include/asterisk/chan_capi.h      2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/include/asterisk/chan_capi.h asterisk-1.2.9.1/include/asterisk/chan_capi.h
+--- asterisk-1.2.9.1.orig/include/asterisk/chan_capi.h 1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.9.1/include/asterisk/chan_capi.h      2006-06-09 10:25:04.000000000 +0200
 @@ -0,0 +1,276 @@
 +/*
 + * (CAPI*)
@@ -9816,9 +10290,9 @@ diff -urN asterisk-1.2.7.1.orig/include/asterisk/chan_capi.h asterisk-1.2.7.1/in
 +#define CAPI_ETSI_NPLAN_INTERNAT      0x10
 +
 +#endif
-diff -urN asterisk-1.2.7.1.orig/include/asterisk/chan_capi_app.h asterisk-1.2.7.1/include/asterisk/chan_capi_app.h
---- asterisk-1.2.7.1.orig/include/asterisk/chan_capi_app.h     1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.7.1/include/asterisk/chan_capi_app.h  2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/include/asterisk/chan_capi_app.h asterisk-1.2.9.1/include/asterisk/chan_capi_app.h
+--- asterisk-1.2.9.1.orig/include/asterisk/chan_capi_app.h     1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.9.1/include/asterisk/chan_capi_app.h  2006-06-09 10:25:04.000000000 +0200
 @@ -0,0 +1,30 @@
 +/*
 + * (CAPI*)
@@ -9850,9 +10324,9 @@ diff -urN asterisk-1.2.7.1.orig/include/asterisk/chan_capi_app.h asterisk-1.2.7.
 +extern MESSAGE_EXCHANGE_ERROR _capi_put_cmsg(_cmsg *CMSG);
 +
 +#endif
-diff -urN asterisk-1.2.7.1.orig/include/asterisk/channel.h asterisk-1.2.7.1/include/asterisk/channel.h
---- asterisk-1.2.7.1.orig/include/asterisk/channel.h   2006-02-11 19:15:00.000000000 +0100
-+++ asterisk-1.2.7.1/include/asterisk/channel.h        2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/include/asterisk/channel.h asterisk-1.2.9.1/include/asterisk/channel.h
+--- asterisk-1.2.9.1.orig/include/asterisk/channel.h   2006-06-01 22:27:50.000000000 +0200
++++ asterisk-1.2.9.1/include/asterisk/channel.h        2006-06-09 10:25:04.000000000 +0200
 @@ -86,6 +86,9 @@
  #ifndef _ASTERISK_CHANNEL_H
  #define _ASTERISK_CHANNEL_H
@@ -9863,7 +10337,7 @@ diff -urN asterisk-1.2.7.1.orig/include/asterisk/channel.h asterisk-1.2.7.1/incl
  #include <unistd.h>
  #include <setjmp.h>
  #ifdef POLLCOMPAT 
-@@ -380,7 +383,7 @@
+@@ -381,7 +384,7 @@
        unsigned int fout;
  
        /* Unique Channel Identifier */
@@ -9872,7 +10346,7 @@ diff -urN asterisk-1.2.7.1.orig/include/asterisk/channel.h asterisk-1.2.7.1/incl
  
        /* Why is the channel hanged up */
        int hangupcause;
-@@ -397,6 +400,12 @@
+@@ -398,6 +401,12 @@
        /*! ISDN Transfer Capbility - AST_FLAG_DIGITAL is not enough */
        unsigned short transfercapability;
  
@@ -9885,7 +10359,7 @@ diff -urN asterisk-1.2.7.1.orig/include/asterisk/channel.h asterisk-1.2.7.1/incl
        struct ast_frame *readq;
        int alertpipe[2];
        /*! Write translation path */
-@@ -533,6 +542,11 @@
+@@ -534,6 +543,11 @@
  #define AST_STATE_MUTE                (1 << 16)       
  /*! @} */
  
@@ -9897,7 +10371,7 @@ diff -urN asterisk-1.2.7.1.orig/include/asterisk/channel.h asterisk-1.2.7.1/incl
  /*! \brief Change the state of a channel */
  int ast_setstate(struct ast_channel *chan, int state);
  
-@@ -569,7 +583,7 @@
+@@ -570,7 +584,7 @@
   * by the low level module
   * \return Returns an ast_channel on success, NULL on failure.
   */
@@ -9906,7 +10380,7 @@ diff -urN asterisk-1.2.7.1.orig/include/asterisk/channel.h asterisk-1.2.7.1/incl
  
  /*!
   * \brief Request a channel of a given type, with data as optional information used 
-@@ -584,9 +598,9 @@
+@@ -585,9 +599,9 @@
   * \return Returns an ast_channel on success or no answer, NULL on failure.  Check the value of chan->_state
   * to know if the call was answered or not.
   */
@@ -9918,7 +10392,7 @@ diff -urN asterisk-1.2.7.1.orig/include/asterisk/channel.h asterisk-1.2.7.1/incl
  
  /*!\brief Register a channel technology (a new channel driver)
   * Called by a channel module to register the kind of channels it supports.
-@@ -839,6 +853,10 @@
+@@ -840,6 +854,10 @@
  /*--- ast_get_channel_by_exten_locked: Get channel by exten (and optionally context) and lock it */
  struct ast_channel *ast_get_channel_by_exten_locked(const char *exten, const char *context);
  
@@ -9929,7 +10403,7 @@ diff -urN asterisk-1.2.7.1.orig/include/asterisk/channel.h asterisk-1.2.7.1/incl
  /*! Waits for a digit */
  /*! 
   * \param c channel to wait for a digit on
-@@ -909,6 +927,9 @@
+@@ -910,6 +928,9 @@
     p->owner pointer) that is affected by the change.  The physical layer of the original
     channel is hung up.  */
  int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clone);
@@ -9939,9 +10413,9 @@ diff -urN asterisk-1.2.7.1.orig/include/asterisk/channel.h asterisk-1.2.7.1/incl
  
  /*! Gives the string form of a given cause code */
  /*! 
-diff -urN asterisk-1.2.7.1.orig/include/asterisk/devicestate.h asterisk-1.2.7.1/include/asterisk/devicestate.h
---- asterisk-1.2.7.1.orig/include/asterisk/devicestate.h       2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.7.1/include/asterisk/devicestate.h    2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/include/asterisk/devicestate.h asterisk-1.2.9.1/include/asterisk/devicestate.h
+--- asterisk-1.2.9.1.orig/include/asterisk/devicestate.h       2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.9.1/include/asterisk/devicestate.h    2006-06-09 10:25:04.000000000 +0200
 @@ -42,7 +42,7 @@
  /*! Device is ringing */
  #define AST_DEVICE_RINGING    6
@@ -9960,9 +10434,9 @@ diff -urN asterisk-1.2.7.1.orig/include/asterisk/devicestate.h asterisk-1.2.7.1/
  
  /*! \brief Registers a device state change callback 
   * \param callback Callback
-diff -urN asterisk-1.2.7.1.orig/include/asterisk/features.h asterisk-1.2.7.1/include/asterisk/features.h
---- asterisk-1.2.7.1.orig/include/asterisk/features.h  2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.7.1/include/asterisk/features.h       2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/include/asterisk/features.h asterisk-1.2.9.1/include/asterisk/features.h
+--- asterisk-1.2.9.1.orig/include/asterisk/features.h  2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.9.1/include/asterisk/features.h       2006-06-09 10:25:04.000000000 +0200
 @@ -45,6 +45,8 @@
  };
  
@@ -10005,9 +10479,30 @@ diff -urN asterisk-1.2.7.1.orig/include/asterisk/features.h asterisk-1.2.7.1/inc
 +extern struct ast_call_feature *ast_find_builtin_feature(char *name);
 +
  #endif /* _AST_FEATURES_H */
-diff -urN asterisk-1.2.7.1.orig/include/asterisk/pbx.h asterisk-1.2.7.1/include/asterisk/pbx.h
---- asterisk-1.2.7.1.orig/include/asterisk/pbx.h       2006-03-29 21:11:18.000000000 +0200
-+++ asterisk-1.2.7.1/include/asterisk/pbx.h    2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/include/asterisk/monitor.h asterisk-1.2.9.1/include/asterisk/monitor.h
+--- asterisk-1.2.9.1.orig/include/asterisk/monitor.h   2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.9.1/include/asterisk/monitor.h        2006-06-09 10:25:04.000000000 +0200
+@@ -35,6 +35,8 @@
+       char write_filename[FILENAME_MAX];
+       char filename_base[FILENAME_MAX];
+       int filename_changed;
++      char target_url[FILENAME_MAX];
++      char target_script[FILENAME_MAX];
+       char *format;
+       int joinfiles;
+       int (*stop)(struct ast_channel *chan, int need_lock);
+@@ -42,7 +44,7 @@
+ /* Start monitoring a channel */
+ int ast_monitor_start(struct ast_channel *chan, const char *format_spec,
+-                    const char *fname_base, int need_lock );
++                    const char *fname_base, const char *target_url, const char *target_script, int need_lock );
+ /* Stop monitoring a channel */
+ int ast_monitor_stop(struct ast_channel *chan, int need_lock);
+diff -urN asterisk-1.2.9.1.orig/include/asterisk/pbx.h asterisk-1.2.9.1/include/asterisk/pbx.h
+--- asterisk-1.2.9.1.orig/include/asterisk/pbx.h       2006-03-29 21:11:18.000000000 +0200
++++ asterisk-1.2.9.1/include/asterisk/pbx.h    2006-06-09 10:25:04.000000000 +0200
 @@ -57,7 +57,7 @@
        AST_EXTENSION_BUSY = 1 << 1,
        /*! All devices UNAVAILABLE/UNREGISTERED */
@@ -10058,9 +10553,9 @@ diff -urN asterisk-1.2.7.1.orig/include/asterisk/pbx.h asterisk-1.2.7.1/include/
  
  #if defined(__cplusplus) || defined(c_plusplus)
  }
-diff -urN asterisk-1.2.7.1.orig/include/asterisk/xlaw.h asterisk-1.2.7.1/include/asterisk/xlaw.h
---- asterisk-1.2.7.1.orig/include/asterisk/xlaw.h      1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.7.1/include/asterisk/xlaw.h   2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/include/asterisk/xlaw.h asterisk-1.2.9.1/include/asterisk/xlaw.h
+--- asterisk-1.2.9.1.orig/include/asterisk/xlaw.h      1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.9.1/include/asterisk/xlaw.h   2006-06-09 10:25:04.000000000 +0200
 @@ -0,0 +1,1665 @@
 +#ifndef _ASTERISK_XLAW_H
 +#define _ASTERISK_XLAW_H
@@ -11727,9 +12222,9 @@ diff -urN asterisk-1.2.7.1.orig/include/asterisk/xlaw.h asterisk-1.2.7.1/include
 +#endif // CAPI_ULAW
 +#endif
 +
-diff -urN asterisk-1.2.7.1.orig/include/asterisk.h asterisk-1.2.7.1/include/asterisk.h
---- asterisk-1.2.7.1.orig/include/asterisk.h   2005-11-30 04:37:37.000000000 +0100
-+++ asterisk-1.2.7.1/include/asterisk.h        2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/include/asterisk.h asterisk-1.2.9.1/include/asterisk.h
+--- asterisk-1.2.9.1.orig/include/asterisk.h   2005-11-30 04:37:37.000000000 +0100
++++ asterisk-1.2.9.1/include/asterisk.h        2006-06-09 10:25:04.000000000 +0200
 @@ -36,6 +36,7 @@
  extern char ast_config_AST_PID[AST_CONFIG_MAX_PATH];
  extern char ast_config_AST_SOCKET[AST_CONFIG_MAX_PATH];
@@ -11738,9 +12233,9 @@ diff -urN asterisk-1.2.7.1.orig/include/asterisk.h asterisk-1.2.7.1/include/aste
  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.7.1.orig/manager.c asterisk-1.2.7.1/manager.c
---- asterisk-1.2.7.1.orig/manager.c    2006-02-11 19:15:00.000000000 +0100
-+++ asterisk-1.2.7.1/manager.c 2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/manager.c asterisk-1.2.9.1/manager.c
+--- asterisk-1.2.9.1.orig/manager.c    2006-02-11 19:15:00.000000000 +0100
++++ asterisk-1.2.9.1/manager.c 2006-06-09 10:25:04.000000000 +0200
 @@ -11,6 +11,9 @@
   * the project provides a web site, mailing lists and IRC
   * channels for your use.
@@ -11836,7 +12331,7 @@ diff -urN asterisk-1.2.7.1.orig/manager.c asterisk-1.2.7.1/manager.c
 -      if (!ast_strlen_zero(name2))
 +      if (!ast_strlen_zero(uniqueid2)) {
 +              chan2 = ast_get_channel_by_uniqueid_locked(uniqueid2);
-+              if (!ast_strlen_zero(priority2) && (sscanf(priority, "%d", &pi2) != 1)) {
++              if (!ast_strlen_zero(priority2) && (sscanf(priority2, "%d", &pi2) != 1)) {
 +                  astman_send_error(s, m, "Invalid priority2\n");
 +                  return 0;
 +              }
@@ -11993,9 +12488,9 @@ diff -urN asterisk-1.2.7.1.orig/manager.c asterisk-1.2.7.1/manager.c
        return 0;
  }
  
-diff -urN asterisk-1.2.7.1.orig/pbx/pbx_spool.c asterisk-1.2.7.1/pbx/pbx_spool.c
---- asterisk-1.2.7.1.orig/pbx/pbx_spool.c      2006-02-11 19:15:00.000000000 +0100
-+++ asterisk-1.2.7.1/pbx/pbx_spool.c   2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/pbx/pbx_spool.c asterisk-1.2.9.1/pbx/pbx_spool.c
+--- asterisk-1.2.9.1.orig/pbx/pbx_spool.c      2006-02-11 19:15:00.000000000 +0100
++++ asterisk-1.2.9.1/pbx/pbx_spool.c   2006-06-09 10:25:04.000000000 +0200
 @@ -259,11 +259,11 @@
        if (!ast_strlen_zero(o->app)) {
                if (option_verbose > 2)
@@ -12010,9 +12505,9 @@ diff -urN asterisk-1.2.7.1.orig/pbx/pbx_spool.c asterisk-1.2.7.1/pbx/pbx_spool.c
        }
        if (res) {
                ast_log(LOG_NOTICE, "Call failed to go through, reason %d\n", reason);
-diff -urN asterisk-1.2.7.1.orig/pbx.c asterisk-1.2.7.1/pbx.c
---- asterisk-1.2.7.1.orig/pbx.c        2006-04-13 17:56:35.000000000 +0200
-+++ asterisk-1.2.7.1/pbx.c     2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/pbx.c asterisk-1.2.9.1/pbx.c
+--- asterisk-1.2.9.1.orig/pbx.c        2006-05-23 19:15:23.000000000 +0200
++++ asterisk-1.2.9.1/pbx.c     2006-06-09 10:25:04.000000000 +0200
 @@ -353,7 +353,8 @@
        
        { "Hangup", pbx_builtin_hangup,
@@ -12023,7 +12518,7 @@ diff -urN asterisk-1.2.7.1.orig/pbx.c asterisk-1.2.7.1/pbx.c
        },
  
        { "NoOp", pbx_builtin_noop,
-@@ -1880,7 +1881,7 @@
+@@ -1883,7 +1884,7 @@
        return ast_extension_state2(e);                 /* Check all devices in the hint */
  }
  
@@ -12032,7 +12527,7 @@ diff -urN asterisk-1.2.7.1.orig/pbx.c asterisk-1.2.7.1/pbx.c
  {
        struct ast_hint *hint;
        struct ast_state_cb *cblist;
-@@ -1908,11 +1909,11 @@
+@@ -1911,11 +1912,11 @@
                        
                        /* For general callbacks */
                        for (cblist = statecbs; cblist; cblist = cblist->next)
@@ -12046,7 +12541,7 @@ diff -urN asterisk-1.2.7.1.orig/pbx.c asterisk-1.2.7.1/pbx.c
                        
                        hint->laststate = state;
                        break;
-@@ -2153,7 +2154,7 @@
+@@ -2156,7 +2157,7 @@
                                /* Notify with -1 and remove all callbacks */
                                cbprev = cblist;            
                                cblist = cblist->next;
@@ -12055,7 +12550,7 @@ diff -urN asterisk-1.2.7.1.orig/pbx.c asterisk-1.2.7.1/pbx.c
                                free(cbprev);
                        }
                        list->callbacks = NULL;
-@@ -3774,7 +3775,7 @@
+@@ -3778,7 +3779,7 @@
                        while (thiscb) {
                                prevcb = thiscb;            
                                thiscb = thiscb->next;
@@ -12064,7 +12559,7 @@ diff -urN asterisk-1.2.7.1.orig/pbx.c asterisk-1.2.7.1/pbx.c
                                free(prevcb);
                        }
                } else {
-@@ -4976,7 +4977,7 @@
+@@ -4980,7 +4981,7 @@
        return 0;  /* success */
  }
  
@@ -12073,7 +12568,7 @@ diff -urN asterisk-1.2.7.1.orig/pbx.c asterisk-1.2.7.1/pbx.c
  {
        struct ast_channel *chan;
        struct async_stat *as;
-@@ -4986,7 +4987,7 @@
+@@ -4990,7 +4991,7 @@
  
        if (sync) {
                LOAD_OH(oh);
@@ -12082,7 +12577,7 @@ diff -urN asterisk-1.2.7.1.orig/pbx.c asterisk-1.2.7.1/pbx.c
                if (channel) {
                        *channel = chan;
                        if (chan)
-@@ -5088,7 +5089,7 @@
+@@ -5092,7 +5093,7 @@
                        goto outgoing_exten_cleanup;
                }       
                memset(as, 0, sizeof(struct async_stat));
@@ -12091,7 +12586,7 @@ diff -urN asterisk-1.2.7.1.orig/pbx.c asterisk-1.2.7.1/pbx.c
                if (channel) {
                        *channel = chan;
                        if (chan)
-@@ -5134,7 +5135,7 @@
+@@ -5138,7 +5139,7 @@
        pthread_t t;
  };
  
@@ -12100,7 +12595,7 @@ diff -urN asterisk-1.2.7.1.orig/pbx.c asterisk-1.2.7.1/pbx.c
  {
        struct app_tmp *tmp = data;
        struct ast_app *app;
-@@ -5150,7 +5151,7 @@
+@@ -5154,7 +5155,7 @@
        return NULL;
  }
  
@@ -12109,7 +12604,7 @@ diff -urN asterisk-1.2.7.1.orig/pbx.c asterisk-1.2.7.1/pbx.c
  {
        struct ast_channel *chan;
        struct async_stat *as;
-@@ -5170,7 +5171,7 @@
+@@ -5174,7 +5175,7 @@
                goto outgoing_app_cleanup;      
        }
        if (sync) {
@@ -12118,7 +12613,7 @@ diff -urN asterisk-1.2.7.1.orig/pbx.c asterisk-1.2.7.1/pbx.c
                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);
-@@ -5257,7 +5258,8 @@
+@@ -5261,7 +5262,8 @@
                        goto outgoing_app_cleanup;
                }
                memset(as, 0, sizeof(struct async_stat));
@@ -12128,7 +12623,7 @@ diff -urN asterisk-1.2.7.1.orig/pbx.c asterisk-1.2.7.1/pbx.c
                if (!chan) {
                        free(as);
                        res = -1;
-@@ -5544,6 +5546,9 @@
+@@ -5548,6 +5550,9 @@
   */
  static int pbx_builtin_hangup(struct ast_channel *chan, void *data)
  {
@@ -12138,7 +12633,7 @@ diff -urN asterisk-1.2.7.1.orig/pbx.c asterisk-1.2.7.1/pbx.c
        /* Just return non-zero and it will hang up */
        if (!chan->hangupcause)
                chan->hangupcause = AST_CAUSE_NORMAL_CLEARING;
-@@ -6200,6 +6205,9 @@
+@@ -6204,6 +6209,9 @@
                        return -1;
                }
        }
@@ -12148,7 +12643,7 @@ diff -urN asterisk-1.2.7.1.orig/pbx.c asterisk-1.2.7.1/pbx.c
        return res = ast_say_number(chan, atoi((char *) tmp), "", chan->language, options);
  }
  
-@@ -6207,8 +6215,12 @@
+@@ -6211,8 +6219,12 @@
  {
        int res = 0;
  
@@ -12162,7 +12657,7 @@ diff -urN asterisk-1.2.7.1.orig/pbx.c asterisk-1.2.7.1/pbx.c
        return res;
  }
        
-@@ -6216,8 +6228,12 @@
+@@ -6220,8 +6232,12 @@
  {
        int res = 0;
  
@@ -12176,7 +12671,7 @@ diff -urN asterisk-1.2.7.1.orig/pbx.c asterisk-1.2.7.1/pbx.c
        return res;
  }
        
-@@ -6225,8 +6241,12 @@
+@@ -6229,8 +6245,12 @@
  {
        int res = 0;
  
@@ -12190,9 +12685,9 @@ diff -urN asterisk-1.2.7.1.orig/pbx.c asterisk-1.2.7.1/pbx.c
        return res;
  }
        
-diff -urN asterisk-1.2.7.1.orig/res/Makefile asterisk-1.2.7.1/res/Makefile
---- asterisk-1.2.7.1.orig/res/Makefile 2005-11-29 19:24:39.000000000 +0100
-+++ asterisk-1.2.7.1/res/Makefile      2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/res/Makefile asterisk-1.2.9.1/res/Makefile
+--- asterisk-1.2.9.1.orig/res/Makefile 2005-11-29 19:24:39.000000000 +0100
++++ asterisk-1.2.9.1/res/Makefile      2006-06-09 10:25:04.000000000 +0200
 @@ -11,7 +11,7 @@
  # the GNU General Public License
  #
@@ -12202,9 +12697,9 @@ diff -urN asterisk-1.2.7.1.orig/res/Makefile asterisk-1.2.7.1/res/Makefile
  
  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.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
---- asterisk-1.2.7.1.orig/res/res_agi.c        2006-02-28 19:31:04.000000000 +0100
-+++ asterisk-1.2.7.1/res/res_agi.c     2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/res/res_agi.c asterisk-1.2.9.1/res/res_agi.c
+--- asterisk-1.2.9.1.orig/res/res_agi.c        2006-06-01 01:50:00.000000000 +0200
++++ asterisk-1.2.9.1/res/res_agi.c     2006-06-09 10:25:04.000000000 +0200
 @@ -11,6 +11,9 @@
   * the project provides a web site, mailing lists and IRC
   * channels for your use.
@@ -12245,7 +12740,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
  "Use the CLI command 'show agi' to list available agi commands\n";
  
  static int agidebug = 0;
-@@ -220,13 +228,14 @@
+@@ -225,13 +233,14 @@
        return 0;
  }
  
@@ -12261,7 +12756,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
        int x;
        int res;
        sigset_t signal_set;
-@@ -271,6 +280,33 @@
+@@ -276,6 +285,33 @@
                        return -1;
                }
        }
@@ -12295,7 +12790,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
        pid = fork();
        if (pid < 0) {
                ast_log(LOG_WARNING, "Failed to fork(): %s\n", strerror(errno));
-@@ -285,15 +321,19 @@
+@@ -290,15 +326,19 @@
                } else {
                        close(STDERR_FILENO + 1);
                }
@@ -12317,7 +12812,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
                        close(x);
  
                /* Don't run AGI scripts with realtime priority -- it causes audio stutter */
-@@ -312,6 +352,9 @@
+@@ -317,6 +357,9 @@
        if (efd) {
                *efd = audio[1];
        }
@@ -12327,7 +12822,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
        /* close what we're not using in the parent */
        close(toast[1]);
        close(fromast[0]);
-@@ -320,6 +363,9 @@
+@@ -325,6 +368,9 @@
                /* [PHM 12/18/03] */
                close(audio[0]);
        }
@@ -12337,7 +12832,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
  
        *opid = pid;
        return 0;
-@@ -350,7 +396,7 @@
+@@ -355,7 +401,7 @@
        fdprintf(fd, "agi_context: %s\n", chan->context);
        fdprintf(fd, "agi_extension: %s\n", chan->exten);
        fdprintf(fd, "agi_priority: %d\n", chan->priority);
@@ -12346,7 +12841,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
  
        /* User information */
        fdprintf(fd, "agi_accountcode: %s\n", chan->accountcode ? chan->accountcode : "");
-@@ -382,7 +428,7 @@
+@@ -387,7 +433,7 @@
                return RESULT_SHOWUSAGE;
        if (sscanf(argv[3], "%d", &to) != 1)
                return RESULT_SHOWUSAGE;
@@ -12355,7 +12850,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
        fdprintf(agi->fd, "200 result=%d\n", res);
        if (res >= 0)
                return RESULT_SUCCESS;
-@@ -558,7 +604,7 @@
+@@ -563,7 +609,7 @@
                else
                        return RESULT_FAILURE;
        }
@@ -12364,7 +12859,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
        /* 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;
-@@ -618,7 +664,7 @@
+@@ -623,7 +669,7 @@
                  else
                          return RESULT_FAILURE;
          }
@@ -12373,7 +12868,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
          /* 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;
-@@ -630,7 +676,7 @@
+@@ -635,7 +681,7 @@
  
        /* If the user didnt press a key, wait for digitTimeout*/
        if (res == 0 ) {
@@ -12382,7 +12877,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
                /* Make sure the new result is in the escape digits of the GET OPTION */
                if ( !strchr(edigits,res) )
                        res=0;
-@@ -657,7 +703,7 @@
+@@ -662,7 +708,7 @@
                return RESULT_SHOWUSAGE;
        if (sscanf(argv[2], "%d", &num) != 1)
                return RESULT_SHOWUSAGE;
@@ -12391,7 +12886,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
        if (res == 1)
                return RESULT_SUCCESS;
        fdprintf(agi->fd, "200 result=%d\n", res);
-@@ -677,7 +723,7 @@
+@@ -682,7 +728,7 @@
        if (sscanf(argv[2], "%d", &num) != 1)
                return RESULT_SHOWUSAGE;
  
@@ -12400,7 +12895,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
        if (res == 1) /* New command */
                return RESULT_SUCCESS;
        fdprintf(agi->fd, "200 result=%d\n", res);
-@@ -694,7 +740,7 @@
+@@ -699,7 +745,7 @@
        if (argc != 4)
                return RESULT_SHOWUSAGE;
  
@@ -12409,7 +12904,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
        if (res == 1) /* New command */
                return RESULT_SUCCESS;
        fdprintf(agi->fd, "200 result=%d\n", res);
-@@ -784,7 +830,7 @@
+@@ -789,7 +835,7 @@
        if (argc != 4)
                return RESULT_SHOWUSAGE;
  
@@ -12418,7 +12913,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
        if (res == 1) /* New command */
                return RESULT_SUCCESS;
        fdprintf(agi->fd, "200 result=%d\n", res);
-@@ -811,7 +857,7 @@
+@@ -816,7 +862,7 @@
                max = atoi(argv[4]); 
        else
                max = 1024;
@@ -12427,7 +12922,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
        if (res == 2)                   /* New command */
                return RESULT_SUCCESS;
        else if (res == 1)
-@@ -1849,7 +1895,12 @@
+@@ -1860,7 +1906,12 @@
        int ms;
        int returnstatus = 0;
        struct ast_frame *f;
@@ -12440,7 +12935,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
        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) */
-@@ -1863,10 +1914,22 @@
+@@ -1874,10 +1925,22 @@
                return -1;
        }
        setlinebuf(readf);
@@ -12465,7 +12960,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
                if (c) {
                        retry = RETRY;
                        /* Idle the channel until we get a command */
-@@ -1877,13 +1940,24 @@
+@@ -1888,13 +1951,24 @@
                                break;
                        } else {
                                /* If it's voice, write it to the audio pipe */
@@ -12492,7 +12987,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
                        retry = RETRY;
                        if (!fgets(buf, sizeof(buf), readf)) {
                                /* Program terminated */
-@@ -1905,6 +1979,7 @@
+@@ -1916,6 +1990,7 @@
                        if ((returnstatus < 0) || (returnstatus == AST_PBX_KEEPALIVE)) {
                                break;
                        }
@@ -12500,7 +12995,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
                } else {
                        if (--retry <= 0) {
                                ast_log(LOG_WARNING, "No channel, no fd?\n");
-@@ -2011,6 +2086,7 @@
+@@ -2022,6 +2097,7 @@
        int argc = 0;
        int fds[2];
        int efd = -1;
@@ -12508,7 +13003,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
        int pid;
          char *stringp;
        AGI agi;
-@@ -2036,15 +2112,18 @@
+@@ -2047,15 +2123,18 @@
                }
        }
  #endif
@@ -12529,7 +13024,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
        }
        LOCAL_USER_REMOVE(u);
        return res;
-@@ -2078,6 +2157,35 @@
+@@ -2089,6 +2168,35 @@
        return res;
  }
  
@@ -12565,7 +13060,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
  static int deadagi_exec(struct ast_channel *chan, void *data)
  {
        return agi_exec_full(chan, data, 0, 1);
-@@ -2107,6 +2215,7 @@
+@@ -2118,6 +2226,7 @@
        ast_cli_unregister(&dumpagihtml);
        ast_cli_unregister(&cli_debug);
        ast_cli_unregister(&cli_no_debug);
@@ -12573,7 +13068,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
        ast_unregister_application(eapp);
        ast_unregister_application(deadapp);
        return ast_unregister_application(app);
-@@ -2120,6 +2229,7 @@
+@@ -2131,6 +2240,7 @@
        ast_cli_register(&cli_no_debug);
        ast_register_application(deadapp, deadagi_exec, deadsynopsis, descrip);
        ast_register_application(eapp, eagi_exec, esynopsis, descrip);
@@ -12581,9 +13076,9 @@ diff -urN asterisk-1.2.7.1.orig/res/res_agi.c asterisk-1.2.7.1/res/res_agi.c
        return ast_register_application(app, agi_exec, synopsis, descrip);
  }
  
-diff -urN asterisk-1.2.7.1.orig/res/res_features.c asterisk-1.2.7.1/res/res_features.c
---- asterisk-1.2.7.1.orig/res/res_features.c   2006-04-10 19:29:51.000000000 +0200
-+++ asterisk-1.2.7.1/res/res_features.c        2006-04-18 14:39:28.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/res/res_features.c asterisk-1.2.9.1/res/res_features.c
+--- asterisk-1.2.9.1.orig/res/res_features.c   2006-05-23 19:15:23.000000000 +0200
++++ asterisk-1.2.9.1/res/res_features.c        2006-06-09 10:25:04.000000000 +0200
 @@ -11,6 +11,10 @@
   * the project provides a web site, mailing lists and IRC
   * channels for your use.
@@ -12752,7 +13247,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_features.c asterisk-1.2.7.1/res/res_feat
  /* 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)
  {
-@@ -1014,7 +1092,7 @@
+@@ -1018,7 +1096,7 @@
                        return res;
                
                while ((tok = strsep(&tmp, "#")) != NULL) {
@@ -12761,7 +13256,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_features.c asterisk-1.2.7.1/res/res_feat
                        
                        if (feature) {
                                /* Feature is up for consideration */
-@@ -1064,7 +1142,7 @@
+@@ -1071,7 +1149,7 @@
  
                        /* while we have a feature */
                        while (NULL != (tok = strsep(&tmp, "#"))) {
@@ -12770,7 +13265,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_features.c asterisk-1.2.7.1/res/res_feat
                                        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);
-@@ -1089,7 +1167,7 @@
+@@ -1096,7 +1174,7 @@
        struct ast_frame *f = NULL;
        int res = 0, ready = 0;
        
@@ -12779,7 +13274,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_features.c asterisk-1.2.7.1/res/res_feat
                ast_set_callerid(chan, cid_num, cid_name, cid_num);
                ast_channel_inherit_variables(caller, chan);    
                if (!ast_call(chan, data, timeout)) {
-@@ -1541,9 +1619,10 @@
+@@ -1549,9 +1627,10 @@
                                        "Channel: %s\r\n"
                                        "CallerID: %s\r\n"
                                        "CallerIDName: %s\r\n"
@@ -12791,7 +13286,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_features.c asterisk-1.2.7.1/res/res_feat
                                        );
  
                                if (option_verbose > 1) 
-@@ -1586,9 +1665,10 @@
+@@ -1594,9 +1673,10 @@
                                                                "Channel: %s\r\n"
                                                                "CallerID: %s\r\n"
                                                                "CallerIDName: %s\r\n"
@@ -12803,7 +13298,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_features.c asterisk-1.2.7.1/res/res_feat
                                                                );
  
                                                        /* There's a problem, hang them up*/
-@@ -1675,6 +1755,280 @@
+@@ -1683,6 +1763,280 @@
        return res;
  }
  
@@ -13084,7 +13579,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_features.c asterisk-1.2.7.1/res/res_feat
  static int park_exec(struct ast_channel *chan, void *data)
  {
        int res=0;
-@@ -1723,9 +2077,10 @@
+@@ -1731,9 +2085,10 @@
                        "From: %s\r\n"
                        "CallerID: %s\r\n"
                        "CallerIDName: %s\r\n"
@@ -13096,7 +13591,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_features.c asterisk-1.2.7.1/res/res_feat
                        );
  
                free(pu);
-@@ -1893,12 +2248,13 @@
+@@ -1901,12 +2256,13 @@
                        "Timeout: %ld\r\n"
                        "CallerID: %s\r\n"
                        "CallerIDName: %s\r\n"
@@ -13111,7 +13606,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_features.c asterisk-1.2.7.1/res/res_feat
                        ,idText);
  
              cur = cur->next;
-@@ -1914,6 +2270,386 @@
+@@ -1922,6 +2278,386 @@
          return RESULT_SUCCESS;
  }
  
@@ -13498,7 +13993,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_features.c asterisk-1.2.7.1/res/res_feat
  
  int ast_pickup_call(struct ast_channel *chan)
  {
-@@ -2068,7 +2804,7 @@
+@@ -2076,7 +2812,7 @@
                        }
  
                        {
@@ -13507,7 +14002,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_features.c asterisk-1.2.7.1/res/res_feat
                                int mallocd=0;
                                
                                if (!feature) {
-@@ -2144,14 +2880,22 @@
+@@ -2151,14 +2887,22 @@
        if ((res = load_config()))
                return res;
        ast_cli_register(&showparked);
@@ -13530,7 +14025,7 @@ diff -urN asterisk-1.2.7.1.orig/res/res_features.c asterisk-1.2.7.1/res/res_feat
        return res;
  }
  
-@@ -2162,7 +2906,11 @@
+@@ -2169,7 +2913,11 @@
  
        ast_manager_unregister("ParkedCalls");
        ast_cli_unregister(&showfeatures);
@@ -13542,9 +14037,148 @@ diff -urN asterisk-1.2.7.1.orig/res/res_features.c asterisk-1.2.7.1/res/res_feat
        ast_unregister_application(parkcall);
        return ast_unregister_application(parkedcall);
  }
-diff -urN asterisk-1.2.7.1.orig/res/res_watchdog.c asterisk-1.2.7.1/res/res_watchdog.c
---- asterisk-1.2.7.1.orig/res/res_watchdog.c   1970-01-01 01:00:00.000000000 +0100
-+++ asterisk-1.2.7.1/res/res_watchdog.c        2006-04-24 09:39:12.000000000 +0200
+diff -urN asterisk-1.2.9.1.orig/res/res_monitor.c asterisk-1.2.9.1/res/res_monitor.c
+--- asterisk-1.2.9.1.orig/res/res_monitor.c    2006-03-02 20:05:40.000000000 +0100
++++ asterisk-1.2.9.1/res/res_monitor.c 2006-06-09 10:25:04.000000000 +0200
+@@ -90,7 +90,7 @@
+ /* Start monitoring a channel */
+ int ast_monitor_start(        struct ast_channel *chan, const char *format_spec,
+-              const char *fname_base, int need_lock)
++              const char *fname_base, const char *target_url, const char *target_script, int need_lock)
+ {
+       int res = 0;
+       char tmp[256];
+@@ -122,6 +122,11 @@
+               }
+               memset(monitor, 0, sizeof(struct ast_channel_monitor));
++              if (target_url)
++                  ast_copy_string(monitor->target_url, target_url, sizeof(monitor->target_url));
++              if (target_script)
++                  ast_copy_string(monitor->target_script, target_script, sizeof(monitor->target_script));
++
+               /* Determine file names */
+               if (!ast_strlen_zero(fname_base)) {
+                       int directory = strchr(fname_base, '/') ? 1 : 0;
+@@ -257,6 +262,8 @@
+               if (chan->monitor->joinfiles && !ast_strlen_zero(chan->monitor->filename_base)) {
+                       char tmp[1024];
+                       char tmp2[1024];
++                      char tmp3[1024];
++                      int result;
+                       char *format = !strcasecmp(chan->monitor->format,"wav49") ? "WAV" : chan->monitor->format;
+                       char *name = chan->monitor->filename_base;
+                       int directory = strchr(name, '/') ? 1 : 0;
+@@ -278,9 +285,19 @@
+                               snprintf(tmp2,sizeof(tmp2), "( %s& rm -f \"%s/%s-\"* ) &",tmp, dir ,name); /* remove legs when done mixing */
+                               ast_copy_string(tmp, tmp2, sizeof(tmp));
+                       }
+-                      ast_log(LOG_DEBUG,"monitor executing %s\n",tmp);
+-                      if (ast_safe_system(tmp) == -1)
++                      if (!ast_strlen_zero(chan->monitor->target_script) && !ast_strlen_zero(chan->monitor->target_url)) {
++                              snprintf(tmp3,sizeof(tmp3), "( %s& nice -19 %s \"%s/%s.%s\" \"%s\" ) &",tmp, chan->monitor->target_script , dir, name, format, chan->monitor->target_url); 
++                              ast_copy_string(tmp, tmp3, sizeof(tmp));
++                      }
++                      ast_log(LOG_NOTICE,"monitor executing %s\n",tmp);
++                      result = ast_safe_system(tmp);
++                      if (result == -1)
+                               ast_log(LOG_WARNING, "Execute of %s failed.\n",tmp);
++                      manager_event(EVENT_FLAG_CALL, "MonitorStopped",
++                                          "Channel: %s\r\n"
++                                          "Uniqueid: %s\r\n"
++                                          "Result: %d\r\n"
++                                      ,chan->name, chan->uniqueid, result);
+               }
+               
+               free(chan->monitor->format);
+@@ -392,7 +409,7 @@
+               return 0;
+       }
+-      res = ast_monitor_start(chan, format, fname_base, 1);
++      res = ast_monitor_start(chan, format, fname_base, NULL, NULL, 1);
+       if (res < 0)
+               res = ast_monitor_change_fname(chan, fname_base, 1);
+       ast_monitor_setjoinfiles(chan, joinfiles);
+@@ -428,19 +445,30 @@
+ {
+       struct ast_channel *c = NULL;
+       char *name = astman_get_header(m, "Channel");
++      char *uniqueid = astman_get_header(m, "Uniqueid");
+       char *fname = astman_get_header(m, "File");
+       char *format = astman_get_header(m, "Format");
+       char *mix = astman_get_header(m, "Mix");
++      char *target_url = astman_get_header(m, "TargetURL");
++      char *target_script = astman_get_header(m, "TargetScript");
+       char *d;
+       
+-      if (ast_strlen_zero(name)) {
+-              astman_send_error(s, m, "No channel specified");
++      if (ast_strlen_zero(name) && ast_strlen_zero(uniqueid)) {
++              astman_send_error(s, m, "No channel/uniqueid specified");
+               return 0;
+       }
+-      c = ast_get_channel_by_name_locked(name);
+-      if (!c) {
++      if (!ast_strlen_zero(uniqueid)) {
++          c = ast_get_channel_by_uniqueid_locked(uniqueid);
++          if (!c) {
++              astman_send_error(s, m, "No such uniqueid");
++              return 0;
++          }
++      } else {
++          c = ast_get_channel_by_name_locked(name);
++          if (!c) {
+               astman_send_error(s, m, "No such channel");
+               return 0;
++          }
+       }
+       if (ast_strlen_zero(fname)) {
+@@ -457,7 +485,7 @@
+               if ((d=strchr(fname, '/'))) *d='-';
+       }
+       
+-      if (ast_monitor_start(c, format, fname, 1)) {
++      if (ast_monitor_start(c, format, fname, target_url, target_script, 1)) {
+               if (ast_monitor_change_fname(c, fname, 1)) {
+                       astman_send_error(s, m, "Could not start monitoring channel");
+                       ast_mutex_unlock(&c->lock);
+@@ -483,16 +511,26 @@
+ {
+       struct ast_channel *c = NULL;
+       char *name = astman_get_header(m, "Channel");
++      char *uniqueid = astman_get_header(m, "Uniqueid");
+       int res;
+-      if (ast_strlen_zero(name)) {
+-              astman_send_error(s, m, "No channel specified");
++      if (ast_strlen_zero(name) && ast_strlen_zero(uniqueid)) {
++              astman_send_error(s, m, "No channel/uniqueid specified");
+               return 0;
+       }
+-      c = ast_get_channel_by_name_locked(name);
+-      if (!c) {
++      if (!ast_strlen_zero(uniqueid)) {
++          c = ast_get_channel_by_uniqueid_locked(uniqueid);
++          if (!c) {
++              astman_send_error(s, m, "No such uniqueid");
++              return 0;
++          }
++      } else {
++          c = ast_get_channel_by_name_locked(name);
++          if (!c) {
+               astman_send_error(s, m, "No such channel");
+               return 0;
++          }
+       }
++
+       res = ast_monitor_stop(c, 1);
+       ast_mutex_unlock(&c->lock);
+       if (res) {
+diff -urN asterisk-1.2.9.1.orig/res/res_watchdog.c asterisk-1.2.9.1/res/res_watchdog.c
+--- asterisk-1.2.9.1.orig/res/res_watchdog.c   1970-01-01 01:00:00.000000000 +0100
++++ asterisk-1.2.9.1/res/res_watchdog.c        2006-06-09 10:25:04.000000000 +0200
 @@ -0,0 +1,149 @@
 +/*
 + * Asterisk -- A telephony toolkit for Linux.
@@ -13695,10 +14329,10 @@ diff -urN asterisk-1.2.7.1.orig/res/res_watchdog.c asterisk-1.2.7.1/res/res_watc
 +{
 +      return ASTERISK_GPL_KEY;
 +}
-diff -urN asterisk-1.2.7.1.orig/rtp.c asterisk-1.2.7.1/rtp.c
---- asterisk-1.2.7.1.orig/rtp.c        2006-03-15 19:07:06.000000000 +0100
-+++ asterisk-1.2.7.1/rtp.c     2006-04-18 14:39:28.000000000 +0200
-@@ -442,6 +442,11 @@
+diff -urN asterisk-1.2.9.1.orig/rtp.c asterisk-1.2.9.1/rtp.c
+--- asterisk-1.2.9.1.orig/rtp.c        2006-06-01 00:26:38.000000000 +0200
++++ asterisk-1.2.9.1/rtp.c     2006-06-09 10:25:04.000000000 +0200
+@@ -444,6 +444,11 @@
        struct rtpPayloadType rtpPT;
        
        len = sizeof(sin);
index ae61c78c2643578f95029df025709eab1116097d..93895deeda188eb6f3fef08894381cfbe547caea 100644 (file)
@@ -1,20 +1,30 @@
-diff -urN libpri-1.2.2.orig/Makefile libpri-1.2.2/Makefile
---- libpri-1.2.2.orig/Makefile 2006-01-10 21:19:14.000000000 +0100
-+++ libpri-1.2.2/Makefile      2006-01-18 12:28:07.000000000 +0100
-@@ -38,7 +38,7 @@
+diff -urN libpri-1.2.3.orig/Makefile libpri-1.2.3/Makefile
+--- libpri-1.2.3.orig/Makefile 2006-04-30 17:17:47.000000000 +0200
++++ libpri-1.2.3/Makefile      2006-06-09 10:18:25.000000000 +0200
+@@ -27,6 +27,9 @@
+ # Uncomment if you want libpri to count number of Q921/Q931 sent/received
+ #LIBPRI_COUNTERS=-DLIBPRI_COUNTERS
++# Uncomment if you want libpri to always keep layer 2 up
++#LAYER2ALWAYSUP=-DLAYER2ALWAYSUP
++
+ CC=gcc
+ OSARCH=$(shell uname -s)
+@@ -38,7 +41,7 @@
  DYNAMIC_LIBRARY=libpri.so.1.0
  STATIC_OBJS=copy_string.o pri.o q921.o prisched.o q931.o pri_facility.o
  DYNAMIC_OBJS=copy_string.lo pri.lo q921.lo prisched.lo q931.lo pri_facility.lo
 -CFLAGS=-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g $(ALERTING) $(LIBPRI_COUNTERS)
-+CFLAGS=-Wall -Wstrict-prototypes -Wmissing-prototypes -g $(ALERTING) $(LIBPRI_COUNTERS) -DRELAX_TRB
- INSTALL_PREFIX?=
++CFLAGS=-Wall -Wstrict-prototypes -Wmissing-prototypes -g $(ALERTING) $(LIBPRI_COUNTERS) $(LAYER2ALWAYSUP) -DRELAX_TRB
+ INSTALL_PREFIX=$(DESTDIR)
  INSTALL_BASE=/usr
  SOFLAGS = -Wl,-hlibpri.so.1.0
-diff -urN libpri-1.2.2.orig/README libpri-1.2.2/README
---- libpri-1.2.2.orig/README   2005-11-29 19:39:18.000000000 +0100
-+++ libpri-1.2.2/README        2006-01-18 12:28:07.000000000 +0100
+diff -urN libpri-1.2.3.orig/README libpri-1.2.3/README
+--- libpri-1.2.3.orig/README   2006-02-15 18:59:38.000000000 +0100
++++ libpri-1.2.3/README        2006-01-18 12:28:07.000000000 +0100
 @@ -1,6 +1,7 @@
--libpri: An implementation of Primate Rate ISDN
+-libpri: An implementation of Primary Rate ISDN
 -
 -Written by Mark Spencer <markster@digium.com>
 +libpri: An implementation of Primate Rate ISDN (and BRI ISDN)
@@ -44,9 +54,9 @@ diff -urN libpri-1.2.2.orig/README libpri-1.2.2/README
  
  
  How do I report bugs or contribute?
-diff -urN libpri-1.2.2.orig/TODO libpri-1.2.2/TODO
---- libpri-1.2.2.orig/TODO     2005-11-29 19:39:18.000000000 +0100
-+++ libpri-1.2.2/TODO  2006-01-18 12:28:07.000000000 +0100
+diff -urN libpri-1.2.3.orig/TODO libpri-1.2.3/TODO
+--- libpri-1.2.3.orig/TODO     2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.3/TODO  2006-01-18 12:28:07.000000000 +0100
 @@ -2,9 +2,7 @@
  -- D-Channel Backup
  -- Test against 4e
@@ -60,9 +70,9 @@ diff -urN libpri-1.2.2.orig/TODO libpri-1.2.2/TODO
 +-- Locking Shift IE (you did that already, didnt you??)
 +-- Implement the 10 missing Q.931 timers
 +-- more facilities
-diff -urN libpri-1.2.2.orig/libpri.h libpri-1.2.2/libpri.h
---- libpri-1.2.2.orig/libpri.h 2005-11-29 19:39:18.000000000 +0100
-+++ libpri-1.2.2/libpri.h      2006-04-15 21:56:47.000000000 +0200
+diff -urN libpri-1.2.3.orig/libpri.h libpri-1.2.3/libpri.h
+--- libpri-1.2.3.orig/libpri.h 2006-04-27 18:08:39.000000000 +0200
++++ libpri-1.2.3/libpri.h      2006-06-06 14:28:32.000000000 +0200
 @@ -5,6 +5,8 @@
   *
   * Copyright (C) 2001, Linux Support Services, Inc.
@@ -191,15 +201,7 @@ diff -urN libpri-1.2.2.orig/libpri.h libpri-1.2.2/libpri.h
        q931_call *call;                        /* Opaque call pointer */
        long aoc_units;                         /* Advise of Charge number of charged units */
        char useruserinfo[260];         /* User->User info */
-@@ -359,6 +381,7 @@
- typedef struct pri_event_setup_ack {
-       int e;
-       int channel;
-+      q931_call *call;                        /* Opaque call pointer */
- } pri_event_setup_ack;
- typedef struct pri_event_notify {
-@@ -374,20 +397,80 @@
+@@ -375,20 +397,80 @@
        char digits[64];
  } pri_event_keypad_digit;
  
@@ -281,7 +283,7 @@ diff -urN libpri-1.2.2.orig/libpri.h libpri-1.2.2/libpri.h
        pri_event_keypad_digit digit;                   /* Digits that come during a call */
  } pri_event;
  
-@@ -402,7 +485,9 @@
+@@ -403,7 +485,9 @@
     channel operating in HDLC mode with FCS computed by the fd's driver.  Also it
     must be NON-BLOCKING! Frames received on the fd should include FCS.  Nodetype 
     must be one of PRI_NETWORK or PRI_CPE.  switchtype should be PRI_SWITCH_* */
@@ -292,7 +294,7 @@ diff -urN libpri-1.2.2.orig/libpri.h libpri-1.2.2/libpri.h
  
  /* Create D-channel just as above with user defined I/O callbacks and data */
  extern struct pri *pri_new_cb(int fd, int nodetype, int switchtype, pri_io_cb io_read, pri_io_cb io_write, void *userdata);
-@@ -426,6 +511,9 @@
+@@ -427,6 +511,9 @@
  /* Enable transmission support of Facility IEs on the pri */
  extern void pri_facility_enable(struct pri *pri);
  
@@ -302,7 +304,7 @@ diff -urN libpri-1.2.2.orig/libpri.h libpri-1.2.2/libpri.h
  /* Run PRI on the given D-channel, taking care of any events that
     need to be handled.  If block is set, it will block until an event
     occurs which needs to be handled */
-@@ -462,6 +550,12 @@
+@@ -463,6 +550,12 @@
  /* Send a digit in overlap mode */
  extern int pri_information(struct pri *pri, q931_call *call, char digit);
  
@@ -315,7 +317,7 @@ diff -urN libpri-1.2.2.orig/libpri.h libpri-1.2.2/libpri.h
  /* Answer the incomplete(call without called number) call on the given channel.
     Set non-isdn to non-zero if you are not connecting to ISDN equipment */
  extern int pri_need_more_info(struct pri *pri, q931_call *call, int channel, int nonisdn);
-@@ -470,6 +564,35 @@
+@@ -471,6 +564,35 @@
     Set non-isdn to non-zero if you are not connecting to ISDN equipment */
  extern int pri_answer(struct pri *pri, q931_call *call, int channel, int nonisdn);
  
@@ -351,7 +353,7 @@ diff -urN libpri-1.2.2.orig/libpri.h libpri-1.2.2/libpri.h
  /* Set CRV reference for GR-303 calls */
  
  
-@@ -478,14 +601,14 @@
+@@ -479,14 +601,14 @@
  
  /* backwards compatibility for those who don't use asterisk with libpri */
  #define pri_release(a,b,c) \
@@ -369,7 +371,7 @@ diff -urN libpri-1.2.2.orig/libpri.h libpri-1.2.2/libpri.h
  
  #define PRI_DESTROYCALL
  extern void pri_destroycall(struct pri *pri, q931_call *call);
-@@ -518,14 +641,13 @@
+@@ -519,14 +641,13 @@
  extern void pri_sr_free(struct pri_sr *sr);
  
  extern int pri_sr_set_channel(struct pri_sr *sr, int channel, int exclusive, int nonisdn);
@@ -385,7 +387,7 @@ diff -urN libpri-1.2.2.orig/libpri.h libpri-1.2.2/libpri.h
  extern void pri_call_set_useruser(q931_call *sr, char *userchars);
  
  extern int pri_setup(struct pri *pri, q931_call *call, struct pri_sr *req);
-@@ -546,8 +668,8 @@
+@@ -547,8 +668,8 @@
  
  /* Override message and error stuff */
  #define PRI_NEW_SET_API
@@ -396,9 +398,9 @@ diff -urN libpri-1.2.2.orig/libpri.h libpri-1.2.2/libpri.h
  
  /* Set overlap mode */
  #define PRI_SET_OVERLAPDIAL
-diff -urN libpri-1.2.2.orig/pri.c libpri-1.2.2/pri.c
---- libpri-1.2.2.orig/pri.c    2005-11-29 19:39:18.000000000 +0100
-+++ libpri-1.2.2/pri.c 2006-04-15 21:57:09.000000000 +0200
+diff -urN libpri-1.2.3.orig/pri.c libpri-1.2.3/pri.c
+--- libpri-1.2.3.orig/pri.c    2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.3/pri.c 2006-06-09 10:17:29.000000000 +0200
 @@ -1,24 +1,14 @@
  /*
   * libpri: An implementation of Primary Rate ISDN
@@ -771,20 +773,22 @@ diff -urN libpri-1.2.2.orig/pri.c libpri-1.2.2/pri.c
        return 0;
  }
  
-@@ -851,3 +979,10 @@
+@@ -851,3 +979,12 @@
        sr->redirectingreason = reason;
        return 0;
  }
 +
 +void pri_shutdown(struct pri *pri)
 +{
++#ifndef LAYER2ALWAYSUP
 +    if ((pri->localtype == BRI_NETWORK) || (pri->localtype == BRI_CPE) || (pri->localtype == BRI_CPE_PTMP)) {
 +      q921_reset(pri, pri->tei, 1);
 +    }
++#endif
 +}
-diff -urN libpri-1.2.2.orig/pri_facility.c libpri-1.2.2/pri_facility.c
---- libpri-1.2.2.orig/pri_facility.c   2005-11-29 19:39:18.000000000 +0100
-+++ libpri-1.2.2/pri_facility.c        2006-04-15 21:56:10.000000000 +0200
+diff -urN libpri-1.2.3.orig/pri_facility.c libpri-1.2.3/pri_facility.c
+--- libpri-1.2.3.orig/pri_facility.c   2006-02-14 00:06:02.000000000 +0100
++++ libpri-1.2.3/pri_facility.c        2006-06-06 14:26:01.000000000 +0200
 @@ -1,26 +1,17 @@
 -/*
 - * libpri: An implementation of Primary Rate ISDN
@@ -1177,7 +1181,7 @@ diff -urN libpri-1.2.2.orig/pri_facility.c libpri-1.2.2/pri_facility.c
        }
  
        return 0;
-@@ -1148,13 +1216,15 @@
+@@ -1152,13 +1220,15 @@
                NEXT_COMPONENT(comp, i);
  
                /* No argument - return with error */
@@ -1198,7 +1202,7 @@ diff -urN libpri-1.2.2.orig/pri_facility.c libpri-1.2.2/pri_facility.c
  
                if (pri->debug & PRI_DEBUG_APDU)
                        pri_message(pri, "  [ Handling operation %d ]\n", operation_tag);
-@@ -1178,7 +1248,11 @@
+@@ -1182,7 +1252,11 @@
                case ROSE_DIVERTING_LEG_INFORMATION2:
                        if (pri->debug & PRI_DEBUG_APDU)
                                pri_message(pri, "  Handle DivertingLegInformation2\n");
@@ -1211,7 +1215,7 @@ diff -urN libpri-1.2.2.orig/pri_facility.c libpri-1.2.2/pri_facility.c
                case ROSE_AOC_NO_CHARGING_INFO_AVAILABLE:
                        if (pri->debug & PRI_DEBUG_APDU) {
                                pri_message(pri, "ROSE %i: AOC No Charging Info Available - not handled!", operation_tag);
-@@ -1206,6 +1280,7 @@
+@@ -1210,6 +1284,7 @@
                        }
                        return -1;
                case ROSE_AOC_AOCD_CHARGING_UNIT:
@@ -1219,7 +1223,7 @@ diff -urN libpri-1.2.2.orig/pri_facility.c libpri-1.2.2/pri_facility.c
                        if (pri->debug & PRI_DEBUG_APDU) {
                                pri_message(pri, "ROSE %i: AOC-D Charging Unit - not handled!", operation_tag);
                                dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
-@@ -1220,7 +1295,7 @@
+@@ -1224,7 +1299,7 @@
                case ROSE_AOC_AOCE_CHARGING_UNIT:
                        return aoc_aoce_charging_unit_decode(pri, call, (u_int8_t *)comp, comp->len + 2);
                        if (0) { /* the following function is currently not used - just to make the compiler happy */
@@ -1228,7 +1232,7 @@ diff -urN libpri-1.2.2.orig/pri_facility.c libpri-1.2.2/pri_facility.c
                                return 0;
                        }
                case ROSE_AOC_IDENTIFICATION_OF_CHARGE:
-@@ -1229,6 +1304,22 @@
+@@ -1233,6 +1308,22 @@
                                dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
                        }
                        return -1;
@@ -1251,9 +1255,9 @@ diff -urN libpri-1.2.2.orig/pri_facility.c libpri-1.2.2/pri_facility.c
                default:
                        if (pri->debug & PRI_DEBUG_APDU) {
                                pri_message(pri, "!! Unable to handle ROSE operation %d", operation_tag);
-diff -urN libpri-1.2.2.orig/pri_facility.h libpri-1.2.2/pri_facility.h
---- libpri-1.2.2.orig/pri_facility.h   2005-11-29 19:39:18.000000000 +0100
-+++ libpri-1.2.2/pri_facility.h        2006-04-15 21:35:05.000000000 +0200
+diff -urN libpri-1.2.3.orig/pri_facility.h libpri-1.2.3/pri_facility.h
+--- libpri-1.2.3.orig/pri_facility.h   2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.3/pri_facility.h        2006-04-15 21:35:05.000000000 +0200
 @@ -34,7 +34,7 @@
  /* Operation ID values */
  /* Q.952 ROSE operations (Diverting) */
@@ -1302,9 +1306,9 @@ diff -urN libpri-1.2.2.orig/pri_facility.h libpri-1.2.2/pri_facility.h
 +extern int aoc_aoce_charging_unit_encode(struct pri *pri, q931_call *c, long chargedunits, int send_facility_message);
 +
  #endif /* _PRI_FACILITY_H */
-diff -urN libpri-1.2.2.orig/pri_internal.h libpri-1.2.2/pri_internal.h
---- libpri-1.2.2.orig/pri_internal.h   2005-11-29 19:39:18.000000000 +0100
-+++ libpri-1.2.2/pri_internal.h        2006-04-15 21:57:19.000000000 +0200
+diff -urN libpri-1.2.3.orig/pri_internal.h libpri-1.2.3/pri_internal.h
+--- libpri-1.2.3.orig/pri_internal.h   2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.3/pri_internal.h        2006-04-15 21:57:19.000000000 +0200
 @@ -5,6 +5,8 @@
   *
   * Copyright (C) 2001, Linux Support Services, Inc.
@@ -1532,9 +1536,9 @@ diff -urN libpri-1.2.2.orig/pri_internal.h libpri-1.2.2/pri_internal.h
  extern void pri_error(struct pri *pri, char *fmt, ...);
  
  void libpri_copy_string(char *dst, const char *src, size_t size);
-diff -urN libpri-1.2.2.orig/pri_q921.h libpri-1.2.2/pri_q921.h
---- libpri-1.2.2.orig/pri_q921.h       2005-11-29 19:39:18.000000000 +0100
-+++ libpri-1.2.2/pri_q921.h    2006-04-15 21:57:24.000000000 +0200
+diff -urN libpri-1.2.3.orig/pri_q921.h libpri-1.2.3/pri_q921.h
+--- libpri-1.2.3.orig/pri_q921.h       2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.3/pri_q921.h    2006-04-15 21:57:24.000000000 +0200
 @@ -5,6 +5,8 @@
   *
   * Copyright (C) 2001, Linux Support Services, Inc.
@@ -1576,9 +1580,9 @@ diff -urN libpri-1.2.2.orig/pri_q921.h libpri-1.2.2/pri_q921.h
 +extern int q921_transmit_iframe(struct pri *pri, void *buf, int len, int cr, int tei);
  
  #endif
-diff -urN libpri-1.2.2.orig/pri_q931.h libpri-1.2.2/pri_q931.h
---- libpri-1.2.2.orig/pri_q931.h       2005-11-29 19:39:18.000000000 +0100
-+++ libpri-1.2.2/pri_q931.h    2006-04-15 21:57:29.000000000 +0200
+diff -urN libpri-1.2.3.orig/pri_q931.h libpri-1.2.3/pri_q931.h
+--- libpri-1.2.3.orig/pri_q931.h       2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.3/pri_q931.h    2006-04-15 21:57:29.000000000 +0200
 @@ -5,6 +5,8 @@
   *
   * Copyright (C) 2001, Linux Support Services, Inc.
@@ -1663,9 +1667,9 @@ diff -urN libpri-1.2.2.orig/pri_q931.h libpri-1.2.2/pri_q931.h
 +//extern int q931_facility(struct pri *pri, q931_call *c, int operation, char *arguments);
 +
  #endif
-diff -urN libpri-1.2.2.orig/pri_timers.h libpri-1.2.2/pri_timers.h
---- libpri-1.2.2.orig/pri_timers.h     2005-11-29 19:39:18.000000000 +0100
-+++ libpri-1.2.2/pri_timers.h  2006-01-18 12:28:07.000000000 +0100
+diff -urN libpri-1.2.3.orig/pri_timers.h libpri-1.2.3/pri_timers.h
+--- libpri-1.2.3.orig/pri_timers.h     2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.3/pri_timers.h  2006-01-18 12:28:07.000000000 +0100
 @@ -27,17 +27,17 @@
  
  /* -1 means we dont currently support the timer/counter */
@@ -1689,9 +1693,9 @@ diff -urN libpri-1.2.2.orig/pri_timers.h libpri-1.2.2/pri_timers.h
                                -1,     /* T304 */ \
                                30000,  /* T305 */ \
                                -1,     /* T306 */ \
-diff -urN libpri-1.2.2.orig/pridump.c libpri-1.2.2/pridump.c
---- libpri-1.2.2.orig/pridump.c        2005-11-29 19:39:18.000000000 +0100
-+++ libpri-1.2.2/pridump.c     2006-01-18 12:28:07.000000000 +0100
+diff -urN libpri-1.2.3.orig/pridump.c libpri-1.2.3/pridump.c
+--- libpri-1.2.3.orig/pridump.c        2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.3/pridump.c     2006-01-18 12:28:07.000000000 +0100
 @@ -1,9 +1,9 @@
  /*
   * libpri: An implementation of Primary Rate ISDN
@@ -1704,9 +1708,9 @@ diff -urN libpri-1.2.2.orig/pridump.c libpri-1.2.2/pridump.c
   * All Rights Reserved.
   *
   * This program is free software; you can redistribute it and/or modify
-diff -urN libpri-1.2.2.orig/prisched.c libpri-1.2.2/prisched.c
---- libpri-1.2.2.orig/prisched.c       2005-11-29 19:39:18.000000000 +0100
-+++ libpri-1.2.2/prisched.c    2006-04-15 21:57:42.000000000 +0200
+diff -urN libpri-1.2.3.orig/prisched.c libpri-1.2.3/prisched.c
+--- libpri-1.2.3.orig/prisched.c       2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.3/prisched.c    2006-04-15 21:57:42.000000000 +0200
 @@ -1,10 +1,12 @@
  /*
   * libpri: An implementation of Primary Rate ISDN
@@ -1843,9 +1847,9 @@ diff -urN libpri-1.2.2.orig/prisched.c libpri-1.2.2/prisched.c
 +      pri->pri_sched[id].callback2 = NULL;
  }
 +
-diff -urN libpri-1.2.2.orig/pritest.c libpri-1.2.2/pritest.c
---- libpri-1.2.2.orig/pritest.c        2005-11-29 19:39:18.000000000 +0100
-+++ libpri-1.2.2/pritest.c     2006-01-18 12:28:07.000000000 +0100
+diff -urN libpri-1.2.3.orig/pritest.c libpri-1.2.3/pritest.c
+--- libpri-1.2.3.orig/pritest.c        2005-11-29 19:39:18.000000000 +0100
++++ libpri-1.2.3/pritest.c     2006-01-18 12:28:07.000000000 +0100
 @@ -1,9 +1,9 @@
  /*
   * libpri: An implementation of Primary Rate ISDN
@@ -1904,9 +1908,9 @@ diff -urN libpri-1.2.2.orig/pritest.c libpri-1.2.2/pritest.c
        default:
                fprintf(stderr, "--!! Unknown PRI event %d\n", e->e);
        }
-diff -urN libpri-1.2.2.orig/q921.c libpri-1.2.2/q921.c
---- libpri-1.2.2.orig/q921.c   2005-12-06 22:35:50.000000000 +0100
-+++ libpri-1.2.2/q921.c        2006-04-24 13:44:24.000000000 +0200
+diff -urN libpri-1.2.3.orig/q921.c libpri-1.2.3/q921.c
+--- libpri-1.2.3.orig/q921.c   2005-12-06 22:35:50.000000000 +0100
++++ libpri-1.2.3/q921.c        2006-06-15 14:55:46.000000000 +0200
 @@ -1,10 +1,12 @@
  /*
   * libpri: An implementation of Primary Rate ISDN
@@ -3385,14 +3389,14 @@ diff -urN libpri-1.2.2.orig/q921.c libpri-1.2.2/q921.c
 +                  q921_rr(pri, h->s.p_f, 0, h->h.tei);
 +//            }
 +          }
-        }
--         pri->busy = 1;
--         break;   
++       }
 +         pri->busy[teio] = 1;
 +       if (pri->t200_timer[teio]) {
 +          pri_schedule_del(pri, pri->t200_timer[teio]);
 +          pri->t200_timer[teio] = 0;
-+       }
+        }
+-         pri->busy = 1;
+-         break;   
 +       pri->t200_timer[teio] = pri_schedule_event2(pri, pri->timers[PRI_TIMER_T200], t200_expire, pri, h->h.tei);
 +         break;
        case 2:
@@ -3515,7 +3519,7 @@ diff -urN libpri-1.2.2.orig/q921.c libpri-1.2.2/q921.c
                                        return ev;
                                                
                                } else {
-@@ -830,21 +1602,144 @@
+@@ -830,21 +1602,148 @@
                                                pri_message(pri, "-- Ignoring unsolicited DM with p/f set to 0\n");
  #if 0
                                        /* Requesting that we start */
@@ -3625,16 +3629,16 @@ diff -urN libpri-1.2.2.orig/q921.c libpri-1.2.2/q921.c
 +                                      } 
 +                                      break;
 +                                      case Q931_PROTOCOL_DISCRIMINATOR:
-+                                          if (pri->localtype == BRI_CPE_PTMP) {
-+                                          res = q931_receive(pri, (q931_h *)h->u.data, len-3, h->h.tei);
-+                                          /* Send an RR if one wasn't sent already */
-+                                          if (pri->v_na[teio] != pri->v_r[teio]) 
-+                                              q921_rr(pri, 0, 0, pri->tei);
-+                                          if (res == -1) {
-+                                              return NULL;
-+                                          }
-+                                          if (res & Q931_RES_HAVEEVENT)
-+                                              return &pri->ev;
++                                          if ((pri->localtype == BRI_CPE_PTMP) || (pri->localtype == BRI_CPE)){ 
++                                              res = q931_receive(pri, (q931_h *)h->u.data, len-3, h->h.tei);
++                                              /* Send an RR if one wasn't sent already */
++                                              if (pri->v_na[teio] != pri->v_r[teio]) 
++                                                  q921_rr(pri, 0, 0, pri->tei);
++                                              if (res == -1) {
++                                                  return NULL;
++                                              }
++                                              if (res & Q931_RES_HAVEEVENT)
++                                                  return &pri->ev;
 +                                          }
 +                                      break;
 +                                  }
@@ -3656,17 +3660,21 @@ diff -urN libpri-1.2.2.orig/q921.c libpri-1.2.2/q921.c
 -                      q921_start(pri, 0);
 +                      q921_send_ua(pri, h->u.p_f, h->h.tei);
 +                      ev = q921_dchannel_down(pri, h->h.tei);
++#ifndef LAYER2ALWAYSUP
 +                      if ((pri->localtype == BRI_CPE_PTMP) || (pri->localtype == BRI_CPE) || (pri->localtype == BRI_NETWORK)) {
 +                          /* release layer 2 */
 +                          return NULL;
 +                      }
 +                      if ((pri->localtype == PRI_NETWORK) || (pri->localtype == PRI_CPE)){
++#endif
 +                          q921_start(pri, 0, 0);
++#ifndef LAYER2ALWAYSUP
 +                      }
++#endif
                        return ev;
                case 3:
                        if (h->u.m2 == 3) {
-@@ -866,17 +1761,28 @@
+@@ -866,17 +1765,28 @@
                                        }
                                }
                                /* Send Unnumbered Acknowledgement */
@@ -3701,7 +3709,7 @@ diff -urN libpri-1.2.2.orig/q921.c libpri-1.2.2/q921.c
                        } else 
                                pri_error(pri, "!! Weird frame received (m3=3, m2 = %d)\n", h->u.m2);
                        break;
-@@ -901,19 +1807,42 @@
+@@ -901,19 +1811,42 @@
        /* Discard FCS */
        len -= 2;
        
@@ -3751,7 +3759,7 @@ diff -urN libpri-1.2.2.orig/q921.c libpri-1.2.2/q921.c
  #ifdef PROCESS_SUBCHANNELS
                /* If it's not us, try any subchannels we have */
                if (pri->subchannel)
-@@ -921,10 +1850,16 @@
+@@ -921,10 +1854,16 @@
                else 
  #endif
                        return NULL;
@@ -3770,7 +3778,7 @@ diff -urN libpri-1.2.2.orig/q921.c libpri-1.2.2/q921.c
        return ev;
  }
  
-@@ -938,14 +1873,58 @@
+@@ -938,14 +1877,58 @@
        return e;
  }
  
@@ -3837,9 +3845,9 @@ diff -urN libpri-1.2.2.orig/q921.c libpri-1.2.2/q921.c
 -      /* Do the SABME XXX Maybe we should implement T_WAIT? XXX */
 -      q921_send_sabme(pri, now);
  }
-diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
---- libpri-1.2.2.orig/q931.c   2006-01-17 14:43:18.000000000 +0100
-+++ libpri-1.2.2/q931.c        2006-04-24 10:35:43.000000000 +0200
+diff -urN libpri-1.2.3.orig/q931.c libpri-1.2.3/q931.c
+--- libpri-1.2.3.orig/q931.c   2006-04-27 18:08:39.000000000 +0200
++++ libpri-1.2.3/q931.c        2006-06-13 10:53:33.000000000 +0200
 @@ -1,10 +1,12 @@
  /*
   * libpri: An implementation of Primary Rate ISDN
@@ -4016,20 +4024,22 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
        pri_error(pri, "!! No channel map, no channel, and no ds1?  What am I supposed to identify?\n");
        return -1;
  }
-@@ -734,8 +797,12 @@
+@@ -734,9 +797,13 @@
        return code2str(pres, press, sizeof(press) / sizeof(press[0]));
  }
  
 -static void q931_get_number(unsigned char *num, int maxlen, unsigned char *src, int len)
 +static void q931_get_number(char *num, int maxlen, unsigned char *src, int len)
  {
+-      if ((len < 0) || (len > maxlen - 1)) {
 +      if (len < 0) {
 +          pri_error(NULL, "q931_get_number received invalid len = %d\n", len);
 +          return;
 +      }
-       if (len > maxlen - 1) {
++      if (len > maxlen - 1) {
                num[0] = 0;
                return;
+       }
 @@ -746,50 +813,75 @@
  
  static FUNC_DUMP(dump_called_party_number)
@@ -4098,14 +4108,14 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
  static FUNC_DUMP(dump_calling_party_subaddr)
  {
 -      unsigned char cnum[256];
--      q931_get_number(cnum, sizeof(cnum), ie->data + 2, len - 4);
+-      q931_get_number(cnum, sizeof(cnum), ie->data + 1, len - 3);
 -      pri_message(pri, "%c Calling Sub-Address (len=%2d) [ Ext: %d  Type: %s (%d) O: %d '%s' ]\n",
 -              prefix, len, ie->data[0] >> 7,
 -              subaddrtype2str((ie->data[0] & 0x70) >> 4), (ie->data[0] & 0x70) >> 4,
 -              (ie->data[0] & 0x08) >> 3, cnum);
 +      char cnum[256];
 +      if (len >= 4) {
-+          q931_get_number(cnum, sizeof(cnum), ie->data + 2, len - 4);
++          q931_get_number(cnum, sizeof(cnum), ie->data + 1, len - 3);
 +          pri_message(pri, "%c Calling Sub-Address (len=%2d) [ Ext: %d  Type: %s (%d) O: %d '%s' ]\n",
 +              prefix, len, ie->data[0] >> 7,
 +              subaddrtype2str((ie->data[0] & 0x70) >> 4), (ie->data[0] & 0x70) >> 4,
@@ -4213,9 +4223,9 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
  static FUNC_RECV(receive_calling_party_subaddr)
  {
        /* copy digits to call->callingsubaddr */
--      q931_get_number((unsigned char *) call->callingsubaddr, sizeof(call->callingsubaddr), ie->data + 2, len - 4);
+-      q931_get_number((unsigned char *) call->callingsubaddr, sizeof(call->callingsubaddr), ie->data + 1, len - 3);
 +      if (len >= 4) {
-+          q931_get_number(call->callingsubaddr, sizeof(call->callingsubaddr), ie->data + 2, len - 4);
++          q931_get_number(call->callingsubaddr, sizeof(call->callingsubaddr), ie->data + 1, len - 3);
 +      } else {
 +          pri_error(call->pri, "Calling Party Subaddress (len=%2d) too short.\n", len);
 +      }
@@ -5439,7 +5449,11 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
        if (channel) { 
                c->ds1no = (channel & 0xff00) >> 8;
                c->ds1explicit = (channel & 0x10000) >> 16;
-@@ -2569,9 +3351,36 @@
+@@ -2566,12 +3348,40 @@
+               c->progressmask = PRI_PROG_CALLED_NOT_ISDN;
+       } else
+               c->progressmask = 0;
++c->progressmask = PRI_PROG_INBAND_AVAILABLE;
        c->ourcallstate = Q931_CALL_STATE_OVERLAP_RECEIVING;
        c->peercallstate = Q931_CALL_STATE_OVERLAP_SENDING;
        c->alive = 1;
@@ -5476,7 +5490,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
  static void pri_connect_timeout(void *data)
  {
        struct q931_call *c = data;
-@@ -2624,6 +3433,7 @@
+@@ -2624,6 +3434,7 @@
  
  int q931_connect(struct pri *pri, q931_call *c, int channel, int nonisdn)
  {
@@ -5484,7 +5498,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
        if (channel) { 
                c->ds1no = (channel & 0xff00) >> 8;
                c->ds1explicit = (channel & 0x10000) >> 16;
-@@ -2638,22 +3448,37 @@
+@@ -2638,22 +3449,37 @@
                c->progressmask = PRI_PROG_CALLED_NOT_ISDN;
        } else
                c->progressmask = 0;
@@ -5525,7 +5539,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
        c->ourcallstate = Q931_CALL_STATE_RELEASE_REQUEST;
        /* c->peercallstate stays the same */
        if (c->alive) {
-@@ -2669,7 +3494,14 @@
+@@ -2669,7 +3495,14 @@
                        } else {
                                c->retranstimer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T308], pri_release_finaltimeout, c);
                        }
@@ -5541,7 +5555,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
                } else
                        return send_message(pri, c, Q931_RELEASE_COMPLETE, release_ies); /* Yes, release_ies, not release_complete_ies */
        } else
-@@ -2681,7 +3513,7 @@
+@@ -2681,7 +3514,7 @@
  int q931_restart(struct pri *pri, int channel)
  {
        struct q931_call *c;
@@ -5550,7 +5564,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
        if (!c)
                return -1;
        if (!channel)
-@@ -2698,10 +3530,12 @@
+@@ -2698,10 +3531,12 @@
        return send_message(pri, c, Q931_RESTART, restart_ies);
  }
  
@@ -5563,7 +5577,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
        c->ourcallstate = Q931_CALL_STATE_DISCONNECT_REQUEST;
        c->peercallstate = Q931_CALL_STATE_DISCONNECT_INDICATION;
        if (c->alive) {
-@@ -2713,14 +3547,27 @@
+@@ -2713,14 +3548,27 @@
                if (c->retranstimer)
                        pri_schedule_del(pri, c->retranstimer);
                c->retranstimer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T305], pri_disconnect_timeout, c);
@@ -5592,7 +5606,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
  static int gr303_setup_ies[] =  { Q931_BEARER_CAPABILITY, Q931_CHANNEL_IDENT, -1 };
  
  static int cis_setup_ies[] = { Q931_BEARER_CAPABILITY, Q931_CHANNEL_IDENT, Q931_IE_FACILITY, Q931_CALLED_PARTY_NUMBER, -1 };
-@@ -2728,7 +3575,12 @@
+@@ -2728,7 +3576,12 @@
  int q931_setup(struct pri *pri, q931_call *c, struct pri_sr *req)
  {
        int res;
@@ -5606,7 +5620,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
        
        c->transcapability = req->transmode;
        c->transmoderate = TRANS_MODE_64_CIRCUIT;
-@@ -2753,6 +3605,7 @@
+@@ -2753,6 +3606,7 @@
                c->chanflags = FLAG_EXCLUSIVE;
        else if (c->channelno)
                c->chanflags = FLAG_PREFERRED;
@@ -5614,7 +5628,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
        if (req->caller) {
                libpri_copy_string(c->callernum, req->caller, sizeof(c->callernum));
                c->callerplan = req->callerplan;
-@@ -2812,14 +3665,19 @@
+@@ -2812,14 +3666,19 @@
                res = send_message(pri, c, Q931_SETUP, gr303_setup_ies);
        else if (c->justsignalling)
                res = send_message(pri, c, Q931_SETUP, cis_setup_ies);
@@ -5634,7 +5648,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
        }
        return res;
        
-@@ -2835,7 +3693,11 @@
+@@ -2835,7 +3694,11 @@
        if (cause > -1) {
                c->cause = cause;
                c->causecode = CODE_CCITT;
@@ -5647,7 +5661,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
                /* release_ies has CAUSE in it */
                res = send_message(pri, c, Q931_RELEASE_COMPLETE, release_ies);
        } else
-@@ -2860,6 +3722,117 @@
+@@ -2860,6 +3723,117 @@
        return 0;
  }
  
@@ -5765,7 +5779,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
  int q931_hangup(struct pri *pri, q931_call *c, int cause)
  {
        int disconnect = 1;
-@@ -2871,7 +3844,7 @@
+@@ -2871,7 +3845,7 @@
        /* If mandatory IE was missing, insist upon that cause code */
        if (c->cause == PRI_CAUSE_MANDATORY_IE_MISSING)
                cause = c->cause;
@@ -5774,7 +5788,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
                /* We'll send RELEASE_COMPLETE with these causes */
                disconnect = 0;
                release_compl = 1;
-@@ -2885,7 +3858,7 @@
+@@ -2885,7 +3859,7 @@
        case Q931_CALL_STATE_NULL:
                if (c->peercallstate == Q931_CALL_STATE_NULL)
                        /* free the resources if we receive or send REL_COMPL */
@@ -5783,7 +5797,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
                else if (c->peercallstate == Q931_CALL_STATE_RELEASE_REQUEST)
                        q931_release_complete(pri,c,cause);
                break;
-@@ -2911,6 +3884,11 @@
+@@ -2911,6 +3885,11 @@
                /* received SETUP_ACKNOWLEDGE */
                /* send DISCONNECT in general */
                if (c->peercallstate != Q931_CALL_STATE_NULL && c->peercallstate != Q931_CALL_STATE_DISCONNECT_REQUEST && c->peercallstate != Q931_CALL_STATE_DISCONNECT_INDICATION && c->peercallstate != Q931_CALL_STATE_RELEASE_REQUEST && c->peercallstate != Q931_CALL_STATE_RESTART_REQUEST && c->peercallstate != Q931_CALL_STATE_RESTART) {
@@ -5795,7 +5809,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
                        if (disconnect)
                                q931_disconnect(pri,c,cause);
                        else if (release_compl)
-@@ -2926,8 +3904,14 @@
+@@ -2926,8 +3905,14 @@
                break;
        case Q931_CALL_STATE_DISCONNECT_INDICATION:
                /* received DISCONNECT */
@@ -5810,7 +5824,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
                        q931_release(pri,c,cause);
                }
                break;
-@@ -2941,19 +3925,17 @@
+@@ -2941,19 +3926,17 @@
                pri_error(pri, "q931_hangup shouldn't be called in this state, ourstate %s, peerstate %s\n",callstate2str(c->ourcallstate),callstate2str(c->peercallstate));
                break;
        default:
@@ -5833,7 +5847,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
        q931_call *c;
        q931_ie *ie;
        unsigned int x;
-@@ -2965,6 +3947,7 @@
+@@ -2965,6 +3948,7 @@
        int codeset, cur_codeset;
        int last_ie[8];
        struct apdu_event *cur = NULL;
@@ -5841,7 +5855,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
  
        memset(last_ie, 0, sizeof(last_ie));
        if (pri->debug & PRI_DEBUG_Q931_DUMP)
-@@ -2978,13 +3961,13 @@
+@@ -2978,13 +3962,13 @@
                   KLUDGE this by changing byte 4 from a 0xf (SERVICE) 
                   to a 0x7 (SERVICE ACKNOWLEDGE) */
                h->raw[h->crlen + 2] -= 0x8;
@@ -5857,7 +5871,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
        if (!c) {
                pri_error(pri, "Unable to locate call %d\n", q931_cr(h));
                return -1;
-@@ -3007,6 +3990,7 @@
+@@ -3007,6 +3991,7 @@
        case Q931_SETUP:
                if (pri->debug & PRI_DEBUG_Q931_STATE)
                        pri_message(pri, "-- Processing Q.931 Call Setup\n");
@@ -5865,7 +5879,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
                c->channelno = -1;
                c->slotmap = -1;
                c->chanflags = 0;
-@@ -3027,28 +4011,44 @@
+@@ -3027,28 +4012,44 @@
                c->callername[0] = '\0';
                c->callerani[0] = '\0';
                c->callerplanani = -1;
@@ -5920,7 +5934,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
                c->progress = -1;
                c->progressmask = 0;
                break;
-@@ -3059,20 +4059,22 @@
+@@ -3059,20 +4060,22 @@
                break;
        case Q931_RELEASE:
        case Q931_DISCONNECT:
@@ -5950,7 +5964,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
        case Q931_STATUS:
                c->cause = -1;
                c->causecode = -1;
-@@ -3089,22 +4091,32 @@
+@@ -3089,22 +4092,32 @@
        case Q931_STATUS_ENQUIRY:
                break;
        case Q931_SETUP_ACKNOWLEDGE:
@@ -5987,7 +6001,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
        case Q931_SUSPEND_ACKNOWLEDGE:
        case Q931_SUSPEND_REJECT:
                pri_error(pri, "!! Not yet handling pre-handle message type %s (%d)\n", msg2str(mh->msg), mh->msg);
-@@ -3113,7 +4125,7 @@
+@@ -3113,7 +4126,7 @@
                pri_error(pri, "!! Don't know how to post-handle message type %s (%d)\n", msg2str(mh->msg), mh->msg);
                q931_status(pri,c, PRI_CAUSE_MESSAGE_TYPE_NONEXIST);
                if (c->newcall) 
@@ -5996,7 +6010,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
                return -1;
        }
        memset(mandies, 0, sizeof(mandies));
-@@ -3193,12 +4205,19 @@
+@@ -3193,12 +4206,19 @@
        missingmand = 0;
        for (x=0;x<MAX_MAND_IES;x++) {
                if (mandies[x]) {
@@ -6021,7 +6035,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
                }
        }
        
-@@ -3207,7 +4226,7 @@
+@@ -3207,7 +4227,7 @@
        case Q931_RESTART:
                if (missingmand) {
                        q931_status(pri, c, PRI_CAUSE_MANDATORY_IE_MISSING);
@@ -6030,7 +6044,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
                        break;
                }
                c->ourcallstate = Q931_CALL_STATE_RESTART;
-@@ -3225,6 +4244,7 @@
+@@ -3225,6 +4245,7 @@
                }
                /* Must be new call */
                if (!c->newcall) {
@@ -6038,7 +6052,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
                        break;
                }
                if (c->progressmask & PRI_PROG_CALLER_NOT_ISDN)
-@@ -3242,16 +4262,20 @@
+@@ -3242,16 +4263,20 @@
                pri->ev.ring.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
                pri->ev.ring.callingpres = c->callerpres;
                pri->ev.ring.callingplan = c->callerplan;
@@ -6061,7 +6075,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
                libpri_copy_string(pri->ev.ring.origcalledname, c->origcalledname, sizeof(pri->ev.ring.origcalledname));
                libpri_copy_string(pri->ev.ring.origcallednum, c->origcallednum, sizeof(pri->ev.ring.origcallednum));
                  libpri_copy_string(pri->ev.ring.redirectingnum, c->redirectingnum, sizeof(pri->ev.ring.redirectingnum));
-@@ -3261,11 +4285,13 @@
+@@ -3261,11 +4286,13 @@
                pri->ev.ring.redirectingreason = c->redirectingreason;
                pri->ev.ring.origredirectingreason = c->origredirectingreason;
                pri->ev.ring.flexible = ! (c->chanflags & FLAG_EXCLUSIVE);
@@ -6076,7 +6090,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
                pri->ev.ring.redirectingreason = c->redirectingreason;
                pri->ev.ring.progress = c->progress;
                pri->ev.ring.progressmask = c->progressmask;
-@@ -3275,6 +4301,9 @@
+@@ -3275,6 +4302,9 @@
                        q931_release_complete(pri,c,PRI_CAUSE_INVALID_CALL_REFERENCE);
                        break;
                }
@@ -6086,7 +6100,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
                c->ourcallstate = Q931_CALL_STATE_CALL_DELIVERED;
                c->peercallstate = Q931_CALL_STATE_CALL_RECEIVED;
                pri->ev.e = PRI_EVENT_RINGING;
-@@ -3295,17 +4324,24 @@
+@@ -3295,17 +4325,24 @@
                        q931_status(pri, c, PRI_CAUSE_WRONG_MESSAGE);
                        break;
                }
@@ -6111,7 +6125,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
                if (c->justsignalling) {  /* Make sure WE release when we initiatie a signalling only connection */
                        q931_release(pri, c, PRI_CAUSE_NORMAL_CLEARING);
                        break;
-@@ -3313,23 +4349,43 @@
+@@ -3313,23 +4350,43 @@
                        return Q931_RES_HAVEEVENT;
        case Q931_FACILITY:
                if (c->newcall) {
@@ -6168,7 +6182,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
                        break;
                }
                pri->ev.e = PRI_EVENT_PROGRESS;
-@@ -3347,6 +4403,11 @@
+@@ -3347,6 +4404,11 @@
                        q931_status(pri,c,PRI_CAUSE_WRONG_MESSAGE);
                        break;
                }
@@ -6180,7 +6194,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
                pri->ev.proceeding.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
                if (mh->msg == Q931_CALL_PROCEEDING) {
                        pri->ev.e = PRI_EVENT_PROCEEDING;
-@@ -3364,16 +4425,21 @@
+@@ -3364,16 +4426,21 @@
                        break;
                }
                if (c->ourcallstate != Q931_CALL_STATE_CONNECT_REQUEST) {
@@ -6204,7 +6218,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
                        break;
                }
                if (c->newcall) {
-@@ -3410,31 +4476,69 @@
+@@ -3410,31 +4477,69 @@
                        if (res)
                                return res;
                }
@@ -6298,7 +6312,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
                break;
        case Q931_RELEASE:
                if (missingmand) {
-@@ -3450,6 +4554,7 @@
+@@ -3450,6 +4555,7 @@
                pri->ev.e = PRI_EVENT_HANGUP;
                pri->ev.hangup.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
                pri->ev.hangup.cref = c->cr;
@@ -6306,7 +6320,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
                pri->ev.hangup.cause = c->cause;
                pri->ev.hangup.call = c;
                pri->ev.hangup.aoc_units = c->aoc_units;
-@@ -3478,9 +4583,16 @@
+@@ -3478,9 +4584,16 @@
                pri->ev.e = PRI_EVENT_HANGUP_REQ;
                pri->ev.hangup.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
                pri->ev.hangup.cref = c->cr;
@@ -6323,7 +6337,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
                if (c->alive)
                        return Q931_RES_HAVEEVENT;
                else
-@@ -3511,7 +4623,7 @@
+@@ -3511,7 +4624,7 @@
                pri->ev.e = PRI_EVENT_INFO_RECEIVED;
                pri->ev.ring.call = c;
                pri->ev.ring.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
@@ -6332,16 +6346,15 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
                libpri_copy_string(pri->ev.ring.callingsubaddr, c->callingsubaddr, sizeof(pri->ev.ring.callingsubaddr));
                pri->ev.ring.complete = c->complete;    /* this covers IE 33 (Sending Complete) */
                return Q931_RES_HAVEEVENT;
-@@ -3530,7 +4642,7 @@
-               c->peercallstate = Q931_CALL_STATE_OVERLAP_RECEIVING;
+@@ -3531,7 +4644,6 @@
                pri->ev.e = PRI_EVENT_SETUP_ACK;
                pri->ev.setup_ack.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
+               pri->ev.setup_ack.call = c;
 -
-+              pri->ev.setup_ack.call = c;
                cur = c->apdus;
                while (cur) {
                        if (!cur->sent && cur->message == Q931_FACILITY) {
-@@ -3546,19 +4658,53 @@
+@@ -3547,19 +4659,53 @@
                pri->ev.notify.channel = c->channelno;
                pri->ev.notify.info = c->notify;
                return Q931_RES_HAVEEVENT;
@@ -6399,7 +6412,7 @@ diff -urN libpri-1.2.2.orig/q931.c libpri-1.2.2/q931.c
        case Q931_SUSPEND_ACKNOWLEDGE:
        case Q931_SUSPEND_REJECT:
                pri_error(pri, "!! Not yet handling post-handle message type %s (%d)\n", msg2str(mh->msg), mh->msg);
-@@ -3568,7 +4714,7 @@
+@@ -3569,7 +4715,7 @@
                pri_error(pri, "!! Don't know how to post-handle message type %s (%d)\n", msg2str(mh->msg), mh->msg);
                q931_status(pri,c, PRI_CAUSE_MESSAGE_TYPE_NONEXIST);
                if (c->newcall) 
index c0d85877f0eb93cb27d6eeb192c51348b2f1178c..c6be661c989799407404337cfd94bc2b11487feb 100644 (file)
@@ -1,8 +1,38 @@
-Only in zaptel-1.2.5: version.h
-Only in zaptel-1.2.5: zaptel
-diff -ur zaptel-1.2.5.orig/zaptel.c zaptel-1.2.5/zaptel.c
---- zaptel-1.2.5.orig/zaptel.c 2005-12-17 03:04:05.000000000 +0100
-+++ zaptel-1.2.5/zaptel.c      2006-04-10 10:39:37.000000000 +0200
+diff -urN zaptel-1.2.6.orig/Makefile zaptel-1.2.6/Makefile
+--- zaptel-1.2.6.orig/Makefile 2006-05-23 01:11:36.000000000 +0200
++++ zaptel-1.2.6/Makefile      2006-06-06 14:54:33.000000000 +0200
+@@ -124,7 +124,7 @@
+ ifneq (,$(wildcard /usr/include/newt.h))
+ ZTTOOL:=zttool
+ endif
+-BINS=ztcfg torisatool makefw ztmonitor ztspeed $(ZTTOOL) zttest fxotune
++BINS=ztcfg torisatool makefw ztmonitor ztspeed $(ZTTOOL) zttest fxotune ztpty
+ all: $(BUILDVER) $(LIBTONEZONE_SO)
+@@ -209,6 +209,9 @@
+ ztmonitor.o: ztmonitor.c zaptel.h
++ztpty.o: ztpty.c
++      $(CC) -o $@ -c $^
++
+ ztspeed.o: ztspeed.c
+       $(CC) -o $@ -c $^
+@@ -221,6 +224,9 @@
+ ztspeed: ztspeed.o
+       $(CC) -o $@ $^
++ztpty: ztpty.o
++      $(CC) -o $@ $^
++
+ sethdlc-new: sethdlc-new.o
+       $(CC) -o $@ $^
+diff -urN zaptel-1.2.6.orig/zaptel.c zaptel-1.2.6/zaptel.c
+--- zaptel-1.2.6.orig/zaptel.c 2005-12-17 03:04:05.000000000 +0100
++++ zaptel-1.2.6/zaptel.c      2006-06-06 14:54:33.000000000 +0200
 @@ -4913,11 +4913,40 @@
                                        *(txb++) = fasthdlc_tx_run_nocheck(&ms->txhdlc);
                                }
@@ -116,9 +146,9 @@ diff -ur zaptel-1.2.5.orig/zaptel.c zaptel-1.2.5/zaptel.c
                        } else {
                                /* Not HDLC */
                                memcpy(buf + ms->readidx[ms->inreadbuf], rxb, left);
-diff -ur zaptel-1.2.5.orig/zaptel.h zaptel-1.2.5/zaptel.h
---- zaptel-1.2.5.orig/zaptel.h 2005-12-17 03:04:05.000000000 +0100
-+++ zaptel-1.2.5/zaptel.h      2006-04-10 10:39:37.000000000 +0200
+diff -urN zaptel-1.2.6.orig/zaptel.h zaptel-1.2.6/zaptel.h
+--- zaptel-1.2.6.orig/zaptel.h 2005-12-17 03:04:05.000000000 +0100
++++ zaptel-1.2.6/zaptel.h      2006-06-06 14:54:33.000000000 +0200
 @@ -994,6 +994,13 @@
        int do_ppp_error;
        struct sk_buff_head ppp_rq;
@@ -153,9 +183,9 @@ diff -ur zaptel-1.2.5.orig/zaptel.h zaptel-1.2.5/zaptel.h
  struct zt_span {
        spinlock_t lock;
        void *pvt;                      /* Private stuff */
-diff -ur zaptel-1.2.5.orig/zconfig.h zaptel-1.2.5/zconfig.h
---- zaptel-1.2.5.orig/zconfig.h        2005-11-29 19:42:08.000000000 +0100
-+++ zaptel-1.2.5/zconfig.h     2006-04-10 10:39:37.000000000 +0200
+diff -urN zaptel-1.2.6.orig/zconfig.h zaptel-1.2.6/zconfig.h
+--- zaptel-1.2.6.orig/zconfig.h        2005-11-29 19:42:08.000000000 +0100
++++ zaptel-1.2.6/zconfig.h     2006-06-06 14:54:33.000000000 +0200
 @@ -152,4 +152,10 @@
   */
  /* #define FXSFLASH */
@@ -167,3 +197,119 @@ diff -ur zaptel-1.2.5.orig/zconfig.h zaptel-1.2.5/zconfig.h
 +#define CONFIG_ZAPATA_BRI_DCHANS
 +
  #endif
+diff -urN zaptel-1.2.6.orig/ztpty.c zaptel-1.2.6/ztpty.c
+--- zaptel-1.2.6.orig/ztpty.c  1970-01-01 01:00:00.000000000 +0100
++++ zaptel-1.2.6/ztpty.c       2006-06-06 14:54:33.000000000 +0200
+@@ -0,0 +1,112 @@
++#include <stdio.h>
++#include <stdlib.h>
++#include <unistd.h>
++#include <errno.h>
++#include <string.h>
++#include <fcntl.h>
++#include <sys/time.h>
++#include <sys/signal.h>
++#include <sys/select.h>
++#include <math.h>
++#include "zaptel.h"
++
++#define SIZE 8000
++
++
++
++void doit(int fd, int stdinfd) {
++    fd_set fds;
++    char inbuffer[4096];
++    char outbuffer[4096];
++    int res = 0;
++    int i = 0;
++
++//    fprintf(stderr, "fd %d stdin fd %d\n", fd, stdinfd);
++
++    for (;;) {
++      FD_ZERO(&fds);
++        FD_SET(fd, &fds);
++      FD_SET(stdinfd, &fds);
++        /* Wait for *some* sort of I/O */
++        res = select(stdinfd + 1, &fds, NULL, NULL, NULL);
++        if (res < 0) {
++                fprintf(stderr, "Error in select: %s\n", strerror(errno));
++                return;
++        }
++        if (FD_ISSET(stdinfd, &fds)) {
++            res = read(stdinfd, inbuffer, sizeof(inbuffer));
++          if (res > 0) {
++//            fprintf(stderr, "read %d bytes from stdin\n", res);
++              if (res > 0) {
++                  for (i=0; i < res ; i++) {
++                      if (inbuffer[i] == '\n') {
++                          if ((i > 0) && (inbuffer[i-1] == ' ')) {
++                              inbuffer[i-1] = 0x1a;
++                          }
++                          inbuffer[i] = 0xd;
++                      }
++                  }
++              res = write(fd, inbuffer, res+2);
++//            res = write(STDOUT_FILENO, inbuffer, res);
++//            fprintf(stderr, "wrote %d bytes to stdout\n", res);
++              }
++          }
++        }
++        if (FD_ISSET(fd, &fds)) {
++            res = read(fd, outbuffer, sizeof(outbuffer));
++//        fprintf(stderr, "read %d bytes from fd\n", res);
++          if (res > 0) {
++              res = write(STDOUT_FILENO, outbuffer, res);
++//            fprintf(stderr, "wrote %d bytes to stdout\n", res);
++          }
++        }
++    }
++
++
++}
++
++int main(int argc, char *argv[])
++{
++      int fd;
++      int stdinfd;
++      struct zt_params p;
++      struct zt_bufferinfo bi;
++      int blocksize=0;
++      fd = open(argv[1], O_RDWR | O_NONBLOCK);
++      if (fd < 0) {
++              fprintf(stderr, "Unable to open zap interface: %s\n", strerror(errno));
++              exit(1);
++      }
++      if (ioctl(fd, ZT_GET_PARAMS, &p)) {
++              fprintf(stderr, "Unable to get parameters on '%s': %s\n", argv[1], strerror(errno));
++              exit(1);
++      }
++      if ((p.sigtype != ZT_SIG_HDLCRAW) && (p.sigtype != ZT_SIG_HDLCFCS)) {
++              fprintf(stderr, "%s is in %d signalling, not FCS HDLC or RAW HDLC mode\n", argv[1], p.sigtype);
++              exit(1);
++      }
++
++      if (ioctl(fd, ZT_GET_BLOCKSIZE, &blocksize)) {
++              fprintf(stderr, "Unable to get blocksize on '%s': %s\n", argv[1], strerror(errno));
++              exit(1);
++      } else {
++//            fprintf(stderr, "blocksize %d\n", blocksize);
++      }
++      
++      bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
++        bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
++      bi.numbufs = 16;
++      bi.bufsize = 1024;
++      if (ioctl(fd, ZT_SET_BUFINFO, &bi)) {
++              fprintf(stderr, "Unable to set buffer info on '%s': %s\n", argv[1], strerror(errno));
++              exit(1);
++      }
++
++      stdinfd = open("/dev/stdin", O_RDONLY | O_NONBLOCK);
++
++      
++      doit(fd, stdinfd);
++      close(stdinfd);
++      close(fd);
++      return 0;
++}
index 341c76333fb6839063bfe631a34aa923af634098..787fc514670f1c473740c5c1cb5e4d1470977187 100644 (file)
@@ -27,6 +27,7 @@ else
        tar cfz ../$PROG-$VER-$PAK_VER.tar.gz files.tgz install.sh uninstall.sh ROOTFILES
 
        cd /install/packages && md5sum $PROG*.tar.gz > $PROG-$VER-$PAK_VER.tar.gz.md5
+       cd /install/packages && md5sum $PROG*.tar.gz >> all-progs.md5
        rm -rf /install/packages/package
        exit 0
 fi