Add a dns_fixedname_initname() helper function
This also turns the dns_fixedname macros into functions. (cherry picked from commit0d2a03c290) (cherry picked from commitcee4fef7c5)
This commit is contained in:
committed by
Evan Hunt
parent
1b4f1c26b2
commit
1dea0795d1
@@ -64,7 +64,8 @@ DNSTAPOBJS = dnstap.@O@ dnstap.pb-c.@O@
|
||||
DNSOBJS = acache.@O@ 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@ dnssec.@O@ ds.@O@ dyndb.@O@ forward.@O@ \
|
||||
dlz.@O@ dns64.@O@ dnssec.@O@ ds.@O@ dyndb.@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@ \
|
||||
@@ -108,7 +109,7 @@ DNSTAPSRCS = dnstap.c dnstap.pb-c.c
|
||||
DNSSRCS = acache.c 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 dnssec.c ds.c dyndb.c forward.c \
|
||||
dlz.c dns64.c dnssec.c ds.c dyndb.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 \
|
||||
|
||||
39
lib/dns/fixedname.c
Normal file
39
lib/dns/fixedname.c
Normal file
@@ -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));
|
||||
}
|
||||
@@ -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 */
|
||||
|
||||
@@ -391,6 +391,10 @@ dns_dyndb_createctx
|
||||
dns_dyndb_destroyctx
|
||||
dns_ecdb_register
|
||||
dns_ecdb_unregister
|
||||
dns_fixedname_init
|
||||
dns_fixedname_invalidate
|
||||
dns_fixedname_name
|
||||
dns_fixedname_initname
|
||||
dns_fwdtable_add
|
||||
dns_fwdtable_addfwd
|
||||
dns_fwdtable_create
|
||||
|
||||
@@ -96,6 +96,9 @@
|
||||
<ClCompile Include="..\ecdb.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>
|
||||
|
||||
@@ -135,6 +135,7 @@
|
||||
<ClCompile Include="..\dst_result.c" />
|
||||
<ClCompile Include="..\dyndb.c" />
|
||||
<ClCompile Include="..\ecdb.c" />
|
||||
<ClCompile Include="..\fixedname.c" />
|
||||
<ClCompile Include="..\forward.c" />
|
||||
@IF GEOIP
|
||||
<ClCompile Include="..\geoip.c" />
|
||||
|
||||
@@ -3242,6 +3242,7 @@
|
||||
./lib/dns/dst_result.c C 1999,2000,2001,2004,2005,2007,2008,2012,2013,2014,2015,2016,2018
|
||||
./lib/dns/dyndb.c C 2015,2016,2017,2018
|
||||
./lib/dns/ecdb.c C 2009,2010,2011,2012,2013,2014,2015,2016,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
|
||||
|
||||
Reference in New Issue
Block a user