Lines Matching refs:peer

9 /* $Id: peer.c,v 1.33 2009/09/02 23:48:02 tbox Exp $ */
23 #include <dns/peer.h>
49 peer_delete(dns_peer_t **peer);
130 dns_peerlist_addpeer(dns_peerlist_t *peers, dns_peer_t *peer) {
133 dns_peer_attach(peer, &p);
141 if (p->prefixlen < peer->prefixlen)
145 ISC_LIST_INSERTBEFORE(peers->elements, p, peer, next);
147 ISC_LIST_APPEND(peers->elements, peer, next);
216 dns_peer_t *peer;
220 peer = isc_mem_get(mem, sizeof(*peer));
221 if (peer == NULL)
224 peer->magic = DNS_PEER_MAGIC;
225 peer->address = *addr;
226 peer->prefixlen = prefixlen;
227 peer->mem = mem;
228 peer->bogus = ISC_FALSE;
229 peer->transfer_format = dns_one_answer;
230 peer->transfers = 0;
231 peer->request_ixfr = ISC_FALSE;
232 peer->provide_ixfr = ISC_FALSE;
233 peer->key = NULL;
234 peer->refs = 1;
235 peer->transfer_source = NULL;
236 peer->notify_source = NULL;
237 peer->query_source = NULL;
239 memset(&peer->bitflags, 0x0, sizeof(peer->bitflags));
241 ISC_LINK_INIT(peer, next);
243 *peerptr = peer;
262 dns_peer_detach(dns_peer_t **peer) {
265 REQUIRE(peer != NULL);
266 REQUIRE(*peer != NULL);
267 REQUIRE(DNS_PEER_VALID(*peer));
269 p = *peer;
273 *peer = NULL;
281 peer_delete(dns_peer_t **peer) {
285 REQUIRE(peer != NULL);
286 REQUIRE(DNS_PEER_VALID(*peer));
288 p = *peer;
313 *peer = NULL;
317 dns_peer_setbogus(dns_peer_t *peer, isc_boolean_t newval) {
320 REQUIRE(DNS_PEER_VALID(peer));
322 existed = DNS_BIT_CHECK(BOGUS_BIT, &peer->bitflags);
324 peer->bogus = newval;
325 DNS_BIT_SET(BOGUS_BIT, &peer->bitflags);
331 dns_peer_getbogus(dns_peer_t *peer, isc_boolean_t *retval) {
332 REQUIRE(DNS_PEER_VALID(peer));
335 if (DNS_BIT_CHECK(BOGUS_BIT, &peer->bitflags)) {
336 *retval = peer->bogus;
344 dns_peer_setprovideixfr(dns_peer_t *peer, isc_boolean_t newval) {
347 REQUIRE(DNS_PEER_VALID(peer));
349 existed = DNS_BIT_CHECK(PROVIDE_IXFR_BIT, &peer->bitflags);
351 peer->provide_ixfr = newval;
352 DNS_BIT_SET(PROVIDE_IXFR_BIT, &peer->bitflags);
358 dns_peer_getprovideixfr(dns_peer_t *peer, isc_boolean_t *retval) {
359 REQUIRE(DNS_PEER_VALID(peer));
362 if (DNS_BIT_CHECK(PROVIDE_IXFR_BIT, &peer->bitflags)) {
363 *retval = peer->provide_ixfr;
371 dns_peer_setrequestixfr(dns_peer_t *peer, isc_boolean_t newval) {
374 REQUIRE(DNS_PEER_VALID(peer));
376 existed = DNS_BIT_CHECK(REQUEST_IXFR_BIT, &peer->bitflags);
378 peer->request_ixfr = newval;
379 DNS_BIT_SET(REQUEST_IXFR_BIT, &peer->bitflags);
385 dns_peer_getrequestixfr(dns_peer_t *peer, isc_boolean_t *retval) {
386 REQUIRE(DNS_PEER_VALID(peer));
389 if (DNS_BIT_CHECK(REQUEST_IXFR_BIT, &peer->bitflags)) {
390 *retval = peer->request_ixfr;
397 dns_peer_setsupportedns(dns_peer_t *peer, isc_boolean_t newval) {
400 REQUIRE(DNS_PEER_VALID(peer));
402 existed = DNS_BIT_CHECK(SUPPORT_EDNS_BIT, &peer->bitflags);
404 peer->support_edns = newval;
405 DNS_BIT_SET(SUPPORT_EDNS_BIT, &peer->bitflags);
411 dns_peer_getsupportedns(dns_peer_t *peer, isc_boolean_t *retval) {
412 REQUIRE(DNS_PEER_VALID(peer));
415 if (DNS_BIT_CHECK(SUPPORT_EDNS_BIT, &peer->bitflags)) {
416 *retval = peer->support_edns;
423 dns_peer_setrequestnsid(dns_peer_t *peer, isc_boolean_t newval) {
426 REQUIRE(DNS_PEER_VALID(peer));
428 existed = DNS_BIT_CHECK(REQUEST_NSID_BIT, &peer->bitflags);
430 peer->request_nsid = newval;
431 DNS_BIT_SET(REQUEST_NSID_BIT, &peer->bitflags);
437 dns_peer_getrequestnsid(dns_peer_t *peer, isc_boolean_t *retval) {
438 REQUIRE(DNS_PEER_VALID(peer));
441 if (DNS_BIT_CHECK(REQUEST_NSID_BIT, &peer->bitflags)) {
442 *retval = peer->request_nsid;
449 dns_peer_setsendcookie(dns_peer_t *peer, isc_boolean_t newval) {
452 REQUIRE(DNS_PEER_VALID(peer));
454 existed = DNS_BIT_CHECK(SEND_COOKIE_BIT, &peer->bitflags);
456 peer->send_cookie = newval;
457 DNS_BIT_SET(SEND_COOKIE_BIT, &peer->bitflags);
463 dns_peer_getsendcookie(dns_peer_t *peer, isc_boolean_t *retval) {
464 REQUIRE(DNS_PEER_VALID(peer));
467 if (DNS_BIT_CHECK(SEND_COOKIE_BIT, &peer->bitflags)) {
468 *retval = peer->send_cookie;
475 dns_peer_setrequestexpire(dns_peer_t *peer, isc_boolean_t newval) {
478 REQUIRE(DNS_PEER_VALID(peer));
480 existed = DNS_BIT_CHECK(REQUEST_EXPIRE_BIT, &peer->bitflags);
482 peer->request_expire = newval;
483 DNS_BIT_SET(REQUEST_EXPIRE_BIT, &peer->bitflags);
489 dns_peer_getrequestexpire(dns_peer_t *peer, isc_boolean_t *retval) {
490 REQUIRE(DNS_PEER_VALID(peer));
493 if (DNS_BIT_CHECK(REQUEST_EXPIRE_BIT, &peer->bitflags)) {
494 *retval = peer->request_expire;
501 dns_peer_setforcetcp(dns_peer_t *peer, isc_boolean_t newval) {
504 REQUIRE(DNS_PEER_VALID(peer));
506 existed = DNS_BIT_CHECK(FORCE_TCP_BIT, &peer->bitflags);
508 peer->force_tcp = newval;
509 DNS_BIT_SET(FORCE_TCP_BIT, &peer->bitflags);
515 dns_peer_getforcetcp(dns_peer_t *peer, isc_boolean_t *retval) {
516 REQUIRE(DNS_PEER_VALID(peer));
519 if (DNS_BIT_CHECK(FORCE_TCP_BIT, &peer->bitflags)) {
520 *retval = peer->force_tcp;
527 dns_peer_settransfers(dns_peer_t *peer, isc_uint32_t newval) {
530 REQUIRE(DNS_PEER_VALID(peer));
532 existed = DNS_BIT_CHECK(TRANSFERS_BIT, &peer->bitflags);
534 peer->transfers = newval;
535 DNS_BIT_SET(TRANSFERS_BIT, &peer->bitflags);
541 dns_peer_gettransfers(dns_peer_t *peer, isc_uint32_t *retval) {
542 REQUIRE(DNS_PEER_VALID(peer));
545 if (DNS_BIT_CHECK(TRANSFERS_BIT, &peer->bitflags)) {
546 *retval = peer->transfers;
554 dns_peer_settransferformat(dns_peer_t *peer, dns_transfer_format_t newval) {
557 REQUIRE(DNS_PEER_VALID(peer));
560 &peer->bitflags);
562 peer->transfer_format = newval;
563 DNS_BIT_SET(SERVER_TRANSFER_FORMAT_BIT, &peer->bitflags);
569 dns_peer_gettransferformat(dns_peer_t *peer, dns_transfer_format_t *retval) {
570 REQUIRE(DNS_PEER_VALID(peer));
573 if (DNS_BIT_CHECK(SERVER_TRANSFER_FORMAT_BIT, &peer->bitflags)) {
574 *retval = peer->transfer_format;
582 dns_peer_getkey(dns_peer_t *peer, dns_name_t **retval) {
583 REQUIRE(DNS_PEER_VALID(peer));
586 if (peer->key != NULL) {
587 *retval = peer->key;
590 return (peer->key == NULL ? ISC_R_NOTFOUND : ISC_R_SUCCESS);
594 dns_peer_setkey(dns_peer_t *peer, dns_name_t **keyval) {
597 if (peer->key != NULL) {
598 dns_name_free(peer->key, peer->mem);
599 isc_mem_put(peer->mem, peer->key, sizeof(dns_name_t));
603 peer->key = *keyval;
610 dns_peer_setkeybycharp(dns_peer_t *peer, const char *keyval) {
624 name = isc_mem_get(peer->mem, sizeof(dns_name_t));
629 result = dns_name_dup(dns_fixedname_name(&fname), peer->mem, name);
631 isc_mem_put(peer->mem, name, sizeof(dns_name_t));
635 result = dns_peer_setkey(peer, &name);
637 isc_mem_put(peer->mem, name, sizeof(dns_name_t));
643 dns_peer_settransfersource(dns_peer_t *peer,
646 REQUIRE(DNS_PEER_VALID(peer));
648 if (peer->transfer_source != NULL) {
649 isc_mem_put(peer->mem, peer->transfer_source,
650 sizeof(*peer->transfer_source));
651 peer->transfer_source = NULL;
654 peer->transfer_source = isc_mem_get(peer->mem,
655 sizeof(*peer->transfer_source));
656 if (peer->transfer_source == NULL)
659 *peer->transfer_source = *transfer_source;
665 dns_peer_gettransfersource(dns_peer_t *peer, isc_sockaddr_t *transfer_source) {
666 REQUIRE(DNS_PEER_VALID(peer));
669 if (peer->transfer_source == NULL)
671 *transfer_source = *peer->transfer_source;
676 dns_peer_setnotifysource(dns_peer_t *peer,
679 REQUIRE(DNS_PEER_VALID(peer));
681 if (peer->notify_source != NULL) {
682 isc_mem_put(peer->mem, peer->notify_source,
683 sizeof(*peer->notify_source));
684 peer->notify_source = NULL;
687 peer->notify_source = isc_mem_get(peer->mem,
688 sizeof(*peer->notify_source));
689 if (peer->notify_source == NULL)
692 *peer->notify_source = *notify_source;
698 dns_peer_getnotifysource(dns_peer_t *peer, isc_sockaddr_t *notify_source) {
699 REQUIRE(DNS_PEER_VALID(peer));
702 if (peer->notify_source == NULL)
704 *notify_source = *peer->notify_source;
709 dns_peer_setquerysource(dns_peer_t *peer, const isc_sockaddr_t *query_source) {
710 REQUIRE(DNS_PEER_VALID(peer));
712 if (peer->query_source != NULL) {
713 isc_mem_put(peer->mem, peer->query_source,
714 sizeof(*peer->query_source));
715 peer->query_source = NULL;
718 peer->query_source = isc_mem_get(peer->mem,
719 sizeof(*peer->query_source));
720 if (peer->query_source == NULL)
723 *peer->query_source = *query_source;
729 dns_peer_getquerysource(dns_peer_t *peer, isc_sockaddr_t *query_source) {
730 REQUIRE(DNS_PEER_VALID(peer));
733 if (peer->query_source == NULL)
735 *query_source = *peer->query_source;
740 dns_peer_setudpsize(dns_peer_t *peer, isc_uint16_t udpsize) {
743 REQUIRE(DNS_PEER_VALID(peer));
745 existed = DNS_BIT_CHECK(SERVER_UDPSIZE_BIT, &peer->bitflags);
747 peer->udpsize = udpsize;
748 DNS_BIT_SET(SERVER_UDPSIZE_BIT, &peer->bitflags);
754 dns_peer_getudpsize(dns_peer_t *peer, isc_uint16_t *udpsize) {
756 REQUIRE(DNS_PEER_VALID(peer));
759 if (DNS_BIT_CHECK(SERVER_UDPSIZE_BIT, &peer->bitflags)) {
760 *udpsize = peer->udpsize;
768 dns_peer_setmaxudp(dns_peer_t *peer, isc_uint16_t maxudp) {
771 REQUIRE(DNS_PEER_VALID(peer));
773 existed = DNS_BIT_CHECK(SERVER_MAXUDP_BIT, &peer->bitflags);
775 peer->maxudp = maxudp;
776 DNS_BIT_SET(SERVER_MAXUDP_BIT, &peer->bitflags);
782 dns_peer_getmaxudp(dns_peer_t *peer, isc_uint16_t *maxudp) {
784 REQUIRE(DNS_PEER_VALID(peer));
787 if (DNS_BIT_CHECK(SERVER_MAXUDP_BIT, &peer->bitflags)) {
788 *maxudp = peer->maxudp;
796 dns_peer_setnotifydscp(dns_peer_t *peer, isc_dscp_t dscp) {
797 REQUIRE(DNS_PEER_VALID(peer));
800 peer->notify_dscp = dscp;
801 DNS_BIT_SET(NOTIFY_DSCP_BIT, &peer->bitflags);
806 dns_peer_getnotifydscp(dns_peer_t *peer, isc_dscp_t *dscpp) {
807 REQUIRE(DNS_PEER_VALID(peer));
810 if (DNS_BIT_CHECK(NOTIFY_DSCP_BIT, &peer->bitflags)) {
811 *dscpp = peer->notify_dscp;
818 dns_peer_settransferdscp(dns_peer_t *peer, isc_dscp_t dscp) {
819 REQUIRE(DNS_PEER_VALID(peer));
822 peer->transfer_dscp = dscp;
823 DNS_BIT_SET(TRANSFER_DSCP_BIT, &peer->bitflags);
828 dns_peer_gettransferdscp(dns_peer_t *peer, isc_dscp_t *dscpp) {
829 REQUIRE(DNS_PEER_VALID(peer));
832 if (DNS_BIT_CHECK(TRANSFER_DSCP_BIT, &peer->bitflags)) {
833 *dscpp = peer->transfer_dscp;
840 dns_peer_setquerydscp(dns_peer_t *peer, isc_dscp_t dscp) {
841 REQUIRE(DNS_PEER_VALID(peer));
844 peer->query_dscp = dscp;
845 DNS_BIT_SET(QUERY_DSCP_BIT, &peer->bitflags);
850 dns_peer_getquerydscp(dns_peer_t *peer, isc_dscp_t *dscpp) {
851 REQUIRE(DNS_PEER_VALID(peer));
854 if (DNS_BIT_CHECK(QUERY_DSCP_BIT, &peer->bitflags)) {
855 *dscpp = peer->query_dscp;
862 dns_peer_setednsversion(dns_peer_t *peer, isc_uint8_t ednsversion) {
863 REQUIRE(DNS_PEER_VALID(peer));
865 peer->ednsversion = ednsversion;
866 DNS_BIT_SET(EDNS_VERSION_BIT, &peer->bitflags);
872 dns_peer_getednsversion(dns_peer_t *peer, isc_uint8_t *ednsversion) {
873 REQUIRE(DNS_PEER_VALID(peer));
876 if (DNS_BIT_CHECK(EDNS_VERSION_BIT, &peer->bitflags)) {
877 *ednsversion = peer->ednsversion;