aboutsummaryrefslogtreecommitdiffstats
path: root/funcs
diff options
context:
space:
mode:
authorbbryant <bbryant@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-09 19:54:45 +0000
committerbbryant <bbryant@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-09 19:54:45 +0000
commit856468a462cf901a434a1707ca4731f8ffb4226e (patch)
tree75981db2012acddf5f0872dd94a115efa2f36540 /funcs
parent44e2dbcb9a4d658a6650a6f53c89161c69694c18 (diff)
The following patch adds new options and alters the default behavior of the ENUM* functions. The TXCIDNAME lookup function has also gotten a
new paramater. The new options for ENUM* functions include 'u', 's', 'i', and 'd' which return the full uri, trigger isn specific rewriting, look for branches into an infrastructure enum tree, or do a direct dns lookup of a number respectively. The new paramater for TXCIDNAME adds a zone-suffix argument for looking up caller id's in DNS that aren't e164.arpa. This patch is based on the original code from otmar, modified by snuffy, and tested by jtodd, me, and others. (closes issue #8089) Reported by: otmar Patches: 20080508_bug8089-1.diff - original code by otmar (license 480), - revised by snuffy (license 35) Tested by: oej, otmar, jtodd, Corydon76, snuffy, alexnikolov, bbryant git-svn-id: http://svn.digium.com/svn/asterisk/trunk@115584 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs')
-rw-r--r--funcs/func_enum.c61
1 files changed, 38 insertions, 23 deletions
diff --git a/funcs/func_enum.c b/funcs/func_enum.c
index e1c29cbfc..0fba5af3b 100644
--- a/funcs/func_enum.c
+++ b/funcs/func_enum.c
@@ -78,16 +78,21 @@ static int function_enum(struct ast_channel *chan, const char *cmd, char *data,
return -1;
}
- ast_copy_string(tech, args.tech ? args.tech : "sip", sizeof(tech));
+ if (args.tech && !ast_strlen_zero(args.tech)) {
+ ast_copy_string(tech,args.tech, sizeof(tech));
+ } else {
+ ast_copy_string(tech,"sip",sizeof(tech));
+ }
- if (!args.zone)
+ if (!args.zone) {
args.zone = "e164.arpa";
-
- if (!args.options)
+ }
+ if (!args.options) {
args.options = "";
-
- if (args.record)
- record = atoi(args.record);
+ }
+ if (args.record) {
+ record = atoi(args.record) ? atoi(args.record) : record;
+ }
/* strip any '-' signs from number */
for (s = p = args.number; *s; s++) {
@@ -97,15 +102,14 @@ static int function_enum(struct ast_channel *chan, const char *cmd, char *data,
}
}
-
- res = ast_get_enum(chan, num, dest, sizeof(dest), tech, sizeof(tech), args.zone, args.options, 1, NULL);
+ res = ast_get_enum(chan, num, dest, sizeof(dest), tech, sizeof(tech), args.zone, args.options, record, NULL);
p = strchr(dest, ':');
- if (p && strcasecmp(tech, "ALL"))
+ if (p && strcasecmp(tech, "ALL") && !strchr(args.options, 'u')) {
ast_copy_string(buf, p + 1, len);
- else
+ } else {
ast_copy_string(buf, dest, len);
-
+ }
return 0;
}
@@ -323,6 +327,10 @@ static struct ast_custom_function enum_function = {
.desc =
"Option 'c' returns an integer count of the number of NAPTRs of a certain RR type.\n"
"Combination of 'c' and Method-type of 'ALL' will return a count of all NAPTRs for the record.\n"
+ "Option 'u' returns the full URI and does not strip off the URI-scheme.\n"
+ "Option 's' triggers ISN specific rewriting\n"
+ "Option 'i' looks for branches into an Infrastructure ENUM tree\n"
+ "Option 'd' for a direct DNS lookup without any flipping of digits\n"
"Defaults are: Method-type=sip, no options, record=1, zone-suffix=e164.arpa\n\n"
"For more information, see doc/asterisk.pdf",
.read = function_enum,
@@ -332,23 +340,30 @@ static int function_txtcidname(struct ast_channel *chan, const char *cmd,
char *data, char *buf, size_t len)
{
int res;
- char tech[80];
- char txt[256] = "";
- char dest[80];
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(number);
+ AST_APP_ARG(zone);
+ );
buf[0] = '\0';
-
if (ast_strlen_zero(data)) {
- ast_log(LOG_WARNING, "TXTCIDNAME requires an argument (number)\n");
+ ast_log(LOG_WARNING, "Syntax: TXTCIDNAME(number[,zone-suffix])\n");
+ return -1;
+ }
+
+ AST_STANDARD_APP_ARGS(args, data);
+
+ if (args.argc < 1) {
+ ast_log(LOG_WARNING, "Syntax: TXTCIDNAME(number[,zone-suffix])\n");
return -1;
}
- res = ast_get_txt(chan, data, dest, sizeof(dest), tech, sizeof(tech), txt,
- sizeof(txt));
+ if (!args.zone) {
+ args.zone = "e164.arpa";
+ }
- if (!ast_strlen_zero(txt))
- ast_copy_string(buf, txt, len);
+ res = ast_get_txt(chan, args.number, buf, len, args.zone);
return 0;
}
@@ -356,11 +371,11 @@ static int function_txtcidname(struct ast_channel *chan, const char *cmd,
static struct ast_custom_function txtcidname_function = {
.name = "TXTCIDNAME",
.synopsis = "TXTCIDNAME looks up a caller name via DNS",
- .syntax = "TXTCIDNAME(<number>)",
+ .syntax = "TXTCIDNAME(<number>[,zone-suffix])",
.desc =
"This function looks up the given phone number in DNS to retrieve\n"
"the caller id name. The result will either be blank or be the value\n"
- "found in the TXT record in DNS.\n",
+ "found in the TXT record in DNS. The default zone-suffix is e164.arpa.\n",
.read = function_txtcidname,
};