1ae8c6e27Sflorian /*
2ae8c6e27Sflorian  * iterator/iter_scrub.h - scrubbing, normalization, sanitization of DNS msgs.
3ae8c6e27Sflorian  *
4ae8c6e27Sflorian  * Copyright (c) 2007, NLnet Labs. All rights reserved.
5ae8c6e27Sflorian  *
6ae8c6e27Sflorian  * This software is open source.
7ae8c6e27Sflorian  *
8ae8c6e27Sflorian  * Redistribution and use in source and binary forms, with or without
9ae8c6e27Sflorian  * modification, are permitted provided that the following conditions
10ae8c6e27Sflorian  * are met:
11ae8c6e27Sflorian  *
12ae8c6e27Sflorian  * Redistributions of source code must retain the above copyright notice,
13ae8c6e27Sflorian  * this list of conditions and the following disclaimer.
14ae8c6e27Sflorian  *
15ae8c6e27Sflorian  * Redistributions in binary form must reproduce the above copyright notice,
16ae8c6e27Sflorian  * this list of conditions and the following disclaimer in the documentation
17ae8c6e27Sflorian  * and/or other materials provided with the distribution.
18ae8c6e27Sflorian  *
19ae8c6e27Sflorian  * Neither the name of the NLNET LABS nor the names of its contributors may
20ae8c6e27Sflorian  * be used to endorse or promote products derived from this software without
21ae8c6e27Sflorian  * specific prior written permission.
22ae8c6e27Sflorian  *
23ae8c6e27Sflorian  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24ae8c6e27Sflorian  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25ae8c6e27Sflorian  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26ae8c6e27Sflorian  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27ae8c6e27Sflorian  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28ae8c6e27Sflorian  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29ae8c6e27Sflorian  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30ae8c6e27Sflorian  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31ae8c6e27Sflorian  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32ae8c6e27Sflorian  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33ae8c6e27Sflorian  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34ae8c6e27Sflorian  */
35ae8c6e27Sflorian 
36ae8c6e27Sflorian /**
37ae8c6e27Sflorian  * \file
38ae8c6e27Sflorian  *
39ae8c6e27Sflorian  * This file has routine(s) for cleaning up incoming DNS messages from
40ae8c6e27Sflorian  * possible useless or malicious junk in it.
41ae8c6e27Sflorian  */
42ae8c6e27Sflorian 
43ae8c6e27Sflorian #ifndef ITERATOR_ITER_SCRUB_H
44ae8c6e27Sflorian #define ITERATOR_ITER_SCRUB_H
45ae8c6e27Sflorian struct sldns_buffer;
46ae8c6e27Sflorian struct msg_parse;
47ae8c6e27Sflorian struct query_info;
48ae8c6e27Sflorian struct regional;
49ae8c6e27Sflorian struct module_env;
50ae8c6e27Sflorian struct iter_env;
51*54cc57acSflorian struct module_qstate;
52ae8c6e27Sflorian 
53ae8c6e27Sflorian /**
54ae8c6e27Sflorian  * Cleanup the passed dns message.
55ae8c6e27Sflorian  * @param pkt: the packet itself, for resolving name compression pointers.
56ae8c6e27Sflorian  *	the packet buffer is unaltered.
57ae8c6e27Sflorian  * @param msg: the parsed packet, this structure is cleaned up.
58ae8c6e27Sflorian  * @param qinfo: the query info that was sent to the server. Checked.
59ae8c6e27Sflorian  * @param zonename: the name of the last delegation point.
60ae8c6e27Sflorian  *	Used to determine out of bailiwick information.
61ae8c6e27Sflorian  * @param regional: where to allocate (new) parts of the message.
62ae8c6e27Sflorian  * @param env: module environment with config settings and cache.
63*54cc57acSflorian  * @param qstate: for setting errinf for EDE error messages.
64ae8c6e27Sflorian  * @param ie: iterator module environment data.
65ae8c6e27Sflorian  * @return: false if the message is total waste. true if scrubbed with success.
66ae8c6e27Sflorian  */
67ae8c6e27Sflorian int scrub_message(struct sldns_buffer* pkt, struct msg_parse* msg,
68ae8c6e27Sflorian 	struct query_info* qinfo, uint8_t* zonename, struct regional* regional,
69*54cc57acSflorian 	struct module_env* env, struct module_qstate* qstate,
70*54cc57acSflorian 	struct iter_env* ie);
71ae8c6e27Sflorian 
72ae8c6e27Sflorian #endif /* ITERATOR_ITER_SCRUB_H */
73