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

Tzafrir Cohen tzafrir-guest at costa.debian.org
Fri Jun 16 12:59:15 UTC 2006


Author: tzafrir-guest
Date: 2006-06-16 12:59:11 +0000 (Fri, 16 Jun 2006)
New Revision: 1897

Modified:
   asterisk/branches/sarge/debian/changelog
   asterisk/branches/sarge/debian/patches/bristuff.dpatch
Log:
new version of bristuff: 0.3.0-PRE-1q

Modified: asterisk/branches/sarge/debian/changelog
===================================================================
--- asterisk/branches/sarge/debian/changelog	2006-06-16 09:06:42 UTC (rev 1896)
+++ asterisk/branches/sarge/debian/changelog	2006-06-16 12:59:11 UTC (rev 1897)
@@ -16,7 +16,7 @@
   [ Tzafrir Cohen ]
   * reunite init.d and logrotate scripts in the package asterisk
   * Re-add correct_pid_display.dpatch
-  * bristuff 0.3.0-PRE1p (gsm functionality missing: needs libgstam)
+  * bristuff 0.3.0-PRE1q (gsm functionality missing: needs libgstam)
   * sys_readline.dpatch: Realine support in the CLI. TODO: tab completion
   * sys_editline.dpatch: alternativly, simply use the system version of
     editline (not used).  

Modified: asterisk/branches/sarge/debian/patches/bristuff.dpatch
===================================================================
--- asterisk/branches/sarge/debian/patches/bristuff.dpatch	2006-06-16 09:06:42 UTC (rev 1896)
+++ asterisk/branches/sarge/debian/patches/bristuff.dpatch	2006-06-16 12:59:11 UTC (rev 1897)
@@ -2,19 +2,19 @@
 ## bristuff.dpatch by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
 ##
 ## All lines beginning with `## DP:' are a description of the patch.
-## DP: bristuff support in asterisk: asterisk.patch from bristuff-0.3.0-PRE-1p
+## DP: bristuff support in asterisk: asterisk.patch from bristuff-0.3.0-PRE-1q
 ## DP: cygdef.h removed ;-)
 
 @DPATCH@
-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-1p
-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.
@@ -35,9 +35,9 @@
  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
@@ -50,10 +50,10 @@
  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" ; \
@@ -63,9 +63,9 @@
  		) > $(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.
@@ -75,9 +75,9 @@
  ================================================================
  
  * 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 
@@ -225,9 +225,9 @@
 +	
 +
 +
-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
  #
@@ -246,9 +246,9 @@
  
  %.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.
@@ -425,9 +425,9 @@
 +		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 \
@@ -445,9 +445,9 @@
  
  #
  # 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.
@@ -519,9 +519,9 @@
 +{
 +    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*)
@@ -695,9 +695,9 @@
 +{
 +	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*)
@@ -909,9 +909,9 @@
 +{
 +	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*)
@@ -1009,9 +1009,9 @@
 +{
 +	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);
@@ -1021,10 +1021,140 @@
  					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
 + * 
@@ -1079,7 +1209,7 @@
 +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]))
@@ -1090,6 +1220,9 @@
 +    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);
 +    }
@@ -1181,6 +1314,8 @@
 +        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)) {
@@ -1194,7 +1329,8 @@
 +
 +        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");
@@ -1244,9 +1380,9 @@
 +{
 +    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-25 14:41:03.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.
@@ -1258,8 +1394,8 @@
   * This program is free software, distributed under the terms of
   * the GNU General Public License Version 2. See the LICENSE file
   * at the top of the source tree.
-@@ -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"
@@ -1268,7 +1404,7 @@
  "    L(x[:y][:z]) - Limit the call to 'x' ms. Play a warning when 'y' ms are\n"
  "           left. Repeat the warning every 'z' ms. The following special\n"
  "           variables can be used with this option:\n"
-@@ -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"
@@ -1281,7 +1417,7 @@
  "    t    - Allow the called party to transfer the calling party by sending the\n"
  "           DTMF sequence defined in features.conf.\n"
  "    T    - Allow the calling party to transfer the called party by sending the\n"
-@@ -211,6 +219,8 @@
+@@ -214,6 +222,8 @@
  	OPT_CALLEE_MONITOR = (1 << 21),
  	OPT_CALLER_MONITOR = (1 << 22),
  	OPT_GOTO = (1 << 23),
@@ -1290,7 +1426,7 @@
  } 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),
@@ -1299,7 +1435,7 @@
  	AST_APP_OPTION_ARG('S', OPT_DURATION_STOP, OPT_ARG_DURATION_STOP),
  	AST_APP_OPTION('t', OPT_CALLEE_TRANSFER),
  	AST_APP_OPTION('T', OPT_CALLER_TRANSFER),
-@@ -386,7 +398,7 @@
+@@ -389,7 +401,7 @@
  	char *context = NULL;
  	char cidname[AST_MAX_EXTENSION];
  
@@ -1308,7 +1444,7 @@
  	
  	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 */
@@ -1316,8 +1452,8 @@
 +						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:
@@ -1342,7 +1478,7 @@
  							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;
@@ -1350,34 +1486,32 @@
  
  	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");
  
@@ -1386,7 +1520,7 @@
  	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 */
