xref: /netbsd/external/mpl/bind/dist/lib/dns/include/dns/peer.h (revision c0b5d9fb)
1 /*	$NetBSD: peer.h,v 1.6 2022/09/23 12:15:30 christos Exp $	*/
2 
3 /*
4  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
5  *
6  * SPDX-License-Identifier: MPL-2.0
7  *
8  * This Source Code Form is subject to the terms of the Mozilla Public
9  * License, v. 2.0. If a copy of the MPL was not distributed with this
10  * file, you can obtain one at https://mozilla.org/MPL/2.0/.
11  *
12  * See the COPYRIGHT file distributed with this work for additional
13  * information regarding copyright ownership.
14  */
15 
16 #ifndef DNS_PEER_H
17 #define DNS_PEER_H 1
18 
19 /*****
20 ***** Module Info
21 *****/
22 
23 /*! \file dns/peer.h
24  * \brief
25  * Data structures for peers (e.g. a 'server' config file statement)
26  */
27 
28 /***
29  *** Imports
30  ***/
31 
32 #include <inttypes.h>
33 #include <stdbool.h>
34 
35 #include <isc/lang.h>
36 #include <isc/magic.h>
37 #include <isc/netaddr.h>
38 #include <isc/refcount.h>
39 
40 #include <dns/types.h>
41 
42 #define DNS_PEERLIST_MAGIC ISC_MAGIC('s', 'e', 'R', 'L')
43 #define DNS_PEER_MAGIC	   ISC_MAGIC('S', 'E', 'r', 'v')
44 
45 #define DNS_PEERLIST_VALID(ptr) ISC_MAGIC_VALID(ptr, DNS_PEERLIST_MAGIC)
46 #define DNS_PEER_VALID(ptr)	ISC_MAGIC_VALID(ptr, DNS_PEER_MAGIC)
47 
48 /***
49  *** Types
50  ***/
51 
52 struct dns_peerlist {
53 	unsigned int   magic;
54 	isc_refcount_t refs;
55 
56 	isc_mem_t *mem;
57 
58 	ISC_LIST(dns_peer_t) elements;
59 };
60 
61 struct dns_peer {
62 	unsigned int   magic;
63 	isc_refcount_t refs;
64 
65 	isc_mem_t *mem;
66 
67 	isc_netaddr_t	      address;
68 	unsigned int	      prefixlen;
69 	bool		      bogus;
70 	dns_transfer_format_t transfer_format;
71 	uint32_t	      transfers;
72 	bool		      support_ixfr;
73 	bool		      provide_ixfr;
74 	bool		      request_ixfr;
75 	bool		      support_edns;
76 	bool		      request_nsid;
77 	bool		      send_cookie;
78 	bool		      request_expire;
79 	bool		      force_tcp;
80 	bool		      tcp_keepalive;
81 	dns_name_t	     *key;
82 	isc_sockaddr_t	     *transfer_source;
83 	isc_dscp_t	      transfer_dscp;
84 	isc_sockaddr_t	     *notify_source;
85 	isc_dscp_t	      notify_dscp;
86 	isc_sockaddr_t	     *query_source;
87 	isc_dscp_t	      query_dscp;
88 	uint16_t	      udpsize;	   /* receive size */
89 	uint16_t	      maxudp;	   /* transmit size */
90 	uint16_t	      padding;	   /* pad block size */
91 	uint8_t		      ednsversion; /* edns version */
92 
93 	uint32_t bitflags;
94 
95 	ISC_LINK(dns_peer_t) next;
96 };
97 
98 /***
99  *** Functions
100  ***/
101 
102 ISC_LANG_BEGINDECLS
103 
104 isc_result_t
105 dns_peerlist_new(isc_mem_t *mem, dns_peerlist_t **list);
106 
107 void
108 dns_peerlist_attach(dns_peerlist_t *source, dns_peerlist_t **target);
109 
110 void
111 dns_peerlist_detach(dns_peerlist_t **list);
112 
113 /*
114  * After return caller still holds a reference to peer.
115  */
116 void
117 dns_peerlist_addpeer(dns_peerlist_t *peers, dns_peer_t *peer);
118 
119 /*
120  * Ditto. */
121 isc_result_t
122 dns_peerlist_peerbyaddr(dns_peerlist_t *peers, const isc_netaddr_t *addr,
123 			dns_peer_t **retval);
124 
125 /*
126  * What he said.
127  */
128 isc_result_t
129 dns_peerlist_currpeer(dns_peerlist_t *peers, dns_peer_t **retval);
130 
131 isc_result_t
132 dns_peer_new(isc_mem_t *mem, const isc_netaddr_t *ipaddr, dns_peer_t **peer);
133 
134 isc_result_t
135 dns_peer_newprefix(isc_mem_t *mem, const isc_netaddr_t *ipaddr,
136 		   unsigned int prefixlen, dns_peer_t **peer);
137 
138 void
139 dns_peer_attach(dns_peer_t *source, dns_peer_t **target);
140 
141 void
142 dns_peer_detach(dns_peer_t **list);
143 
144 isc_result_t
145 dns_peer_setbogus(dns_peer_t *peer, bool newval);
146 
147 isc_result_t
148 dns_peer_getbogus(dns_peer_t *peer, bool *retval);
149 
150 isc_result_t
151 dns_peer_setrequestixfr(dns_peer_t *peer, bool newval);
152 
153 isc_result_t
154 dns_peer_getrequestixfr(dns_peer_t *peer, bool *retval);
155 
156 isc_result_t
157 dns_peer_setprovideixfr(dns_peer_t *peer, bool newval);
158 
159 isc_result_t
160 dns_peer_getprovideixfr(dns_peer_t *peer, bool *retval);
161 
162 isc_result_t
163 dns_peer_setrequestnsid(dns_peer_t *peer, bool newval);
164 
165 isc_result_t
166 dns_peer_getrequestnsid(dns_peer_t *peer, bool *retval);
167 
168 isc_result_t
169 dns_peer_setsendcookie(dns_peer_t *peer, bool newval);
170 
171 isc_result_t
172 dns_peer_getsendcookie(dns_peer_t *peer, bool *retval);
173 
174 isc_result_t
175 dns_peer_setrequestexpire(dns_peer_t *peer, bool newval);
176 
177 isc_result_t
178 dns_peer_getrequestexpire(dns_peer_t *peer, bool *retval);
179 
180 isc_result_t
181 dns_peer_setsupportedns(dns_peer_t *peer, bool newval);
182 
183 isc_result_t
184 dns_peer_getforcetcp(dns_peer_t *peer, bool *retval);
185 
186 isc_result_t
187 dns_peer_setforcetcp(dns_peer_t *peer, bool newval);
188 
189 isc_result_t
190 dns_peer_gettcpkeepalive(dns_peer_t *peer, bool *retval);
191 
192 isc_result_t
193 dns_peer_settcpkeepalive(dns_peer_t *peer, bool newval);
194 
195 isc_result_t
196 dns_peer_getsupportedns(dns_peer_t *peer, bool *retval);
197 
198 isc_result_t
199 dns_peer_settransfers(dns_peer_t *peer, uint32_t newval);
200 
201 isc_result_t
202 dns_peer_gettransfers(dns_peer_t *peer, uint32_t *retval);
203 
204 isc_result_t
205 dns_peer_settransferformat(dns_peer_t *peer, dns_transfer_format_t newval);
206 
207 isc_result_t
208 dns_peer_gettransferformat(dns_peer_t *peer, dns_transfer_format_t *retval);
209 
210 isc_result_t
211 dns_peer_setkeybycharp(dns_peer_t *peer, const char *keyval);
212 
213 isc_result_t
214 dns_peer_getkey(dns_peer_t *peer, dns_name_t **retval);
215 
216 isc_result_t
217 dns_peer_setkey(dns_peer_t *peer, dns_name_t **keyval);
218 
219 isc_result_t
220 dns_peer_settransfersource(dns_peer_t		*peer,
221 			   const isc_sockaddr_t *transfer_source);
222 
223 isc_result_t
224 dns_peer_gettransfersource(dns_peer_t *peer, isc_sockaddr_t *transfer_source);
225 
226 isc_result_t
227 dns_peer_setudpsize(dns_peer_t *peer, uint16_t udpsize);
228 
229 isc_result_t
230 dns_peer_getudpsize(dns_peer_t *peer, uint16_t *udpsize);
231 
232 isc_result_t
233 dns_peer_setmaxudp(dns_peer_t *peer, uint16_t maxudp);
234 
235 isc_result_t
236 dns_peer_getmaxudp(dns_peer_t *peer, uint16_t *maxudp);
237 
238 isc_result_t
239 dns_peer_setpadding(dns_peer_t *peer, uint16_t padding);
240 
241 isc_result_t
242 dns_peer_getpadding(dns_peer_t *peer, uint16_t *padding);
243 
244 isc_result_t
245 dns_peer_setnotifysource(dns_peer_t *peer, const isc_sockaddr_t *notify_source);
246 
247 isc_result_t
248 dns_peer_getnotifysource(dns_peer_t *peer, isc_sockaddr_t *notify_source);
249 
250 isc_result_t
251 dns_peer_setquerysource(dns_peer_t *peer, const isc_sockaddr_t *query_source);
252 
253 isc_result_t
254 dns_peer_getquerysource(dns_peer_t *peer, isc_sockaddr_t *query_source);
255 
256 isc_result_t
257 dns_peer_setnotifydscp(dns_peer_t *peer, isc_dscp_t dscp);
258 
259 isc_result_t
260 dns_peer_getnotifydscp(dns_peer_t *peer, isc_dscp_t *dscpp);
261 
262 isc_result_t
263 dns_peer_settransferdscp(dns_peer_t *peer, isc_dscp_t dscp);
264 
265 isc_result_t
266 dns_peer_gettransferdscp(dns_peer_t *peer, isc_dscp_t *dscpp);
267 
268 isc_result_t
269 dns_peer_setquerydscp(dns_peer_t *peer, isc_dscp_t dscp);
270 
271 isc_result_t
272 dns_peer_getquerydscp(dns_peer_t *peer, isc_dscp_t *dscpp);
273 
274 isc_result_t
275 dns_peer_setednsversion(dns_peer_t *peer, uint8_t ednsversion);
276 
277 isc_result_t
278 dns_peer_getednsversion(dns_peer_t *peer, uint8_t *ednsversion);
279 ISC_LANG_ENDDECLS
280 
281 #endif /* DNS_PEER_H */
282