--- include/asterisk/channel.h	2006-06-01 16:27:50.000000000 -0400
+++ /usr/src/asterisk-1.2.10/include/asterisk/channel.h	2006-09-10 16:43:43.000000000 -0400
@@ -458,6 +458,8 @@
 	char *warning_sound;
 	char *end_sound;
 	char *start_sound;
+	char *limit_exit_caller;
+	char *limit_exit_callee;
 	int firstpass;
 	unsigned int flags;
 };
--- channel.c	2006-07-10 17:01:35.000000000 -0400
+++ /usr/src/asterisk-1.2.10/channel.c	2006-09-10 16:43:43.000000000 -0400
@@ -3373,6 +3373,8 @@
 	struct timeval nexteventts = { 0, };
 	char caller_warning = 0;
 	char callee_warning = 0;
+	char *limit_exit_caller = NULL;
+	char *limit_exit_callee = NULL;
 	int to;
 
 	if (c0->_bridge) {
@@ -3431,6 +3433,15 @@
 			nexteventts = ast_tvsub(nexteventts, ast_samp2tv(config->play_warning, 1000));
 	}
 
+	if ( config->limit_exit_caller) {
+		limit_exit_caller = config->limit_exit_caller;
+		config->limit_exit_caller = NULL;
+	}
+	
+	if ( config->limit_exit_callee) {
+		limit_exit_callee = config->limit_exit_callee;
+		config->limit_exit_callee = NULL;
+	}
 	for (/* ever */;;) {
 		to = -1;
 		if (config->timelimit) {
@@ -3448,9 +3459,20 @@
 					bridge_playfile(c0, c1, config->end_sound, 0);
 				if (callee_warning && config->end_sound)
 					bridge_playfile(c1, c0, config->end_sound, 0);
+		
+				/* Since timeout occured, setting the backuped lecs to struct */			
+				if ( limit_exit_caller )				
+					config->limit_exit_caller = limit_exit_caller;
+				if ( limit_exit_callee )
+					config->limit_exit_callee = limit_exit_callee;
+					
 				*fo = NULL;
 				if (who) 
 					*rc = who;
+				
+				caller_warning = ast_test_flag(&config->features_caller, AST_FEATURE_PLAY_WARNING);
+				callee_warning = ast_test_flag(&config->features_callee, AST_FEATURE_PLAY_WARNING);
+				
 				res = 0;
 				break;
 			}
--- res/res_features.c	2006-05-23 13:15:23.000000000 -0400
+++ /usr/src/asterisk-1.2.10/res/res_features.c	2006-09-10 16:43:44.000000000 -0400
@@ -1324,7 +1324,6 @@
 			start = ast_tvnow();
 
 		res = ast_channel_bridge(chan, peer, config, &f, &who);
-
 		if (config->feature_timer) {
 			/* Update time limit for next pass */
 			diff = ast_tvdiff_ms(ast_tvnow(), start);
@@ -1468,6 +1467,8 @@
 					config->end_sound = NULL;
 					config->start_sound = NULL;
 					config->firstpass = 0;
+					config->limit_exit_caller = NULL;
+					config->limit_exit_callee = NULL;
 				}
 				config->feature_timer = featuredigittimeout;
 				ast_log(LOG_DEBUG, "Set time limit to %ld\n", config->feature_timer);
--- apps/app_dial.c	2006-06-09 14:08:00.000000000 -0400
+++ /usr/src/asterisk-1.2.10/apps/app_dial.c	2006-09-10 18:25:01.000000000 -0400
@@ -127,6 +127,8 @@
 "           * LIMIT_CONNECT_FILE       File to play when call begins.\n"
 "           * LIMIT_WARNING_FILE       File to play as warning if 'y' is defined.\n"
 "                                      The default is to say the time remaining.\n"
+"	    * LIMIT_EXIT_CALLER		CEP to call for the caller when limit is achieved\n"
+"	    * LIMIT_EXIT_CALLEE		CEP to call for the callee when limit is achieved\n"
 "    m([class]) - Provide hold music to the calling party until a requested\n"
 "           channel answers. A specific MusicOnHold class can be\n"
 "           specified.\n"
@@ -756,8 +758,11 @@
 	char *warning_sound=NULL;
 	char *end_sound=NULL;
 	char *start_sound=NULL;
+	char *limit_exit_caller=NULL;
+	char *limit_exit_callee=NULL;
 	char *dtmfcalled=NULL, *dtmfcalling=NULL;
 	char *var;
+	char *ch;
 	char status[256];
 	int play_to_caller=0,play_to_callee=0;
 	int sentringing=0, moh=0;
@@ -869,6 +874,12 @@
 		var = pbx_builtin_getvar_helper(chan,"LIMIT_CONNECT_FILE");
 		start_sound = var ? var : NULL;
 
+		var = pbx_builtin_getvar_helper(chan,"LIMIT_EXIT_CALLER");
+		limit_exit_caller = var ? var : NULL;
+	
+		var = pbx_builtin_getvar_helper(chan,"LIMIT_EXIT_CALLEE");
+		limit_exit_callee = var ? var : NULL;
+		
 		/* undo effect of S(x) in case they are both used */
 		calldurationlimit = 0; 
 		/* more efficient do it like S(x) does since no advanced opts*/
@@ -885,6 +896,8 @@
 			ast_verbose(VERBOSE_PREFIX_3 "- start_sound   = %s\n", start_sound ? start_sound : "UNDEF");
 			ast_verbose(VERBOSE_PREFIX_3 "- warning_sound = %s\n", warning_sound ? warning_sound : "UNDEF");
 			ast_verbose(VERBOSE_PREFIX_3 "- end_sound     = %s\n", end_sound ? end_sound : "UNDEF");
+			ast_verbose(VERBOSE_PREFIX_3 "- limit_exit_callee = %s\n", limit_exit_callee ? limit_exit_callee : "UNDEF");
+			ast_verbose(VERBOSE_PREFIX_3 "- limit_exit_caller = %s\n", limit_exit_caller ? limit_exit_caller : "UNDEF");
 		}
 	}
 