@@ -1395,7 +1529,7 @@
  		if (!tmp->chan) {
  			/* If we can't, just go on to the next call */
  			ast_log(LOG_NOTICE, "Unable to create channel of type '%s' (cause %d - %s)\n", tech, cause, ast_cause2str(cause));
-@@ -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 */
@@ -1403,30 +1537,31 @@
 +				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,15 @@
+@@ -1599,7 +1621,15 @@
  		}
  		snprintf(toast, sizeof(toast), "%ld", (long)(end_time - start_time));
  		pbx_builtin_setvar_helper(chan, "DIALEDTIME", toast);
@@ -1443,9 +1578,9 @@
  		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"
  
@@ -1455,10 +1590,10 @@
  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;
@@ -1467,7 +1602,7 @@
  			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;
@@ -1478,7 +1613,7 @@
  	char *buf = __buf + AST_FRIENDLY_OFFSET;
  	
  	if (!user) {
-@@ -992,7 +993,7 @@
+@@ -990,7 +991,7 @@
  		}
  		/* Setup buffering information */
  		memset(&bi, 0, sizeof(bi));
@@ -1487,7 +1622,7 @@
  		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;
@@ -1502,7 +1637,7 @@
  				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) {
@@ -1511,9 +1646,9 @@
  				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;
@@ -1549,9 +1684,9 @@
  	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;
@@ -1561,9 +1696,9 @@
  	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));
@@ -1573,9 +1708,9 @@
  
  	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.
@@ -1896,10 +2031,10 @@
 +{
 +	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;
  }
  
@@ -1908,7 +2043,7 @@
  {
  	/* 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 */
@@ -1917,7 +2052,7 @@
  	if (!tmp->chan) {			/* If we can't, just go on to the next call */
  #if 0
  		ast_log(LOG_NOTICE, "Unable to create channel of type '%s' for Queue\n", cur->tech);
-@@ -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 */
@@ -1926,9 +2061,27 @@
  					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"
@@ -1938,9 +2091,9 @@
  
  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
@@ -2017,67 +2170,10 @@
 +{
 +    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 */
@@ -2086,9 +2182,9 @@
  			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";
@@ -2097,7 +2193,7 @@
  
  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));
@@ -2105,18 +2201,18 @@
  
  	/* 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"
@@ -2125,9 +2221,9 @@
  
  #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;
@@ -2277,7 +2373,7 @@
  }
  
  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);
  }
  
@@ -2286,7 +2382,7 @@
  {
  	int state = 0;
  	int cause = 0;
-@@ -2370,7 +2399,7 @@
+@@ -2372,7 +2401,7 @@
  	struct ast_frame *f;
  	int res = 0;
  	
@@ -2295,7 +2391,7 @@
  	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);
  
@@ -2303,7 +2399,7 @@
  		if (!ast_call(chan, data, 0)) {
  			res = 1;	/* in case chan->_state is already AST_STATE_UP */
  			while (timeout && (chan->_state != AST_STATE_UP)) {
-@@ -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)) {
@@ -2311,7 +2407,7 @@
  						state = f->subclass;
  						ast_frfree(f);
  						break;
-@@ -2476,12 +2507,12 @@
+@@ -2478,12 +2509,12 @@
  	return chan;
  }
  
@@ -2327,7 +2423,7 @@
  {
  	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;
  
@@ -2335,7 +2431,7 @@
  		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;
  }
  
@@ -2365,7 +2461,16 @@
  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 @@
  				);
  }
  
@@ -2383,7 +2488,7 @@
  	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;
  }
  
@@ -2394,7 +2499,7 @@
  /*--- 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;
  
@@ -2402,7 +2507,7 @@
  	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;
  	}
@@ -2413,9 +2518,9 @@
  	
  	/* 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
@@ -2483,9 +2588,18 @@
  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)) {
@@ -2495,9 +2609,9 @@
  						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*)
@@ -5387,9 +5501,9 @@
 +{
 +	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);
@@ -5399,9 +5513,9 @@
  		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.
@@ -5412,7 +5526,7 @@
   * This program is free software, distributed under the terms of
   * the GNU General Public License Version 2. See the LICENSE file
   * at the top of the source tree.
-@@ -3065,7 +3068,7 @@
+@@ -3068,7 +3071,7 @@
   	memset(&ied, 0, sizeof(ied));
  	ast_mutex_lock(&iaxsl[callno]);
  	if (callno && iaxs[callno]) {
@@ -5421,7 +5535,7 @@
  		alreadygone = ast_test_flag(iaxs[callno], IAX_ALREADYGONE);
  		/* Send the hangup unless we have had a transmission error or are already gone */
   		iax_ie_append_byte(&ied, IAX_IE_CAUSECODE, (unsigned char)c->hangupcause);
-@@ -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, };
@@ -5431,19 +5545,10 @@
  	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 */
@@ -5451,23 +5556,33 @@
  	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);
@@ -5476,7 +5591,7 @@
  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;
@@ -5485,7 +5600,7 @@
  		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 */
@@ -5517,7 +5632,7 @@
  	if (pedanticsipchecking) {
  		/* In principle Call-ID's uniquely identify a call, but with a forking SIP proxy
  		   we need more to identify a branch - so we have to check branch, from
-@@ -4058,6 +4075,7 @@
+@@ -4141,6 +4161,7 @@
  	if (sipmethod == SIP_CANCEL) {
  		c = p->initreq.rlPart2;	/* Use original URI */
  	} else if (sipmethod == SIP_ACK) {
@@ -5525,7 +5640,7 @@
  		/* 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));
@@ -5542,7 +5657,7 @@
  	} 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);
  	}
@@ -5554,7 +5669,7 @@
  #ifdef OSP_SUPPORT
  	if ((req.method != SIP_OPTIONS) && p->options && !ast_strlen_zero(p->options->osptoken)) {
  		ast_log(LOG_DEBUG,"Adding OSP Token: %s\n", p->options->osptoken);
-@@ -4961,8 +4986,7 @@
+@@ -5044,8 +5072,7 @@
  }
  
  /*! \brief  transmit_state_notify: Used in the SUBSCRIBE notification subsystem ----*/
@@ -5564,7 +5679,7 @@
  	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);
