aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_enumlookup.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2005-11-06 18:36:37 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2005-11-06 18:36:37 +0000
commitcc1e66bff35882e710df4c43c4f8836b9c8d03fd (patch)
tree3d7421e2eca2c2bde64b6ae72701a269fb7aaaff /apps/app_enumlookup.c
parent599a1f39fc72310788527fad52162084a2a91f3d (diff)
issue #5614
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6982 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_enumlookup.c')
-rwxr-xr-xapps/app_enumlookup.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/apps/app_enumlookup.c b/apps/app_enumlookup.c
index 41536b32f..cc07ea712 100755
--- a/apps/app_enumlookup.c
+++ b/apps/app_enumlookup.c
@@ -43,6 +43,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/module.h"
#include "asterisk/enum.h"
#include "asterisk/utils.h"
+#include "asterisk/options.h"
static char *tdesc = "ENUM Lookup";
@@ -51,7 +52,7 @@ static char *app = "EnumLookup";
static char *synopsis = "Lookup number in ENUM";
static char *descrip =
-" EnumLookup(exten): Looks up an extension via ENUM and sets\n"
+" EnumLookup(exten[|option]): Looks up an extension via ENUM and sets\n"
"the variable 'ENUM'. For VoIP URIs this variable will \n"
"look like 'TECHNOLOGY/URI' with the appropriate technology.\n"
"Returns -1 on hangup, or 0 on completion\n"
@@ -60,11 +61,9 @@ static char *descrip =
" ERROR Failed to do a lookup\n"
" <tech> Technology of the successful lookup: SIP, H323, IAX, IAX2 or TEL\n"
" BADURI Got URI Asterisk does not understand.\n"
-"\nOld, depreciated, behaviour:\n"
-"\nA SIP, H323, IAX or IAX2 entry will result in normal priority handling, \n"
-"whereas a TEL entry will increase the priority by 51 (if existing).\n"
-"If the lookup was *not* successful and there exists a priority n + 101,\n"
-"then that priority will be taken next.\n" ;
+" The option string may contain zero or the following character:\n"
+" 'j' -- jump to +101 priority if the lookup isn't successful.\n"
+" and jump to +51 priority on a TEL entry.\n";
#define ENUM_CONFIG "enum.conf"
@@ -78,11 +77,11 @@ LOCAL_USER_DECL;
/*--- enumlookup_exec: Look up number in ENUM and return result */
static int enumlookup_exec(struct ast_channel *chan, void *data)
{
- int res=0;
+ int res=0,priority_jump=0;
char tech[80];
char dest[80];
char tmp[256];
- char *c,*t;
+ char *c,*t,*d,*o = NULL;
static int dep_warning=0;
struct localuser *u;
@@ -100,11 +99,24 @@ static int enumlookup_exec(struct ast_channel *chan, void *data)
tech[0] = '\0';
- res = ast_get_enum(chan, data, dest, sizeof(dest), tech, sizeof(tech), NULL, NULL);
+ if (strchr(data, '|')) {
+ d = strsep(data, "|");
+ o = strsep(data, "\0");
+ } else
+ d = strsep(data, "\0");
+
+ if (o) {
+ if (strchr(o, 'j'))
+ priority_jump = 1;
+ }
+
+ res = ast_get_enum(chan, d, dest, sizeof(dest), tech, sizeof(tech), NULL, NULL);
if (!res) { /* Failed to do a lookup */
- /* Look for a "busy" place */
- ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
+ if (priority_jump || option_priority_jumping) {
+ /* Look for a "busy" place */
+ ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
+ }
pbx_builtin_setvar_helper(chan, "ENUMSTATUS", "ERROR");
LOCAL_USER_REMOVE(u);
return 0;
@@ -159,8 +171,10 @@ static int enumlookup_exec(struct ast_channel *chan, void *data)
*t = 0;
pbx_builtin_setvar_helper(chan, "ENUM", tmp);
ast_log(LOG_NOTICE, "tel: ENUM set to \"%s\"\n", tmp);
- if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 51))
- res = 0;
+ if (priority_jump || option_priority_jumping) {
+ if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 51))
+ res = 0;
+ }
}
} else if (!ast_strlen_zero(tech)) {
ast_log(LOG_NOTICE, "Don't know how to handle technology '%s'\n", tech);