xref: /netbsd-src/external/bsd/unbound/dist/daemon/cachedump.h (revision 7cd94d692f099dff0c03996f61fd7a476e40159b)
13b6c3722Schristos /*
23b6c3722Schristos  * daemon/cachedump.h - dump the cache to text format.
33b6c3722Schristos  *
43b6c3722Schristos  * Copyright (c) 2008, NLnet Labs. All rights reserved.
53b6c3722Schristos  *
63b6c3722Schristos  * This software is open source.
73b6c3722Schristos  *
83b6c3722Schristos  * Redistribution and use in source and binary forms, with or without
93b6c3722Schristos  * modification, are permitted provided that the following conditions
103b6c3722Schristos  * are met:
113b6c3722Schristos  *
123b6c3722Schristos  * Redistributions of source code must retain the above copyright notice,
133b6c3722Schristos  * this list of conditions and the following disclaimer.
143b6c3722Schristos  *
153b6c3722Schristos  * Redistributions in binary form must reproduce the above copyright notice,
163b6c3722Schristos  * this list of conditions and the following disclaimer in the documentation
173b6c3722Schristos  * and/or other materials provided with the distribution.
183b6c3722Schristos  *
193b6c3722Schristos  * Neither the name of the NLNET LABS nor the names of its contributors may
203b6c3722Schristos  * be used to endorse or promote products derived from this software without
213b6c3722Schristos  * specific prior written permission.
223b6c3722Schristos  *
233b6c3722Schristos  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
243b6c3722Schristos  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
253b6c3722Schristos  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
263b6c3722Schristos  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
273b6c3722Schristos  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
283b6c3722Schristos  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
293b6c3722Schristos  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
303b6c3722Schristos  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
313b6c3722Schristos  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
323b6c3722Schristos  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
333b6c3722Schristos  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
343b6c3722Schristos  */
353b6c3722Schristos 
363b6c3722Schristos /**
373b6c3722Schristos  * \file
383b6c3722Schristos  *
393b6c3722Schristos  * This file contains functions to read and write the cache(s)
403b6c3722Schristos  * to text format.
413b6c3722Schristos  *
423b6c3722Schristos  * The format of the file is as follows:
433b6c3722Schristos  * [RRset cache]
443b6c3722Schristos  * [Message cache]
453b6c3722Schristos  * EOF		-- fixed string "EOF" before end of the file.
463b6c3722Schristos  *
473b6c3722Schristos  * The RRset cache is:
483b6c3722Schristos  * START_RRSET_CACHE
493b6c3722Schristos  * [rrset]*
503b6c3722Schristos  * END_RRSET_CACHE
513b6c3722Schristos  *
523b6c3722Schristos  * rrset is:
533b6c3722Schristos  * ;rrset [nsec_apex] TTL rr_count rrsig_count trust security
543b6c3722Schristos  * resource records, one per line, in zonefile format
553b6c3722Schristos  * rrsig records, one per line, in zonefile format
563b6c3722Schristos  * If the text conversion fails, BADRR is printed on the line.
573b6c3722Schristos  *
583b6c3722Schristos  * The Message cache is:
593b6c3722Schristos  * START_MSG_CACHE
603b6c3722Schristos  * [msg]*
613b6c3722Schristos  * END_MSG_CACHE
623b6c3722Schristos  *
633b6c3722Schristos  * msg is:
643b6c3722Schristos  * msg name class type flags qdcount ttl security an ns ar
653b6c3722Schristos  * list of rrset references, one per line. If conversion fails, BADREF
663b6c3722Schristos  * reference is:
673b6c3722Schristos  * name class type flags
683b6c3722Schristos  *
693b6c3722Schristos  * Expired cache entries are not printed.
703b6c3722Schristos  */
713b6c3722Schristos 
723b6c3722Schristos #ifndef DAEMON_DUMPCACHE_H
733b6c3722Schristos #define DAEMON_DUMPCACHE_H
743b6c3722Schristos struct worker;
75*7cd94d69Schristos #include "daemon/remote.h"
763b6c3722Schristos 
773b6c3722Schristos /**
783b6c3722Schristos  * Dump cache(s) to text
793b6c3722Schristos  * @param ssl: to print to
803b6c3722Schristos  * @param worker: worker that is available (buffers, etc) and has
813b6c3722Schristos  * 	ptrs to the caches.
823b6c3722Schristos  * @return false on ssl print error.
833b6c3722Schristos  */
84*7cd94d69Schristos int dump_cache(RES* ssl, struct worker* worker);
853b6c3722Schristos 
863b6c3722Schristos /**
873b6c3722Schristos  * Load cache(s) from text
883b6c3722Schristos  * @param ssl: to read from
893b6c3722Schristos  * @param worker: worker that is available (buffers, etc) and has
903b6c3722Schristos  * 	ptrs to the caches.
913b6c3722Schristos  * @return false on ssl error.
923b6c3722Schristos  */
93*7cd94d69Schristos int load_cache(RES* ssl, struct worker* worker);
943b6c3722Schristos 
953b6c3722Schristos /**
963b6c3722Schristos  * Print the delegation used to lookup for this name.
973b6c3722Schristos  * @param ssl: to read from
983b6c3722Schristos  * @param worker: worker that is available (buffers, etc) and has
993b6c3722Schristos  * 	ptrs to the caches.
1003b6c3722Schristos  * @param nm: name to lookup
1013b6c3722Schristos  * @param nmlen: length of name.
1023b6c3722Schristos  * @param nmlabs: labels in name.
1033b6c3722Schristos  * @return false on ssl error.
1043b6c3722Schristos  */
105*7cd94d69Schristos int print_deleg_lookup(RES* ssl, struct worker* worker, uint8_t* nm,
1063b6c3722Schristos 	size_t nmlen, int nmlabs);
1073b6c3722Schristos 
1083b6c3722Schristos #endif /* DAEMON_DUMPCACHE_H */
109