]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Change dns_tsigkey_identity from macro to a function and const argument and result
authorOndřej Surý <ondrej@sury.org>
Fri, 27 Sep 2019 07:39:02 +0000 (09:39 +0200)
committerOndřej Surý <ondrej@sury.org>
Thu, 3 Oct 2019 07:50:25 +0000 (09:50 +0200)
(cherry picked from commit 2e304b0b7f5f08d01572cc855deadb1026e15ca8)

lib/dns/include/dns/tsig.h
lib/dns/tsig.c
lib/dns/win32/libdns.def.in

index 62660fd676376e6baa2e7235c355bbab1d9816f3..4ba141ae7ae43c0958a16aa9e0c53c2f15a1bc3f 100644 (file)
@@ -86,13 +86,21 @@ struct dns_tsigkey {
        ISC_LINK(dns_tsigkey_t) link;
 };
 
-#define dns_tsigkey_identity(tsigkey) \
-       ((tsigkey) == NULL ? NULL : \
-        (tsigkey)->generated ? ((tsigkey)->creator) : \
-        (&((tsigkey)->name)))
-
 ISC_LANG_BEGINDECLS
 
+const dns_name_t *
+dns_tsigkey_identity(const dns_tsigkey_t *tsigkey);
+/*%<
+ *     Returns the identity of the provided TSIG key.
+ *
+ *     Requires:
+ *\li          'tsigkey' is a valid TSIG key or NULL
+ *
+ *     Returns:
+ *\li          NULL if 'tsigkey' was NULL
+ *\li          identity of the provided TSIG key
+ */
+
 isc_result_t
 dns_tsigkey_create(const dns_name_t *name, const dns_name_t *algorithm,
                   unsigned char *secret, int length, bool generated,
index 5030e24e7cfd90a09ea496d26e938c49f06c38f4..27cb18a7b29bf4966c8b08e0d9f60a2bd07a834e 100644 (file)
@@ -660,6 +660,20 @@ dns_tsigkeyring_dumpanddetach(dns_tsig_keyring_t **ringp, FILE *fp) {
        return (result);
 }
 
+const dns_name_t *
+dns_tsigkey_identity(const dns_tsigkey_t *tsigkey) {
+       REQUIRE(tsigkey == NULL || VALID_TSIG_KEY(tsigkey));
+
+       if (tsigkey == NULL) {
+               return (NULL);
+       }
+       if (tsigkey->generated) {
+               return (tsigkey->creator);
+       } else {
+               return (&tsigkey->name);
+       }
+}
+
 isc_result_t
 dns_tsigkey_create(const dns_name_t *name, const dns_name_t *algorithm,
                   unsigned char *secret, int length, bool generated,
index 1ba7995073bcc1fcd90da8f6a521ca18da64caec..d44f6036f02000f89371620eae2d03b01c20375d 100644 (file)
@@ -1021,6 +1021,7 @@ dns_tsigkey_create
 dns_tsigkey_createfromkey
 dns_tsigkey_detach
 dns_tsigkey_find
+dns_tsigkey_identity
 dns_tsigkey_setdeleted
 dns_tsigkeyring_add
 dns_tsigkeyring_attach