]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/unbound/libunbound/worker.h
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / unbound / libunbound / worker.h
1 /*
2  * libunbound/worker.h - prototypes for worker methods.
3  *
4  * Copyright (c) 2007, 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 LIMITED
25  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35
36 /**
37  * \file
38  *
39  * This file declares the methods any worker has to implement.
40  */
41
42 #ifndef LIBUNBOUND_WORKER_H
43 #define LIBUNBOUND_WORKER_H
44
45 #include "ldns/sbuffer.h"
46 #include "util/data/packed_rrset.h" /* for enum sec_status */
47 struct comm_reply;
48 struct comm_point;
49 struct module_qstate;
50 struct tube;
51
52 /**
53  * Worker service routine to send serviced queries to authoritative servers.
54  * @param qname: query name. (host order)
55  * @param qnamelen: length in bytes of qname, including trailing 0.
56  * @param qtype: query type. (host order)
57  * @param qclass: query class. (host order)
58  * @param flags: host order flags word, with opcode and CD bit.
59  * @param dnssec: if set, EDNS record will have DO bit set.
60  * @param want_dnssec: signatures needed.
61  * @param nocaps: ignore capsforid(if in config), do not perturb qname.
62  * @param addr: where to.
63  * @param addrlen: length of addr.
64  * @param zone: delegation point name.
65  * @param zonelen: length of zone name wireformat dname.
66  * @param q: wich query state to reactivate upon return.
67  * @return: false on failure (memory or socket related). no query was
68  *      sent.
69  */
70 struct outbound_entry* libworker_send_query(uint8_t* qname, size_t qnamelen,
71         uint16_t qtype, uint16_t qclass, uint16_t flags, int dnssec,
72         int want_dnssec, int nocaps, struct sockaddr_storage* addr,
73         socklen_t addrlen, uint8_t* zone, size_t zonelen,
74         struct module_qstate* q);
75
76 /** process incoming replies from the network */
77 int libworker_handle_reply(struct comm_point* c, void* arg, int error,
78         struct comm_reply* reply_info);
79
80 /** process incoming serviced query replies from the network */
81 int libworker_handle_service_reply(struct comm_point* c, void* arg, int error,
82         struct comm_reply* reply_info);
83
84 /** handle control command coming into server */
85 void libworker_handle_control_cmd(struct tube* tube, uint8_t* msg, size_t len,
86         int err, void* arg);
87
88 /** mesh callback with fg results */
89 void libworker_fg_done_cb(void* arg, int rcode, sldns_buffer* buf, 
90         enum sec_status s, char* why_bogus);
91
92 /** mesh callback with bg results */
93 void libworker_bg_done_cb(void* arg, int rcode, sldns_buffer* buf, 
94         enum sec_status s, char* why_bogus);
95
96 /** mesh callback with event results */
97 void libworker_event_done_cb(void* arg, int rcode, struct sldns_buffer* buf, 
98         enum sec_status s, char* why_bogus);
99
100 /**
101  * Worker signal handler function. User argument is the worker itself.
102  * @param sig: signal number.
103  * @param arg: the worker (main worker) that handles signals.
104  */
105 void worker_sighandler(int sig, void* arg);
106
107 /**
108  * Worker service routine to send serviced queries to authoritative servers.
109  * @param qname: query name. (host order)
110  * @param qnamelen: length in bytes of qname, including trailing 0.
111  * @param qtype: query type. (host order)
112  * @param qclass: query class. (host order)
113  * @param flags: host order flags word, with opcode and CD bit.
114  * @param dnssec: if set, EDNS record will have DO bit set.
115  * @param want_dnssec: signatures needed.
116  * @param nocaps: ignore capsforid(if in config), do not perturb qname.
117  * @param addr: where to.
118  * @param addrlen: length of addr.
119  * @param zone: wireformat dname of the zone.
120  * @param zonelen: length of zone name.
121  * @param q: wich query state to reactivate upon return.
122  * @return: false on failure (memory or socket related). no query was
123  *      sent.
124  */
125 struct outbound_entry* worker_send_query(uint8_t* qname, size_t qnamelen, 
126         uint16_t qtype, uint16_t qclass, uint16_t flags, int dnssec, 
127         int want_dnssec, int nocaps, struct sockaddr_storage* addr,
128         socklen_t addrlen, uint8_t* zone, size_t zonelen,
129         struct module_qstate* q);
130
131 /** 
132  * process control messages from the main thread. Frees the control 
133  * command message.
134  * @param tube: tube control message came on.
135  * @param msg: message contents.  Is freed.
136  * @param len: length of message.
137  * @param error: if error (NETEVENT_*) happened.
138  * @param arg: user argument
139  */
140 void worker_handle_control_cmd(struct tube* tube, uint8_t* msg, size_t len,
141         int error, void* arg);
142
143 /** handles callbacks from listening event interface */
144 int worker_handle_request(struct comm_point* c, void* arg, int error,
145         struct comm_reply* repinfo);
146
147 /** process incoming replies from the network */
148 int worker_handle_reply(struct comm_point* c, void* arg, int error, 
149         struct comm_reply* reply_info);
150
151 /** process incoming serviced query replies from the network */
152 int worker_handle_service_reply(struct comm_point* c, void* arg, int error, 
153         struct comm_reply* reply_info);
154
155 /** cleanup the cache to remove all rrset IDs from it, arg is worker */
156 void worker_alloc_cleanup(void* arg);
157
158 /** statistics timer callback handler */
159 void worker_stat_timer_cb(void* arg);
160
161 /** probe timer callback handler */
162 void worker_probe_timer_cb(void* arg);
163
164 /** start accept callback handler */
165 void worker_start_accept(void* arg);
166
167 /** stop accept callback handler */
168 void worker_stop_accept(void* arg);
169
170 /** handle remote control accept callbacks */
171 int remote_accept_callback(struct comm_point*, void*, int, struct comm_reply*);
172
173 /** handle remote control data callbacks */
174 int remote_control_callback(struct comm_point*, void*, int, struct comm_reply*);
175
176 /** routine to printout option values over SSL */
177 void  remote_get_opt_ssl(char* line, void* arg);
178
179 #endif /* LIBUNBOUND_WORKER_H */