@@ -1580,6 +1593,8 @@
 			config.warning_sound = warning_sound;
 			config.end_sound = end_sound;
 			config.start_sound = start_sound;
+			config.limit_exit_caller = limit_exit_caller;
+			config.limit_exit_callee = limit_exit_callee;
 			if (moh) {
 				moh = 0;
 				ast_moh_stop(chan);
@@ -1601,7 +1616,25 @@
 			time(&end_time);
 			snprintf(toast, sizeof(toast), "%ld", (long)(end_time - answer_time));
 			pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", toast);
-			
+	                if ( config.limit_exit_callee ) {
+				ast_log(LOG_DEBUG, "Pitch the CALLEE to (CPE %s)\n",config.limit_exit_callee);
+				for (ch = config.limit_exit_callee; *ch; ch++) {
+					if (*ch == '^')
+						*ch = '|';
+				}
+				ast_parseable_goto(peer,config.limit_exit_callee);
+				ast_pbx_start(peer);
+				res = AST_PBX_NO_HANGUP_PEER;
+			} 
+			if ( config.limit_exit_caller ) {
+				ast_set_flag(peerflags, OPT_GO_ON);
+				ast_log(LOG_DEBUG, "Pitch the CALLER to (CPE %s)\n",config.limit_exit_caller);
+				for (ch = config.limit_exit_caller; *ch; ch++) {
+					if (*ch == '^')
+						*ch = '|';
+				} 
+				ast_parseable_goto(chan,config.limit_exit_caller);	       
+			} 
 		} else {
 			time(&end_time);
 			res = -1;
@@ -1631,7 +1664,6 @@
 		res=0;
 	
 	LOCAL_USER_REMOVE(u);    
-	
 	return res;
 }
 