@@ -5587,7 +5702,19 @@
  		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 */
@@ -5596,7 +5723,7 @@
  {
  	struct sip_pvt *p = data;
  
-@@ -6340,7 +6373,7 @@
+@@ -6430,7 +6468,7 @@
  		p->laststate = state;
  		break;
  	}
@@ -5605,7 +5732,174 @@
  
  	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;
@@ -5613,7 +5907,7 @@
  	
  	/* 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;
@@ -5633,7 +5927,7 @@
  	} 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;
  }
  
@@ -5698,7 +5992,7 @@
  	if (argc < 4)
  		return RESULT_SHOWUSAGE;
  
-@@ -8791,41 +8889,13 @@
+@@ -8909,41 +9099,13 @@
  	}
  
  	for (i = 3; i < argc; i++) {
@@ -5745,9 +6039,9 @@
  /*! \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 */
@@ -5758,39 +6052,138 @@
 -				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);
@@ -5799,7 +6192,16 @@
  			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);
@@ -5808,7 +6210,7 @@
  	if (p) {
  		/* Go ahead and lock the owner if it has one -- we may need it */
  		if (p->owner && ast_mutex_trylock(&p->owner->lock)) {
-@@ -11468,6 +11540,52 @@
+@@ -11634,6 +11859,52 @@
  	return 0;
  }
  
@@ -5861,7 +6263,72 @@
  /*! \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);
@@ -5870,7 +6337,7 @@
  
  	sip_poke_all_peers();	
  	sip_send_all_registers();
-@@ -13197,6 +13317,7 @@
+@@ -13389,6 +13686,7 @@
  
  	ast_rtp_proto_unregister(&sip_rtp);
  
@@ -5878,9 +6345,9 @@
  	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-05-08 10:59:30.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.
@@ -6318,7 +6785,7 @@
 +		    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);
@@ -6369,7 +6836,7 @@
  		if (p->pri->facilityenable)
  			pri_facility_enable(p->pri->pri);
  
-@@ -2287,8 +2503,10 @@
+@@ -2286,8 +2502,10 @@
  	}
  	if (newslot < 0) {
  		newslot = 0;
@@ -6381,7 +6848,7 @@
  	}
  	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);
@@ -6391,7 +6858,7 @@
  	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) {
@@ -6399,7 +6866,7 @@
  		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) {
@@ -6462,7 +6929,7 @@
  						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);
  						}
@@ -6492,7 +6959,7 @@
  					}
  					if (res < 0) 
  						ast_log(LOG_WARNING, "pri_disconnect failed\n");
-@@ -2532,7 +2813,13 @@
+@@ -2531,7 +2812,13 @@
  
  		}
  #endif
@@ -6507,7 +6974,7 @@
  			res = zt_set_hook(p->subs[SUB_REAL].zfd, ZT_ONHOOK);
  		if (res < 0) {
  			ast_log(LOG_WARNING, "Unable to hangup line %s\n", ast->name);
-@@ -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);
@@ -6522,7 +6989,7 @@
  		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			
@@ -6536,7 +7003,7 @@
  	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;
@@ -6552,7 +7019,7 @@
  	ast_mutex_lock(&p->lock);
  	ast_log(LOG_DEBUG, "New owner for channel %d is %s\n", p->channel, newchan->name);
  	if (p->owner == oldchan) {
-@@ -3637,7 +3944,7 @@
+@@ -3636,7 +3943,7 @@
  			if (p->call) {
  				if (p->pri && p->pri->pri) {
  					if (!pri_grab(p, p->pri)) {
@@ -6561,7 +7028,7 @@
  						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;
  	}
@@ -6570,7 +7037,7 @@
  		/* 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
@@ -6582,7 +7049,7 @@
  					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);
@@ -6595,7 +7062,7 @@
  				} 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) {
@@ -6606,7 +7073,7 @@
  			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
@@ -6615,7 +7082,7 @@
  				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
@@ -6624,7 +7091,7 @@
  				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;
@@ -6639,7 +7106,7 @@
  			tmp->callgroup = i->callgroup;
  			tmp->pickupgroup = i->pickupgroup;
  		}
-@@ -5217,6 +5533,7 @@
+@@ -5216,6 +5532,7 @@
  	int len = 0;
  	int res;
  	int index;
@@ -6647,7 +7114,7 @@
  	if (option_verbose > 2) 
  		ast_verbose( VERBOSE_PREFIX_3 "Starting simple switch on '%s'\n", chan->name);
  	index = zt_get_index(chan, p, 1);
-@@ -5235,10 +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)) {
@@ -6668,7 +7135,7 @@
  			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;
@@ -6677,7 +7144,7 @@
  			} else {
  				pris[*span].dchannels[0] = 24 + offset;
  			}
-@@ -6806,6 +7132,10 @@
+@@ -6811,6 +7137,10 @@
  
  #endif
  
@@ -6688,7 +7155,7 @@
  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;
  						}
@@ -6700,7 +7167,7 @@
  						if (!ast_strlen_zero(pris[span].idledial) && strcmp(pris[span].idledial, idledial)) {
  							ast_log(LOG_ERROR, "Span %d already has idledial '%s'.\n", span + 1, idledial);
  							destroy_zt_pvt(&tmp);
-@@ -6991,6 +7326,17 @@
+@@ -6996,6 +7331,17 @@
  							return NULL;
  						}
  						pris[span].nodetype = pritype;
@@ -6718,7 +7185,7 @@
  						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;
@@ -6733,7 +7200,7 @@
  						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
@@ -6770,7 +7237,7 @@
  #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;
@@ -6778,7 +7245,7 @@
  		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;
@@ -6787,7 +7254,7 @@
  			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;
@@ -6796,7 +7263,7 @@
  	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;
@@ -6808,7 +7275,7 @@
  				} else {
  					ast_log(LOG_WARNING, "Unknown option '%c' in '%s'\n", opt, (char *)data);
  				}
-@@ -7674,6 +8061,164 @@
+@@ -7679,6 +8066,164 @@
  	return tmp;
  }
  
@@ -6973,7 +7440,7 @@
  
  #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;
  }
  
@@ -7031,7 +7498,7 @@
  
  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;
@@ -7041,7 +7508,7 @@
  	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;
@@ -7049,7 +7516,7 @@
  		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;
@@ -7107,7 +7574,7 @@
  			}
  			return principle;
  		}
-@@ -7788,7 +8424,9 @@
+@@ -7793,7 +8429,9 @@
  		}
  		crv = crv->next;
  	}
@@ -7118,7 +7585,7 @@
  	return -1;
  }
  
-@@ -7850,86 +8488,33 @@
+@@ -7855,86 +8493,33 @@
  #ifndef PRI_RESTART
  #error "Upgrade your libpri"
  #endif
@@ -7216,13 +7683,13 @@
  
  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 @@
  	}
  }
  
@@ -7255,7 +7722,7 @@
  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++;
  			}
@@ -7264,7 +7731,7 @@
  #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);
@@ -7303,7 +7770,7 @@
  					}
  				
  					if (option_debug)
-@@ -8218,8 +8858,7 @@
+@@ -8223,8 +8863,7 @@
  					break;
  			}
  		} else if (errno != EINTR)
@@ -7313,7 +7780,7 @@
  		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:
@@ -7440,7 +7907,7 @@
  					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) {
@@ -7477,7 +7944,7 @@
  				}
  				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;
  							}
@@ -7488,7 +7955,7 @@
   							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;
@@ -7496,7 +7963,7 @@
  			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) {
@@ -7509,7 +7976,7 @@
  							/* 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);
  								}
  							}
@@ -7524,7 +7991,7 @@
  						}
  						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
  					}
-@@ -8372,39 +9100,55 @@
+@@ -8377,39 +9105,58 @@
  				break;
  			case PRI_EVENT_RING:
  				crv = NULL;
@@ -7567,20 +8034,22 @@
 -								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;
 +					    }
@@ -7602,7 +8071,7 @@
  					if (pri->switchtype == PRI_SWITCH_GR303_TMC) {
  						/* Should be safe to lock CRV AFAIK while bearer is still locked */
  						crv = pri_find_crv(pri, pri_get_crv(pri->pri, e->ring.call, NULL));
-@@ -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);
@@ -7618,7 +8087,7 @@
  					pri->pvts[chanpos]->call = e->ring.call;
  					apply_plan_to_number(plancallingnum, sizeof(plancallingnum), pri, e->ring.callingnum, e->ring.callingplan);
  					if (pri->pvts[chanpos]->use_callerid) {
-@@ -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);
@@ -7710,7 +8179,7 @@
  					/* Make sure extension exists (or in overlap dial mode, can exist) */
  					if ((pri->overlapdial && ast_canmatch_extension(NULL, pri->pvts[chanpos]->context, pri->pvts[chanpos]->exten, 1, pri->pvts[chanpos]->cid_num)) ||
  						ast_exists_extension(NULL, pri->pvts[chanpos]->context, pri->pvts[chanpos]->exten, 1, pri->pvts[chanpos]->cid_num)) {
-@@ -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);
@@ -7756,7 +8225,7 @@
  						if (pri->overlapdial && ast_matchmore_extension(NULL, pri->pvts[chanpos]->context, pri->pvts[chanpos]->exten, 1, pri->pvts[chanpos]->cid_num)) {
  							/* Release the PRI lock while we create the channel */
  							ast_mutex_unlock(&pri->lock);
-@@ -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);
@@ -7788,7 +8257,7 @@
  							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)
