[asterisk-commits] tilghman: trunk r120227 - in /trunk: ./ pbx/pbx_loopback.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 3 17:42:03 CDT 2008


Author: tilghman
Date: Tue Jun  3 17:42:03 2008
New Revision: 120227

URL: http://svn.digium.com/view/asterisk?view=rev&rev=120227
Log:
Merged revisions 120226 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r120226 | tilghman | 2008-06-03 17:41:04 -0500 (Tue, 03 Jun 2008) | 8 lines

Due to incorrect use of the AST_LIST_INSERT_HEAD() macro the loopback switch
cannot perform any translation on the extension number before searching for it
in the target context.
(closes issue #12473)
 Reported by: chappell
 Patches: 
       pbx_loopback.c.diff uploaded by chappell (license 8)

........

Modified:
    trunk/   (props changed)
    trunk/pbx/pbx_loopback.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/pbx/pbx_loopback.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_loopback.c?view=diff&rev=120227&r1=120226&r2=120227
==============================================================================
--- trunk/pbx/pbx_loopback.c (original)
+++ trunk/pbx/pbx_loopback.c Tue Jun  3 17:42:03 2008
@@ -45,17 +45,26 @@
 #include "asterisk/astdb.h"
 
 
-/* Loopback switch substitutes ${EXTEN}, ${CONTEXT}, and ${PRIORITY} into
-   the data passed to it to try to get a string of the form:
+/* Loopback switch creates a 'tunnel' to another context.  When extension
+   lookups pass through the 'tunnel', Asterisk expressions can be used
+   to modify the target extension, context, and priority in any way desired.
+   If there is a match at the far end, execution jumps through the 'tunnel'
+   to the matched context, extension, and priority.
+ 
+   Global variables as well as ${CONTEXT}, ${EXTEN}, and ${PRIORITY} are 
+   available for substitution.  After substitution Loopback expects to get
+   a string of the form:
 
 	[exten]@context[:priority][/extramatch]
    
    Where exten, context, and priority are another extension, context, and priority
-   to lookup and "extramatch" is an extra match restriction the *original* number 
-   must fit if  specified.  The "extramatch" begins with _ like an exten pattern
-   if it is specified.  Note that the search context MUST be a different context
-   from the current context or the search will not succeed in an effort to reduce
-   the likelihood of loops (they're still possible if you try hard, so be careful!)
+   to lookup and "extramatch" is a dialplan extension pattern which the *original*
+   number must match.  If exten or priority are empty, the original values are 
+   used.
+
+   Note that the search context MUST be a different context from the current
+   context or the search will not succeed.  This is intended to reduce the
+   likelihood of loops (they're still possible if you try hard, so be careful!)
 
 */
 
@@ -66,13 +75,12 @@
 	char *newexten=(char *)exten, *newcontext=(char *)context; \
 	int newpriority=priority; \
 	char *newpattern=NULL; \
-	loopback_helper(buf, sizeof(buf), exten, context, priority, data); \
-	loopback_subst(&newexten, &newcontext, &newpriority, &newpattern, buf); \
+	loopback_subst(buf, sizeof(buf), exten, context, priority, data); \
+	loopback_parse(&newexten, &newcontext, &newpriority, &newpattern, buf); \
 	ast_log(LOG_DEBUG, "Parsed into %s @ %s priority %d\n", newexten, newcontext, newpriority); \
 	if (!strcasecmp(newcontext, context)) return -1
 
-
-static char *loopback_helper(char *buf, int buflen, const char *exten, const char *context, int priority, const char *data)
+static char *loopback_subst(char *buf, int buflen, const char *exten, const char *context, int priority, const char *data)
 {
 	struct ast_var_t *newvariable;
 	struct varshead headp;
@@ -80,9 +88,12 @@
 
 	snprintf(tmp, sizeof(tmp), "%d", priority);
 	AST_LIST_HEAD_INIT_NOLOCK(&headp);
-	AST_LIST_INSERT_HEAD(&headp, ast_var_assign("EXTEN", exten), entries);
-	AST_LIST_INSERT_HEAD(&headp, ast_var_assign("CONTEXT", context), entries);
-	AST_LIST_INSERT_HEAD(&headp, ast_var_assign("PRIORITY", tmp), entries);
+	newvariable = ast_var_assign("EXTEN", exten);
+	AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
+	newvariable = ast_var_assign("CONTEXT", context);
+	AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
+	newvariable = ast_var_assign("PRIORITY", tmp);
+	AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
 	/* Substitute variables */
 	pbx_substitute_variables_varshead(&headp, data, buf, buflen);
 	/* free the list */
@@ -91,7 +102,7 @@
 	return buf;
 }
 
-static void loopback_subst(char **newexten, char **newcontext, int *priority, char **newpattern, char *buf)
+static void loopback_parse(char **newexten, char **newcontext, int *priority, char **newpattern, char *buf)
 {
 	char *con;
 	char *pri;
@@ -135,9 +146,6 @@
 	int found;
 	LOOPBACK_COMMON;
 	res = ast_spawn_extension(chan, newcontext, newexten, newpriority, callerid, &found, 0);
-	/* XXX hmmm... res is overridden ? */
-	if (newpattern && !ast_extension_match(newpattern, exten))
-		res = -1;
 	return res;
 }
 




More information about the asterisk-commits mailing list