[asterisk-commits] mnicholson: branch group/newcdr r199270 - in /team/group/newcdr: ./ apps/ cha...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 5 10:08:40 CDT 2009


Author: mnicholson
Date: Fri Jun  5 10:08:35 2009
New Revision: 199270

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=199270
Log:
Merged revisions 198725,198727,198729,198762,198791,198824,198856,198892,198954,198958,199051,199091,199139 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
  r198725 | tilghman | 2009-06-01 15:33:50 -0500 (Mon, 01 Jun 2009) | 8 lines
  
  Add INCrement and DECrement functions
  (closes issue #15025)
   Reported by: greenfieldtech
   Patches: 
         func_math.c.patch_v4 uploaded by greenfieldtech (license 369)
         slightly modified by me
   Tested by: greenfieldtech, lmadsen
................
  r198727 | mmichelson | 2009-06-01 15:57:31 -0500 (Mon, 01 Jun 2009) | 13 lines
  
  Add the ability to execute connected line interception macros.
  
  When connected line updates are received or generated in the middle
  of an application call, it is now possible to execute a macro to
  manipulate the connected line data. This way, phone numbers may be
  manipulated to be more presentable to users, names may be changed 
  for...whatever reason, or whatever else needs to be done may be.
  
  Review: https://reviewboard.asterisk.org/r/256
  
  AST-165
................
  r198729 | russell | 2009-06-01 16:03:18 -0500 (Mon, 01 Jun 2009) | 2 lines
  
  Tell the IAX2 parser about more control frame types.
................
  r198762 | file | 2009-06-02 08:12:59 -0500 (Tue, 02 Jun 2009) | 5 lines
  
  Fix a bug where we were passing in address information that should remain unmodified to a function that may modify it.
  
  (closes issue #15243)
  Reported by: pj
................
  r198791 | file | 2009-06-02 08:48:06 -0500 (Tue, 02 Jun 2009) | 5 lines
  
  Correct documentation for the register line, specifically where the domain should be specified.
  
  (closes issue #14367)
  Reported by: Nick_Lewis
................
  r198824 | dvossel | 2009-06-02 12:55:35 -0500 (Tue, 02 Jun 2009) | 8 lines
  
  fixes issue with channels not going down after transfer
  
  Iax2 currently does not support native bridging if the timeoutms value is set.  We check for that in iax2_bridge, but then set timeoutms to 0 by default.  If the timeoutms is not provided it is set to -1. By setting timeoutms to 0 it is processed causing a bridging retry loop.
  
  (closes issue #15216)
  Reported by: oxymoron
  Tested by: dvossel
................
  r198856 | dvossel | 2009-06-02 16:17:49 -0500 (Tue, 02 Jun 2009) | 10 lines
  
  Generic call forward api, ast_call_forward()
  
  The function ast_call_forward() forwards a call to an extension specified in an ast_channel's call_forward string.  After an ast_channel is called, if the channel's call_forward string is set this function can be used to forward the call to a new channel and terminate the original one.  I have included this api call in both channel.c's ast_request_and_dial() and feature.c's feature_request_and_dial().  App_dial and app_queue already contain call forward logic specific for their application and options.
  
  (closes issue #13630)
  Reported by: festr
  
  Review: https://reviewboard.asterisk.org/r/271/
................
  r198892 | dvossel | 2009-06-03 10:51:10 -0500 (Wed, 03 Jun 2009) | 15 lines
  
  Blocked revisions 198891 via svnmerge
  
  ........
    r198891 | dvossel | 2009-06-03 10:49:46 -0500 (Wed, 03 Jun 2009) | 10 lines
    
    Generic call forward api, ast_call_forward()
    
    The function ast_call_forward() forwards a call to an extension specified in an ast_channel's call_forward string.  After an ast_channel is called, if the channel's call_forward string is set this function can be used to forward the call to a new channel and terminate the original one.  I have included this api call in both channel.c's ast_request_and_dial() and res_feature.c's feature_request_and_dial().  App_dial and app_queue already contain call forward logic specific for their application and options.
    
    (closes issue #13630)
    Reported by: festr
    
    Review: https://reviewboard.asterisk.org/r/271/
  ........
................
  r198954 | dvossel | 2009-06-03 15:30:10 -0500 (Wed, 03 Jun 2009) | 3 lines
  
  ast_call_forward() todo notes and originate flag copy.
................
  r198958 | seanbright | 2009-06-03 15:49:11 -0500 (Wed, 03 Jun 2009) | 17 lines
  
  Blocked revisions 198957 via svnmerge
  
  ........
    r198957 | seanbright | 2009-06-03 16:39:10 -0400 (Wed, 03 Jun 2009) | 11 lines
    
    Fix a possible crash in pbx_spool.
    
    We were trying to reference members of a struct that had previously been freed.
    This patch makes sure that we free the struct after it has been removed from
    the spooler queue.
    
    (closes issue #15072)
    Reported by: garlew
    Patches:
          spool.diff uploaded by garlew (license 376)
  ........
................
  r199051 | seanbright | 2009-06-04 09:31:24 -0500 (Thu, 04 Jun 2009) | 47 lines
  
  Merged revisions 199022 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
    r199022 | seanbright | 2009-06-04 10:14:57 -0400 (Thu, 04 Jun 2009) | 40 lines
    
    Safely handle AMI connections/reload requests that occur during startup.
    
    During asterisk startup, a lock on the list of modules is obtained by the
    primary thread while each module is initialized.  Issue 13778 pointed out a
    problem with this approach, however.  Because the AMI is loaded before other
    modules, it is possible for a module reload to be issued by a connected client
    (via Action: Command), causing a deadlock.
    
    The resolution for 13778 was to move initialization of the manager to happen
    after the other modules had already been lodaded.  While this fixed this
    particular issue, it caused a problem for users (like FreePBX) who call AMI
    scripts via an #exec in a configuration file (See issue 15189).
    
    The solution I have come up with is to defer any reload requests that come in
    until after the server is fully booted.  When a call comes in to
    ast_module_reload (from wherever) before we are fully booted, the request is
    added to a queue of pending requests.  Once we are done booting up, we then
    execute these deferred requests in turn.
    
    Note that I have tried to make this a bit more intelligent in that it will not
    queue up more than 1 request for the same module to be reloaded, and if a
    general reload request comes in ('module reload') the queue is flushed and we
    only issue a single deferred reload for the entire system.
    
    As for how this will impact existing installations - Before 13778, a reload
    issued before module initialization was completed would result in a deadlock.
    After 13778, you simply couldn't connect to the manager during startup (which
    causes problems with #exec-that-calls-AMI configuration files).  I believe this
    is a good general purpose solution that won't negatively impact existing
    installations.
    
    (closes issue #15189)
    (closes issue #13778)
    Reported by: p_lindheimer
    Patches:
          06032009_15189_deferred_reloads.diff uploaded by seanbright (license 71)
    Tested by: p_lindheimer, seanbright
    
    Review: https://reviewboard.asterisk.org/r/272/
  ........
................
  r199091 | eliel | 2009-06-04 11:29:50 -0500 (Thu, 04 Jun 2009) | 11 lines
  
  Move static docs to the new AstXML form.
  
  Move SMDI_MSG and SMDI_MSG_RETRIEVE functions statis documentation
  to XML.
  
  (issue #15245)
  Reported by: eliel
  Patches:
        res_smdi_static_conversion.txt uploaded by lmadsen (license 10)
................
  r199139 | dvossel | 2009-06-04 14:10:16 -0500 (Thu, 04 Jun 2009) | 9 lines
  
  Merged revisions 199138 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
    r199138 | dvossel | 2009-06-04 14:00:15 -0500 (Thu, 04 Jun 2009) | 3 lines
    
    Additional updates to AST-2009-001
  ........
................

Modified:
    team/group/newcdr/   (props changed)
    team/group/newcdr/apps/app_dial.c
    team/group/newcdr/apps/app_directed_pickup.c
    team/group/newcdr/apps/app_macro.c
    team/group/newcdr/apps/app_queue.c
    team/group/newcdr/channels/chan_iax2.c
    team/group/newcdr/channels/chan_sip.c
    team/group/newcdr/channels/iax2-parser.c
    team/group/newcdr/configs/sip.conf.sample
    team/group/newcdr/doc/tex/channelvariables.tex
    team/group/newcdr/funcs/func_math.c
    team/group/newcdr/include/asterisk/_private.h
    team/group/newcdr/include/asterisk/app.h
    team/group/newcdr/include/asterisk/channel.h
    team/group/newcdr/main/app.c
    team/group/newcdr/main/asterisk.c
    team/group/newcdr/main/channel.c
    team/group/newcdr/main/dial.c
    team/group/newcdr/main/features.c
    team/group/newcdr/main/loader.c
    team/group/newcdr/main/rtp_engine.c
    team/group/newcdr/res/res_smdi.c

Propchange: team/group/newcdr/
------------------------------------------------------------------------------
    automerge = on

Propchange: team/group/newcdr/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.

Propchange: team/group/newcdr/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/group/newcdr/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Jun  5 10:08:35 2009
@@ -1,1 +1,1 @@
-/trunk:1-198678
+/trunk:1-199218

Modified: team/group/newcdr/apps/app_dial.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/apps/app_dial.c?view=diff&rev=199270&r1=199269&r2=199270
==============================================================================
--- team/group/newcdr/apps/app_dial.c (original)
+++ team/group/newcdr/apps/app_dial.c Fri Jun  5 10:08:35 2009
@@ -724,6 +724,8 @@
  *
  * XXX this code is highly suspicious, as it essentially overwrites
  * the outgoing channel without properly deleting it.
+ *
+ * \todo eventually this function should be intergrated into and replaced by ast_call_forward() 
  */
 static void do_forward(struct chanlist *o,
 	struct cause_args *num, struct ast_flags64 *peerflags, int single, int *to)
@@ -940,7 +942,9 @@
 					ast_verb(3, "%s answered %s\n", c->name, in->name);
 					if (!single && !ast_test_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE)) {
 						if (o->connected.id.number) {
-							ast_channel_update_connected_line(in, &o->connected);
+							if (ast_channel_connected_line_macro(c, in, &o->connected, 1, 0)) {
+								ast_channel_update_connected_line(in, &o->connected);
+							}
 						} else if (!ast_test_flag64(o, DIAL_NOCONNECTEDLINE)) {
 							ast_channel_lock(c);
 							ast_connected_line_copy_from_caller(&connected_caller, &c->cid);
@@ -990,7 +994,9 @@
 						ast_verb(3, "%s answered %s\n", c->name, in->name);
 						if (!single && !ast_test_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE)) {
 							if (o->connected.id.number) {
-								ast_channel_update_connected_line(in, &o->connected);
+								if (ast_channel_connected_line_macro(c, in, &o->connected, 1, 0)) {
+									ast_channel_update_connected_line(in, &o->connected);
+								}
 							} else if (!ast_test_flag64(o, DIAL_NOCONNECTEDLINE)) {
 								ast_channel_lock(c);
 								ast_connected_line_copy_from_caller(&connected_caller, &c->cid);
@@ -1079,8 +1085,9 @@
 						ast_party_connected_line_set(&o->connected, &connected);
 						ast_party_connected_line_free(&connected);
 					} else {
-						ast_verb(3, "%s connected line has changed, passing it to %s\n", c->name, in->name);
-						ast_indicate_data(in, AST_CONTROL_CONNECTED_LINE, f->data.ptr, f->datalen);
+						if (ast_channel_connected_line_macro(c, in, f, 1, 1)) {
+							ast_indicate_data(in, AST_CONTROL_CONNECTED_LINE, f->data.ptr, f->datalen);
+						}
 					}
 					break;
 				case AST_CONTROL_REDIRECTING:
@@ -1201,15 +1208,19 @@
 				if (ast_write(outgoing->chan, f))
 					ast_log(LOG_WARNING, "Unable to forward voice or dtmf\n");
 			}
-			if (single && (f->frametype == AST_FRAME_CONTROL) &&
-				((f->subclass == AST_CONTROL_HOLD) ||
-				(f->subclass == AST_CONTROL_UNHOLD) ||
-				(f->subclass == AST_CONTROL_VIDUPDATE) ||
-				(f->subclass == AST_CONTROL_SRCUPDATE) ||
-				(f->subclass == AST_CONTROL_CONNECTED_LINE) ||
-				(f->subclass == AST_CONTROL_REDIRECTING))) {
-				ast_verb(3, "%s requested special control %d, passing it to %s\n", in->name, f->subclass, outgoing->chan->name);
-				ast_indicate_data(outgoing->chan, f->subclass, f->data.ptr, f->datalen);
+			if (single && (f->frametype == AST_FRAME_CONTROL)) { 
+				if ((f->subclass == AST_CONTROL_HOLD) ||
+				    (f->subclass == AST_CONTROL_UNHOLD) ||
+				    (f->subclass == AST_CONTROL_VIDUPDATE) ||
+				    (f->subclass == AST_CONTROL_SRCUPDATE) ||
+				    (f->subclass == AST_CONTROL_REDIRECTING)) {
+					ast_verb(3, "%s requested special control %d, passing it to %s\n", in->name, f->subclass, outgoing->chan->name);
+					ast_indicate_data(outgoing->chan, f->subclass, f->data.ptr, f->datalen);
+				} else if (f->subclass == AST_CONTROL_CONNECTED_LINE) {
+					if (ast_channel_connected_line_macro(in, outgoing->chan, f, 0, 1)) {
+						ast_indicate_data(outgoing->chan, f->subclass, f->data.ptr, f->datalen);
+					}
+				}
 			}
 			ast_frfree(f);
 		}

Modified: team/group/newcdr/apps/app_directed_pickup.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/apps/app_directed_pickup.c?view=diff&rev=199270&r1=199269&r2=199270
==============================================================================
--- team/group/newcdr/apps/app_directed_pickup.c (original)
+++ team/group/newcdr/apps/app_directed_pickup.c Fri Jun  5 10:08:35 2009
@@ -99,7 +99,9 @@
 
 	connected_caller = target->connected;
 	connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
-	ast_channel_update_connected_line(chan, &connected_caller);
+	if (ast_channel_connected_line_macro(NULL, chan, &connected_caller, 0, 0)) {
+		ast_channel_update_connected_line(chan, &connected_caller);
+	}
 
 	ast_channel_lock(chan);
 	ast_connected_line_copy_from_caller(&connected_caller, &chan->cid);

Modified: team/group/newcdr/apps/app_macro.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/apps/app_macro.c?view=diff&rev=199270&r1=199269&r2=199270
==============================================================================
--- team/group/newcdr/apps/app_macro.c (original)
+++ team/group/newcdr/apps/app_macro.c Fri Jun  5 10:08:35 2009
@@ -36,6 +36,7 @@
 #include "asterisk/config.h"
 #include "asterisk/utils.h"
 #include "asterisk/lock.h"
+#include "asterisk/app.h"
 
 /*** DOCUMENTATION
 	<application name="Macro" language="en_US">

Modified: team/group/newcdr/apps/app_queue.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/apps/app_queue.c?view=diff&rev=199270&r1=199269&r2=199270
==============================================================================
--- team/group/newcdr/apps/app_queue.c (original)
+++ team/group/newcdr/apps/app_queue.c Fri Jun  5 10:08:35 2009
@@ -3001,6 +3001,8 @@
  * \param[in] prebusies number of busy members calculated prior to calling wait_for_answer
  * \param[in] caller_disconnect if the 'H' option is used when calling Queue(), this is used to detect if the caller pressed * to disconnect the call
  * \param[in] forwardsallowed used to detect if we should allow call forwarding, based on the 'i' option to Queue()
+ *
+ * \todo eventually all call forward logic should be intergerated into and replaced by ast_call_forward()
  */
 static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callattempt *outgoing, int *to, char *digit, int prebusies, int caller_disconnect, int forwardsallowed, int update_connectedline)
 {
@@ -3092,7 +3094,9 @@
 					ast_verb(3, "%s answered %s\n", ochan_name, inchan_name);
 					if (update_connectedline) {
 						if (o->connected.id.number) {
-							ast_channel_update_connected_line(in, &o->connected);
+							if (ast_channel_connected_line_macro(o->chan, in, &o->connected, 1, 0)) {
+								ast_channel_update_connected_line(in, &o->connected);
+							}
 						} else if (o->update_connectedline) {
 							ast_channel_lock(o->chan);
 							ast_connected_line_copy_from_caller(&connected_caller, &o->chan->cid);
@@ -3195,7 +3199,9 @@
 								ast_verb(3, "%s answered %s\n", ochan_name, inchan_name);
 								if (update_connectedline) {
 									if (o->connected.id.number) {
-										ast_channel_update_connected_line(in, &o->connected);
+										if (ast_channel_connected_line_macro(o->chan, in, &o->connected, 1, 0)) {
+											ast_channel_update_connected_line(in, &o->connected);
+										}
 									} else if (o->update_connectedline) {
 										ast_channel_lock(o->chan);
 										ast_connected_line_copy_from_caller(&connected_caller, &o->chan->cid);
@@ -3255,8 +3261,9 @@
 								ast_party_connected_line_set(&o->connected, &connected);
 								ast_party_connected_line_free(&connected);
 							} else {
-								ast_verb(3, "%s connected line has changed, passing it to %s\n", ochan_name, inchan_name);
-								ast_indicate_data(in, AST_CONTROL_CONNECTED_LINE, f->data.ptr, f->datalen);
+								if (ast_channel_connected_line_macro(o->chan, in, f, 1, 1)) {
+									ast_indicate_data(in, AST_CONTROL_CONNECTED_LINE, f->data.ptr, f->datalen);
+								}
 							}
 							break;
 						case AST_CONTROL_REDIRECTING:

Modified: team/group/newcdr/channels/chan_iax2.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/channels/chan_iax2.c?view=diff&rev=199270&r1=199269&r2=199270
==============================================================================
--- team/group/newcdr/channels/chan_iax2.c (original)
+++ team/group/newcdr/channels/chan_iax2.c Fri Jun  5 10:08:35 2009
@@ -736,7 +736,8 @@
 		/*! Default parkinglot */
 		AST_STRING_FIELD(parkinglot);
 	);
-	
+	/*! AUTHREJ all AUTHREP frames */
+	int authrej;
 	/*! permitted authentication methods */
 	int authmethods;
 	/*! permitted encryption methods */
@@ -4277,7 +4278,7 @@
 		return AST_BRIDGE_FAILED;
 	}
 
-	timeoutms = 0;
+	timeoutms = -1;
 
 	lock_both(callno0, callno1);
 	if (!iaxs[callno0] || !iaxs[callno1]) {
@@ -6488,6 +6489,18 @@
 			ast_string_field_set(iaxs[callno], secret, user->secret);
 		res = 0;
 		user = user_unref(user);
+	} else {
+		 /* user was not found, but we should still fake an AUTHREQ.
+		  * Set authmethods to the last known authmethod used by the system
+		  * Set a fake secret, it's not looked at, just required to attempt authentication.
+		  * Set authrej so the AUTHREP is rejected without even looking at its contents */
+		iaxs[callno]->authmethods = last_authmethod ? last_authmethod : (IAX_AUTH_MD5 | IAX_AUTH_PLAINTEXT);
+		ast_string_field_set(iaxs[callno], secret, "badsecret");
+		iaxs[callno]->authrej = 1;
+		if (!ast_strlen_zero(iaxs[callno]->username)) {
+			/* only send the AUTHREQ if a username was specified. */
+			res = 0;
+		}
 	}
 	ast_set2_flag(iaxs[callno], iax2_getpeertrunk(*sin), IAX_TRUNK);	
 	return res;
@@ -6598,6 +6611,9 @@
 		.name = p->username,	
 	};
 
+	if (p->authrej) {
+		return res;
+	}
 	user = ao2_find(users, &tmp_user, OBJ_POINTER);
 	if (user) {
 		if (ast_test_flag(p, IAX_MAXAUTHREQ)) {

Modified: team/group/newcdr/channels/chan_sip.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/channels/chan_sip.c?view=diff&rev=199270&r1=199269&r2=199270
==============================================================================
--- team/group/newcdr/channels/chan_sip.c (original)
+++ team/group/newcdr/channels/chan_sip.c Fri Jun  5 10:08:35 2009
@@ -7240,7 +7240,7 @@
 	if (hostname)
 		*hostname++ = '\0';
 	if (ast_strlen_zero(username) || ast_strlen_zero(hostname)) {
-		ast_log(LOG_WARNING, "Format for registration is [transport://]user[:secret[:authuser]]@domain[:port][/extension][~expiry] at line %d\n", lineno);
+		ast_log(LOG_WARNING, "Format for registration is [transport://]user[@domain][:secret[:authuser]]@host[:port][/extension][~expiry] at line %d\n", lineno);
 		return -1;
 	}
 
@@ -20412,6 +20412,8 @@
 					/* Chan 2: Call from Asterisk to target */
 	int res = 0;
 	struct sip_pvt *targetcall_pvt;
+	struct ast_party_connected_line connected_to_transferee;
+	struct ast_party_connected_line connected_to_target;
 	char transferer_linkedid[32];
 
 	/* Check if the call ID of the replaces header does exist locally */
@@ -20482,6 +20484,13 @@
 		transferer->callid,
 		target.chan1->name,
 		target.chan1->uniqueid);
+	ast_party_connected_line_init(&connected_to_transferee);
+	ast_party_connected_line_init(&connected_to_target);
+	/* No need to lock current->chan1 here since it was locked in sipsock_read */
+	ast_party_connected_line_copy(&connected_to_transferee, &current->chan1->connected);
+	/* No need to lock target.chan1 here since it was locked in get_sip_pvt_byid_locked */
+	ast_party_connected_line_copy(&connected_to_target, &target.chan1->connected);
+	connected_to_target.source = connected_to_transferee.source = AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER;
 	res = attempt_transfer(current, &target);
 	sip_pvt_unlock(targetcall_pvt);
 	if (res) {
@@ -20492,8 +20501,6 @@
 			ast_channel_unlock(targetcall_pvt->owner);
 		ast_clear_flag(&transferer->flags[0], SIP_DEFER_BYE_ON_TRANSFER);
 	} else {
-		struct ast_party_connected_line connected_caller;
-
 		/* Transfer succeeded! */
 		const char *xfersound = pbx_builtin_getvar_helper(target.chan1, "ATTENDED_TRANSFER_COMPLETE_SOUND");
 
@@ -20511,45 +20518,29 @@
 			ast_channel_unlock(targetcall_pvt->owner);
 		}
 
-		ast_party_connected_line_init(&connected_caller);
+		/* By forcing the masquerade, we know that target.chan1 and target.chan2 are bridged. We then
+		 * can queue connected line updates where they need to go.
+		 *
+		 * No need to lock target.chan1 here since it was previously locked in get_sip_pvt_byid_locked
+		 */
+		if (target.chan1->masq) {
+			/* If the channel thread already did the masquerade, then we don't need to do anything */
+			ast_do_masquerade(target.chan1);
+		}
 		if (target.chan2) {
-			if (current->chan2) {
-				/* Tell each of the other channels to whom they are now connected */
-				ast_channel_lock(current->chan2);
-				ast_connected_line_copy_from_caller(&connected_caller, &current->chan2->cid);
-				ast_channel_unlock(current->chan2);
-				connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER;
-				ast_channel_update_connected_line(target.chan2, &connected_caller);
-				ast_channel_lock(target.chan2);
-				ast_connected_line_copy_from_caller(&connected_caller, &target.chan2->cid);
-				ast_channel_unlock(target.chan2);
-				connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER;
-				ast_channel_update_connected_line(current->chan2, &connected_caller);
-				ast_party_connected_line_free(&connected_caller);
-			}
+			ast_channel_queue_connected_line_update(target.chan1, &connected_to_transferee);
+			ast_channel_queue_connected_line_update(target.chan2, &connected_to_target);
 		} else {
-			/* Notify the first other party that they are connected to someone else assuming that target.chan1
-			   has progressed far enough through the dialplan to have its called party information set. */
-			if (current->chan2) {
-				ast_channel_lock(target.chan1);
-				ast_party_connected_line_copy(&connected_caller, &target.chan1->connected);
-				ast_channel_unlock(target.chan1);
-				connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER;
-				ast_channel_update_connected_line(current->chan2, &connected_caller);
-				ast_party_connected_line_free(&connected_caller);
-			}
-
-			/* We can't indicate to the called channel directly so we force the masquerade to complete
-			   and queue and update to be read and passed-through */
-			ast_channel_lock(target.chan1);
-			ast_do_masquerade(target.chan1);
-			ast_channel_unlock(target.chan1);
-
-			ast_party_connected_line_collect_caller(&connected_caller, &target.chan1->cid);
-			connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER;
-			ast_channel_queue_connected_line_update(target.chan1, &connected_caller);
-		}
-	}
+			/* Since target.chan1 isn't actually connected to another channel, there is no way for us
+			 * to queue a frame so that its connected line status will be updated. Instead, we have to
+			 * change it directly. Since we are not the channel thread, we cannot run a connected line
+			 * interception macro on target.chan1
+			 */
+			ast_channel_update_connected_line(target.chan1, &connected_to_target);
+		}
+	}
+	ast_party_connected_line_free(&connected_to_target);
+	ast_party_connected_line_free(&connected_to_transferee);
 	if (targetcall_pvt)
 		ao2_t_ref(targetcall_pvt, -1, "drop targetcall_pvt");
 	return 1;

Modified: team/group/newcdr/channels/iax2-parser.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/channels/iax2-parser.c?view=diff&rev=199270&r1=199269&r2=199270
==============================================================================
--- team/group/newcdr/channels/iax2-parser.c (original)
+++ team/group/newcdr/channels/iax2-parser.c Fri Jun  5 10:08:35 2009
@@ -573,7 +573,13 @@
 		"PROCDNG",
 		"HOLD   ",
 		"UNHOLD ",
-		"VIDUPDT", };
+		"VIDUPDT",
+		"T38    ",
+		"SRCUPDT",
+		"TXFER  ",
+		"CNLINE ",
+		"REDIR  ",
+	};
 	struct ast_iax2_full_hdr *fh;
 	char retries[20];
 	char class2[20];

Modified: team/group/newcdr/configs/sip.conf.sample
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/configs/sip.conf.sample?view=diff&rev=199270&r1=199269&r2=199270
==============================================================================
--- team/group/newcdr/configs/sip.conf.sample (original)
+++ team/group/newcdr/configs/sip.conf.sample Fri Jun  5 10:08:35 2009
@@ -475,7 +475,7 @@
 ;----------------------------------------- OUTBOUND SIP REGISTRATIONS  ------------------------
 ; Asterisk can register as a SIP user agent to a SIP proxy (provider)
 ; Format for the register statement is:
-;       register => [transport://]user[:secret[:authuser]]@domain[:port][/extension][~expiry]
+;       register => [transport://]user[@domain][:secret[:authuser]]@host[:port][/extension][~expiry]
 ;
 ;
 ;

Modified: team/group/newcdr/doc/tex/channelvariables.tex
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/doc/tex/channelvariables.tex?view=diff&rev=199270&r1=199269&r2=199270
==============================================================================
--- team/group/newcdr/doc/tex/channelvariables.tex (original)
+++ team/group/newcdr/doc/tex/channelvariables.tex Fri Jun  5 10:08:35 2009
@@ -1005,3 +1005,10 @@
 ${OSPOUTTIMELIMIT}      Duration limit for out_bound call
 ${OSPRESULTS}           Number of remained destinations
 \end{verbatim}
+
+\subsection{Connected line digit manipulation}
+\begin{verbatim}
+${CONNECTED_LINE_SEND_CALLEE_MACRO}        Macro to call before sending a connected line update to the callee
+${CONNECTED_LINE_SEND_CALLEE_MACRO_ARGS}   Arguments to pass to ${CONNECTED_LINE_SEND_CALLEE_MACRO}
+${CONNECTED_LINE_SEND_CALLER_MACRO}        Macro to call before sending a connected line update to the caller
+${CONNECTED_LINE_SEND_CALLER_MACRO_ARGS}   Arguments to pass to ${CONNECTED_LINE_SEND_CALLER_MACRO}

Modified: team/group/newcdr/funcs/func_math.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/funcs/func_math.c?view=diff&rev=199270&r1=199269&r2=199270
==============================================================================
--- team/group/newcdr/funcs/func_math.c (original)
+++ team/group/newcdr/funcs/func_math.c Fri Jun  5 10:08:35 2009
@@ -1,9 +1,10 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 2004 - 2006, Andy Powell 
+ * Copyright (C) 2004 - 2006, Andy Powell
  *
  * Updated by Mark Spencer <markster at digium.com>
+ * Updated by Nir Simionovich <nirs at greenfieldtech.net>
  *
  * See http://www.asterisk.org for more information about
  * the Asterisk project. Please do not directly contact
@@ -22,6 +23,7 @@
  *
  * \author Andy Powell
  * \author Mark Spencer <markster at digium.com>
+ * \author Nir Simionovich <nirs at greenfieldtech.net>
  *
  * \ingroup functions
  */
@@ -66,6 +68,40 @@
 			<para>Example: Set(i=${MATH(123%16,int)}) - sets var i=11</para>
 		</description>
 	</function>
+	<function name="INC" language="en_US">
+		<synopsis>
+			Increments the value of a variable, while returning the updated value to the dialplan
+		</synopsis>
+		<syntax>
+			<parameter name="variable" required="true">
+				<para>
+				The variable name to be manipulated, without the braces.
+				</para>
+			</parameter>
+		</syntax>
+		<description>
+			<para>Increments the value of a variable, while returning the updated value to the dialplan</para>
+			<para>Example: INC(MyVAR) - Increments MyVar</para>
+			<para>Note: INC(${MyVAR}) - Is wrong, as INC expects the variable name, not its value</para>
+		</description>
+	</function>
+	<function name="DEC" language="en_US">
+		<synopsis>
+			Decrements the value of a variable, while returning the updated value to the dialplan
+		</synopsis>
+		<syntax>
+			<parameter name="variable" required="true">
+				<para>
+				The variable name to be manipulated, without the braces.
+				</para>
+			</parameter>
+		</syntax>
+		<description>
+			<para>Decrements the value of a variable, while returning the updated value to the dialplan</para>
+			<para>Example: DEC(MyVAR) - Increments MyVar</para>
+			<para>Note: DEC(${MyVAR}) - Is wrong, as INC expects the variable name, not its value</para>
+		</description>
+	</function>
  ***/
 
 enum TypeOfFunctions {
@@ -333,19 +369,107 @@
 	return 0;
 }
 
+static int crement_function_read(struct ast_channel *chan, const char *cmd,
+                     char *data, char *buf, size_t len)
+{
+	int ret = -1;
+	int int_value = 0;
+	int modify_orig = 0;
+	const char *var;
+	char endchar = 0, returnvar[12]; /* If you need a variable longer than 11 digits - something is way wrong */
+
+	if (ast_strlen_zero(data)) {
+		ast_log(LOG_WARNING, "Syntax: %s(<data>) - missing argument!\n", cmd);
+		return -1;
+	}
+
+	ast_channel_lock(chan);
+
+	if (!(var = pbx_builtin_getvar_helper(chan, data))) {
+		ast_log(LOG_NOTICE, "Failed to obtain variable %s, bailing out\n", data);
+		ast_channel_unlock(chan);
+		return -1;
+	}
+
+	if (ast_strlen_zero(var)) {
+		ast_log(LOG_NOTICE, "Variable %s doesn't exist - are you sure you wrote it corrrectly?\n", data);
+		ast_channel_unlock(chan);
+		return -1;
+	}
+
+	if (sscanf(var, "%d%c", &int_value, &endchar) == 0 || endchar != 0) {
+		ast_log(LOG_NOTICE, "The content of ${%s} is not a numeric value - bailing out!\n", data);
+		ast_channel_unlock(chan);
+		return -1;
+	}
+
+	/* now we'll actually do something useful */
+	if (!strcasecmp(cmd, "INC")) {              /* Increment variable */
+		int_value++;
+		modify_orig = 1;
+	} else if (!strcasecmp(cmd, "DEC")) {       /* Decrement variable */
+		int_value--;
+		modify_orig = 1;
+	}
+
+	ast_log(LOG_NOTICE, "The value is now: %d\n", int_value);
+
+	if (snprintf(returnvar, sizeof(returnvar), "%d", int_value) > 0) {
+		pbx_builtin_setvar_helper(chan, data, returnvar);
+		if (modify_orig) {
+			ast_copy_string(buf, returnvar, len);
+		}
+		ret = 0;
+	} else {
+		pbx_builtin_setvar_helper(chan, data, "0");
+		if (modify_orig) {
+			ast_copy_string(buf, "0", len);
+		}
+		ast_log(LOG_NOTICE, "Variable %s refused to be %sREMENTED, setting value to 0", data, cmd);
+		ret = 0;
+	}
+
+	ast_channel_unlock(chan);
+
+	return ret;
+}
+
+
 static struct ast_custom_function math_function = {
 	.name = "MATH",
 	.read = math
 };
 
+static struct ast_custom_function increment_function = {
+	.name = "INC",
+	.read = crement_function_read,
+};
+
+static struct ast_custom_function decrement_function = {
+	.name = "DEC",
+	.read = crement_function_read,
+};
+
 static int unload_module(void)
 {
-	return ast_custom_function_unregister(&math_function);
+	int res = 0;
+
+	res |= ast_custom_function_unregister(&math_function);
+	res |= ast_custom_function_unregister(&increment_function);
+	res |= ast_custom_function_unregister(&decrement_function);
+
+	return res;
 }
 
 static int load_module(void)
 {
-	return ast_custom_function_register(&math_function);
+	int res = 0;
+
+	res |= ast_custom_function_register(&math_function);
+	res |= ast_custom_function_register(&increment_function);
+	res |= ast_custom_function_register(&decrement_function);
+
+	return res;
 }
 
 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Mathematical dialplan function");

Modified: team/group/newcdr/include/asterisk/_private.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/include/asterisk/_private.h?view=diff&rev=199270&r1=199269&r2=199270
==============================================================================
--- team/group/newcdr/include/asterisk/_private.h (original)
+++ team/group/newcdr/include/asterisk/_private.h Fri Jun  5 10:08:35 2009
@@ -60,6 +60,18 @@
  */
 int ast_module_reload(const char *name);
 
+/*!
+ * \brief Process reload requests received during startup.
+ *
+ * This function requests that the loader execute the pending reload requests
+ * that were queued during server startup.
+ *
+ * \note This function will do nothing if the server has not completely started
+ *       up.  Once called, the reload queue is emptied, and further invocations
+ *       will have no affect.
+ */
+void ast_process_pending_reloads(void);
+
 /*! \brief Load XML documentation. Provided by xmldoc.c 
  *  \retval 1 on error.
  *  \retval 0 on success. 

Modified: team/group/newcdr/include/asterisk/app.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/include/asterisk/app.h?view=diff&rev=199270&r1=199269&r2=199270
==============================================================================
--- team/group/newcdr/include/asterisk/app.h (original)
+++ team/group/newcdr/include/asterisk/app.h Fri Jun  5 10:08:35 2009
@@ -109,6 +109,26 @@
 int ast_app_getdata_full(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout, int audiofd, int ctrlfd);
 
 /*!
+ * \since 1.6.3
+ * \brief Run a macro on a channel, placing a second channel into autoservice.
+ *
+ * This is a shorthand method that makes it very easy to run a macro on any given 
+ * channel. It is perfectly reasonable to supply a NULL autoservice_chan here in case
+ * there is no channel to place into autoservice. It is very important that the 
+ * autoservice_chan parameter is not locked prior to calling ast_app_run_macro. A 
+ * deadlock could result, otherwise.
+ *
+ * \param autoservice_chan A channel to place into autoservice while the macro is run
+ * \param macro_chan The channel to run the macro on
+ * \param macro_name The name of the macro to run
+ * \param macro_args The arguments to pass to the macro
+ * \retval 0 success
+ * \retval -1 failure
+ */
+int ast_app_run_macro(struct ast_channel *autoservice_chan, struct ast_channel 
+		*macro_chan, const char * const macro_name, const char * const macro_args);
+
+/*!
  * \brief Set voicemail function callbacks
  * \param[in] inboxcount2_func set function pointer
  * \param[in] sayname_func set function pointer

Modified: team/group/newcdr/include/asterisk/channel.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/include/asterisk/channel.h?view=diff&rev=199270&r1=199269&r2=199270
==============================================================================
--- team/group/newcdr/include/asterisk/channel.h (original)
+++ team/group/newcdr/include/asterisk/channel.h Fri Jun  5 10:08:35 2009
@@ -1102,6 +1102,18 @@
 	int timeout, int *reason, const char *cid_num, const char *cid_name, struct outgoing_helper *oh);
 
 /*!
+ * \brief Forwards a call to a new channel specified by the original channel's call_forward str.  If possible, the new forwarded channel is created and returned while the original one is terminated.
+ * \param caller in channel that requested orig
+ * \param orig channel being replaced by the call forward channel
+ * \param timeout maximum amount of time to wait for setup of new forward channel
+ * \param format requested channel format
+ * \param oh outgoing helper used with original channel
+ * \param outstate reason why unsuccessful (if uncuccessful)
+ * \return Returns the forwarded call's ast_channel on success or NULL on failure
+ */
+struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, int format, struct outgoing_helper *oh, int *outstate);
+
+/*!
  * \brief Register a channel technology (a new channel driver)
  * Called by a channel module to register the kind of channels it supports.
  * \param tech Structure defining channel technology or "type"
@@ -2587,6 +2599,34 @@
  */
 void ast_channel_queue_redirecting_update(struct ast_channel *chan, const struct ast_party_redirecting *redirecting);
 
+/*!
+ * \since 1.6.3
+ * \brief Run a connected line interception macro and update a channel's connected line
+ * information
+ *
+ * Whenever we want to update a channel's connected line information, we may need to run
+ * a macro so that an administrator can manipulate the information before sending it 
+ * out. This function both runs the macro and sends the update to the channel.
+ *
+ * \param autoservice_chan Channel to place into autoservice while the macro is running. 
+ * 	It is perfectly safe for this to be NULL 
+ * \param macro_chan The channel to run the macro on. Also the channel from which we 
+ * 	determine which macro we need to run.
+ * \param connected_info Either an ast_party_connected_line or ast_frame pointer of type 
+ * 	AST_CONTROL_CONNECTED_LINE
+ * \param caller If true, then run CONNECTED_LINE_CALLER_SEND_MACRO, otherwise run 
+ * 	CONNECTED_LINE_CALLEE_SEND_MACRO
+ * \param frame If true, then connected_info is an ast_frame pointer, otherwise it is an 
+ * 	ast_party_connected_line pointer.
+ * \retval 0 Success
+ * \retval -1 Either the macro does not exist, or there was an error while attempting to 
+ * 	run the macro
+ *
+ * \todo Have multiple return codes based on the MACRO_RESULT
+ * \todo Make constants so that caller and frame can be more expressive than just '1' and
+ * 	'0'
+ */
+int ast_channel_connected_line_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *connected_info, int caller, int frame);
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

Modified: team/group/newcdr/main/app.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/main/app.c?view=diff&rev=199270&r1=199269&r2=199270
==============================================================================
--- team/group/newcdr/main/app.c (original)
+++ team/group/newcdr/main/app.c Fri Jun  5 10:08:35 2009
@@ -200,6 +200,28 @@
 
 	res = ast_readstring_full(c, s, maxlen, to, fto, "#", audiofd, ctrlfd);
 
+	return res;
+}
+
+int ast_app_run_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char * const macro_name, const char * const macro_args)
+{
+	struct ast_app *macro_app;
+	int res;
+	char buf[1024];
+
+	macro_app = pbx_findapp("Macro");
+	if (!macro_app) {
+		ast_log(LOG_WARNING, "Cannot run macro '%s' because the 'Macro' application in not available\n", macro_name);
+		return -1;
+	}
+	snprintf(buf, sizeof(buf), "%s%s%s", macro_name, ast_strlen_zero(macro_args) ? "" : ",", S_OR(macro_args, ""));
+	if (autoservice_chan) {
+		ast_autoservice_start(autoservice_chan);
+	}
+	res = pbx_exec(macro_chan, macro_app, buf);
+	if (autoservice_chan) {
+		ast_autoservice_stop(autoservice_chan);
+	}
 	return res;
 }
 

Modified: team/group/newcdr/main/asterisk.c

[... 683 lines stripped ...]



More information about the asterisk-commits mailing list