xref: /freebsd/contrib/unbound/services/authzone.h (revision 405c3050f102b8c74782f0366c8ead927bd07b68)
1 /*
2  * services/authzone.h - authoritative zone that is locally hosted.
3  *
4  * Copyright (c) 2017, 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 the functions for an authority zone.  This zone
40  * is queried by the iterator, just like a stub or forward zone, but then
41  * the data is locally held.
42  */
43 
44 #ifndef SERVICES_AUTHZONE_H
45 #define SERVICES_AUTHZONE_H
46 #include "util/rbtree.h"
47 #include "util/locks.h"
48 #include "services/mesh.h"
49 struct ub_packed_rrset_key;
50 struct regional;
51 struct config_file;
52 struct config_auth;
53 struct query_info;
54 struct dns_msg;
55 struct edns_data;
56 struct module_env;
57 struct worker;
58 struct comm_point;
59 struct comm_timer;
60 struct comm_reply;
61 struct auth_rrset;
62 struct auth_nextprobe;
63 struct auth_probe;
64 struct auth_transfer;
65 struct auth_master;
66 struct auth_chunk;
67 
68 /**
69  * Authoritative zones, shared.
70  */
71 struct auth_zones {
72 	/** lock on the authzone trees */
73 	lock_rw_type lock;
74 	/** rbtree of struct auth_zone */
75 	rbtree_type ztree;
76 	/** rbtree of struct auth_xfer */
77 	rbtree_type xtree;
78 	/** do we have downstream enabled */
79 	int have_downstream;
80 	/** number of queries upstream */
81 	size_t num_query_up;
82 	/** number of queries downstream */
83 	size_t num_query_down;
84 };
85 
86 /**
87  * Auth zone.  Authoritative data, that is fetched from instead of sending
88  * packets to the internet.
89  */
90 struct auth_zone {
91 	/** rbtree node, key is name and class */
92 	rbnode_type node;
93 
94 	/** zone name, in uncompressed wireformat */
95 	uint8_t* name;
96 	/** length of zone name */
97 	size_t namelen;
98 	/** number of labels in zone name */
99 	int namelabs;
100 	/** the class of this zone, in host byteorder.
101 	 * uses 'dclass' to not conflict with c++ keyword class. */
102 	uint16_t dclass;
103 
104 	/** lock on the data in the structure
105 	 * For the node, parent, name, namelen, namelabs, dclass, you
106 	 * need to also hold the zones_tree lock to change them (or to
107 	 * delete this zone) */
108 	lock_rw_type lock;
109 
110 	/** auth data for this zone
111 	 * rbtree of struct auth_data */
112 	rbtree_type data;
113 
114 	/** zonefile name (or NULL for no zonefile) */
115 	char* zonefile;
116 	/** fallback to the internet on failure or ttl-expiry of auth zone */
117 	int fallback_enabled;
118 	/** the zone has expired (enabled by the xfer worker), fallback
119 	 * happens if that option is enabled. */
120 	int zone_expired;
121 	/** zone is a slave zone (it has masters) */
122 	int zone_is_slave;
123 	/** for downstream: this zone answers queries towards the downstream
124 	 * clients */
125 	int for_downstream;
126 	/** for upstream: this zone answers queries that unbound intends to
127 	 * send upstream. */
128 	int for_upstream;
129 	/** zone has been deleted */
130 	int zone_deleted;
131 	/** deletelist pointer, unused normally except during delete */
132 	struct auth_zone* delete_next;
133 };
134 
135 /**
136  * Auth data. One domain name, and the RRs to go with it.
137  */
138 struct auth_data {
139 	/** rbtree node, key is name only */
140 	rbnode_type node;
141 	/** domain name */
142 	uint8_t* name;
143 	/** length of name */
144 	size_t namelen;
145 	/** number of labels in name */
146 	int namelabs;
147 	/** the data rrsets, with different types, linked list.
148 	 * if the list if NULL the node would be an empty non-terminal,
149 	 * but in this data structure such nodes that represent an empty
150 	 * non-terminal are not needed; they just don't exist.
151 	 */
152 	struct auth_rrset* rrsets;
153 };
154 
155 /**
156  * A auth data RRset
157  */
158 struct auth_rrset {
159 	/** next in list */
160 	struct auth_rrset* next;
161 	/** RR type in host byteorder */
162 	uint16_t type;
163 	/** RRset data item */
164 	struct packed_rrset_data* data;
165 };
166 
167 /**
168  * Authoritative zone transfer structure.
169  * Create and destroy needs the auth_zones* biglock.
170  * The structure consists of different tasks.  Each can be unowned (-1) or
171  * owner by a worker (worker-num).  A worker can pick up a task and then do
172  * it.  This means the events (timeouts, sockets) are for that worker.
173  *
174  * (move this to tasks).
175  * They don't have locks themselves, the worker (that owns it) uses it,
176  * also as part of callbacks, hence it has separate zonename pointers for
177  * lookup in the main zonetree.  If the zone has no transfers, this
178  * structure is not created.
179  */
180 struct auth_xfer {
181 	/** rbtree node, key is name and class */
182 	rbnode_type node;
183 
184 	/** lock on this structure, and on the workernum elements of the
185 	 * tasks.  First hold the tree-lock in auth_zones, find the auth_xfer,
186 	 * lock this lock.  Then a worker can reassign itself to fill up
187 	 * one of the tasks.
188 	 * Once it has the task assigned to it, the worker can access the
189 	 * other elements of the task structure without a lock, because that
190 	 * is necessary for the eventloop and callbacks from that. */
191 	lock_basic_type lock;
192 
193 	/** zone name, in uncompressed wireformat */
194 	uint8_t* name;
195 	/** length of zone name */
196 	size_t namelen;
197 	/** number of labels in zone name */
198 	int namelabs;
199 	/** the class of this zone, in host byteorder.
200 	 * uses 'dclass' to not conflict with c++ keyword class. */
201 	uint16_t dclass;
202 
203 	/** task to wait for next-probe-timeout,
204 	 * once timeouted, see if a SOA probe is needed, or already
205 	 * in progress */
206 	struct auth_nextprobe* task_nextprobe;
207 
208 	/** task for SOA probe.  Check if the zone can be updated */
209 	struct auth_probe* task_probe;
210 
211 	/** Task for transfer.  Transferring and updating the zone.  This
212 	 * includes trying (potentially) several upstream masters.  Downloading
213 	 * and storing the zone */
214 	struct auth_transfer* task_transfer;
215 
216 	/** a notify was received, but a zone transfer or probe was already
217 	 * acted on.
218 	 * However, the zone transfer could signal a newer serial number.
219 	 * The serial number of that notify is saved below.  The transfer and
220 	 * probe tasks should check this once done to see if they need to
221 	 * restart the transfer task for the newer notify serial.
222 	 * Hold the lock to access this member (and the serial).
223 	 */
224 	int notify_received;
225 	/** true if the notify_received has a serial number */
226 	int notify_has_serial;
227 	/** serial number of the notify */
228 	uint32_t notify_serial;
229 	/** the list of masters for checking notifies.  This list is
230 	 * empty on start, and a copy of the list from the probe_task when
231 	 * it is done looking them up. */
232 	struct auth_master* allow_notify_list;
233 
234 	/* protected by the lock on the structure, information about
235 	 * the loaded authority zone. */
236 	/** is the zone currently considered expired? after expiry also older
237          * serial numbers are allowed (not just newer) */
238 	int zone_expired;
239 	/** do we have a zone (if 0, no zone data at all) */
240 	int have_zone;
241 
242 	/** current serial (from SOA), if we have no zone, 0 */
243 	uint32_t serial;
244 	/** retry time (from SOA), time to wait with next_probe
245 	 * if no master responds */
246 	time_t retry;
247 	/** refresh time (from SOA), time to wait with next_probe
248 	 * if everything is fine */
249 	time_t refresh;
250 	/** expiry time (from SOA), time until zone data is not considered
251 	 * valid any more, if no master responds within this time, either
252 	 * with the current zone or a new zone. */
253 	time_t expiry;
254 
255 	/** zone lease start time (start+expiry is expiration time).
256 	 * this is renewed every SOA probe and transfer.  On zone load
257 	 * from zonefile it is also set (with probe set soon to check) */
258 	time_t lease_time;
259 };
260 
261 /**
262  * The next probe task.
263  * This task consists of waiting for the probetimeout.  It is a task because
264  * it needs an event in the eventtable.  Once the timeout has passed, that
265  * worker can (potentially) become the auth_probe worker, or if another worker
266  * is already doing that, do nothing.  Tasks becomes unowned.
267  * The probe worker, if it detects nothing has to be done picks up this task,
268  * if unowned.
269  */
270 struct auth_nextprobe {
271 	/* Worker pointer. NULL means unowned. */
272 	struct worker* worker;
273 	/* module env for this task */
274 	struct module_env* env;
275 
276 	/** increasing backoff for failures */
277 	time_t backoff;
278 	/** Timeout for next probe (for SOA) */
279 	time_t next_probe;
280 	/** timeout callback for next_probe or expiry(if that is sooner).
281 	 * it is on the worker's event_base */
282 	struct comm_timer* timer;
283 };
284 
285 /**
286  * The probe task.
287  * Send a SOA UDP query to see if the zone needs to be updated (or similar,
288  * potential, HTTP probe query) and check serial number.
289  * If yes, start the auth_transfer task.  If no, make sure auth_nextprobe
290  * timeout wait task is running.
291  * Needs to be a task, because the UDP query needs an event entry.
292  * This task could also be started by eg. a NOTIFY being received, even though
293  * another worker is performing the nextprobe task (and that worker keeps
294  * waiting uninterrupted).
295  */
296 struct auth_probe {
297 	/* Worker pointer. NULL means unowned. */
298 	struct worker* worker;
299 	/* module env for this task */
300 	struct module_env* env;
301 
302 	/** list of upstream masters for this zone, from config */
303 	struct auth_master* masters;
304 
305 	/** for the hostname lookups, which master is current */
306 	struct auth_master* lookup_target;
307 	/** are we looking up A or AAAA, first A, then AAAA (if ip6 enabled) */
308 	int lookup_aaaa;
309 	/** we only want to do lookups for making config work (for notify),
310 	 * don't proceed with UDP SOA probe queries */
311 	int only_lookup;
312 	/** we have seen a new lease this scan, because one of the masters
313 	 * replied with the current SOA serial version */
314 	int have_new_lease;
315 
316 	/** once notified, or the timeout has been reached. a scan starts. */
317 	/** the scan specific target (notify source), or NULL if none */
318 	struct auth_master* scan_specific;
319 	/** scan tries all the upstream masters. the scan current target.
320 	 * or NULL if not working on sequential scan */
321 	struct auth_master* scan_target;
322 	/** if not NULL, the specific addr for the current master */
323 	struct auth_addr* scan_addr;
324 
325 	/** dns id of packet in flight */
326 	uint16_t id;
327 	/** the SOA probe udp event.
328 	 * on the workers event base. */
329 	struct comm_point* cp;
330 	/** timeout for packets.
331 	 * on the workers event base. */
332 	struct comm_timer* timer;
333 	/** timeout in msec */
334 	int timeout;
335 };
336 
337 /**
338  * The transfer task.
339  * Once done, make sure the nextprobe waiting task is running, whether done
340  * with failure or success.  If failure, use shorter timeout for wait time.
341  */
342 struct auth_transfer {
343 	/* Worker pointer. NULL means unowned. */
344 	struct worker* worker;
345 	/* module env for this task */
346 	struct module_env* env;
347 
348 	/** xfer data that has been transferred, the data is applied
349 	 * once the transfer has completed correctly */
350 	struct auth_chunk* chunks_first;
351 	/** last element in chunks list (to append new data at the end) */
352 	struct auth_chunk* chunks_last;
353 
354 	/** list of upstream masters for this zone, from config */
355 	struct auth_master* masters;
356 
357 	/** for the hostname lookups, which master is current */
358 	struct auth_master* lookup_target;
359 	/** are we looking up A or AAAA, first A, then AAAA (if ip6 enabled) */
360 	int lookup_aaaa;
361 
362 	/** once notified, or the timeout has been reached. a scan starts. */
363 	/** the scan specific target (notify source), or NULL if none */
364 	struct auth_master* scan_specific;
365 	/** scan tries all the upstream masters. the scan current target.
366 	 * or NULL if not working on sequential scan */
367 	struct auth_master* scan_target;
368 	/** what address we are scanning for the master, or NULL if the
369 	 * master is in IP format itself */
370 	struct auth_addr* scan_addr;
371 	/** the zone transfer in progress (or NULL if in scan).  It is
372 	 * from this master */
373 	struct auth_master* master;
374 
375 	/** failed ixfr transfer, retry with axfr (to the current master),
376 	 * the IXFR was 'REFUSED', 'SERVFAIL', 'NOTIMPL' or the contents of
377 	 * the IXFR did not apply cleanly (out of sync, delete of nonexistent
378 	 * data or add of duplicate data).  Flag is cleared once the retry
379 	 * with axfr is done. */
380 	int ixfr_fail;
381 	/** we are doing IXFR right now */
382 	int on_ixfr;
383 	/** did we detect the current AXFR/IXFR serial number yet, 0 not yet,
384 	 * 1 we saw the first, 2 we saw the second, 3 must be last SOA in xfr*/
385 	int got_xfr_serial;
386 	/** number of RRs scanned for AXFR/IXFR detection */
387 	size_t rr_scan_num;
388 	/** we are doing an IXFR but we detected an AXFR contents */
389 	int on_ixfr_is_axfr;
390 	/** the serial number for the current AXFR/IXFR incoming reply,
391 	 * for IXFR, the outermost SOA records serial */
392 	uint32_t incoming_xfr_serial;
393 
394 	/** dns id of AXFR query */
395 	uint16_t id;
396 	/** the transfer (TCP) to the master.
397 	 * on the workers event base. */
398 	struct comm_point* cp;
399 };
400 
401 /** list of addresses */
402 struct auth_addr {
403 	/** next in list */
404 	struct auth_addr* next;
405 	/** IP address */
406 	struct sockaddr_storage addr;
407 	/** addr length */
408 	socklen_t addrlen;
409 };
410 
411 /** auth zone master upstream, and the config settings for it */
412 struct auth_master {
413 	/** next master in list */
414 	struct auth_master* next;
415 	/** master IP address (and port), or hostname, string */
416 	char* host;
417 	/** for http, filename */
418 	char* file;
419 	/** use HTTP for this master */
420 	int http;
421 	/** use IXFR for this master */
422 	int ixfr;
423 	/** this is an allow notify member, the master can send notifies
424 	 * to us, but we don't send SOA probes, or zone transfer from it */
425 	int allow_notify;
426 	/** use ssl for channel */
427 	int ssl;
428 	/** the port number (for urls) */
429 	int port;
430 	/** if the host is a hostname, the list of resolved addrs, if any*/
431 	struct auth_addr* list;
432 };
433 
434 /** auth zone master zone transfer data chunk */
435 struct auth_chunk {
436 	/** next chunk in list */
437 	struct auth_chunk* next;
438 	/** the data from this chunk, this is what was received.
439 	 * for an IXFR that means results from comm_net tcp actions,
440 	 * packets. also for an AXFR. For HTTP a zonefile chunk. */
441 	uint8_t* data;
442 	/** length of allocated data */
443 	size_t len;
444 };
445 
446 /**
447  * Create auth zones structure
448  */
449 struct auth_zones* auth_zones_create(void);
450 
451 /**
452  * Apply configuration to auth zones.  Reads zonefiles.
453  * @param az: auth zones structure
454  * @param cfg: config to apply.
455  * @param setup: if true, also sets up values in the auth zones structure
456  * @return false on failure.
457  */
458 int auth_zones_apply_cfg(struct auth_zones* az, struct config_file* cfg,
459 	int setup);
460 
461 /** initial pick up of worker timeouts, ties events to worker event loop
462  * @param az: auth zones structure
463  * @param env: worker env, of first worker that receives the events (if any)
464  * 	in its eventloop.
465  */
466 void auth_xfer_pickup_initial(struct auth_zones* az, struct module_env* env);
467 
468 /**
469  * Cleanup auth zones.  This removes all events from event bases.
470  * Stops the xfr tasks.  But leaves zone data.
471  * @param az: auth zones structure.
472  */
473 void auth_zones_cleanup(struct auth_zones* az);
474 
475 /**
476  * Delete auth zones structure
477  */
478 void auth_zones_delete(struct auth_zones* az);
479 
480 /**
481  * Write auth zone data to file, in zonefile format.
482  */
483 int auth_zone_write_file(struct auth_zone* z, const char* fname);
484 
485 /**
486  * Use auth zones to lookup the answer to a query.
487  * The query is from the iterator.  And the auth zones attempts to provide
488  * the answer instead of going to the internet.
489  *
490  * @param az: auth zones structure.
491  * @param qinfo: query info to lookup.
492  * @param region: region to use to allocate the reply in.
493  * @param msg: reply is stored here (if one).
494  * @param fallback: if true, fallback to making a query to the internet.
495  * @param dp_nm: name of delegation point to look for.  This zone is used
496  *	to answer the query.
497  *	If the dp_nm is not found, fallback is set to true and false returned.
498  * @param dp_nmlen: length of dp_nm.
499  * @return 0: failure (an error of some sort, like servfail).
500  *         if 0 and fallback is true, fallback to the internet.
501  *         if 0 and fallback is false, like getting servfail.
502  *         If true, an answer is available.
503  */
504 int auth_zones_lookup(struct auth_zones* az, struct query_info* qinfo,
505 	struct regional* region, struct dns_msg** msg, int* fallback,
506 	uint8_t* dp_nm, size_t dp_nmlen);
507 
508 /**
509  * Answer query from auth zone.  Create authoritative answer.
510  * @param az: auth zones structure.
511  * @param env: the module environment.
512  * @param qinfo: query info (parsed).
513  * @param edns: edns info (parsed).
514  * @param buf: buffer with query ID and flags, also for reply.
515  * @param repinfo: reply information for a communication point.
516  * @param temp: temporary storage region.
517  * @return false if not answered
518  */
519 int auth_zones_answer(struct auth_zones* az, struct module_env* env,
520 	struct query_info* qinfo, struct edns_data* edns,
521 	struct comm_reply* repinfo, struct sldns_buffer* buf, struct regional* temp);
522 
523 /**
524  * Find the auth zone that is above the given qname.
525  * Return NULL when there is no auth_zone above the give name, otherwise
526  * returns the closest auth_zone above the qname that pertains to it.
527  * @param az: auth zones structure.
528  * @param name: query to look up for.
529  * @param name_len: length of name.
530  * @param dclass: class of zone to find.
531  * @return NULL or auth_zone that pertains to the query.
532  */
533 struct auth_zone* auth_zones_find_zone(struct auth_zones* az,
534 	uint8_t* name, size_t name_len, uint16_t dclass);
535 
536 /** find an auth zone by name (exact match by name or NULL returned) */
537 struct auth_zone* auth_zone_find(struct auth_zones* az, uint8_t* nm,
538 	size_t nmlen, uint16_t dclass);
539 
540 /** find an xfer zone by name (exact match by name or NULL returned) */
541 struct auth_xfer* auth_xfer_find(struct auth_zones* az, uint8_t* nm,
542 	size_t nmlen, uint16_t dclass);
543 
544 /** create an auth zone. returns wrlocked zone. caller must have wrlock
545  * on az. returns NULL on malloc failure */
546 struct auth_zone* auth_zone_create(struct auth_zones* az, uint8_t* nm,
547 	size_t nmlen, uint16_t dclass);
548 
549 /** set auth zone zonefile string. caller must have lock on zone */
550 int auth_zone_set_zonefile(struct auth_zone* z, char* zonefile);
551 
552 /** set auth zone fallback. caller must have lock on zone.
553  * fallbackstr is "yes" or "no". false on parse failure. */
554 int auth_zone_set_fallback(struct auth_zone* z, char* fallbackstr);
555 
556 /** see if the auth zone for the name can fallback
557  * @param az: auth zones
558  * @param nm: name of delegation point.
559  * @param nmlen: length of nm.
560  * @param dclass: class of zone to look for.
561  * @return true if fallback_enabled is true. false if not.
562  * if the zone does not exist, fallback is true (more lenient)
563  * also true if zone does not do upstream requests.
564  */
565 int auth_zones_can_fallback(struct auth_zones* az, uint8_t* nm, size_t nmlen,
566 	uint16_t dclass);
567 
568 /** process notify for auth zones.
569  * first checks the access list.  Then processes the notify. This starts
570  * the probe sequence or it notes the serial number (if any)
571  * @param az: auth zones structure.
572  * @param env: module env of the worker that is handling the notify. it will
573  * 	pick up the task probe (or transfer), unless already in progress by
574  * 	another worker.
575  * @param nm: name of the zone.  Uncompressed. from query.
576  * @param nmlen: length of name.
577  * @param dclass: class of zone.
578  * @param addr: source address of notify
579  * @param addrlen: length of addr.
580  * @param has_serial: if true, the notify has a serial attached.
581  * @param serial: the serial number, if has_serial is true.
582  * @param refused: is set to true on failure to note refused access.
583  * @return fail on failures (refused is false) and when access is
584  * 	denied (refused is true).  True when processed.
585  */
586 int auth_zones_notify(struct auth_zones* az, struct module_env* env,
587 	uint8_t* nm, size_t nmlen, uint16_t dclass,
588 	struct sockaddr_storage* addr, socklen_t addrlen, int has_serial,
589 	uint32_t serial, int* refused);
590 
591 /** process notify packet and read serial number from SOA.
592  * returns 0 if no soa record in the notify */
593 int auth_zone_parse_notify_serial(struct sldns_buffer* pkt, uint32_t *serial);
594 
595 /** for the zone and if not already going, starts the probe sequence.
596  * false if zone cannot be found.  This is like a notify arrived and was
597  * accepted for that zone. */
598 int auth_zones_startprobesequence(struct auth_zones* az,
599 	struct module_env* env, uint8_t* nm, size_t nmlen, uint16_t dclass);
600 
601 /** read auth zone from zonefile. caller must lock zone. false on failure */
602 int auth_zone_read_zonefile(struct auth_zone* z);
603 
604 /** find serial number of zone or false if none (no SOA record) */
605 int auth_zone_get_serial(struct auth_zone* z, uint32_t* serial);
606 
607 /** compare auth_zones for sorted rbtree */
608 int auth_zone_cmp(const void* z1, const void* z2);
609 
610 /** compare auth_data for sorted rbtree */
611 int auth_data_cmp(const void* z1, const void* z2);
612 
613 /** compare auth_xfer for sorted rbtree */
614 int auth_xfer_cmp(const void* z1, const void* z2);
615 
616 /** Create auth_xfer structure.
617  * Caller must have wrlock on az. Returns locked xfer zone.
618  * @param az: zones structure.
619  * @param z: zone with name and class
620  * @return xfer zone or NULL
621  */
622 struct auth_xfer* auth_xfer_create(struct auth_zones* az, struct auth_zone* z);
623 
624 /**
625  * Set masters in auth xfer structure from config.
626  * @param list: pointer to start of list.  The malloced list is returned here.
627  * @param c: the config items to copy over.
628  * @param with_http: if true, http urls are also included, before the masters.
629  * @return false on failure.
630  */
631 int xfer_set_masters(struct auth_master** list, struct config_auth* c,
632 	int with_http);
633 
634 /** xfer nextprobe timeout callback, this is part of task_nextprobe */
635 void auth_xfer_timer(void* arg);
636 
637 /** callback for commpoint udp replies to task_probe */
638 int auth_xfer_probe_udp_callback(struct comm_point* c, void* arg, int err,
639         struct comm_reply* repinfo);
640 /** callback for task_transfer tcp connections */
641 int auth_xfer_transfer_tcp_callback(struct comm_point* c, void* arg, int err,
642         struct comm_reply* repinfo);
643 /** callback for task_transfer http connections */
644 int auth_xfer_transfer_http_callback(struct comm_point* c, void* arg, int err,
645         struct comm_reply* repinfo);
646 /** xfer probe timeout callback, part of task_probe */
647 void auth_xfer_probe_timer_callback(void* arg);
648 /** mesh callback for task_probe on lookup of host names */
649 void auth_xfer_probe_lookup_callback(void* arg, int rcode,
650 	struct sldns_buffer* buf, enum sec_status sec, char* why_bogus,
651 	int was_ratelimited);
652 /** mesh callback for task_transfer on lookup of host names */
653 void auth_xfer_transfer_lookup_callback(void* arg, int rcode,
654 	struct sldns_buffer* buf, enum sec_status sec, char* why_bogus,
655 	int was_ratelimited);
656 
657 /*
658  * Compares two 32-bit serial numbers as defined in RFC1982.  Returns
659  * <0 if a < b, 0 if a == b, and >0 if a > b.  The result is undefined
660  * if a != b but neither is greater or smaller (see RFC1982 section
661  * 3.2.).
662  */
663 int compare_serial(uint32_t a, uint32_t b);
664 
665 #endif /* SERVICES_AUTHZONE_H */
666