Lines Matching defs:peer
1 /* $NetBSD: peer.c,v 1.11 2024/02/21 22:52:07 christos Exp $ */
29 #include <dns/peer.h>
102 peer_delete(dns_peer_t **peer);
175 dns_peerlist_addpeer(dns_peerlist_t *peers, dns_peer_t *peer) {
178 dns_peer_attach(peer, &p);
186 if (p->prefixlen < peer->prefixlen) {
192 ISC_LIST_INSERTBEFORE(peers->elements, p, peer, next);
194 ISC_LIST_APPEND(peers->elements, peer, next);
261 dns_peer_t *peer;
265 peer = isc_mem_get(mem, sizeof(*peer));
267 *peer = (dns_peer_t){
275 isc_refcount_init(&peer->refs, 1);
277 ISC_LINK_INIT(peer, next);
279 *peerptr = peer;
296 dns_peer_detach(dns_peer_t **peer) {
299 REQUIRE(peer != NULL);
300 REQUIRE(*peer != NULL);
301 REQUIRE(DNS_PEER_VALID(*peer));
303 p = *peer;
304 *peer = NULL;
312 peer_delete(dns_peer_t **peer) {
316 REQUIRE(peer != NULL);
317 REQUIRE(DNS_PEER_VALID(*peer));
319 p = *peer;
320 *peer = NULL;
350 dns_peer_setbogus(dns_peer_t *peer, bool newval) {
353 REQUIRE(DNS_PEER_VALID(peer));
355 existed = DNS_BIT_CHECK(BOGUS_BIT, &peer->bitflags);
357 peer->bogus = newval;
358 DNS_BIT_SET(BOGUS_BIT, &peer->bitflags);
364 dns_peer_getbogus(dns_peer_t *peer, bool *retval) {
365 REQUIRE(DNS_PEER_VALID(peer));
368 if (DNS_BIT_CHECK(BOGUS_BIT, &peer->bitflags)) {
369 *retval = peer->bogus;
377 dns_peer_setprovideixfr(dns_peer_t *peer, bool newval) {
380 REQUIRE(DNS_PEER_VALID(peer));
382 existed = DNS_BIT_CHECK(PROVIDE_IXFR_BIT, &peer->bitflags);
384 peer->provide_ixfr = newval;
385 DNS_BIT_SET(PROVIDE_IXFR_BIT, &peer->bitflags);
391 dns_peer_getprovideixfr(dns_peer_t *peer, bool *retval) {
392 REQUIRE(DNS_PEER_VALID(peer));
395 if (DNS_BIT_CHECK(PROVIDE_IXFR_BIT, &peer->bitflags)) {
396 *retval = peer->provide_ixfr;
404 dns_peer_setrequestixfr(dns_peer_t *peer, bool newval) {
407 REQUIRE(DNS_PEER_VALID(peer));
409 existed = DNS_BIT_CHECK(REQUEST_IXFR_BIT, &peer->bitflags);
411 peer->request_ixfr = newval;
412 DNS_BIT_SET(REQUEST_IXFR_BIT, &peer->bitflags);
418 dns_peer_getrequestixfr(dns_peer_t *peer, bool *retval) {
419 REQUIRE(DNS_PEER_VALID(peer));
422 if (DNS_BIT_CHECK(REQUEST_IXFR_BIT, &peer->bitflags)) {
423 *retval = peer->request_ixfr;
431 dns_peer_setsupportedns(dns_peer_t *peer, bool newval) {
434 REQUIRE(DNS_PEER_VALID(peer));
436 existed = DNS_BIT_CHECK(SUPPORT_EDNS_BIT, &peer->bitflags);
438 peer->support_edns = newval;
439 DNS_BIT_SET(SUPPORT_EDNS_BIT, &peer->bitflags);
445 dns_peer_getsupportedns(dns_peer_t *peer, bool *retval) {
446 REQUIRE(DNS_PEER_VALID(peer));
449 if (DNS_BIT_CHECK(SUPPORT_EDNS_BIT, &peer->bitflags)) {
450 *retval = peer->support_edns;
458 dns_peer_setrequestnsid(dns_peer_t *peer, bool newval) {
461 REQUIRE(DNS_PEER_VALID(peer));
463 existed = DNS_BIT_CHECK(REQUEST_NSID_BIT, &peer->bitflags);
465 peer->request_nsid = newval;
466 DNS_BIT_SET(REQUEST_NSID_BIT, &peer->bitflags);
472 dns_peer_getrequestnsid(dns_peer_t *peer, bool *retval) {
473 REQUIRE(DNS_PEER_VALID(peer));
476 if (DNS_BIT_CHECK(REQUEST_NSID_BIT, &peer->bitflags)) {
477 *retval = peer->request_nsid;
485 dns_peer_setsendcookie(dns_peer_t *peer, bool newval) {
488 REQUIRE(DNS_PEER_VALID(peer));
490 existed = DNS_BIT_CHECK(SEND_COOKIE_BIT, &peer->bitflags);
492 peer->send_cookie = newval;
493 DNS_BIT_SET(SEND_COOKIE_BIT, &peer->bitflags);
499 dns_peer_getsendcookie(dns_peer_t *peer, bool *retval) {
500 REQUIRE(DNS_PEER_VALID(peer));
503 if (DNS_BIT_CHECK(SEND_COOKIE_BIT, &peer->bitflags)) {
504 *retval = peer->send_cookie;
512 dns_peer_setrequestexpire(dns_peer_t *peer, bool newval) {
515 REQUIRE(DNS_PEER_VALID(peer));
517 existed = DNS_BIT_CHECK(REQUEST_EXPIRE_BIT, &peer->bitflags);
519 peer->request_expire = newval;
520 DNS_BIT_SET(REQUEST_EXPIRE_BIT, &peer->bitflags);
526 dns_peer_getrequestexpire(dns_peer_t *peer, bool *retval) {
527 REQUIRE(DNS_PEER_VALID(peer));
530 if (DNS_BIT_CHECK(REQUEST_EXPIRE_BIT, &peer->bitflags)) {
531 *retval = peer->request_expire;
539 dns_peer_setforcetcp(dns_peer_t *peer, bool newval) {
542 REQUIRE(DNS_PEER_VALID(peer));
544 existed = DNS_BIT_CHECK(FORCE_TCP_BIT, &peer->bitflags);
546 peer->force_tcp = newval;
547 DNS_BIT_SET(FORCE_TCP_BIT, &peer->bitflags);
553 dns_peer_getforcetcp(dns_peer_t *peer, bool *retval) {
554 REQUIRE(DNS_PEER_VALID(peer));
557 if (DNS_BIT_CHECK(FORCE_TCP_BIT, &peer->bitflags)) {
558 *retval = peer->force_tcp;
566 dns_peer_settcpkeepalive(dns_peer_t *peer, bool newval) {
569 REQUIRE(DNS_PEER_VALID(peer));
571 existed = DNS_BIT_CHECK(REQUEST_TCP_KEEPALIVE_BIT, &peer->bitflags);
573 peer->tcp_keepalive = newval;
574 DNS_BIT_SET(REQUEST_TCP_KEEPALIVE_BIT, &peer->bitflags);
580 dns_peer_gettcpkeepalive(dns_peer_t *peer, bool *retval) {
581 REQUIRE(DNS_PEER_VALID(peer));
584 if (DNS_BIT_CHECK(REQUEST_TCP_KEEPALIVE_BIT, &peer->bitflags)) {
585 *retval = peer->tcp_keepalive;
593 dns_peer_settransfers(dns_peer_t *peer, uint32_t newval) {
596 REQUIRE(DNS_PEER_VALID(peer));
598 existed = DNS_BIT_CHECK(TRANSFERS_BIT, &peer->bitflags);
600 peer->transfers = newval;
601 DNS_BIT_SET(TRANSFERS_BIT, &peer->bitflags);
607 dns_peer_gettransfers(dns_peer_t *peer, uint32_t *retval) {
608 REQUIRE(DNS_PEER_VALID(peer));
611 if (DNS_BIT_CHECK(TRANSFERS_BIT, &peer->bitflags)) {
612 *retval = peer->transfers;
620 dns_peer_settransferformat(dns_peer_t *peer, dns_transfer_format_t newval) {
623 REQUIRE(DNS_PEER_VALID(peer));
625 existed = DNS_BIT_CHECK(SERVER_TRANSFER_FORMAT_BIT, &peer->bitflags);
627 peer->transfer_format = newval;
628 DNS_BIT_SET(SERVER_TRANSFER_FORMAT_BIT, &peer->bitflags);
634 dns_peer_gettransferformat(dns_peer_t *peer, dns_transfer_format_t *retval) {
635 REQUIRE(DNS_PEER_VALID(peer));
638 if (DNS_BIT_CHECK(SERVER_TRANSFER_FORMAT_BIT, &peer->bitflags)) {
639 *retval = peer->transfer_format;
647 dns_peer_getkey(dns_peer_t *peer, dns_name_t **retval) {
648 REQUIRE(DNS_PEER_VALID(peer));
651 if (peer->key != NULL) {
652 *retval = peer->key;
655 return (peer->key == NULL ? ISC_R_NOTFOUND : ISC_R_SUCCESS);
659 dns_peer_setkey(dns_peer_t *peer, dns_name_t **keyval) {
662 if (peer->key != NULL) {
663 dns_name_free(peer->key, peer->mem);
664 isc_mem_put(peer->mem, peer->key, sizeof(dns_name_t));
668 peer->key = *keyval;
675 dns_peer_setkeybycharp(dns_peer_t *peer, const char *keyval) {
690 name = isc_mem_get(peer->mem, sizeof(dns_name_t));
693 dns_name_dup(dns_fixedname_name(&fname), peer->mem, name);
695 result = dns_peer_setkey(peer, &name);
697 isc_mem_put(peer->mem, name, sizeof(dns_name_t));
704 dns_peer_settransfersource(dns_peer_t *peer,
706 REQUIRE(DNS_PEER_VALID(peer));
708 if (peer->transfer_source != NULL) {
709 isc_mem_put(peer->mem, peer->transfer_source,
710 sizeof(*peer->transfer_source));
711 peer->transfer_source = NULL;
714 peer->transfer_source =
715 isc_mem_get(peer->mem, sizeof(*peer->transfer_source));
717 *peer->transfer_source = *transfer_source;
723 dns_peer_gettransfersource(dns_peer_t *peer, isc_sockaddr_t *transfer_source) {
724 REQUIRE(DNS_PEER_VALID(peer));
727 if (peer->transfer_source == NULL) {
730 *transfer_source = *peer->transfer_source;
735 dns_peer_setnotifysource(dns_peer_t *peer,
737 REQUIRE(DNS_PEER_VALID(peer));
739 if (peer->notify_source != NULL) {
740 isc_mem_put(peer->mem, peer->notify_source,
741 sizeof(*peer->notify_source));
742 peer->notify_source = NULL;
745 peer->notify_source = isc_mem_get(peer->mem,
746 sizeof(*peer->notify_source));
748 *peer->notify_source = *notify_source;
754 dns_peer_getnotifysource(dns_peer_t *peer, isc_sockaddr_t *notify_source) {
755 REQUIRE(DNS_PEER_VALID(peer));
758 if (peer->notify_source == NULL) {
761 *notify_source = *peer->notify_source;
766 dns_peer_setquerysource(dns_peer_t *peer, const isc_sockaddr_t *query_source) {
767 REQUIRE(DNS_PEER_VALID(peer));
769 if (peer->query_source != NULL) {
770 isc_mem_put(peer->mem, peer->query_source,
771 sizeof(*peer->query_source));
772 peer->query_source = NULL;
775 peer->query_source = isc_mem_get(peer->mem,
776 sizeof(*peer->query_source));
778 *peer->query_source = *query_source;
784 dns_peer_getquerysource(dns_peer_t *peer, isc_sockaddr_t *query_source) {
785 REQUIRE(DNS_PEER_VALID(peer));
788 if (peer->query_source == NULL) {
791 *query_source = *peer->query_source;
796 dns_peer_setudpsize(dns_peer_t *peer, uint16_t udpsize) {
799 REQUIRE(DNS_PEER_VALID(peer));
801 existed = DNS_BIT_CHECK(SERVER_UDPSIZE_BIT, &peer->bitflags);
803 peer->udpsize = udpsize;
804 DNS_BIT_SET(SERVER_UDPSIZE_BIT, &peer->bitflags);
810 dns_peer_getudpsize(dns_peer_t *peer, uint16_t *udpsize) {
811 REQUIRE(DNS_PEER_VALID(peer));
814 if (DNS_BIT_CHECK(SERVER_UDPSIZE_BIT, &peer->bitflags)) {
815 *udpsize = peer->udpsize;
823 dns_peer_setmaxudp(dns_peer_t *peer, uint16_t maxudp) {
826 REQUIRE(DNS_PEER_VALID(peer));
828 existed = DNS_BIT_CHECK(SERVER_MAXUDP_BIT, &peer->bitflags);
830 peer->maxudp = maxudp;
831 DNS_BIT_SET(SERVER_MAXUDP_BIT, &peer->bitflags);
837 dns_peer_getmaxudp(dns_peer_t *peer, uint16_t *maxudp) {
838 REQUIRE(DNS_PEER_VALID(peer));
841 if (DNS_BIT_CHECK(SERVER_MAXUDP_BIT, &peer->bitflags)) {
842 *maxudp = peer->maxudp;
850 dns_peer_setpadding(dns_peer_t *peer, uint16_t padding) {
853 REQUIRE(DNS_PEER_VALID(peer));
855 existed = DNS_BIT_CHECK(SERVER_PADDING_BIT, &peer->bitflags);
860 peer->padding = padding;
861 DNS_BIT_SET(SERVER_PADDING_BIT, &peer->bitflags);
867 dns_peer_getpadding(dns_peer_t *peer, uint16_t *padding) {
868 REQUIRE(DNS_PEER_VALID(peer));
871 if (DNS_BIT_CHECK(SERVER_PADDING_BIT, &peer->bitflags)) {
872 *padding = peer->padding;
880 dns_peer_setednsversion(dns_peer_t *peer, uint8_t ednsversion) {
881 REQUIRE(DNS_PEER_VALID(peer));
883 peer->ednsversion = ednsversion;
884 DNS_BIT_SET(EDNS_VERSION_BIT, &peer->bitflags);
890 dns_peer_getednsversion(dns_peer_t *peer, uint8_t *ednsversion) {
891 REQUIRE(DNS_PEER_VALID(peer));
894 if (DNS_BIT_CHECK(EDNS_VERSION_BIT, &peer->bitflags)) {
895 *ednsversion = peer->ednsversion;