diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-10-24 02:53:24 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-10-24 02:53:24 +0000 |
commit | 5cb692d65fa970c02ee1b206d505d76ae0359227 (patch) | |
tree | 6abd655b3843f9bf2d1bcce7022dd5017ef9701e /pbx | |
parent | 13f34443b97dc96413410706b691285377dab919 (diff) |
Add "Loopback" switch
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@4070 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'pbx')
-rwxr-xr-x | pbx/Makefile | 2 | ||||
-rwxr-xr-x | pbx/pbx_config.c | 7 | ||||
-rwxr-xr-x | pbx/pbx_dundi.c | 53 |
3 files changed, 35 insertions, 27 deletions
diff --git a/pbx/Makefile b/pbx/Makefile index 8fb70b645..3bb8d33cf 100755 --- a/pbx/Makefile +++ b/pbx/Makefile @@ -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 #PBX_LIBS+=$(shell gtk-config --cflags >/dev/null 2>/dev/null && echo "pbx_gtkconsole.so") diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c index 7e0d6d9cd..63c66016c 100755 --- a/pbx/pbx_config.c +++ b/pbx/pbx_config.c @@ -1754,10 +1754,13 @@ static int pbx_load_module(void) pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1); if (ast_context_add_ignorepat2(con, realvalue, registrar)) 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; 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; stringp=tc; appl = strsep(&stringp, "/"); diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c index 7dc346764..89e18dfa0 100755 --- a/pbx/pbx_dundi.c +++ b/pbx/pbx_dundi.c @@ -480,7 +480,6 @@ static int dundi_lookup_local(struct dundi_result *dr, struct dundi_mapping *map { int flags; int x; - struct ast_channel *chan=NULL; if (!ast_strlen_zero(map->lcontext)) { flags = 0; 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); } if (flags) { - /* Clearly we can't say 'don't ask' anymore... */ - chan = ast_channel_alloc(0); - if (chan) { - flags |= map->options & 0xffff; - dr[anscnt].flags = flags; - dr[anscnt].techint = map->tech; - dr[anscnt].weight = map->weight; - dr[anscnt].expiration = DUNDI_DEFAULT_CACHE_TIME; - strncpy(dr[anscnt].tech, tech2str(map->tech), sizeof(dr[anscnt].tech)); - dr[anscnt].eid = *us_eid; - dundi_eid_to_str(dr[anscnt].eid_str, sizeof(dr[anscnt].eid_str), &dr[anscnt].eid); - if (flags & DUNDI_FLAG_EXISTS) { - pbx_builtin_setvar_helper(chan, "NUMBER", called_number); - pbx_builtin_setvar_helper(chan, "EID", dr[anscnt].eid_str); - pbx_builtin_setvar_helper(chan, "SECRET", cursecret); - pbx_builtin_setvar_helper(chan, "IPADDR", ipaddr); - pbx_substitute_variables_helper(chan, map->dest, dr[anscnt].dest, sizeof(dr[anscnt].dest)); - } else - dr[anscnt].dest[0] = '\0'; - anscnt++; - } + struct varshead headp; + struct ast_var_t *newvariable; + flags |= map->options & 0xffff; + dr[anscnt].flags = flags; + dr[anscnt].techint = map->tech; + dr[anscnt].weight = map->weight; + dr[anscnt].expiration = DUNDI_DEFAULT_CACHE_TIME; + strncpy(dr[anscnt].tech, tech2str(map->tech), sizeof(dr[anscnt].tech)); + dr[anscnt].eid = *us_eid; + dundi_eid_to_str(dr[anscnt].eid_str, sizeof(dr[anscnt].eid_str), &dr[anscnt].eid); + if (flags & DUNDI_FLAG_EXISTS) { + AST_LIST_HEAD_INIT(&headp); + newvariable = ast_var_assign("NUMBER", called_number); + AST_LIST_INSERT_HEAD(&headp, newvariable, entries); + newvariable = ast_var_assign("EID", dr[anscnt].eid_str); + AST_LIST_INSERT_HEAD(&headp, newvariable, entries); + newvariable = ast_var_assign("SECRET", cursecret); + AST_LIST_INSERT_HEAD(&headp, newvariable, entries); + newvariable = ast_var_assign("IPADDR", ipaddr); + 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 { /* No answers... Find the fewest number of digits from the 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; } |