Commit 0d2a03c2 authored by Mukund Sivaraman's avatar Mukund Sivaraman Committed by Ondřej Surý

Add a dns_fixedname_initname() helper function

This also turns the dns_fixedname macros into functions.
parent 76fa1c18
......@@ -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 \
......
/*
* 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 */
......@@ -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
......
......@@ -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>
......
......@@ -135,6 +135,7 @@
<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" />
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment