1933707f3Ssthen /* 2933707f3Ssthen * daemon/cachedump.h - dump the cache to text format. 3933707f3Ssthen * 4933707f3Ssthen * Copyright (c) 2008, NLnet Labs. All rights reserved. 5933707f3Ssthen * 6933707f3Ssthen * This software is open source. 7933707f3Ssthen * 8933707f3Ssthen * Redistribution and use in source and binary forms, with or without 9933707f3Ssthen * modification, are permitted provided that the following conditions 10933707f3Ssthen * are met: 11933707f3Ssthen * 12933707f3Ssthen * Redistributions of source code must retain the above copyright notice, 13933707f3Ssthen * this list of conditions and the following disclaimer. 14933707f3Ssthen * 15933707f3Ssthen * Redistributions in binary form must reproduce the above copyright notice, 16933707f3Ssthen * this list of conditions and the following disclaimer in the documentation 17933707f3Ssthen * and/or other materials provided with the distribution. 18933707f3Ssthen * 19933707f3Ssthen * Neither the name of the NLNET LABS nor the names of its contributors may 20933707f3Ssthen * be used to endorse or promote products derived from this software without 21933707f3Ssthen * specific prior written permission. 22933707f3Ssthen * 23933707f3Ssthen * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 245d76a658Ssthen * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 255d76a658Ssthen * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 265d76a658Ssthen * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 275d76a658Ssthen * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 285d76a658Ssthen * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 295d76a658Ssthen * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 305d76a658Ssthen * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 315d76a658Ssthen * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 325d76a658Ssthen * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 335d76a658Ssthen * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34933707f3Ssthen */ 35933707f3Ssthen 36933707f3Ssthen /** 37933707f3Ssthen * \file 38933707f3Ssthen * 39933707f3Ssthen * This file contains functions to read and write the cache(s) 40933707f3Ssthen * to text format. 41933707f3Ssthen * 42933707f3Ssthen * The format of the file is as follows: 43933707f3Ssthen * [RRset cache] 44933707f3Ssthen * [Message cache] 45933707f3Ssthen * EOF -- fixed string "EOF" before end of the file. 46933707f3Ssthen * 47933707f3Ssthen * The RRset cache is: 48933707f3Ssthen * START_RRSET_CACHE 49933707f3Ssthen * [rrset]* 50933707f3Ssthen * END_RRSET_CACHE 51933707f3Ssthen * 52933707f3Ssthen * rrset is: 53933707f3Ssthen * ;rrset [nsec_apex] TTL rr_count rrsig_count trust security 54933707f3Ssthen * resource records, one per line, in zonefile format 55933707f3Ssthen * rrsig records, one per line, in zonefile format 56933707f3Ssthen * If the text conversion fails, BADRR is printed on the line. 57933707f3Ssthen * 58933707f3Ssthen * The Message cache is: 59933707f3Ssthen * START_MSG_CACHE 60933707f3Ssthen * [msg]* 61933707f3Ssthen * END_MSG_CACHE 62933707f3Ssthen * 63933707f3Ssthen * msg is: 64933707f3Ssthen * msg name class type flags qdcount ttl security an ns ar 65933707f3Ssthen * list of rrset references, one per line. If conversion fails, BADREF 66933707f3Ssthen * reference is: 67933707f3Ssthen * name class type flags 68933707f3Ssthen * 69933707f3Ssthen * Expired cache entries are not printed. 70933707f3Ssthen */ 71933707f3Ssthen 72933707f3Ssthen #ifndef DAEMON_DUMPCACHE_H 73933707f3Ssthen #define DAEMON_DUMPCACHE_H 74933707f3Ssthen struct worker; 75*712b2f30Ssthen #include "daemon/remote.h" 76933707f3Ssthen 77933707f3Ssthen /** 78933707f3Ssthen * Dump cache(s) to text 79933707f3Ssthen * @param ssl: to print to 80933707f3Ssthen * @param worker: worker that is available (buffers, etc) and has 81933707f3Ssthen * ptrs to the caches. 82933707f3Ssthen * @return false on ssl print error. 83933707f3Ssthen */ 84*712b2f30Ssthen int dump_cache(RES* ssl, struct worker* worker); 85933707f3Ssthen 86933707f3Ssthen /** 87933707f3Ssthen * Load cache(s) from text 88933707f3Ssthen * @param ssl: to read from 89933707f3Ssthen * @param worker: worker that is available (buffers, etc) and has 90933707f3Ssthen * ptrs to the caches. 91933707f3Ssthen * @return false on ssl error. 92933707f3Ssthen */ 93*712b2f30Ssthen int load_cache(RES* ssl, struct worker* worker); 94933707f3Ssthen 95933707f3Ssthen /** 96933707f3Ssthen * Print the delegation used to lookup for this name. 97933707f3Ssthen * @param ssl: to read from 98933707f3Ssthen * @param worker: worker that is available (buffers, etc) and has 99933707f3Ssthen * ptrs to the caches. 100933707f3Ssthen * @param nm: name to lookup 101933707f3Ssthen * @param nmlen: length of name. 102933707f3Ssthen * @param nmlabs: labels in name. 103933707f3Ssthen * @return false on ssl error. 104933707f3Ssthen */ 105*712b2f30Ssthen int print_deleg_lookup(RES* ssl, struct worker* worker, uint8_t* nm, 106933707f3Ssthen size_t nmlen, int nmlabs); 107933707f3Ssthen 108933707f3Ssthen #endif /* DAEMON_DUMPCACHE_H */ 109