xref: /openbsd/usr.sbin/nsd/xfrd-notify.h (revision a6445c1d)
1 /*
2  * xfrd-notify.h - notify sending routines.
3  *
4  * Copyright (c) 2006, NLnet Labs. All rights reserved.
5  *
6  * See LICENSE for the license.
7  *
8  */
9 
10 #ifndef XFRD_NOTIFY_H
11 #define XFRD_NOTIFY_H
12 
13 #ifndef USE_MINI_EVENT
14 #  ifdef HAVE_EVENT_H
15 #    include <event.h>
16 #  else
17 #    include <event2/event.h>
18 #    include "event2/event_struct.h"
19 #    include "event2/event_compat.h"
20 #  endif
21 #else
22 #  include "mini_event.h"
23 #endif
24 #include "tsig.h"
25 #include "rbtree.h"
26 
27 struct nsd;
28 struct region;
29 struct xfrd_zone;
30 struct zone_options;
31 struct zone;
32 struct xfrd_soa;
33 struct acl_options;
34 struct xfrd_state;
35 
36 /**
37  * This struct keeps track of outbound notifies for a zone.
38  */
39 struct notify_zone_t {
40 	rbnode_t node;
41 	/* name of the zone */
42 	const dname_type* apex;
43 	const char* apex_str;
44 
45 	tsig_record_type notify_tsig; /* tsig state for notify */
46 	struct zone_options* options;
47 	struct xfrd_soa *current_soa; /* current SOA in NSD */
48 
49 	/* notify sending handler */
50 	/* Not saved on disk (i.e. kill of daemon stops notifies) */
51 	int notify_send_enable;
52 	struct event notify_send_handler;
53 	struct timeval notify_timeout;
54 	struct acl_options* notify_current; /* current slave to notify */
55 	uint8_t notify_restart; /* restart notify after repattern */
56 	uint8_t notify_retry; /* how manieth retry in sending to current */
57 	uint16_t notify_query_id;
58 
59 	/* is this notify waiting for a socket? */
60 	uint8_t is_waiting;
61 	/* the double linked waiting list for the udp sockets */
62 	struct notify_zone_t* waiting_next;
63 	struct notify_zone_t* waiting_prev;
64 };
65 
66 /* initialise outgoing notifies */
67 void init_notify_send(rbtree_t* tree, region_type* region,
68 	struct zone_options* options);
69 /* delete notify zone */
70 void xfrd_del_notify(struct xfrd_state* xfrd, const dname_type* dname);
71 
72 /* send notifications to all in the notify list */
73 void xfrd_send_notify(rbtree_t* tree, const struct dname* apex,
74 	struct xfrd_soa* new_soa);
75 /* start notifications, if not started already (does not clobber SOA) */
76 void xfrd_notify_start(struct notify_zone_t* zone);
77 
78 /* handle soa update notify for a master zone. newsoa can be NULL.
79    Makes sure that the soa (serial) has changed. Or drops notify. */
80 void notify_handle_master_zone_soainfo(rbtree_t* tree,
81 	const dname_type* apex, struct xfrd_soa* new_soa);
82 
83 /* close fds in use for notification sending */
84 void close_notify_fds(rbtree_t* tree);
85 /* stop send of notify */
86 void notify_disable(struct notify_zone_t* zone);
87 
88 #endif /* XFRD_NOTIFY_H */
89