Remove building with NOCRYPTO option
[minix.git] / external / bsd / bind / dist / lib / dns / peer.c
blobea3fe3eed13544ae2e9bc041195f910521ce16ba
1 /* $NetBSD: peer.c,v 1.7 2014/12/10 04:37:58 christos Exp $ */
3 /*
4 * Copyright (C) 2004-2009, 2012-2014 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
20 /* Id: peer.c,v 1.33 2009/09/02 23:48:02 tbox Exp */
22 /*! \file */
24 #include <config.h>
26 #include <isc/mem.h>
27 #include <isc/string.h>
28 #include <isc/util.h>
29 #include <isc/sockaddr.h>
31 #include <dns/bit.h>
32 #include <dns/fixedname.h>
33 #include <dns/name.h>
34 #include <dns/peer.h>
36 /*%
37 * Bit positions in the dns_peer_t structure flags field
39 #define BOGUS_BIT 0
40 #define SERVER_TRANSFER_FORMAT_BIT 1
41 #define TRANSFERS_BIT 2
42 #define PROVIDE_IXFR_BIT 3
43 #define REQUEST_IXFR_BIT 4
44 #define SUPPORT_EDNS_BIT 5
45 #define SERVER_UDPSIZE_BIT 6
46 #define SERVER_MAXUDP_BIT 7
47 #define REQUEST_NSID_BIT 8
48 #define REQUEST_SIT_BIT 9
49 #define NOTIFY_DSCP_BIT 10
50 #define TRANSFER_DSCP_BIT 11
51 #define QUERY_DSCP_BIT 12
53 static void
54 peerlist_delete(dns_peerlist_t **list);
56 static void
57 peer_delete(dns_peer_t **peer);
59 isc_result_t
60 dns_peerlist_new(isc_mem_t *mem, dns_peerlist_t **list) {
61 dns_peerlist_t *l;
63 REQUIRE(list != NULL);
65 l = isc_mem_get(mem, sizeof(*l));
66 if (l == NULL)
67 return (ISC_R_NOMEMORY);
69 ISC_LIST_INIT(l->elements);
70 l->mem = mem;
71 l->refs = 1;
72 l->magic = DNS_PEERLIST_MAGIC;
74 *list = l;
76 return (ISC_R_SUCCESS);
79 void
80 dns_peerlist_attach(dns_peerlist_t *source, dns_peerlist_t **target) {
81 REQUIRE(DNS_PEERLIST_VALID(source));
82 REQUIRE(target != NULL);
83 REQUIRE(*target == NULL);
85 source->refs++;
87 ENSURE(source->refs != 0xffffffffU);
89 *target = source;
92 void
93 dns_peerlist_detach(dns_peerlist_t **list) {
94 dns_peerlist_t *plist;
96 REQUIRE(list != NULL);
97 REQUIRE(*list != NULL);
98 REQUIRE(DNS_PEERLIST_VALID(*list));
100 plist = *list;
101 *list = NULL;
103 REQUIRE(plist->refs > 0);
105 plist->refs--;
107 if (plist->refs == 0)
108 peerlist_delete(&plist);
111 static void
112 peerlist_delete(dns_peerlist_t **list) {
113 dns_peerlist_t *l;
114 dns_peer_t *server, *stmp;
116 REQUIRE(list != NULL);
117 REQUIRE(DNS_PEERLIST_VALID(*list));
119 l = *list;
121 REQUIRE(l->refs == 0);
123 server = ISC_LIST_HEAD(l->elements);
124 while (server != NULL) {
125 stmp = ISC_LIST_NEXT(server, next);
126 ISC_LIST_UNLINK(l->elements, server, next);
127 dns_peer_detach(&server);
128 server = stmp;
131 l->magic = 0;
132 isc_mem_put(l->mem, l, sizeof(*l));
134 *list = NULL;
137 void
138 dns_peerlist_addpeer(dns_peerlist_t *peers, dns_peer_t *peer) {
139 dns_peer_t *p = NULL;
141 dns_peer_attach(peer, &p);
144 * More specifics to front of list.
146 for (p = ISC_LIST_HEAD(peers->elements);
147 p != NULL;
148 p = ISC_LIST_NEXT(p, next))
149 if (p->prefixlen < peer->prefixlen)
150 break;
152 if (p != NULL)
153 ISC_LIST_INSERTBEFORE(peers->elements, p, peer, next);
154 else
155 ISC_LIST_APPEND(peers->elements, peer, next);
159 isc_result_t
160 dns_peerlist_peerbyaddr(dns_peerlist_t *servers,
161 isc_netaddr_t *addr, dns_peer_t **retval)
163 dns_peer_t *server;
164 isc_result_t res;
166 REQUIRE(retval != NULL);
167 REQUIRE(DNS_PEERLIST_VALID(servers));
169 server = ISC_LIST_HEAD(servers->elements);
170 while (server != NULL) {
171 if (isc_netaddr_eqprefix(addr, &server->address,
172 server->prefixlen))
173 break;
175 server = ISC_LIST_NEXT(server, next);
178 if (server != NULL) {
179 *retval = server;
180 res = ISC_R_SUCCESS;
181 } else {
182 res = ISC_R_NOTFOUND;
185 return (res);
190 isc_result_t
191 dns_peerlist_currpeer(dns_peerlist_t *peers, dns_peer_t **retval) {
192 dns_peer_t *p = NULL;
194 p = ISC_LIST_TAIL(peers->elements);
196 dns_peer_attach(p, retval);
198 return (ISC_R_SUCCESS);
201 isc_result_t
202 dns_peer_new(isc_mem_t *mem, isc_netaddr_t *addr, dns_peer_t **peerptr) {
203 unsigned int prefixlen = 0;
205 REQUIRE(peerptr != NULL);
206 switch(addr->family) {
207 case AF_INET:
208 prefixlen = 32;
209 break;
210 case AF_INET6:
211 prefixlen = 128;
212 break;
213 default:
214 INSIST(0);
217 return (dns_peer_newprefix(mem, addr, prefixlen, peerptr));
220 isc_result_t
221 dns_peer_newprefix(isc_mem_t *mem, isc_netaddr_t *addr, unsigned int prefixlen,
222 dns_peer_t **peerptr)
224 dns_peer_t *peer;
226 REQUIRE(peerptr != NULL);
228 peer = isc_mem_get(mem, sizeof(*peer));
229 if (peer == NULL)
230 return (ISC_R_NOMEMORY);
232 peer->magic = DNS_PEER_MAGIC;
233 peer->address = *addr;
234 peer->prefixlen = prefixlen;
235 peer->mem = mem;
236 peer->bogus = ISC_FALSE;
237 peer->transfer_format = dns_one_answer;
238 peer->transfers = 0;
239 peer->request_ixfr = ISC_FALSE;
240 peer->provide_ixfr = ISC_FALSE;
241 peer->key = NULL;
242 peer->refs = 1;
243 peer->transfer_source = NULL;
244 peer->notify_source = NULL;
245 peer->query_source = NULL;
247 memset(&peer->bitflags, 0x0, sizeof(peer->bitflags));
249 ISC_LINK_INIT(peer, next);
251 *peerptr = peer;
253 return (ISC_R_SUCCESS);
256 void
257 dns_peer_attach(dns_peer_t *source, dns_peer_t **target) {
258 REQUIRE(DNS_PEER_VALID(source));
259 REQUIRE(target != NULL);
260 REQUIRE(*target == NULL);
262 source->refs++;
264 ENSURE(source->refs != 0xffffffffU);
266 *target = source;
269 void
270 dns_peer_detach(dns_peer_t **peer) {
271 dns_peer_t *p;
273 REQUIRE(peer != NULL);
274 REQUIRE(*peer != NULL);
275 REQUIRE(DNS_PEER_VALID(*peer));
277 p = *peer;
279 REQUIRE(p->refs > 0);
281 *peer = NULL;
282 p->refs--;
284 if (p->refs == 0)
285 peer_delete(&p);
288 static void
289 peer_delete(dns_peer_t **peer) {
290 dns_peer_t *p;
291 isc_mem_t *mem;
293 REQUIRE(peer != NULL);
294 REQUIRE(DNS_PEER_VALID(*peer));
296 p = *peer;
298 REQUIRE(p->refs == 0);
300 mem = p->mem;
301 p->mem = NULL;
302 p->magic = 0;
304 if (p->key != NULL) {
305 dns_name_free(p->key, mem);
306 isc_mem_put(mem, p->key, sizeof(dns_name_t));
309 if (p->query_source != NULL)
310 isc_mem_put(mem, p->query_source, sizeof(*p->query_source));
312 if (p->notify_source != NULL)
313 isc_mem_put(mem, p->notify_source, sizeof(*p->notify_source));
315 if (p->transfer_source != NULL)
316 isc_mem_put(mem, p->transfer_source,
317 sizeof(*p->transfer_source));
319 isc_mem_put(mem, p, sizeof(*p));
321 *peer = NULL;
324 isc_result_t
325 dns_peer_setbogus(dns_peer_t *peer, isc_boolean_t newval) {
326 isc_boolean_t existed;
328 REQUIRE(DNS_PEER_VALID(peer));
330 existed = DNS_BIT_CHECK(BOGUS_BIT, &peer->bitflags);
332 peer->bogus = newval;
333 DNS_BIT_SET(BOGUS_BIT, &peer->bitflags);
335 return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS);
338 isc_result_t
339 dns_peer_getbogus(dns_peer_t *peer, isc_boolean_t *retval) {
340 REQUIRE(DNS_PEER_VALID(peer));
341 REQUIRE(retval != NULL);
343 if (DNS_BIT_CHECK(BOGUS_BIT, &peer->bitflags)) {
344 *retval = peer->bogus;
345 return (ISC_R_SUCCESS);
346 } else
347 return (ISC_R_NOTFOUND);
351 isc_result_t
352 dns_peer_setprovideixfr(dns_peer_t *peer, isc_boolean_t newval) {
353 isc_boolean_t existed;
355 REQUIRE(DNS_PEER_VALID(peer));
357 existed = DNS_BIT_CHECK(PROVIDE_IXFR_BIT, &peer->bitflags);
359 peer->provide_ixfr = newval;
360 DNS_BIT_SET(PROVIDE_IXFR_BIT, &peer->bitflags);
362 return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS);
365 isc_result_t
366 dns_peer_getprovideixfr(dns_peer_t *peer, isc_boolean_t *retval) {
367 REQUIRE(DNS_PEER_VALID(peer));
368 REQUIRE(retval != NULL);
370 if (DNS_BIT_CHECK(PROVIDE_IXFR_BIT, &peer->bitflags)) {
371 *retval = peer->provide_ixfr;
372 return (ISC_R_SUCCESS);
373 } else {
374 return (ISC_R_NOTFOUND);
378 isc_result_t
379 dns_peer_setrequestixfr(dns_peer_t *peer, isc_boolean_t newval) {
380 isc_boolean_t existed;
382 REQUIRE(DNS_PEER_VALID(peer));
384 existed = DNS_BIT_CHECK(REQUEST_IXFR_BIT, &peer->bitflags);
386 peer->request_ixfr = newval;
387 DNS_BIT_SET(REQUEST_IXFR_BIT, &peer->bitflags);
389 return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS);
392 isc_result_t
393 dns_peer_getrequestixfr(dns_peer_t *peer, isc_boolean_t *retval) {
394 REQUIRE(DNS_PEER_VALID(peer));
395 REQUIRE(retval != NULL);
397 if (DNS_BIT_CHECK(REQUEST_IXFR_BIT, &peer->bitflags)) {
398 *retval = peer->request_ixfr;
399 return (ISC_R_SUCCESS);
400 } else
401 return (ISC_R_NOTFOUND);
404 isc_result_t
405 dns_peer_setsupportedns(dns_peer_t *peer, isc_boolean_t newval) {
406 isc_boolean_t existed;
408 REQUIRE(DNS_PEER_VALID(peer));
410 existed = DNS_BIT_CHECK(SUPPORT_EDNS_BIT, &peer->bitflags);
412 peer->support_edns = newval;
413 DNS_BIT_SET(SUPPORT_EDNS_BIT, &peer->bitflags);
415 return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS);
418 isc_result_t
419 dns_peer_getsupportedns(dns_peer_t *peer, isc_boolean_t *retval) {
420 REQUIRE(DNS_PEER_VALID(peer));
421 REQUIRE(retval != NULL);
423 if (DNS_BIT_CHECK(SUPPORT_EDNS_BIT, &peer->bitflags)) {
424 *retval = peer->support_edns;
425 return (ISC_R_SUCCESS);
426 } else
427 return (ISC_R_NOTFOUND);
430 isc_result_t
431 dns_peer_setrequestnsid(dns_peer_t *peer, isc_boolean_t newval) {
432 isc_boolean_t existed;
434 REQUIRE(DNS_PEER_VALID(peer));
436 existed = DNS_BIT_CHECK(REQUEST_NSID_BIT, &peer->bitflags);
438 peer->request_nsid = newval;
439 DNS_BIT_SET(REQUEST_NSID_BIT, &peer->bitflags);
441 return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS);
444 isc_result_t
445 dns_peer_getrequestnsid(dns_peer_t *peer, isc_boolean_t *retval) {
446 REQUIRE(DNS_PEER_VALID(peer));
447 REQUIRE(retval != NULL);
449 if (DNS_BIT_CHECK(REQUEST_NSID_BIT, &peer->bitflags)) {
450 *retval = peer->request_nsid;
451 return (ISC_R_SUCCESS);
452 } else
453 return (ISC_R_NOTFOUND);
456 isc_result_t
457 dns_peer_setrequestsit(dns_peer_t *peer, isc_boolean_t newval) {
458 isc_boolean_t existed;
460 REQUIRE(DNS_PEER_VALID(peer));
462 existed = DNS_BIT_CHECK(REQUEST_SIT_BIT, &peer->bitflags);
464 peer->request_sit = newval;
465 DNS_BIT_SET(REQUEST_SIT_BIT, &peer->bitflags);
467 return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS);
470 isc_result_t
471 dns_peer_getrequestsit(dns_peer_t *peer, isc_boolean_t *retval) {
472 REQUIRE(DNS_PEER_VALID(peer));
473 REQUIRE(retval != NULL);
475 if (DNS_BIT_CHECK(REQUEST_SIT_BIT, &peer->bitflags)) {
476 *retval = peer->request_sit;
477 return (ISC_R_SUCCESS);
478 } else
479 return (ISC_R_NOTFOUND);
482 isc_result_t
483 dns_peer_settransfers(dns_peer_t *peer, isc_uint32_t newval) {
484 isc_boolean_t existed;
486 REQUIRE(DNS_PEER_VALID(peer));
488 existed = DNS_BIT_CHECK(TRANSFERS_BIT, &peer->bitflags);
490 peer->transfers = newval;
491 DNS_BIT_SET(TRANSFERS_BIT, &peer->bitflags);
493 return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS);
496 isc_result_t
497 dns_peer_gettransfers(dns_peer_t *peer, isc_uint32_t *retval) {
498 REQUIRE(DNS_PEER_VALID(peer));
499 REQUIRE(retval != NULL);
501 if (DNS_BIT_CHECK(TRANSFERS_BIT, &peer->bitflags)) {
502 *retval = peer->transfers;
503 return (ISC_R_SUCCESS);
504 } else {
505 return (ISC_R_NOTFOUND);
509 isc_result_t
510 dns_peer_settransferformat(dns_peer_t *peer, dns_transfer_format_t newval) {
511 isc_boolean_t existed;
513 REQUIRE(DNS_PEER_VALID(peer));
515 existed = DNS_BIT_CHECK(SERVER_TRANSFER_FORMAT_BIT,
516 &peer->bitflags);
518 peer->transfer_format = newval;
519 DNS_BIT_SET(SERVER_TRANSFER_FORMAT_BIT, &peer->bitflags);
521 return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS);
524 isc_result_t
525 dns_peer_gettransferformat(dns_peer_t *peer, dns_transfer_format_t *retval) {
526 REQUIRE(DNS_PEER_VALID(peer));
527 REQUIRE(retval != NULL);
529 if (DNS_BIT_CHECK(SERVER_TRANSFER_FORMAT_BIT, &peer->bitflags)) {
530 *retval = peer->transfer_format;
531 return (ISC_R_SUCCESS);
532 } else {
533 return (ISC_R_NOTFOUND);
537 isc_result_t
538 dns_peer_getkey(dns_peer_t *peer, dns_name_t **retval) {
539 REQUIRE(DNS_PEER_VALID(peer));
540 REQUIRE(retval != NULL);
542 if (peer->key != NULL) {
543 *retval = peer->key;
546 return (peer->key == NULL ? ISC_R_NOTFOUND : ISC_R_SUCCESS);
549 isc_result_t
550 dns_peer_setkey(dns_peer_t *peer, dns_name_t **keyval) {
551 isc_boolean_t exists = ISC_FALSE;
553 if (peer->key != NULL) {
554 dns_name_free(peer->key, peer->mem);
555 isc_mem_put(peer->mem, peer->key, sizeof(dns_name_t));
556 exists = ISC_TRUE;
559 peer->key = *keyval;
560 *keyval = NULL;
562 return (exists ? ISC_R_EXISTS : ISC_R_SUCCESS);
565 isc_result_t
566 dns_peer_setkeybycharp(dns_peer_t *peer, const char *keyval) {
567 isc_buffer_t b;
568 dns_fixedname_t fname;
569 dns_name_t *name;
570 isc_result_t result;
572 dns_fixedname_init(&fname);
573 isc_buffer_constinit(&b, keyval, strlen(keyval));
574 isc_buffer_add(&b, strlen(keyval));
575 result = dns_name_fromtext(dns_fixedname_name(&fname), &b,
576 dns_rootname, 0, NULL);
577 if (result != ISC_R_SUCCESS)
578 return (result);
580 name = isc_mem_get(peer->mem, sizeof(dns_name_t));
581 if (name == NULL)
582 return (ISC_R_NOMEMORY);
584 dns_name_init(name, NULL);
585 result = dns_name_dup(dns_fixedname_name(&fname), peer->mem, name);
586 if (result != ISC_R_SUCCESS) {
587 isc_mem_put(peer->mem, name, sizeof(dns_name_t));
588 return (result);
591 result = dns_peer_setkey(peer, &name);
592 if (result != ISC_R_SUCCESS)
593 isc_mem_put(peer->mem, name, sizeof(dns_name_t));
595 return (result);
598 isc_result_t
599 dns_peer_settransfersource(dns_peer_t *peer,
600 const isc_sockaddr_t *transfer_source)
602 REQUIRE(DNS_PEER_VALID(peer));
604 if (peer->transfer_source != NULL) {
605 isc_mem_put(peer->mem, peer->transfer_source,
606 sizeof(*peer->transfer_source));
607 peer->transfer_source = NULL;
609 if (transfer_source != NULL) {
610 peer->transfer_source = isc_mem_get(peer->mem,
611 sizeof(*peer->transfer_source));
612 if (peer->transfer_source == NULL)
613 return (ISC_R_NOMEMORY);
615 *peer->transfer_source = *transfer_source;
617 return (ISC_R_SUCCESS);
620 isc_result_t
621 dns_peer_gettransfersource(dns_peer_t *peer, isc_sockaddr_t *transfer_source) {
622 REQUIRE(DNS_PEER_VALID(peer));
623 REQUIRE(transfer_source != NULL);
625 if (peer->transfer_source == NULL)
626 return (ISC_R_NOTFOUND);
627 *transfer_source = *peer->transfer_source;
628 return (ISC_R_SUCCESS);
631 isc_result_t
632 dns_peer_setnotifysource(dns_peer_t *peer,
633 const isc_sockaddr_t *notify_source)
635 REQUIRE(DNS_PEER_VALID(peer));
637 if (peer->notify_source != NULL) {
638 isc_mem_put(peer->mem, peer->notify_source,
639 sizeof(*peer->notify_source));
640 peer->notify_source = NULL;
642 if (notify_source != NULL) {
643 peer->notify_source = isc_mem_get(peer->mem,
644 sizeof(*peer->notify_source));
645 if (peer->notify_source == NULL)
646 return (ISC_R_NOMEMORY);
648 *peer->notify_source = *notify_source;
650 return (ISC_R_SUCCESS);
653 isc_result_t
654 dns_peer_getnotifysource(dns_peer_t *peer, isc_sockaddr_t *notify_source) {
655 REQUIRE(DNS_PEER_VALID(peer));
656 REQUIRE(notify_source != NULL);
658 if (peer->notify_source == NULL)
659 return (ISC_R_NOTFOUND);
660 *notify_source = *peer->notify_source;
661 return (ISC_R_SUCCESS);
664 isc_result_t
665 dns_peer_setquerysource(dns_peer_t *peer, const isc_sockaddr_t *query_source) {
666 REQUIRE(DNS_PEER_VALID(peer));
668 if (peer->query_source != NULL) {
669 isc_mem_put(peer->mem, peer->query_source,
670 sizeof(*peer->query_source));
671 peer->query_source = NULL;
673 if (query_source != NULL) {
674 peer->query_source = isc_mem_get(peer->mem,
675 sizeof(*peer->query_source));
676 if (peer->query_source == NULL)
677 return (ISC_R_NOMEMORY);
679 *peer->query_source = *query_source;
681 return (ISC_R_SUCCESS);
684 isc_result_t
685 dns_peer_getquerysource(dns_peer_t *peer, isc_sockaddr_t *query_source) {
686 REQUIRE(DNS_PEER_VALID(peer));
687 REQUIRE(query_source != NULL);
689 if (peer->query_source == NULL)
690 return (ISC_R_NOTFOUND);
691 *query_source = *peer->query_source;
692 return (ISC_R_SUCCESS);
695 isc_result_t
696 dns_peer_setudpsize(dns_peer_t *peer, isc_uint16_t udpsize) {
697 isc_boolean_t existed;
699 REQUIRE(DNS_PEER_VALID(peer));
701 existed = DNS_BIT_CHECK(SERVER_UDPSIZE_BIT, &peer->bitflags);
703 peer->udpsize = udpsize;
704 DNS_BIT_SET(SERVER_UDPSIZE_BIT, &peer->bitflags);
706 return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS);
709 isc_result_t
710 dns_peer_getudpsize(dns_peer_t *peer, isc_uint16_t *udpsize) {
712 REQUIRE(DNS_PEER_VALID(peer));
713 REQUIRE(udpsize != NULL);
715 if (DNS_BIT_CHECK(SERVER_UDPSIZE_BIT, &peer->bitflags)) {
716 *udpsize = peer->udpsize;
717 return (ISC_R_SUCCESS);
718 } else {
719 return (ISC_R_NOTFOUND);
723 isc_result_t
724 dns_peer_setmaxudp(dns_peer_t *peer, isc_uint16_t maxudp) {
725 isc_boolean_t existed;
727 REQUIRE(DNS_PEER_VALID(peer));
729 existed = DNS_BIT_CHECK(SERVER_MAXUDP_BIT, &peer->bitflags);
731 peer->maxudp = maxudp;
732 DNS_BIT_SET(SERVER_MAXUDP_BIT, &peer->bitflags);
734 return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS);
737 isc_result_t
738 dns_peer_getmaxudp(dns_peer_t *peer, isc_uint16_t *maxudp) {
740 REQUIRE(DNS_PEER_VALID(peer));
741 REQUIRE(maxudp != NULL);
743 if (DNS_BIT_CHECK(SERVER_MAXUDP_BIT, &peer->bitflags)) {
744 *maxudp = peer->maxudp;
745 return (ISC_R_SUCCESS);
746 } else {
747 return (ISC_R_NOTFOUND);
751 isc_result_t
752 dns_peer_setnotifydscp(dns_peer_t *peer, isc_dscp_t dscp) {
753 REQUIRE(DNS_PEER_VALID(peer));
754 REQUIRE(dscp < 64);
756 peer->notify_dscp = dscp;
757 DNS_BIT_SET(NOTIFY_DSCP_BIT, &peer->bitflags);
758 return (ISC_R_SUCCESS);
761 isc_result_t
762 dns_peer_getnotifydscp(dns_peer_t *peer, isc_dscp_t *dscpp) {
763 REQUIRE(DNS_PEER_VALID(peer));
764 REQUIRE(dscpp != NULL);
766 if (DNS_BIT_CHECK(NOTIFY_DSCP_BIT, &peer->bitflags)) {
767 *dscpp = peer->notify_dscp;
768 return (ISC_R_SUCCESS);
770 return (ISC_R_NOTFOUND);
773 isc_result_t
774 dns_peer_settransferdscp(dns_peer_t *peer, isc_dscp_t dscp) {
775 REQUIRE(DNS_PEER_VALID(peer));
776 REQUIRE(dscp < 64);
778 peer->transfer_dscp = dscp;
779 DNS_BIT_SET(TRANSFER_DSCP_BIT, &peer->bitflags);
780 return (ISC_R_SUCCESS);
783 isc_result_t
784 dns_peer_gettransferdscp(dns_peer_t *peer, isc_dscp_t *dscpp) {
785 REQUIRE(DNS_PEER_VALID(peer));
786 REQUIRE(dscpp != NULL);
788 if (DNS_BIT_CHECK(TRANSFER_DSCP_BIT, &peer->bitflags)) {
789 *dscpp = peer->transfer_dscp;
790 return (ISC_R_SUCCESS);
792 return (ISC_R_NOTFOUND);
795 isc_result_t
796 dns_peer_setquerydscp(dns_peer_t *peer, isc_dscp_t dscp) {
797 REQUIRE(DNS_PEER_VALID(peer));
798 REQUIRE(dscp < 64);
800 peer->query_dscp = dscp;
801 DNS_BIT_SET(QUERY_DSCP_BIT, &peer->bitflags);
802 return (ISC_R_SUCCESS);
805 isc_result_t
806 dns_peer_getquerydscp(dns_peer_t *peer, isc_dscp_t *dscpp) {
807 REQUIRE(DNS_PEER_VALID(peer));
808 REQUIRE(dscpp != NULL);
810 if (DNS_BIT_CHECK(QUERY_DSCP_BIT, &peer->bitflags)) {
811 *dscpp = peer->query_dscp;
812 return (ISC_R_SUCCESS);
814 return (ISC_R_NOTFOUND);