@@ -7799,7 +8268,7 @@
  										pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span);
  							} else {
  								ast_log(LOG_WARNING, "Unable to start PBX on channel %d/%d, span %d\n", 
-@@ -8549,14 +9376,18 @@
+@@ -8554,14 +9384,18 @@
  								if (c)
  									ast_hangup(c);
  								else {
@@ -7819,7 +8288,7 @@
  							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)
@@ -7864,7 +8333,7 @@
  						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 
@@ -7873,7 +8342,7 @@
  				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)) {
@@ -7882,7 +8351,7 @@
  							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:
@@ -7899,7 +8368,7 @@
  #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) {
@@ -7912,7 +8381,7 @@
  					if (!pri->pvts[chanpos]->proceeding) {
  						struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_PROCEEDING, };
  						
-@@ -8747,6 +9607,295 @@
+@@ -8752,6 +9615,295 @@
  					}
  				}
  				break;				
@@ -8208,7 +8677,7 @@
  			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);
@@ -8216,7 +8685,7 @@
  						/* 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,16 @@
+@@ -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) {
@@ -8234,7 +8703,7 @@
  						}
  
  #ifdef SUPPORT_USERUSER
-@@ -8844,23 +9999,32 @@
+@@ -8849,23 +10007,32 @@
  								}
  							}
  							if (option_verbose > 2) 
@@ -8274,7 +8743,7 @@
  
  #ifdef SUPPORT_USERUSER
  						if (!ast_strlen_zero(e->hangup.useruserinfo)) {
-@@ -8870,8 +10034,20 @@
+@@ -8875,8 +10042,20 @@
  
  						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
  					} else {
@@ -8297,7 +8766,7 @@
  					}
  				} 
  				break;
-@@ -8881,17 +10057,25 @@
+@@ -8886,17 +10065,25 @@
  			case PRI_EVENT_HANGUP_REQ:
  				chanpos = pri_find_principle(pri, e->hangup.channel);
  				if (chanpos < 0) {
@@ -8326,7 +8795,7 @@
  							pri->pvts[chanpos]->owner->hangupcause = e->hangup.cause;
  							switch(e->hangup.cause) {
  							case PRI_CAUSE_USER_BUSY:
-@@ -8910,20 +10094,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);
@@ -8424,7 +8893,7 @@
  						}
  
  #ifdef SUPPORT_USERUSER
-@@ -8934,9 +10185,36 @@
+@@ -8939,9 +10193,36 @@
  
  						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
  					} else {
@@ -8462,7 +8931,7 @@
  				break;
  			case PRI_EVENT_HANGUP_ACK:
  				chanpos = pri_find_principle(pri, e->hangup.channel);
-@@ -8950,6 +10228,7 @@
+@@ -8955,6 +10236,7 @@
  					if (chanpos > -1) {
  						ast_mutex_lock(&pri->pvts[chanpos]->lock);
  						pri->pvts[chanpos]->call = NULL;
@@ -8470,7 +8939,7 @@
  						pri->pvts[chanpos]->resetting = 0;
  						if (pri->pvts[chanpos]->owner) {
  							if (option_verbose > 2) 
-@@ -8963,7 +10242,9 @@
+@@ -8968,7 +10250,9 @@
  #endif
  
  						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
@@ -8480,16 +8949,7 @@
  				}
  				break;
  			case PRI_EVENT_CONFIG_ERR:
-@@ -9030,7 +10311,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 +10336,22 @@
+@@ -9060,10 +10344,22 @@
  					ast_mutex_lock(&pri->pvts[chanpos]->lock);
  					switch(e->notify.info) {
  					case PRI_NOTIFY_REMOTE_HOLD:
@@ -8512,7 +8972,7 @@
  						f.subclass = AST_CONTROL_UNHOLD;
  						zap_queue_frame(pri->pvts[chanpos], &f, pri);
  						break;
-@@ -9066,6 +10359,77 @@
+@@ -9071,6 +10367,77 @@
  					ast_mutex_unlock(&pri->pvts[chanpos]->lock);
  				}
  				break;
@@ -8590,7 +9050,7 @@
  			default:
  				ast_log(LOG_DEBUG, "Event: %d\n", e->e);
  			}
-@@ -9127,7 +10491,7 @@
+@@ -9132,7 +10499,7 @@
  			pri->fds[i] = -1;
  			return -1;
  		}
@@ -8599,7 +9059,7 @@
  		/* Force overlap dial if we're doing GR-303! */
  		if (pri->switchtype == PRI_SWITCH_GR303_TMC)
  			pri->overlapdial = 1;
