aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_enumlookup.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-10-04 21:58:16 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-10-04 21:58:16 +0000
commit83eccefddcf2a79110f399e80e9b87660974b209 (patch)
tree75d4ee6bc24a0d39bacdcb8ebd09b935dba78f9e /apps/app_enumlookup.c
parent52169f5647e2f8285579db7d720756bea3075e3e (diff)
SRV and ENUM fixes (bug #'s 350 and 351)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1606 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_enumlookup.c')
-rwxr-xr-xapps/app_enumlookup.c69
1 files changed, 59 insertions, 10 deletions
diff --git a/apps/app_enumlookup.c b/apps/app_enumlookup.c
index fb0956721..22e76012d 100755
--- a/apps/app_enumlookup.c
+++ b/apps/app_enumlookup.c
@@ -16,6 +16,8 @@
#include <asterisk/logger.h>
#include <asterisk/channel.h>
#include <asterisk/pbx.h>
+#include <asterisk/options.h>
+#include <asterisk/config.h>
#include <asterisk/module.h>
#include <asterisk/enum.h>
#include <stdlib.h>
@@ -35,14 +37,21 @@ static char *synopsis = "Lookup number in ENUM";
static char *descrip =
" EnumLookup(exten): Looks up an extension via ENUM and sets\n"
-"the variable 'ENUM'. Returns -1 on hangup, or 0 on completion\n"
-"regardless of whether the lookup was successful. Currently, the\n"
-"enumservices SIP and TEL are recognized. A good SIP entry\n"
-"will result in normal priority handling, whereas a good TEL entry\n"
-"will increase the priority by 51 (if existing)\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"
+"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"
"If the lookup was *not* successful and there exists a priority n + 101,\n"
"then that priority will be taken next.\n" ;
+#define ENUM_CONFIG "enum.conf"
+
+static char h323driver[80];
+#define H323DRIVERDEFAULT "H323"
+
STANDARD_LOCAL_USER;
LOCAL_USER_DECL;
@@ -73,19 +82,23 @@ static int enumlookup_exec(struct ast_channel *chan, void *data)
c += 4;
snprintf(tmp, sizeof(tmp), "SIP/%s", c);
pbx_builtin_setvar_helper(chan, "ENUM", tmp);
- } else if (!strcasecmp(tech, "H323")) {
+ } else if (!strcasecmp(tech, "h323")) {
c = dest;
if (!strncmp(c, "h323:", 5))
c += 5;
- snprintf(tmp, sizeof(tmp), "H323/%s", c);
+ snprintf(tmp, sizeof(tmp), "%s/%s", h323driver, c);
+/* do a s!;.*!! on the H323 URI */
+ t = strchr(c,';');
+ if (t)
+ *t = 0;
pbx_builtin_setvar_helper(chan, "ENUM", tmp);
- } else if (!strcasecmp(tech, "IAX")) {
+ } else if (!strcasecmp(tech, "iax")) {
c = dest;
if (!strncmp(c, "iax:", 4))
c += 4;
snprintf(tmp, sizeof(tmp), "IAX/%s", c);
pbx_builtin_setvar_helper(chan, "ENUM", tmp);
- } else if (!strcasecmp(tech, "IAX2")) {
+ } else if (!strcasecmp(tech, "iax2")) {
c = dest;
if (!strncmp(c, "iax2:", 5))
c += 5;
@@ -129,6 +142,28 @@ static int enumlookup_exec(struct ast_channel *chan, void *data)
return res;
}
+static int load_config(void)
+{
+ struct ast_config *cfg;
+ char *s;
+
+ ast_log(LOG_WARNING, "reading enum config\n");
+
+ cfg = ast_load(ENUM_CONFIG);
+ if (cfg) {
+ if (!(s=ast_variable_retrieve(cfg, "general", "h323driver"))) {
+ strcpy(h323driver, H323DRIVERDEFAULT);
+ } else {
+ strcpy(h323driver, s);
+ }
+ ast_destroy(cfg);
+ return 0;
+ }
+ ast_log(LOG_WARNING, "Error reading enum config\n");
+ return -1;
+}
+
+
int unload_module(void)
{
STANDARD_HANGUP_LOCALUSERS;
@@ -137,9 +172,22 @@ int unload_module(void)
int load_module(void)
{
- return ast_register_application(app, enumlookup_exec, synopsis, descrip);
+ int res;
+ res = ast_register_application(app, enumlookup_exec, synopsis, descrip);
+ if (res)
+ return(res);
+ if ((res=load_config())) {
+ return(res);
+ }
+ return(0);
}
+int reload(void)
+{
+ return(load_config());
+}
+
+
char *description(void)
{
return tdesc;
@@ -156,3 +204,4 @@ char *key()
{
return ASTERISK_GPL_KEY;
}
+