[Asterisk-cvs] asterisk/apps app_enumlookup.c,1.15,1.16
markster
markster
Sun Aug 7 10:41:45 CDT 2005
Update of /usr/cvsroot/asterisk/apps
In directory mongoose.digium.com:/tmp/cvs-serv573/apps
Modified Files:
app_enumlookup.c
Log Message:
Allow enumlookup to return a status variable (bug #4788)
Index: app_enumlookup.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_enumlookup.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- app_enumlookup.c 6 Jun 2005 22:39:31 -0000 1.15
+++ app_enumlookup.c 7 Aug 2005 14:45:31 -0000 1.16
@@ -1,8 +1,8 @@
/*
* Asterisk -- A telephony toolkit for Linux.
*
- * Time of day - Report the time of day
- *
+ * Enumlookup - lookup entry in ENUM
+ *
* Copyright (C) 1999 - 2005, Digium, Inc.
*
* Mark Spencer <markster at digium.com>
@@ -42,11 +42,15 @@
" EnumLookup(exten): 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 regardless of whether the \n"
-"lookup was successful. \n"
+"Returns -1 on hangup, or 0 on completion\n"
"Currently, the enumservices SIP, H323, IAX, IAX2 and TEL are recognized. \n"
-"A good SIP, H323, IAX or IAX2 entry will result in normal priority handling, \n"
-"whereas a good TEL entry will increase the priority by 51 (if existing).\n"
+"\nReturns status in the ENUMSTATUS channel variable:\n"
+" 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" ;
@@ -59,6 +63,7 @@
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;
@@ -67,9 +72,10 @@
char tmp[256];
char *c,*t;
struct localuser *u;
+
if (!data || ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "EnumLookup requires an argument (extension)\n");
- res = 1;
+ res = 0;
}
LOCAL_USER_ADD(u);
if (!res) {
@@ -77,6 +83,14 @@
printf("ENUM got '%d'\n", res);
}
LOCAL_USER_REMOVE(u);
+ if (!res) { /* Failed to do a lookup */
+ /* Look for a "busy" place */
+ if (option_priority_jumping && ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
+ chan->priority += 100;
+ pbx_builtin_setvar_helper(chan, "ENUMSTATUS", "ERROR");
+ return 0;
+ }
+ pbx_builtin_setvar_helper(chan, "ENUMSTATUS", tech);
/* Parse it out */
if (res > 0) {
if (!strcasecmp(tech, "SIP")) {
@@ -126,25 +140,21 @@
*t = 0;
pbx_builtin_setvar_helper(chan, "ENUM", tmp);
ast_log(LOG_NOTICE, "tel: ENUM set to \"%s\"\n", tmp);
- if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 51, chan->cid.cid_num))
+ if (option_priority_jumping && ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 51, chan->cid.cid_num))
chan->priority += 50;
else
res = 0;
}
} else if (!ast_strlen_zero(tech)) {
ast_log(LOG_NOTICE, "Don't know how to handle technology '%s'\n", tech);
+ pbx_builtin_setvar_helper(chan, "ENUMSTATUS", "BADURI");
res = 0;
}
}
- if (!res) {
- /* Look for a "busy" place */
- if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
- chan->priority += 100;
- } else if (res > 0)
- res = 0;
- return res;
+ return 0;
}
+/*--- load_config: Load enum.conf and find out how to handle H.323 */
static int load_config(void)
{
struct ast_config *cfg;
@@ -165,12 +175,14 @@
}
+/*--- unload_module: Unload this application from PBX */
int unload_module(void)
{
STANDARD_HANGUP_LOCALUSERS;
return ast_unregister_application(app);
}
+/*--- load_module: Load this application into PBX */
int load_module(void)
{
int res;
@@ -183,12 +195,14 @@
return(0);
}
+/*--- reload: Reload configuration file */
int reload(void)
{
return(load_config());
}
+/*--- description: Describe module */
char *description(void)
{
return tdesc;
More information about the svn-commits
mailing list