[Asterisk-code-review] func_enum.c: Deprecate TXTCIDNAME() and underlying ast_get_txt() API ... (asterisk[13])

Sean Bright asteriskteam at digium.com
Wed Mar 4 15:51:49 CST 2020


Sean Bright has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/13854 )


Change subject: func_enum.c: Deprecate TXTCIDNAME() and underlying ast_get_txt() API function.
......................................................................

func_enum.c: Deprecate TXTCIDNAME() and underlying ast_get_txt() API function.

A large code restructuring in 65b8381550a9f46fdce84de79960073e9d51b05d
erroneously removed the DNS lookup functionality from
ast_get_txt(). Since then, ast_get_txt() and TXTCIDNAME() have
invariably returned an empty string regardless of the arguments
passed.

Mark both the dialplan function and the API as deprecated and remove
them completely in master.

ASTERISK-19460 #close
Reported by: George Joseph

Change-Id: Id19db439eecb36128179c5030032db54057b2123
---
A doc/CHANGES-staging/ast_get_txt.txt
M funcs/func_enum.c
M include/asterisk/enum.h
M main/enum.c
4 files changed, 19 insertions(+), 43 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/54/13854/1

diff --git a/doc/CHANGES-staging/ast_get_txt.txt b/doc/CHANGES-staging/ast_get_txt.txt
new file mode 100644
index 0000000..7dce514
--- /dev/null
+++ b/doc/CHANGES-staging/ast_get_txt.txt
@@ -0,0 +1,4 @@
+Subject: func_enum
+
+The TXTCIDNAME() has not worked since 2008 and has now been marked as
+deprecated. It will be removed completely in Asterisk 18.
diff --git a/funcs/func_enum.c b/funcs/func_enum.c
index 95e8d21..3c88055 100644
--- a/funcs/func_enum.c
+++ b/funcs/func_enum.c
@@ -146,6 +146,8 @@
 			</parameter>
 		</syntax>
 		<description>
+			<note><para>This function is deprecated as it has not worked since
+			2008-05-09.</para></note>
 			<para>This function looks up the given phone number in DNS to retrieve
 			the caller id name.  The result will either be blank or be the value
 			found in the TXT record in DNS.</para>
@@ -414,6 +416,8 @@
 	.read = function_enum,
 };
 
+static int deprecation_warning = 0;
+
 static int function_txtcidname(struct ast_channel *chan, const char *cmd,
 			       char *data, char *buf, size_t len)
 {
@@ -422,6 +426,12 @@
 		AST_APP_ARG(zone);
 	);
 
+	if (!deprecation_warning) {
+		ast_log(LOG_WARNING, "The TXTCIDNAME() function has not returned anything "
+			"since 2008-05-09 and will be removed in Asterisk 18.\n");
+		deprecation_warning = 1;
+	}
+
 	buf[0] = '\0';
 
 	if (ast_strlen_zero(data)) {
diff --git a/include/asterisk/enum.h b/include/asterisk/enum.h
index 877c0c3..990c94a 100644
--- a/include/asterisk/enum.h
+++ b/include/asterisk/enum.h
@@ -79,21 +79,10 @@
 int ast_get_enum(struct ast_channel *chan, const char *number, char *location, int maxloc, char *technology,
 		int maxtech, char* suffix, char* options, unsigned int record, struct enum_context **argcontext);
 
-/*!	\brief Lookup DNS TXT record (used by app TXTCIDnum)
+/*!	\brief (Formerly) Lookup DNS TXT record (used by app TXTCIDnum)
  *
- * Really has nothing to do with enum, but anyway...
- * Actually, there is now an internet-draft which describes how callerID should
- * be stored in ENUM domains: draft-ietf-enum-cnam-04.txt
- * The algorithm implemented here will thus be obsolete soon.
- *
- * \param chan	Channel
- * \param number   E164 number with or without the leading +
- * \param txt	Text string (return value)
- * \param maxtxt	Max length of "txt"
- * \param suffix	Zone suffix
- * \version 1.6.1 new suffix parameter to take into account caller ids that aren't in e164.arpa
- * \version 1.6.1 removed parameters location, maxloc, technology, maxtech as all the information
- * is stored the txt string
+ * This function has done nothing 2008-05-09 and is now deprecated as of Asterisk 13.32.0,
+ * 16.9.0, and 17.3.0. It will no longer be available in Asterisk 18+.
  */
 int ast_get_txt(struct ast_channel *chan, const char *number, char *txt, int maxtxt, char *suffix);
 
diff --git a/main/enum.c b/main/enum.c
index e003f07..7f18fb9 100644
--- a/main/enum.c
+++ b/main/enum.c
@@ -934,35 +934,8 @@
 
 int ast_get_txt(struct ast_channel *chan, const char *number, char *txt, int txtlen, char *suffix)
 {
-	struct txt_context context;
-	char tmp[259 + 512];
-	int pos = strlen(number) - 1;
-	int newpos = 0;
-	int ret = -1;
-
-	ast_debug(4, "ast_get_txt: Number = '%s', suffix = '%s'\n", number, suffix);
-
-	if (pos > 128) {
-		pos = 128;
-	}
-
-	while (pos >= 0) {
-		if (isdigit(number[pos])) {
-			tmp[newpos++] = number[pos];
-			tmp[newpos++] = '.';
-		}
-		pos--;
-	}
-
-	ast_copy_string(&tmp[newpos], suffix, sizeof(tmp) - newpos);
-
-	if (ret < 0) {
-		ast_debug(2, "No such number found in ENUM: %s (%s)\n", tmp, strerror(errno));
-		ret = 0;
-	} else {
-		ast_copy_string(txt, context.txt, txtlen);
-	}
-	return ret;
+	/* This function was an expensive no-op and now it is a cheap no-op */
+	return 0;
 }
 
 /*! \brief Initialize the ENUM support subsystem */

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/13854
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: Id19db439eecb36128179c5030032db54057b2123
Gerrit-Change-Number: 13854
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200304/d316ea34/attachment-0001.html>


More information about the asterisk-code-review mailing list