2 * libunbound/worker.h - prototypes for worker methods.
4 * Copyright (c) 2007, NLnet Labs. All rights reserved.
6 * This software is open source.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
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.
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.
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.
39 * This file declares the methods any worker has to implement.
42 #ifndef LIBUNBOUND_WORKER_H
43 #define LIBUNBOUND_WORKER_H
45 #include "sldns/sbuffer.h"
46 #include "util/data/packed_rrset.h" /* for enum sec_status */
54 * Worker service routine to send serviced queries to authoritative servers.
55 * @param qname: query name. (host order)
56 * @param qnamelen: length in bytes of qname, including trailing 0.
57 * @param qtype: query type. (host order)
58 * @param qclass: query class. (host order)
59 * @param flags: host order flags word, with opcode and CD bit.
60 * @param dnssec: if set, EDNS record will have DO bit set.
61 * @param want_dnssec: signatures needed.
62 * @param nocaps: ignore capsforid(if in config), do not perturb qname.
63 * @param opt_list: EDNS options on outgoing packet.
64 * @param addr: where to.
65 * @param addrlen: length of addr.
66 * @param zone: delegation point name.
67 * @param zonelen: length of zone name wireformat dname.
68 * @param q: wich query state to reactivate upon return.
69 * @return: false on failure (memory or socket related). no query was
72 struct outbound_entry* libworker_send_query(uint8_t* qname, size_t qnamelen,
73 uint16_t qtype, uint16_t qclass, uint16_t flags, int dnssec,
74 int want_dnssec, int nocaps, struct edns_option* opt_list,
75 struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* zone,
76 size_t zonelen, struct module_qstate* q);
78 /** process incoming replies from the network */
79 int libworker_handle_reply(struct comm_point* c, void* arg, int error,
80 struct comm_reply* reply_info);
82 /** process incoming serviced query replies from the network */
83 int libworker_handle_service_reply(struct comm_point* c, void* arg, int error,
84 struct comm_reply* reply_info);
86 /** handle control command coming into server */
87 void libworker_handle_control_cmd(struct tube* tube, uint8_t* msg, size_t len,
90 /** mesh callback with fg results */
91 void libworker_fg_done_cb(void* arg, int rcode, sldns_buffer* buf,
92 enum sec_status s, char* why_bogus);
94 /** mesh callback with bg results */
95 void libworker_bg_done_cb(void* arg, int rcode, sldns_buffer* buf,
96 enum sec_status s, char* why_bogus);
98 /** mesh callback with event results */
99 void libworker_event_done_cb(void* arg, int rcode, struct sldns_buffer* buf,
100 enum sec_status s, char* why_bogus);
103 * Worker signal handler function. User argument is the worker itself.
104 * @param sig: signal number.
105 * @param arg: the worker (main worker) that handles signals.
107 void worker_sighandler(int sig, void* arg);
110 * Worker service routine to send serviced queries to authoritative servers.
111 * @param qname: query name. (host order)
112 * @param qnamelen: length in bytes of qname, including trailing 0.
113 * @param qtype: query type. (host order)
114 * @param qclass: query class. (host order)
115 * @param flags: host order flags word, with opcode and CD bit.
116 * @param dnssec: if set, EDNS record will have DO bit set.
117 * @param want_dnssec: signatures needed.
118 * @param nocaps: ignore capsforid(if in config), do not perturb qname.
119 * @param opt_list: EDNS options on outgoing packet.
120 * @param addr: where to.
121 * @param addrlen: length of addr.
122 * @param zone: wireformat dname of the zone.
123 * @param zonelen: length of zone name.
124 * @param q: wich query state to reactivate upon return.
125 * @return: false on failure (memory or socket related). no query was
128 struct outbound_entry* worker_send_query(uint8_t* qname, size_t qnamelen,
129 uint16_t qtype, uint16_t qclass, uint16_t flags, int dnssec,
130 int want_dnssec, int nocaps, struct edns_option* opt_list,
131 struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* zone,
132 size_t zonelen, struct module_qstate* q);
135 * process control messages from the main thread. Frees the control
137 * @param tube: tube control message came on.
138 * @param msg: message contents. Is freed.
139 * @param len: length of message.
140 * @param error: if error (NETEVENT_*) happened.
141 * @param arg: user argument
143 void worker_handle_control_cmd(struct tube* tube, uint8_t* msg, size_t len,
144 int error, void* arg);
146 /** handles callbacks from listening event interface */
147 int worker_handle_request(struct comm_point* c, void* arg, int error,
148 struct comm_reply* repinfo);
150 /** process incoming replies from the network */
151 int worker_handle_reply(struct comm_point* c, void* arg, int error,
152 struct comm_reply* reply_info);
154 /** process incoming serviced query replies from the network */
155 int worker_handle_service_reply(struct comm_point* c, void* arg, int error,
156 struct comm_reply* reply_info);
158 /** cleanup the cache to remove all rrset IDs from it, arg is worker */
159 void worker_alloc_cleanup(void* arg);
161 /** statistics timer callback handler */
162 void worker_stat_timer_cb(void* arg);
164 /** probe timer callback handler */
165 void worker_probe_timer_cb(void* arg);
167 /** start accept callback handler */
168 void worker_start_accept(void* arg);
170 /** stop accept callback handler */
171 void worker_stop_accept(void* arg);
173 /** handle remote control accept callbacks */
174 int remote_accept_callback(struct comm_point*, void*, int, struct comm_reply*);
176 /** handle remote control data callbacks */
177 int remote_control_callback(struct comm_point*, void*, int, struct comm_reply*);
179 /** routine to printout option values over SSL */
180 void remote_get_opt_ssl(char* line, void* arg);
182 #endif /* LIBUNBOUND_WORKER_H */