diff --git a/lib/dns/Makefile.in b/lib/dns/Makefile.in index b8e6e722c0..9a3234b7f9 100644 --- a/lib/dns/Makefile.in +++ b/lib/dns/Makefile.in @@ -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 index 0000000000..3d5de3b42d --- /dev/null +++ b/lib/dns/fixedname.c @@ -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 + +#include + +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)); +} diff --git a/lib/dns/include/dns/fixedname.h b/lib/dns/include/dns/fixedname.h index 208c96aacd..01fc41d94e 100644 --- a/lib/dns/include/dns/fixedname.h +++ b/lib/dns/include/dns/fixedname.h @@ -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 */ diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index a5f6060e75..bacd9c881e 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -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 diff --git a/lib/dns/win32/libdns.vcxproj.filters.in b/lib/dns/win32/libdns.vcxproj.filters.in index 674f2514c3..067daf9542 100644 --- a/lib/dns/win32/libdns.vcxproj.filters.in +++ b/lib/dns/win32/libdns.vcxproj.filters.in @@ -96,6 +96,9 @@ Library Source Files + + Library Source Files + Library Source Files diff --git a/lib/dns/win32/libdns.vcxproj.in b/lib/dns/win32/libdns.vcxproj.in index 502a58d7ec..d6d272d03b 100644 --- a/lib/dns/win32/libdns.vcxproj.in +++ b/lib/dns/win32/libdns.vcxproj.in @@ -135,6 +135,7 @@ + @IF GEOIP diff --git a/util/copyrights b/util/copyrights index 00479c0daf..12624339a3 100644 --- a/util/copyrights +++ b/util/copyrights @@ -2941,6 +2941,7 @@ ./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