[asterisk-commits] tilghman: branch 1.4 r120226 - /branches/1.4/pbx/pbx_loopback.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jun 3 17:41:05 CDT 2008
Author: tilghman
Date: Tue Jun 3 17:41:04 2008
New Revision: 120226
URL: http://svn.digium.com/view/asterisk?view=rev&rev=120226
Log:
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:
branches/1.4/pbx/pbx_loopback.c
Modified: branches/1.4/pbx/pbx_loopback.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/pbx/pbx_loopback.c?view=diff&rev=120226&r1=120225&r2=120226
==============================================================================
--- branches/1.4/pbx/pbx_loopback.c (original)
+++ branches/1.4/pbx/pbx_loopback.c Tue Jun 3 17:41:04 2008
@@ -53,17 +53,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!)
*/
@@ -74,13 +83,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;
@@ -89,9 +97,12 @@
snprintf(tmp, sizeof(tmp), "%d", priority);
memset(buf, 0, buflen);
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 */
@@ -100,7 +111,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;
@@ -143,9 +154,6 @@
{
LOOPBACK_COMMON;
res = ast_spawn_extension(chan, newcontext, newexten, newpriority, callerid);
- /* XXX hmmm... res is overridden ? */
- if (newpattern && !ast_extension_match(newpattern, exten))
- res = -1;
return res;
}
More information about the asterisk-commits
mailing list