-@@ -9196,39 +10560,77 @@
+@@ -9201,39 +10568,77 @@
  
  static int handle_pri_set_debug_file(int fd, int argc, char **argv)
  {
@@ -8699,7 +9159,7 @@
  	}
  
  	return RESULT_SUCCESS;
-@@ -9260,6 +10662,7 @@
+@@ -9265,6 +10670,7 @@
  
  
  
@@ -8707,7 +9167,7 @@
  static int handle_pri_no_debug(int fd, int argc, char *argv[])
  {
  	int span;
-@@ -9366,36 +10769,6 @@
+@@ -9371,36 +10777,6 @@
  	return RESULT_SUCCESS;
  }
  
@@ -8744,7 +9204,7 @@
  static char pri_debug_help[] = 
  	"Usage: pri debug span <span>\n"
  	"       Enables debugging on a given PRI span\n";
-@@ -9412,6 +10785,18 @@
+@@ -9417,6 +10793,18 @@
  	"Usage: pri show span <span>\n"
  	"       Displays PRI Information\n";
  
@@ -8763,7 +9223,7 @@
  static struct ast_cli_entry zap_pri_cli[] = {
  	{ { "pri", "debug", "span", NULL }, handle_pri_debug,
  	  "Enables PRI debugging on a span", pri_debug_help, complete_span_4 },
-@@ -9419,19 +10804,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 },
@@ -8784,6 +9244,10 @@
  	  "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;
@@ -8795,9 +9259,16 @@
 +    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 */
  
  
