1*b7579f77SDag-Erling Smørgrav /* 2*b7579f77SDag-Erling Smørgrav * daemon/cachedump.h - dump the cache to text format. 3*b7579f77SDag-Erling Smørgrav * 4*b7579f77SDag-Erling Smørgrav * Copyright (c) 2008, NLnet Labs. All rights reserved. 5*b7579f77SDag-Erling Smørgrav * 6*b7579f77SDag-Erling Smørgrav * This software is open source. 7*b7579f77SDag-Erling Smørgrav * 8*b7579f77SDag-Erling Smørgrav * Redistribution and use in source and binary forms, with or without 9*b7579f77SDag-Erling Smørgrav * modification, are permitted provided that the following conditions 10*b7579f77SDag-Erling Smørgrav * are met: 11*b7579f77SDag-Erling Smørgrav * 12*b7579f77SDag-Erling Smørgrav * Redistributions of source code must retain the above copyright notice, 13*b7579f77SDag-Erling Smørgrav * this list of conditions and the following disclaimer. 14*b7579f77SDag-Erling Smørgrav * 15*b7579f77SDag-Erling Smørgrav * Redistributions in binary form must reproduce the above copyright notice, 16*b7579f77SDag-Erling Smørgrav * this list of conditions and the following disclaimer in the documentation 17*b7579f77SDag-Erling Smørgrav * and/or other materials provided with the distribution. 18*b7579f77SDag-Erling Smørgrav * 19*b7579f77SDag-Erling Smørgrav * Neither the name of the NLNET LABS nor the names of its contributors may 20*b7579f77SDag-Erling Smørgrav * be used to endorse or promote products derived from this software without 21*b7579f77SDag-Erling Smørgrav * specific prior written permission. 22*b7579f77SDag-Erling Smørgrav * 23*b7579f77SDag-Erling Smørgrav * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24*b7579f77SDag-Erling Smørgrav * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 25*b7579f77SDag-Erling Smørgrav * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 26*b7579f77SDag-Erling Smørgrav * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE 27*b7579f77SDag-Erling Smørgrav * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28*b7579f77SDag-Erling Smørgrav * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29*b7579f77SDag-Erling Smørgrav * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30*b7579f77SDag-Erling Smørgrav * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31*b7579f77SDag-Erling Smørgrav * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32*b7579f77SDag-Erling Smørgrav * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33*b7579f77SDag-Erling Smørgrav * POSSIBILITY OF SUCH DAMAGE. 34*b7579f77SDag-Erling Smørgrav */ 35*b7579f77SDag-Erling Smørgrav 36*b7579f77SDag-Erling Smørgrav /** 37*b7579f77SDag-Erling Smørgrav * \file 38*b7579f77SDag-Erling Smørgrav * 39*b7579f77SDag-Erling Smørgrav * This file contains functions to read and write the cache(s) 40*b7579f77SDag-Erling Smørgrav * to text format. 41*b7579f77SDag-Erling Smørgrav * 42*b7579f77SDag-Erling Smørgrav * The format of the file is as follows: 43*b7579f77SDag-Erling Smørgrav * [RRset cache] 44*b7579f77SDag-Erling Smørgrav * [Message cache] 45*b7579f77SDag-Erling Smørgrav * EOF -- fixed string "EOF" before end of the file. 46*b7579f77SDag-Erling Smørgrav * 47*b7579f77SDag-Erling Smørgrav * The RRset cache is: 48*b7579f77SDag-Erling Smørgrav * START_RRSET_CACHE 49*b7579f77SDag-Erling Smørgrav * [rrset]* 50*b7579f77SDag-Erling Smørgrav * END_RRSET_CACHE 51*b7579f77SDag-Erling Smørgrav * 52*b7579f77SDag-Erling Smørgrav * rrset is: 53*b7579f77SDag-Erling Smørgrav * ;rrset [nsec_apex] TTL rr_count rrsig_count trust security 54*b7579f77SDag-Erling Smørgrav * resource records, one per line, in zonefile format 55*b7579f77SDag-Erling Smørgrav * rrsig records, one per line, in zonefile format 56*b7579f77SDag-Erling Smørgrav * If the text conversion fails, BADRR is printed on the line. 57*b7579f77SDag-Erling Smørgrav * 58*b7579f77SDag-Erling Smørgrav * The Message cache is: 59*b7579f77SDag-Erling Smørgrav * START_MSG_CACHE 60*b7579f77SDag-Erling Smørgrav * [msg]* 61*b7579f77SDag-Erling Smørgrav * END_MSG_CACHE 62*b7579f77SDag-Erling Smørgrav * 63*b7579f77SDag-Erling Smørgrav * msg is: 64*b7579f77SDag-Erling Smørgrav * msg name class type flags qdcount ttl security an ns ar 65*b7579f77SDag-Erling Smørgrav * list of rrset references, one per line. If conversion fails, BADREF 66*b7579f77SDag-Erling Smørgrav * reference is: 67*b7579f77SDag-Erling Smørgrav * name class type flags 68*b7579f77SDag-Erling Smørgrav * 69*b7579f77SDag-Erling Smørgrav * Expired cache entries are not printed. 70*b7579f77SDag-Erling Smørgrav */ 71*b7579f77SDag-Erling Smørgrav 72*b7579f77SDag-Erling Smørgrav #ifndef DAEMON_DUMPCACHE_H 73*b7579f77SDag-Erling Smørgrav #define DAEMON_DUMPCACHE_H 74*b7579f77SDag-Erling Smørgrav struct worker; 75*b7579f77SDag-Erling Smørgrav 76*b7579f77SDag-Erling Smørgrav /** 77*b7579f77SDag-Erling Smørgrav * Dump cache(s) to text 78*b7579f77SDag-Erling Smørgrav * @param ssl: to print to 79*b7579f77SDag-Erling Smørgrav * @param worker: worker that is available (buffers, etc) and has 80*b7579f77SDag-Erling Smørgrav * ptrs to the caches. 81*b7579f77SDag-Erling Smørgrav * @return false on ssl print error. 82*b7579f77SDag-Erling Smørgrav */ 83*b7579f77SDag-Erling Smørgrav int dump_cache(SSL* ssl, struct worker* worker); 84*b7579f77SDag-Erling Smørgrav 85*b7579f77SDag-Erling Smørgrav /** 86*b7579f77SDag-Erling Smørgrav * Load cache(s) from text 87*b7579f77SDag-Erling Smørgrav * @param ssl: to read from 88*b7579f77SDag-Erling Smørgrav * @param worker: worker that is available (buffers, etc) and has 89*b7579f77SDag-Erling Smørgrav * ptrs to the caches. 90*b7579f77SDag-Erling Smørgrav * @return false on ssl error. 91*b7579f77SDag-Erling Smørgrav */ 92*b7579f77SDag-Erling Smørgrav int load_cache(SSL* ssl, struct worker* worker); 93*b7579f77SDag-Erling Smørgrav 94*b7579f77SDag-Erling Smørgrav /** 95*b7579f77SDag-Erling Smørgrav * Print the delegation used to lookup for this name. 96*b7579f77SDag-Erling Smørgrav * @param ssl: to read from 97*b7579f77SDag-Erling Smørgrav * @param worker: worker that is available (buffers, etc) and has 98*b7579f77SDag-Erling Smørgrav * ptrs to the caches. 99*b7579f77SDag-Erling Smørgrav * @param nm: name to lookup 100*b7579f77SDag-Erling Smørgrav * @param nmlen: length of name. 101*b7579f77SDag-Erling Smørgrav * @param nmlabs: labels in name. 102*b7579f77SDag-Erling Smørgrav * @return false on ssl error. 103*b7579f77SDag-Erling Smørgrav */ 104*b7579f77SDag-Erling Smørgrav int print_deleg_lookup(SSL* ssl, struct worker* worker, uint8_t* nm, 105*b7579f77SDag-Erling Smørgrav size_t nmlen, int nmlabs); 106*b7579f77SDag-Erling Smørgrav 107*b7579f77SDag-Erling Smørgrav #endif /* DAEMON_DUMPCACHE_H */ 108