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