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