xref: /freebsd/contrib/unbound/iterator/iter_scrub.h (revision 103ba509e72e3949d22485666949e9705d4af8cd)
1b7579f77SDag-Erling Smørgrav /*
2b7579f77SDag-Erling Smørgrav  * iterator/iter_scrub.h - scrubbing, normalization, sanitization of DNS msgs.
3b7579f77SDag-Erling Smørgrav  *
4b7579f77SDag-Erling Smørgrav  * Copyright (c) 2007, 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 has routine(s) for cleaning up incoming DNS messages from
40b7579f77SDag-Erling Smørgrav  * possible useless or malicious junk in it.
41b7579f77SDag-Erling Smørgrav  */
42b7579f77SDag-Erling Smørgrav 
43b7579f77SDag-Erling Smørgrav #ifndef ITERATOR_ITER_SCRUB_H
44b7579f77SDag-Erling Smørgrav #define ITERATOR_ITER_SCRUB_H
4517d15b25SDag-Erling Smørgrav struct sldns_buffer;
46b7579f77SDag-Erling Smørgrav struct msg_parse;
47b7579f77SDag-Erling Smørgrav struct query_info;
48b7579f77SDag-Erling Smørgrav struct regional;
49b7579f77SDag-Erling Smørgrav struct module_env;
50b7579f77SDag-Erling Smørgrav struct iter_env;
51*103ba509SCy Schubert struct module_qstate;
52b7579f77SDag-Erling Smørgrav 
53b7579f77SDag-Erling Smørgrav /**
54b7579f77SDag-Erling Smørgrav  * Cleanup the passed dns message.
55b7579f77SDag-Erling Smørgrav  * @param pkt: the packet itself, for resolving name compression pointers.
56b7579f77SDag-Erling Smørgrav  *	the packet buffer is unaltered.
57b7579f77SDag-Erling Smørgrav  * @param msg: the parsed packet, this structure is cleaned up.
58b7579f77SDag-Erling Smørgrav  * @param qinfo: the query info that was sent to the server. Checked.
59b7579f77SDag-Erling Smørgrav  * @param zonename: the name of the last delegation point.
60b7579f77SDag-Erling Smørgrav  *	Used to determine out of bailiwick information.
61b7579f77SDag-Erling Smørgrav  * @param regional: where to allocate (new) parts of the message.
62b7579f77SDag-Erling Smørgrav  * @param env: module environment with config settings and cache.
63*103ba509SCy Schubert  * @param qstate: for setting errinf for EDE error messages.
64b7579f77SDag-Erling Smørgrav  * @param ie: iterator module environment data.
65b7579f77SDag-Erling Smørgrav  * @return: false if the message is total waste. true if scrubbed with success.
66b7579f77SDag-Erling Smørgrav  */
6717d15b25SDag-Erling Smørgrav int scrub_message(struct sldns_buffer* pkt, struct msg_parse* msg,
68b7579f77SDag-Erling Smørgrav 	struct query_info* qinfo, uint8_t* zonename, struct regional* regional,
69*103ba509SCy Schubert 	struct module_env* env, struct module_qstate* qstate,
70*103ba509SCy Schubert 	struct iter_env* ie);
71b7579f77SDag-Erling Smørgrav 
72b7579f77SDag-Erling Smørgrav #endif /* ITERATOR_ITER_SCRUB_H */
73