]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add a dns_fixedname_initname() helper function
authorMukund Sivaraman <muks@isc.org>
Tue, 27 Mar 2018 11:56:35 +0000 (17:26 +0530)
committerOndřej Surý <ondrej@sury.org>
Mon, 9 Apr 2018 10:14:16 +0000 (12:14 +0200)
This also turns the dns_fixedname macros into functions.

lib/dns/Makefile.in
lib/dns/fixedname.c [new file with mode: 0644]
lib/dns/include/dns/fixedname.h
lib/dns/win32/libdns.def.in
lib/dns/win32/libdns.vcxproj.filters.in
lib/dns/win32/libdns.vcxproj.in
util/copyrights

index b8e6e722c018e945fd7530b53f88f2a9eebdb962..9a3234b7f91f62ba4b53ed1d1412d3f3a897cf39 100644 (file)
@@ -65,7 +65,7 @@ DNSOBJS =     acl.@O@ adb.@O@ badcache.@O@ byaddr.@O@ \
                cache.@O@ callbacks.@O@ catz.@O@ clientinfo.@O@ compress.@O@ \
                db.@O@ dbiterator.@O@ dbtable.@O@ diff.@O@ dispatch.@O@ \
                dlz.@O@ dns64.@O@ dnsrps.@O@ dnssec.@O@ ds.@O@ dyndb.@O@ \
-               ecs.@O@ forward.@O@ \
+               ecs.@O@ fixedname.@O@ forward.@O@ \
                ipkeylist.@O@ iptable.@O@ journal.@O@ keydata.@O@ \
                keytable.@O@ lib.@O@ log.@O@ lookup.@O@ \
                master.@O@ masterdump.@O@ message.@O@ \
@@ -109,7 +109,8 @@ DNSTAPSRCS = dnstap.c dnstap.pb-c.c
 DNSSRCS =      acl.c adb.c badcache. byaddr.c \
                cache.c callbacks.c clientinfo.c compress.c \
                db.c dbiterator.c dbtable.c diff.c dispatch.c \
-               dlz.c dns64.c dnsrps.c dnssec.c ds.c dyndb.c ecs.c forward.c \
+               dlz.c dns64.c dnsrps.c dnssec.c ds.c dyndb.c \
+               ecs.c fixedname.c forward.c \
                ipkeylist.c iptable.c journal.c keydata.c keytable.c lib.c \
                log.c lookup.c master.c masterdump.c message.c \
                name.c ncache.c nsec.c nsec3.c nta.c \
diff --git a/lib/dns/fixedname.c b/lib/dns/fixedname.c
new file mode 100644 (file)
index 0000000..3d5de3b
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+/*! \file */
+
+#include <config.h>
+
+#include <dns/fixedname.h>
+
+void
+dns_fixedname_init(dns_fixedname_t *fixed) {
+       dns_name_init(&fixed->name, fixed->offsets);
+       isc_buffer_init(&fixed->buffer, fixed->data, DNS_NAME_MAXWIRE);
+       dns_name_setbuffer(&fixed->name, &fixed->buffer);
+}
+
+void
+dns_fixedname_invalidate(dns_fixedname_t *fixed) {
+       dns_name_invalidate(&fixed->name);
+}
+
+dns_name_t *
+dns_fixedname_name(dns_fixedname_t *fixed) {
+       return (&fixed->name);
+}
+
+dns_name_t *
+dns_fixedname_initname(dns_fixedname_t *fixed) {
+       dns_fixedname_init(fixed);
+       return (dns_fixedname_name(fixed));
+}
index 208c96aacdbd66b1f14849d8125df5540e5521d6..01fc41d94e6e042cdbb56675df706a2526d7a2a6 100644 (file)
@@ -22,8 +22,9 @@
  * \brief
  * Fixed-size Names
  *
- * dns_fixedname_t is a convenience type containing a name, an offsets table,
- * and a dedicated buffer big enough for the longest possible name.
+ * dns_fixedname_t is a convenience type containing a name, an offsets
+ * table, and a dedicated buffer big enough for the longest possible
+ * name. This is typically used for stack-allocated names.
  *
  * MP:
  *\li  The caller must ensure any required synchronization.
@@ -64,17 +65,16 @@ struct dns_fixedname {
        unsigned char                   data[DNS_NAME_MAXWIRE];
 };
 
-#define dns_fixedname_init(fn) \
-       do { \
-               dns_name_init(&((fn)->name), (fn)->offsets); \
-               isc_buffer_init(&((fn)->buffer), (fn)->data, \
-                                 DNS_NAME_MAXWIRE); \
-               dns_name_setbuffer(&((fn)->name), &((fn)->buffer)); \
-       } while (0)
+void
+dns_fixedname_init(dns_fixedname_t *fixed);
 
-#define dns_fixedname_invalidate(fn) \
-       dns_name_invalidate(&((fn)->name))
+void
+dns_fixedname_invalidate(dns_fixedname_t *fixed);
 
-#define dns_fixedname_name(fn)         (&((fn)->name))
+dns_name_t *
+dns_fixedname_name(dns_fixedname_t *fixed);
+
+dns_name_t *
+dns_fixedname_initname(dns_fixedname_t *fixed);
 
 #endif /* DNS_FIXEDNAME_H */
index a5f6060e75b3196eef9118a102094d7206b1befa..bacd9c881ece9f77810336edc58cf843fd5e08b0 100644 (file)
@@ -366,6 +366,10 @@ dns_ecdb_register
 dns_ecdb_unregister
 dns_ecs_init
 dns_ecs_format
+dns_fixedname_init
+dns_fixedname_invalidate
+dns_fixedname_name
+dns_fixedname_initname
 dns_fwdtable_add
 dns_fwdtable_addfwd
 dns_fwdtable_create
index 674f2514c3a9054e10b077541760cd763f432e6b..067daf95428fbb8bab449219d7842844bd2db3c8 100644 (file)
@@ -96,6 +96,9 @@
     <ClCompile Include="..\ecs.c">
       <Filter>Library Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\fixedname.c">
+      <Filter>Library Source Files</Filter>
+    </ClCompile>
     <ClCompile Include="..\forward.c">
       <Filter>Library Source Files</Filter>
     </ClCompile>
index 502a58d7ec28bc94725046b6468d035e84c8cc7b..d6d272d03bfc2d4ae9cdc2f2be6bd13aa2a1d2e5 100644 (file)
     <ClCompile Include="..\dyndb.c" />
     <ClCompile Include="..\ecdb.c" />
     <ClCompile Include="..\ecs.c" />
+    <ClCompile Include="..\fixedname.c" />
     <ClCompile Include="..\forward.c" />
 @IF GEOIP
     <ClCompile Include="..\geoip.c" />
index 00479c0daff15f9c8d9ab7c46672bdb9159b8fc8..12624339a3706c5bc61a57348d80c2a24d37b2b1 100644 (file)
 ./lib/dns/dyndb.c                              C       2015,2016,2017,2018
 ./lib/dns/ecdb.c                               C       2009,2010,2011,2012,2013,2014,2015,2016,2017,2018
 ./lib/dns/ecs.c                                        C       2017,2018
+./lib/dns/fixedname.c                          C       2018
 ./lib/dns/forward.c                            C       2000,2001,2004,2005,2007,2009,2013,2016,2018
 ./lib/dns/gen-unix.h                           C       1999,2000,2001,2004,2005,2007,2009,2016,2018
 ./lib/dns/gen-win32.h                          C       1999,2000,2001,2004,2005,2006,2007,2009,2014,2016,2018