mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 12:16:00 +00:00
Add "Loopback" switch
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4070 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
2
Makefile
2
Makefile
@@ -162,9 +162,11 @@ CFLAGS+=$(shell if [ -f /usr/local/include/zaptel.h ]; then echo "-DZAPTEL_OPTIM
|
|||||||
LIBEDIT=editline/libedit.a
|
LIBEDIT=editline/libedit.a
|
||||||
|
|
||||||
ASTERISKVERSION=$(shell if [ -f .version ]; then cat .version; else if [ -d CVS ]; then if [ -f CVS/Tag ] ; then echo "CVS-`sed 's/^T//g' CVS/Tag`-`date +"%D-%T"`"; else echo "CVS-HEAD-`date +"%D-%T"`"; fi; fi; fi)
|
ASTERISKVERSION=$(shell if [ -f .version ]; then cat .version; else if [ -d CVS ]; then if [ -f CVS/Tag ] ; then echo "CVS-`sed 's/^T//g' CVS/Tag`-`date +"%D-%T"`"; else echo "CVS-HEAD-`date +"%D-%T"`"; fi; fi; fi)
|
||||||
|
ASTERISKVERSIONNUM=$(shell if [ -d CVS ]; then echo 999999 ; else if [ -f .version ] ; then awk -F. '{printf "%02d%02d%02d", $$1, $$2, $$3}' .version ; else echo 000000 ; fi ; fi)
|
||||||
HTTPDIR=$(shell if [ -d /var/www ]; then echo "/var/www"; else echo "/home/httpd"; fi)
|
HTTPDIR=$(shell if [ -d /var/www ]; then echo "/var/www"; else echo "/home/httpd"; fi)
|
||||||
RPMVERSION=$(shell if [ -f .version ]; then sed 's/[-\/:]/_/g' .version; else echo "unknown" ; fi)
|
RPMVERSION=$(shell if [ -f .version ]; then sed 's/[-\/:]/_/g' .version; else echo "unknown" ; fi)
|
||||||
CFLAGS+=-DASTERISK_VERSION=\"$(ASTERISKVERSION)\"
|
CFLAGS+=-DASTERISK_VERSION=\"$(ASTERISKVERSION)\"
|
||||||
|
CFLAGS+=-DASTERISK_VERSION_NUM=\"$(ASTERISKVERSIONNUM)\"
|
||||||
CFLAGS+=-DINSTALL_PREFIX=\"$(INSTALL_PREFIX)\"
|
CFLAGS+=-DINSTALL_PREFIX=\"$(INSTALL_PREFIX)\"
|
||||||
CFLAGS+=-DASTETCDIR=\"$(ASTETCDIR)\"
|
CFLAGS+=-DASTETCDIR=\"$(ASTETCDIR)\"
|
||||||
CFLAGS+=-DASTLIBDIR=\"$(ASTLIBDIR)\"
|
CFLAGS+=-DASTLIBDIR=\"$(ASTLIBDIR)\"
|
||||||
|
@@ -340,8 +340,6 @@ struct ast_channel *ast_channel_alloc(int needqueue)
|
|||||||
headp=&tmp->varshead;
|
headp=&tmp->varshead;
|
||||||
ast_mutex_init(&tmp->lock);
|
ast_mutex_init(&tmp->lock);
|
||||||
AST_LIST_HEAD_INIT(headp);
|
AST_LIST_HEAD_INIT(headp);
|
||||||
tmp->vars=ast_var_assign("tempvar","tempval");
|
|
||||||
AST_LIST_INSERT_HEAD(headp,tmp->vars,entries);
|
|
||||||
strncpy(tmp->context, "default", sizeof(tmp->context)-1);
|
strncpy(tmp->context, "default", sizeof(tmp->context)-1);
|
||||||
strncpy(tmp->language, defaultlanguage, sizeof(tmp->language)-1);
|
strncpy(tmp->language, defaultlanguage, sizeof(tmp->language)-1);
|
||||||
strncpy(tmp->exten, "s", sizeof(tmp->exten)-1);
|
strncpy(tmp->exten, "s", sizeof(tmp->exten)-1);
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
#include <asterisk/chanvars.h>
|
#include <asterisk/chanvars.h>
|
||||||
#include <asterisk/logger.h>
|
#include <asterisk/logger.h>
|
||||||
|
|
||||||
struct ast_var_t *ast_var_assign(char *name, char *value)
|
struct ast_var_t *ast_var_assign(const char *name, const char *value)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct ast_var_t *var;
|
struct ast_var_t *var;
|
||||||
|
@@ -247,6 +247,13 @@ include => iaxprovider
|
|||||||
; Asterisk PBX
|
; Asterisk PBX
|
||||||
;
|
;
|
||||||
; switch => IAX2/user:password@bigserver/local
|
; switch => IAX2/user:password@bigserver/local
|
||||||
|
;
|
||||||
|
; An "lswitch" is like a switch but is literal, in that
|
||||||
|
; variable substitution is not performed at load time
|
||||||
|
; but is passed to the switch directly (presumably to
|
||||||
|
; be substituted in the switch routine itself)
|
||||||
|
;
|
||||||
|
; lswitch => Loopback/12${EXTEN}@othercontext
|
||||||
|
|
||||||
[macro-stdexten];
|
[macro-stdexten];
|
||||||
;
|
;
|
||||||
|
@@ -228,7 +228,6 @@ struct ast_channel {
|
|||||||
int hangupcause;
|
int hangupcause;
|
||||||
|
|
||||||
/* A linked list for variables */
|
/* A linked list for variables */
|
||||||
struct ast_var_t *vars;
|
|
||||||
AST_LIST_HEAD(varshead,ast_var_t) varshead;
|
AST_LIST_HEAD(varshead,ast_var_t) varshead;
|
||||||
|
|
||||||
unsigned int callgroup;
|
unsigned int callgroup;
|
||||||
|
@@ -22,7 +22,7 @@ struct ast_var_t {
|
|||||||
AST_LIST_ENTRY(ast_var_t) entries;
|
AST_LIST_ENTRY(ast_var_t) entries;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ast_var_t *ast_var_assign(char *name,char *value);
|
struct ast_var_t *ast_var_assign(const char *name, const char *value);
|
||||||
void ast_var_delete(struct ast_var_t *var);
|
void ast_var_delete(struct ast_var_t *var);
|
||||||
char *ast_var_name(struct ast_var_t *var);
|
char *ast_var_name(struct ast_var_t *var);
|
||||||
char *ast_var_value(struct ast_var_t *var);
|
char *ast_var_value(struct ast_var_t *var);
|
||||||
|
@@ -548,6 +548,7 @@ extern void pbx_builtin_setvar_helper(struct ast_channel *chan, char *name, char
|
|||||||
extern void pbx_builtin_clear_globals(void);
|
extern void pbx_builtin_clear_globals(void);
|
||||||
extern int pbx_builtin_setvar(struct ast_channel *chan, void *data);
|
extern int pbx_builtin_setvar(struct ast_channel *chan, void *data);
|
||||||
extern void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char *cp2,int count);
|
extern void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char *cp2,int count);
|
||||||
|
extern void pbx_substitute_variables_varshead(struct varshead *headp, const char *cp1, char *cp2, int count);
|
||||||
|
|
||||||
int ast_extension_patmatch(const char *pattern, const char *data);
|
int ast_extension_patmatch(const char *pattern, const char *data);
|
||||||
|
|
||||||
|
27
pbx.c
27
pbx.c
@@ -828,7 +828,7 @@ static struct ast_exten *pbx_find_extension(struct ast_channel *chan, struct ast
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pbx_substitute_variables_temp(struct ast_channel *c, const char *var, char **ret, char *workspace, int workspacelen)
|
static void pbx_substitute_variables_temp(struct ast_channel *c, const char *var, char **ret, char *workspace, int workspacelen, struct varshead *headp)
|
||||||
{
|
{
|
||||||
char *first,*second;
|
char *first,*second;
|
||||||
char tmpvar[80] = "";
|
char tmpvar[80] = "";
|
||||||
@@ -836,7 +836,6 @@ static void pbx_substitute_variables_temp(struct ast_channel *c, const char *var
|
|||||||
struct tm brokentime;
|
struct tm brokentime;
|
||||||
int offset,offset2;
|
int offset,offset2;
|
||||||
struct ast_var_t *variables;
|
struct ast_var_t *variables;
|
||||||
struct varshead *headp=NULL;
|
|
||||||
|
|
||||||
if (c)
|
if (c)
|
||||||
headp=&c->varshead;
|
headp=&c->varshead;
|
||||||
@@ -861,7 +860,7 @@ static void pbx_substitute_variables_temp(struct ast_channel *c, const char *var
|
|||||||
if (!first)
|
if (!first)
|
||||||
first = tmpvar + strlen(tmpvar);
|
first = tmpvar + strlen(tmpvar);
|
||||||
*first='\0';
|
*first='\0';
|
||||||
pbx_substitute_variables_temp(c,tmpvar,ret,workspace,workspacelen - 1);
|
pbx_substitute_variables_temp(c,tmpvar,ret,workspace,workspacelen - 1, headp);
|
||||||
if (!(*ret)) return;
|
if (!(*ret)) return;
|
||||||
offset=atoi(first+1);
|
offset=atoi(first+1);
|
||||||
if ((second=strchr(first+1,':'))) {
|
if ((second=strchr(first+1,':'))) {
|
||||||
@@ -1009,7 +1008,7 @@ static void pbx_substitute_variables_temp(struct ast_channel *c, const char *var
|
|||||||
strncpy(workspace, c->language, workspacelen - 1);
|
strncpy(workspace, c->language, workspacelen - 1);
|
||||||
*ret = workspace;
|
*ret = workspace;
|
||||||
} else {
|
} else {
|
||||||
if (c) {
|
if (headp) {
|
||||||
AST_LIST_TRAVERSE(headp,variables,entries) {
|
AST_LIST_TRAVERSE(headp,variables,entries) {
|
||||||
#if 0
|
#if 0
|
||||||
ast_log(LOG_WARNING,"Comparing variable '%s' with '%s'\n",var,ast_var_name(variables));
|
ast_log(LOG_WARNING,"Comparing variable '%s' with '%s'\n",var,ast_var_name(variables));
|
||||||
@@ -1056,7 +1055,7 @@ static void pbx_substitute_variables_temp(struct ast_channel *c, const char *var
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
|
static void pbx_substitute_variables_helper_full(struct ast_channel *c, const char *cp1, char *cp2, int count, struct varshead *headp)
|
||||||
{
|
{
|
||||||
char *cp4;
|
char *cp4;
|
||||||
const char *tmp, *whereweare;
|
const char *tmp, *whereweare;
|
||||||
@@ -1147,7 +1146,7 @@ void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, cha
|
|||||||
|
|
||||||
/* Retrieve variable value */
|
/* Retrieve variable value */
|
||||||
workspace[0] = '\0';
|
workspace[0] = '\0';
|
||||||
pbx_substitute_variables_temp(c,vars,&cp4, workspace, sizeof(workspace));
|
pbx_substitute_variables_temp(c,vars,&cp4, workspace, sizeof(workspace), headp);
|
||||||
if (cp4) {
|
if (cp4) {
|
||||||
length = strlen(cp4);
|
length = strlen(cp4);
|
||||||
if (length > count)
|
if (length > count)
|
||||||
@@ -1222,6 +1221,16 @@ void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, cha
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
|
||||||
|
{
|
||||||
|
pbx_substitute_variables_helper_full(c, cp1, cp2, count, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pbx_substitute_variables_varshead(struct varshead *headp, const char *cp1, char *cp2, int count)
|
||||||
|
{
|
||||||
|
pbx_substitute_variables_helper_full(NULL, cp1, cp2, count, headp);
|
||||||
|
}
|
||||||
|
|
||||||
static void pbx_substitute_variables(char *passdata, int datalen, struct ast_channel *c, struct ast_exten *e) {
|
static void pbx_substitute_variables(char *passdata, int datalen, struct ast_channel *c, struct ast_exten *e) {
|
||||||
|
|
||||||
memset(passdata, 0, datalen);
|
memset(passdata, 0, datalen);
|
||||||
@@ -1806,6 +1815,11 @@ int ast_spawn_extension(struct ast_channel *c, const char *context, const char *
|
|||||||
return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, HELPER_SPAWN);
|
return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, HELPER_SPAWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ast_exec_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
|
||||||
|
{
|
||||||
|
return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, HELPER_EXEC);
|
||||||
|
}
|
||||||
|
|
||||||
int ast_pbx_run(struct ast_channel *c)
|
int ast_pbx_run(struct ast_channel *c)
|
||||||
{
|
{
|
||||||
int firstpass = 1;
|
int firstpass = 1;
|
||||||
@@ -5335,3 +5349,4 @@ int ast_context_verify_includes(struct ast_context *con)
|
|||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
PBX_LIBS=pbx_config.so pbx_spool.so pbx_dundi.so
|
PBX_LIBS=pbx_config.so pbx_spool.so pbx_dundi.so pbx_loopback.so
|
||||||
|
|
||||||
# Add GTK console if appropriate
|
# Add GTK console if appropriate
|
||||||
#PBX_LIBS+=$(shell gtk-config --cflags >/dev/null 2>/dev/null && echo "pbx_gtkconsole.so")
|
#PBX_LIBS+=$(shell gtk-config --cflags >/dev/null 2>/dev/null && echo "pbx_gtkconsole.so")
|
||||||
|
@@ -1754,10 +1754,13 @@ static int pbx_load_module(void)
|
|||||||
pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
|
pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
|
||||||
if (ast_context_add_ignorepat2(con, realvalue, registrar))
|
if (ast_context_add_ignorepat2(con, realvalue, registrar))
|
||||||
ast_log(LOG_WARNING, "Unable to include ignorepat '%s' in context '%s'\n", v->value, cxt);
|
ast_log(LOG_WARNING, "Unable to include ignorepat '%s' in context '%s'\n", v->value, cxt);
|
||||||
} else if (!strcasecmp(v->name, "switch")) {
|
} else if (!strcasecmp(v->name, "switch") || !strcasecmp(v->name, "lswitch")) {
|
||||||
char *stringp=NULL;
|
char *stringp=NULL;
|
||||||
memset(realvalue, 0, sizeof(realvalue));
|
memset(realvalue, 0, sizeof(realvalue));
|
||||||
pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
|
if (!strcasecmp(v->name, "switch"))
|
||||||
|
pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
|
||||||
|
else
|
||||||
|
strncpy(realvalue, v->value, sizeof(realvalue) - 1);
|
||||||
tc = realvalue;
|
tc = realvalue;
|
||||||
stringp=tc;
|
stringp=tc;
|
||||||
appl = strsep(&stringp, "/");
|
appl = strsep(&stringp, "/");
|
||||||
|
@@ -480,7 +480,6 @@ static int dundi_lookup_local(struct dundi_result *dr, struct dundi_mapping *map
|
|||||||
{
|
{
|
||||||
int flags;
|
int flags;
|
||||||
int x;
|
int x;
|
||||||
struct ast_channel *chan=NULL;
|
|
||||||
if (!ast_strlen_zero(map->lcontext)) {
|
if (!ast_strlen_zero(map->lcontext)) {
|
||||||
flags = 0;
|
flags = 0;
|
||||||
if (ast_exists_extension(NULL, map->lcontext, called_number, 1, NULL))
|
if (ast_exists_extension(NULL, map->lcontext, called_number, 1, NULL))
|
||||||
@@ -501,27 +500,35 @@ static int dundi_lookup_local(struct dundi_result *dr, struct dundi_mapping *map
|
|||||||
flags &= ~(DUNDI_FLAG_MATCHMORE|DUNDI_FLAG_CANMATCH);
|
flags &= ~(DUNDI_FLAG_MATCHMORE|DUNDI_FLAG_CANMATCH);
|
||||||
}
|
}
|
||||||
if (flags) {
|
if (flags) {
|
||||||
/* Clearly we can't say 'don't ask' anymore... */
|
struct varshead headp;
|
||||||
chan = ast_channel_alloc(0);
|
struct ast_var_t *newvariable;
|
||||||
if (chan) {
|
flags |= map->options & 0xffff;
|
||||||
flags |= map->options & 0xffff;
|
dr[anscnt].flags = flags;
|
||||||
dr[anscnt].flags = flags;
|
dr[anscnt].techint = map->tech;
|
||||||
dr[anscnt].techint = map->tech;
|
dr[anscnt].weight = map->weight;
|
||||||
dr[anscnt].weight = map->weight;
|
dr[anscnt].expiration = DUNDI_DEFAULT_CACHE_TIME;
|
||||||
dr[anscnt].expiration = DUNDI_DEFAULT_CACHE_TIME;
|
strncpy(dr[anscnt].tech, tech2str(map->tech), sizeof(dr[anscnt].tech));
|
||||||
strncpy(dr[anscnt].tech, tech2str(map->tech), sizeof(dr[anscnt].tech));
|
dr[anscnt].eid = *us_eid;
|
||||||
dr[anscnt].eid = *us_eid;
|
dundi_eid_to_str(dr[anscnt].eid_str, sizeof(dr[anscnt].eid_str), &dr[anscnt].eid);
|
||||||
dundi_eid_to_str(dr[anscnt].eid_str, sizeof(dr[anscnt].eid_str), &dr[anscnt].eid);
|
if (flags & DUNDI_FLAG_EXISTS) {
|
||||||
if (flags & DUNDI_FLAG_EXISTS) {
|
AST_LIST_HEAD_INIT(&headp);
|
||||||
pbx_builtin_setvar_helper(chan, "NUMBER", called_number);
|
newvariable = ast_var_assign("NUMBER", called_number);
|
||||||
pbx_builtin_setvar_helper(chan, "EID", dr[anscnt].eid_str);
|
AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
|
||||||
pbx_builtin_setvar_helper(chan, "SECRET", cursecret);
|
newvariable = ast_var_assign("EID", dr[anscnt].eid_str);
|
||||||
pbx_builtin_setvar_helper(chan, "IPADDR", ipaddr);
|
AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
|
||||||
pbx_substitute_variables_helper(chan, map->dest, dr[anscnt].dest, sizeof(dr[anscnt].dest));
|
newvariable = ast_var_assign("SECRET", cursecret);
|
||||||
} else
|
AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
|
||||||
dr[anscnt].dest[0] = '\0';
|
newvariable = ast_var_assign("IPADDR", ipaddr);
|
||||||
anscnt++;
|
AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
|
||||||
}
|
pbx_substitute_variables_varshead(&headp, map->dest, dr[anscnt].dest, sizeof(dr[anscnt].dest));
|
||||||
|
while (!AST_LIST_EMPTY(&headp)) { /* List Deletion. */
|
||||||
|
newvariable = AST_LIST_FIRST(&headp);
|
||||||
|
AST_LIST_REMOVE_HEAD(&headp, entries);
|
||||||
|
ast_var_delete(newvariable);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
dr[anscnt].dest[0] = '\0';
|
||||||
|
anscnt++;
|
||||||
} else {
|
} else {
|
||||||
/* No answers... Find the fewest number of digits from the
|
/* No answers... Find the fewest number of digits from the
|
||||||
number for which we have no answer. */
|
number for which we have no answer. */
|
||||||
@@ -541,8 +548,6 @@ static int dundi_lookup_local(struct dundi_result *dr, struct dundi_mapping *map
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (chan)
|
|
||||||
ast_hangup(chan);
|
|
||||||
return anscnt;
|
return anscnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user