1 /* $NetBSD: peer.c,v 1.7 2014/12/10 04:37:58 christos Exp $ */
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 */
27 #include <isc/string.h>
29 #include <isc/sockaddr.h>
32 #include <dns/fixedname.h>
37 * Bit positions in the dns_peer_t structure flags field
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
54 peerlist_delete(dns_peerlist_t
**list
);
57 peer_delete(dns_peer_t
**peer
);
60 dns_peerlist_new(isc_mem_t
*mem
, dns_peerlist_t
**list
) {
63 REQUIRE(list
!= NULL
);
65 l
= isc_mem_get(mem
, sizeof(*l
));
67 return (ISC_R_NOMEMORY
);
69 ISC_LIST_INIT(l
->elements
);
72 l
->magic
= DNS_PEERLIST_MAGIC
;
76 return (ISC_R_SUCCESS
);
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
);
87 ENSURE(source
->refs
!= 0xffffffffU
);
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
));
103 REQUIRE(plist
->refs
> 0);
107 if (plist
->refs
== 0)
108 peerlist_delete(&plist
);
112 peerlist_delete(dns_peerlist_t
**list
) {
114 dns_peer_t
*server
, *stmp
;
116 REQUIRE(list
!= NULL
);
117 REQUIRE(DNS_PEERLIST_VALID(*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
);
132 isc_mem_put(l
->mem
, l
, sizeof(*l
));
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
);
148 p
= ISC_LIST_NEXT(p
, next
))
149 if (p
->prefixlen
< peer
->prefixlen
)
153 ISC_LIST_INSERTBEFORE(peers
->elements
, p
, peer
, next
);
155 ISC_LIST_APPEND(peers
->elements
, peer
, next
);
160 dns_peerlist_peerbyaddr(dns_peerlist_t
*servers
,
161 isc_netaddr_t
*addr
, dns_peer_t
**retval
)
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
,
175 server
= ISC_LIST_NEXT(server
, next
);
178 if (server
!= NULL
) {
182 res
= ISC_R_NOTFOUND
;
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
);
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
) {
217 return (dns_peer_newprefix(mem
, addr
, prefixlen
, peerptr
));
221 dns_peer_newprefix(isc_mem_t
*mem
, isc_netaddr_t
*addr
, unsigned int prefixlen
,
222 dns_peer_t
**peerptr
)
226 REQUIRE(peerptr
!= NULL
);
228 peer
= isc_mem_get(mem
, sizeof(*peer
));
230 return (ISC_R_NOMEMORY
);
232 peer
->magic
= DNS_PEER_MAGIC
;
233 peer
->address
= *addr
;
234 peer
->prefixlen
= prefixlen
;
236 peer
->bogus
= ISC_FALSE
;
237 peer
->transfer_format
= dns_one_answer
;
239 peer
->request_ixfr
= ISC_FALSE
;
240 peer
->provide_ixfr
= ISC_FALSE
;
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
);
253 return (ISC_R_SUCCESS
);
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
);
264 ENSURE(source
->refs
!= 0xffffffffU
);
270 dns_peer_detach(dns_peer_t
**peer
) {
273 REQUIRE(peer
!= NULL
);
274 REQUIRE(*peer
!= NULL
);
275 REQUIRE(DNS_PEER_VALID(*peer
));
279 REQUIRE(p
->refs
> 0);
289 peer_delete(dns_peer_t
**peer
) {
293 REQUIRE(peer
!= NULL
);
294 REQUIRE(DNS_PEER_VALID(*peer
));
298 REQUIRE(p
->refs
== 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
));
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
);
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
);
347 return (ISC_R_NOTFOUND
);
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
);
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
);
374 return (ISC_R_NOTFOUND
);
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
);
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
);
401 return (ISC_R_NOTFOUND
);
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
);
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
);
427 return (ISC_R_NOTFOUND
);
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
);
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
);
453 return (ISC_R_NOTFOUND
);
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
);
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
);
479 return (ISC_R_NOTFOUND
);
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
);
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
);
505 return (ISC_R_NOTFOUND
);
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
,
518 peer
->transfer_format
= newval
;
519 DNS_BIT_SET(SERVER_TRANSFER_FORMAT_BIT
, &peer
->bitflags
);
521 return (existed
? ISC_R_EXISTS
: ISC_R_SUCCESS
);
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
);
533 return (ISC_R_NOTFOUND
);
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
) {
546 return (peer
->key
== NULL
? ISC_R_NOTFOUND
: ISC_R_SUCCESS
);
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
));
562 return (exists
? ISC_R_EXISTS
: ISC_R_SUCCESS
);
566 dns_peer_setkeybycharp(dns_peer_t
*peer
, const char *keyval
) {
568 dns_fixedname_t fname
;
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
)
580 name
= isc_mem_get(peer
->mem
, sizeof(dns_name_t
));
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
));
591 result
= dns_peer_setkey(peer
, &name
);
592 if (result
!= ISC_R_SUCCESS
)
593 isc_mem_put(peer
->mem
, name
, sizeof(dns_name_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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
719 return (ISC_R_NOTFOUND
);
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
);
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
);
747 return (ISC_R_NOTFOUND
);
752 dns_peer_setnotifydscp(dns_peer_t
*peer
, isc_dscp_t dscp
) {
753 REQUIRE(DNS_PEER_VALID(peer
));
756 peer
->notify_dscp
= dscp
;
757 DNS_BIT_SET(NOTIFY_DSCP_BIT
, &peer
->bitflags
);
758 return (ISC_R_SUCCESS
);
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
);
774 dns_peer_settransferdscp(dns_peer_t
*peer
, isc_dscp_t dscp
) {
775 REQUIRE(DNS_PEER_VALID(peer
));
778 peer
->transfer_dscp
= dscp
;
779 DNS_BIT_SET(TRANSFER_DSCP_BIT
, &peer
->bitflags
);
780 return (ISC_R_SUCCESS
);
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
);
796 dns_peer_setquerydscp(dns_peer_t
*peer
, isc_dscp_t dscp
) {
797 REQUIRE(DNS_PEER_VALID(peer
));
800 peer
->query_dscp
= dscp
;
801 DNS_BIT_SET(QUERY_DSCP_BIT
, &peer
->bitflags
);
802 return (ISC_R_SUCCESS
);
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
);