@@ -8974,19 +9445,21 @@
  #ifdef ZAPATA_R2
  static int handle_r2_no_debug(int fd, int argc, char *argv[])
  {
-@@ -10044,6 +11617,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 +11632,7 @@
+@@ -10059,6 +11653,7 @@
  	ast_manager_unregister( "ZapDNDoff" );
  	ast_manager_unregister( "ZapDNDon" );
  	ast_manager_unregister("ZapShowChannels");
@@ -8994,7 +9467,7 @@
  	ast_channel_unregister(&zap_tech);
  	if (!ast_mutex_lock(&iflock)) {
  		/* Hangup all interfaces if they have an owner */
-@@ -10412,8 +11991,8 @@
+@@ -10417,8 +12012,8 @@
  			}
  		} else if (!strcasecmp(v->name, "echotraining")) {
  			if (sscanf(v->value, "%d", &y) == 1) {
@@ -9005,7 +9478,7 @@
  				} else {
  					echotraining = y;
  				}
-@@ -10599,12 +12178,33 @@
+@@ -10604,12 +12199,33 @@
  					cur_signalling = SIG_GR303FXSKS;
  					cur_radio = 0;
  					pritype = PRI_CPE;
@@ -9039,7 +9512,7 @@
  				} else {
  					ast_log(LOG_ERROR, "Unknown signalling method '%s'\n", v->value);
  				}
-@@ -10687,8 +12287,20 @@
+@@ -10692,8 +12308,20 @@
  					priindication_oob = 1;
  				else if (!strcasecmp(v->value, "inband"))
  					priindication_oob = 0;
@@ -9061,7 +9534,7 @@
  						v->value, v->lineno);
  			} else if (!strcasecmp(v->name, "priexclusive")) {
  				cur_priexclusive = ast_true(v->value);
-@@ -10702,6 +12314,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));
@@ -9076,7 +9549,7 @@
  			} else if (!strcasecmp(v->name, "resetinterval")) {
  				if (!strcasecmp(v->value, "never"))
  					resetinterval = -1;
-@@ -10716,6 +12336,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));
@@ -9085,7 +9558,7 @@
  			} else if (!strcasecmp(v->name, "overlapdial")) {
  				overlapdial = ast_true(v->value);
  			} else if (!strcasecmp(v->name, "pritimer")) {
-@@ -10901,6 +12523,7 @@
+@@ -10908,6 +12546,7 @@
  #ifdef ZAPATA_PRI
  	if (!reload) {
  		for (x=0;x<NUM_SPANS;x++) {
@@ -9093,7 +9566,7 @@
  			if (pris[x].pvts[0]) {
  				if (start_pri(pris + x)) {
  					ast_log(LOG_ERROR, "Unable to start D-channel on span %d\n", x + 1);
-@@ -10933,6 +12556,10 @@
+@@ -10940,6 +12579,10 @@
  	pri_set_error(zt_pri_error);
  	pri_set_message(zt_pri_message);
  #endif
@@ -9104,7 +9577,7 @@
  	res = setup_zap(0);
  	/* Make sure we can register our Zap channel type */
  	if(res) {
-@@ -10950,6 +12577,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]));
@@ -9116,7 +9589,7 @@
  	
  	memset(round_robin, 0, sizeof(round_robin));
  	ast_manager_register( "ZapTransfer", 0, action_transfer, "Transfer Zap Channel" );
-@@ -10958,11 +12590,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");
@@ -9124,6 +9597,7 @@
 +	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;
  }
@@ -9164,7 +9638,7 @@
  {
  #define	END_SILENCE_LEN 400
  #define	HEADER_MS 50
-@@ -10981,6 +12648,7 @@
+@@ -10988,6 +12672,7 @@
  	float scont = 0.0;
  	int index;
  
@@ -9172,9 +9646,9 @@
  	index = zt_get_index(c, p, 0);
  	if (index < 0) {
  		ast_log(LOG_WARNING, "Huh?  I don't exist?\n");
-diff -urN asterisk-1.2.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"
@@ -9184,9 +9658,9 @@
  #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
@@ -9232,17 +9706,17 @@
 +;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
@@ -9266,9 +9740,9 @@
 +;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
@@ -9290,9 +9764,9 @@
  ; If you need to override the existing channels selection routine and force all
  ; PRI channels to be marked as exclusively selected, set this to yes.
  ; priexclusive = yes
-diff -urN asterisk-1.2.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 };
@@ -9386,9 +9860,9 @@
 +	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 {
@@ -9505,9 +9979,9 @@
  			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
@@ -9516,9 +9990,9 @@
  
  [files]
  ; Changing the following lines may compromise your security
-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 {
@@ -9529,9 +10003,9 @@
  	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*)
@@ -9809,9 +10283,9 @@
 +#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*)
@@ -9843,9 +10317,9 @@
 +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
@@ -9856,7 +10330,7 @@
  #include <unistd.h>
  #include <setjmp.h>
  #ifdef POLLCOMPAT 
-@@ -380,7 +383,7 @@
+@@ -381,7 +384,7 @@
  	unsigned int fout;
  
  	/* Unique Channel Identifier */
@@ -9865,7 +10339,7 @@
  
  	/* 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;
  
@@ -9878,7 +10352,7 @@
  	struct ast_frame *readq;
  	int alertpipe[2];
  	/*! Write translation path */
-@@ -533,6 +542,11 @@
+@@ -534,6 +543,11 @@
  #define AST_STATE_MUTE		(1 << 16)	
  /*! @} */
  
@@ -9890,7 +10364,7 @@
  /*! \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.
   */
@@ -9899,7 +10373,7 @@
  
  /*!
   * \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.
   */
@@ -9911,7 +10385,7 @@
  
  /*!\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);
  
@@ -9922,7 +10396,7 @@
  /*! 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);
@@ -9932,9 +10406,9 @@
  
  /*! 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
@@ -9953,9 +10427,9 @@
  
  /*! \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 @@
  };
  
@@ -9998,9 +10472,30 @@
 +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 */
@@ -10051,9 +10546,9 @@
  
  #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
@@ -11720,9 +12215,9 @@
 +#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];
@@ -11731,9 +12226,9 @@
  extern char ast_config_AST_CTL_PERMISSIONS[AST_CONFIG_MAX_PATH];
  extern char ast_config_AST_CTL_OWNER[AST_CONFIG_MAX_PATH];
  extern char ast_config_AST_CTL_GROUP[AST_CONFIG_MAX_PATH];
-diff -urN asterisk-1.2.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.
@@ -11829,7 +12324,7 @@
 -	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;
 + 		}
@@ -11986,9 +12481,9 @@
  	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)
@@ -12003,9 +12498,9 @@
  	}
  	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,
@@ -12016,7 +12511,7 @@
  	},
  
  	{ "NoOp", pbx_builtin_noop,
-@@ -1880,7 +1881,7 @@
+@@ -1883,7 +1884,7 @@
  	return ast_extension_state2(e);    		/* Check all devices in the hint */
  }
  
