xref: /openbsd/usr.sbin/nsd/xfrd-notify.h (revision ee5153b7)
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 /** number of concurrent notify packets in flight */
37 #define NOTIFY_CONCURRENT_MAX 16
38 
39 /** notify packet info */
40 struct notify_pkt {
41 	struct acl_options* dest; /* target, NULL if entry not in use */
42 	uint8_t notify_retry; /* how manieth retry in sending to current */
43 	uint16_t notify_query_id;
44 	time_t send_time;
45 };
46 
47 /**
48  * This struct keeps track of outbound notifies for a zone.
49  */
50 struct notify_zone {
51 	rbnode_type node;
52 	/* name of the zone */
53 	const dname_type* apex;
54 	const char* apex_str;
55 
56 	tsig_record_type notify_tsig; /* tsig state for notify */
57 	struct zone_options* options;
58 	struct xfrd_soa *current_soa; /* current SOA in NSD */
59 
60 	/* notify sending handler */
61 	/* Not saved on disk (i.e. kill of daemon stops notifies) */
62 	int notify_send_enable;
63 	struct event notify_send_handler;
64 	int notify_send6_enable;
65 	struct event notify_send6_handler;
66 	struct timeval notify_timeout;
67 	struct acl_options* notify_current; /* current slave to notify */
68 	uint8_t notify_restart; /* restart notify after repattern */
69 	struct notify_pkt pkts[NOTIFY_CONCURRENT_MAX];
70 	int notify_pkt_count; /* number of entries nonNULL in pkts */
71 
72 	/* is this notify waiting for a socket? */
73 	uint8_t is_waiting;
74 	/* the double linked waiting list for the udp sockets */
75 	struct notify_zone* waiting_next;
76 	struct notify_zone* waiting_prev;
77 } ATTR_PACKED;
78 
79 /* initialise outgoing notifies */
80 void init_notify_send(rbtree_type* tree, region_type* region,
81 	struct zone_options* options);
82 /* delete notify zone */
83 void xfrd_del_notify(struct xfrd_state* xfrd, const dname_type* dname);
84 
85 /* send notifications to all in the notify list */
86 void xfrd_send_notify(rbtree_type* tree, const struct dname* apex,
87 	struct xfrd_soa* new_soa);
88 /* start notifications, if not started already (does not clobber SOA) */
89 void xfrd_notify_start(struct notify_zone* zone, struct xfrd_state* xfrd);
90 
91 /* handle soa update notify for a master zone. newsoa can be NULL.
92    Makes sure that the soa (serial) has changed. Or drops notify. */
93 void notify_handle_master_zone_soainfo(rbtree_type* tree,
94 	const dname_type* apex, struct xfrd_soa* new_soa);
95 
96 /* close fds in use for notification sending */
97 void close_notify_fds(rbtree_type* tree);
98 /* stop send of notify */
99 void notify_disable(struct notify_zone* zone);
100 
101 #endif /* XFRD_NOTIFY_H */
102