aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-06-03 22:41:04 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-06-03 22:41:04 +0000
commitade7ed66253d927b6a36c253099380fe2a0fd354 (patch)
treefe9e4cdd6ce26a8d55bf6860f2ce8910cf4f02d2
parent577046f960cb57825db09e1f62cb0a89557ef71a (diff)
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) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@120226 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--pbx/pbx_loopback.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/pbx/pbx_loopback.c b/pbx/pbx_loopback.c
index dcbef909b..042cbfb5f 100644
--- a/pbx/pbx_loopback.c
+++ b/pbx/pbx_loopback.c
@@ -53,17 +53,26 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#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 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
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 @@ static char *loopback_helper(char *buf, int buflen, const char *exten, const cha
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 @@ static char *loopback_helper(char *buf, int buflen, const char *exten, const cha
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 @@ static int loopback_exec(struct ast_channel *chan, const char *context, const ch
{
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;
}