@@ -12025,7 +12520,7 @@
  {
  	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)
@@ -12039,7 +12534,7 @@
  			
  			hint->laststate = state;
  			break;
-@@ -2153,7 +2154,7 @@
+@@ -2156,7 +2157,7 @@
  				/* Notify with -1 and remove all callbacks */
  				cbprev = cblist;	    
  				cblist = cblist->next;
@@ -12048,7 +12543,7 @@
  				free(cbprev);
  	    		}
  	    		list->callbacks = NULL;
-@@ -3774,7 +3775,7 @@
+@@ -3778,7 +3779,7 @@
  			while (thiscb) {
  				prevcb = thiscb;	    
  				thiscb = thiscb->next;
@@ -12057,7 +12552,7 @@
  				free(prevcb);
  	    		}
  		} else {
-@@ -4976,7 +4977,7 @@
+@@ -4980,7 +4981,7 @@
  	return 0;  /* success */
  }
  
@@ -12066,7 +12561,7 @@
  {
  	struct ast_channel *chan;
  	struct async_stat *as;
-@@ -4986,7 +4987,7 @@
+@@ -4990,7 +4991,7 @@
  
  	if (sync) {
  		LOAD_OH(oh);
@@ -12075,7 +12570,7 @@
  		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));
@@ -12084,7 +12579,7 @@
  		if (channel) {
  			*channel = chan;
  			if (chan)
-@@ -5134,7 +5135,7 @@
+@@ -5138,7 +5139,7 @@
  	pthread_t t;
  };
  
@@ -12093,7 +12588,7 @@
  {
  	struct app_tmp *tmp = data;
  	struct ast_app *app;
-@@ -5150,7 +5151,7 @@
+@@ -5154,7 +5155,7 @@
  	return NULL;
  }
  
@@ -12102,7 +12597,7 @@
  {
  	struct ast_channel *chan;
  	struct async_stat *as;
-@@ -5170,7 +5171,7 @@
+@@ -5174,7 +5175,7 @@
  		goto outgoing_app_cleanup;	
  	}
  	if (sync) {
@@ -12111,7 +12606,7 @@
  		if (chan) {
  			if (chan->cdr) { /* check if the channel already has a cdr record, if not give it one */
  				ast_log(LOG_WARNING, "%s already has a call record??\n", chan->name);
-@@ -5257,7 +5258,8 @@
+@@ -5261,7 +5262,8 @@
  			goto outgoing_app_cleanup;
  		}
  		memset(as, 0, sizeof(struct async_stat));
@@ -12121,7 +12616,7 @@
  		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)
  {
@@ -12131,7 +12626,7 @@
  	/* 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;
  		}
  	}
@@ -12141,7 +12636,7 @@
  	return res = ast_say_number(chan, atoi((char *) tmp), "", chan->language, options);
  }
  
-@@ -6207,8 +6215,12 @@
+@@ -6211,8 +6219,12 @@
  {
  	int res = 0;
  
@@ -12155,7 +12650,7 @@
  	return res;
  }
  	
-@@ -6216,8 +6228,12 @@
+@@ -6220,8 +6232,12 @@
  {
  	int res = 0;
  
@@ -12169,7 +12664,7 @@
  	return res;
  }
  	
-@@ -6225,8 +6241,12 @@
+@@ -6229,8 +6245,12 @@
  {
  	int res = 0;
  
@@ -12183,9 +12678,9 @@
  	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
  #
@@ -12195,9 +12690,9 @@
  
  ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/odbcinst.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/odbcinst.h),)
    ifneq (${OSARCH},FreeBSD)
-diff -urN asterisk-1.2.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.
@@ -12238,7 +12733,7 @@
  "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;
  }
  
@@ -12254,7 +12749,7 @@
  	int x;
  	int res;
  	sigset_t signal_set;
-@@ -271,6 +280,33 @@
+@@ -276,6 +285,33 @@
  			return -1;
  		}
  	}
@@ -12288,7 +12783,7 @@
  	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);
  		}
@@ -12310,7 +12805,7 @@
  			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];
  	}
@@ -12320,7 +12815,7 @@
  	/* 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]);
  	}
@@ -12330,7 +12825,7 @@
  
  	*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);
@@ -12339,7 +12834,7 @@
  
  	/* 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;
@@ -12348,7 +12843,7 @@
  	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;
  	}
@@ -12357,7 +12852,7 @@
  	/* this is to check for if ast_waitstream closed the stream, we probably are at
  	 * the end of the stream, return that amount, else check for the amount */
  	sample_offset = (chan->stream) ? ast_tellstream(fs) : max_length;
-@@ -618,7 +664,7 @@
+@@ -623,7 +669,7 @@
                  else
                          return RESULT_FAILURE;
          }
@@ -12366,7 +12861,7 @@
          /* this is to check for if ast_waitstream closed the stream, we probably are at
           * the end of the stream, return that amount, else check for the amount */
          sample_offset = (chan->stream)?ast_tellstream(fs):max_length;
-@@ -630,7 +676,7 @@
+@@ -635,7 +681,7 @@
  
  	/* If the user didnt press a key, wait for digitTimeout*/
  	if (res == 0 ) {
@@ -12375,7 +12870,7 @@
  		/* 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;
@@ -12384,7 +12879,7 @@
  	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;
  
@@ -12393,7 +12888,7 @@
  	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;
  
@@ -12402,7 +12897,7 @@
  	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;
  
@@ -12411,7 +12906,7 @@
  	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;
@@ -12420,7 +12915,7 @@
  	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;
@@ -12433,7 +12928,7 @@
  	FILE *readf;
  	/* how many times we'll retry if ast_waitfor_nandfs will return without either 
  	  channel or file descriptor in case select is interrupted by a system call (EINTR) */
-@@ -1863,10 +1914,22 @@
+@@ -1874,10 +1925,22 @@
  		return -1;
  	}
  	setlinebuf(readf);
@@ -12458,7 +12953,7 @@
  		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 */
@@ -12485,7 +12980,7 @@
  			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;
  			}
@@ -12493,7 +12988,7 @@
  		} 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;
@@ -12501,7 +12996,7 @@
  	int pid;
          char *stringp;
  	AGI agi;
-@@ -2036,15 +2112,18 @@
+@@ -2047,15 +2123,18 @@
  		}
  	}
  #endif
@@ -12522,7 +13017,7 @@
  	}
  	LOCAL_USER_REMOVE(u);
  	return res;
-@@ -2078,6 +2157,35 @@
+@@ -2089,6 +2168,35 @@
  	return res;
  }
  
@@ -12558,7 +13053,7 @@
  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);
@@ -12566,7 +13061,7 @@
  	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);
@@ -12574,9 +13069,9 @@
  	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.
@@ -12745,7 +13240,7 @@
  /* exec an app by feature */
  static int feature_exec_app(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, char *code, int sense)
  {
-@@ -1014,7 +1092,7 @@
+@@ -1018,7 +1096,7 @@
  			return res;
  		
  		while ((tok = strsep(&tmp, "#")) != NULL) {
@@ -12754,7 +13249,7 @@
  			
  			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, "#"))) {
@@ -12763,7 +13258,7 @@
  					if (ast_test_flag(feature, AST_FEATURE_FLAG_NEEDSDTMF)) {
  						if (ast_test_flag(feature, AST_FEATURE_FLAG_CALLER))
  							ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_0);
-@@ -1089,7 +1167,7 @@
+@@ -1096,7 +1174,7 @@
  	struct ast_frame *f = NULL;
  	int res = 0, ready = 0;
  	
@@ -12772,7 +13267,7 @@
  		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"
@@ -12784,7 +13279,7 @@
  					);
  
  				if (option_verbose > 1) 
-@@ -1586,9 +1665,10 @@
+@@ -1594,9 +1673,10 @@
  								"Channel: %s\r\n"
  								"CallerID: %s\r\n"
  								"CallerIDName: %s\r\n"
@@ -12796,7 +13291,7 @@
  								);
  
  							/* There's a problem, hang them up*/
-@@ -1675,6 +1755,280 @@
+@@ -1683,6 +1763,280 @@
  	return res;
  }
  
@@ -13077,7 +13572,7 @@
  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"
@@ -13089,7 +13584,7 @@
  			);
  
  		free(pu);
-@@ -1893,12 +2248,13 @@
+@@ -1901,12 +2256,13 @@
  			"Timeout: %ld\r\n"
  			"CallerID: %s\r\n"
  			"CallerIDName: %s\r\n"
@@ -13104,7 +13599,7 @@
  			,idText);
  
              cur = cur->next;
-@@ -1914,6 +2270,386 @@
+@@ -1922,6 +2278,386 @@
          return RESULT_SUCCESS;
  }
  
@@ -13491,7 +13986,7 @@
  
  int ast_pickup_call(struct ast_channel *chan)
  {
-@@ -2068,7 +2804,7 @@
+@@ -2076,7 +2812,7 @@
  			}
  
  			{
@@ -13500,7 +13995,7 @@
  				int mallocd=0;
  				
  				if (!feature) {
-@@ -2144,14 +2880,22 @@
+@@ -2151,14 +2887,22 @@
  	if ((res = load_config()))
  		return res;
  	ast_cli_register(&showparked);
@@ -13523,7 +14018,7 @@
  	return res;
  }
  
-@@ -2162,7 +2906,11 @@
+@@ -2169,7 +2913,11 @@
  
  	ast_manager_unregister("ParkedCalls");
  	ast_cli_unregister(&showfeatures);
@@ -13535,9 +14030,148 @@
  	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.
@@ -13688,10 +14322,10 @@
 +{
 +	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);




More information about the Pkg-voip-commits mailing list