0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Copyright (C) 2000, 2001, 2003-2009, 2012-2016 Internet Systems Consortium, Inc. ("ISC")
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * file, You can obtain one at http://mozilla.org/MPL/2.0/.
d7201de09b85929a86b157f4b2d91667c68c6b52Automatic Updater/* $Id: peer.c,v 1.33 2009/09/02 23:48:02 tbox Exp $ */
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister * Bit positions in the dns_peer_t structure flags field
b3e77535185043f089b346166440402d092030c3David Lawrencedns_peerlist_new(isc_mem_t *mem, dns_peerlist_t **list) {
b3e77535185043f089b346166440402d092030c3David Lawrencedns_peerlist_attach(dns_peerlist_t *source, dns_peerlist_t **target) {
b3e77535185043f089b346166440402d092030c3David Lawrencedns_peerlist_addpeer(dns_peerlist_t *peers, dns_peer_t *peer) {
4844ed026a9b5a91044e76399cee80a6514cbf0dMark Andrews * More specifics to front of list.
4844ed026a9b5a91044e76399cee80a6514cbf0dMark Andrews ISC_LIST_INSERTBEFORE(peers->elements, p, peer, next);
2cde028c51055c9fd4837337116cd4fdfe8ff623James Bristerdns_peerlist_peerbyaddr(dns_peerlist_t *servers,
4844ed026a9b5a91044e76399cee80a6514cbf0dMark Andrews if (isc_netaddr_eqprefix(addr, &server->address,
b3e77535185043f089b346166440402d092030c3David Lawrencedns_peerlist_currpeer(dns_peerlist_t *peers, dns_peer_t **retval) {
b3e77535185043f089b346166440402d092030c3David Lawrencedns_peer_new(isc_mem_t *mem, isc_netaddr_t *addr, dns_peer_t **peerptr) {
4844ed026a9b5a91044e76399cee80a6514cbf0dMark Andrews return (dns_peer_newprefix(mem, addr, prefixlen, peerptr));
4844ed026a9b5a91044e76399cee80a6514cbf0dMark Andrewsdns_peer_newprefix(isc_mem_t *mem, isc_netaddr_t *addr, unsigned int prefixlen,
f3ca27e9fe307b55e35ea8d7b37351650630e5a3Andreas Gustafsson memset(&peer->bitflags, 0x0, sizeof(peer->bitflags));
b3e77535185043f089b346166440402d092030c3David Lawrencedns_peer_attach(dns_peer_t *source, dns_peer_t **target) {
75d747e1c5a30d6ef6c6238c6e27baa11d6f3bf6Mark Andrews isc_mem_put(mem, p->query_source, sizeof(*p->query_source));
75d747e1c5a30d6ef6c6238c6e27baa11d6f3bf6Mark Andrews isc_mem_put(mem, p->notify_source, sizeof(*p->notify_source));
b3e77535185043f089b346166440402d092030c3David Lawrencedns_peer_setbogus(dns_peer_t *peer, isc_boolean_t newval) {
b3e77535185043f089b346166440402d092030c3David Lawrence existed = DNS_BIT_CHECK(BOGUS_BIT, &peer->bitflags);
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS);
b3e77535185043f089b346166440402d092030c3David Lawrencedns_peer_getbogus(dns_peer_t *peer, isc_boolean_t *retval) {
b3e77535185043f089b346166440402d092030c3David Lawrence if (DNS_BIT_CHECK(BOGUS_BIT, &peer->bitflags)) {
b3e77535185043f089b346166440402d092030c3David Lawrencedns_peer_setprovideixfr(dns_peer_t *peer, isc_boolean_t newval) {
b3e77535185043f089b346166440402d092030c3David Lawrence existed = DNS_BIT_CHECK(PROVIDE_IXFR_BIT, &peer->bitflags);
b3e77535185043f089b346166440402d092030c3David Lawrence DNS_BIT_SET(PROVIDE_IXFR_BIT, &peer->bitflags);
5475a2d296215b7a93bd89804dc33c36a6de7cb5James Brister return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS);
b3e77535185043f089b346166440402d092030c3David Lawrencedns_peer_getprovideixfr(dns_peer_t *peer, isc_boolean_t *retval) {
b3e77535185043f089b346166440402d092030c3David Lawrence if (DNS_BIT_CHECK(PROVIDE_IXFR_BIT, &peer->bitflags)) {
b3e77535185043f089b346166440402d092030c3David Lawrencedns_peer_setrequestixfr(dns_peer_t *peer, isc_boolean_t newval) {
b3e77535185043f089b346166440402d092030c3David Lawrence existed = DNS_BIT_CHECK(REQUEST_IXFR_BIT, &peer->bitflags);
b3e77535185043f089b346166440402d092030c3David Lawrence DNS_BIT_SET(REQUEST_IXFR_BIT, &peer->bitflags);
5475a2d296215b7a93bd89804dc33c36a6de7cb5James Brister return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS);
b3e77535185043f089b346166440402d092030c3David Lawrencedns_peer_getrequestixfr(dns_peer_t *peer, isc_boolean_t *retval) {
b3e77535185043f089b346166440402d092030c3David Lawrence if (DNS_BIT_CHECK(REQUEST_IXFR_BIT, &peer->bitflags)) {
d25dd5b0567f67ecf40b7ed1cb20e0dce7b41c49Brian Wellingtondns_peer_setsupportedns(dns_peer_t *peer, isc_boolean_t newval) {
d25dd5b0567f67ecf40b7ed1cb20e0dce7b41c49Brian Wellington existed = DNS_BIT_CHECK(SUPPORT_EDNS_BIT, &peer->bitflags);
d25dd5b0567f67ecf40b7ed1cb20e0dce7b41c49Brian Wellington DNS_BIT_SET(SUPPORT_EDNS_BIT, &peer->bitflags);
d25dd5b0567f67ecf40b7ed1cb20e0dce7b41c49Brian Wellington return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS);
d25dd5b0567f67ecf40b7ed1cb20e0dce7b41c49Brian Wellingtondns_peer_getsupportedns(dns_peer_t *peer, isc_boolean_t *retval) {
d25dd5b0567f67ecf40b7ed1cb20e0dce7b41c49Brian Wellington if (DNS_BIT_CHECK(SUPPORT_EDNS_BIT, &peer->bitflags)) {
db30f4bdcb66afb7eb1ab0c6882cc70be9a53d79Mark Andrewsdns_peer_setrequestnsid(dns_peer_t *peer, isc_boolean_t newval) {
db30f4bdcb66afb7eb1ab0c6882cc70be9a53d79Mark Andrews existed = DNS_BIT_CHECK(REQUEST_NSID_BIT, &peer->bitflags);
db30f4bdcb66afb7eb1ab0c6882cc70be9a53d79Mark Andrews DNS_BIT_SET(REQUEST_NSID_BIT, &peer->bitflags);
db30f4bdcb66afb7eb1ab0c6882cc70be9a53d79Mark Andrews return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS);
db30f4bdcb66afb7eb1ab0c6882cc70be9a53d79Mark Andrewsdns_peer_getrequestnsid(dns_peer_t *peer, isc_boolean_t *retval) {
db30f4bdcb66afb7eb1ab0c6882cc70be9a53d79Mark Andrews if (DNS_BIT_CHECK(REQUEST_NSID_BIT, &peer->bitflags)) {
ce67023ae3ad39a77da5361d0187ab6f3f0219cbMark Andrewsdns_peer_setsendcookie(dns_peer_t *peer, isc_boolean_t newval) {
ce67023ae3ad39a77da5361d0187ab6f3f0219cbMark Andrews existed = DNS_BIT_CHECK(SEND_COOKIE_BIT, &peer->bitflags);
b5f6271f4daf1e54501af2cb7dd278d7e8003d65Mark Andrews return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS);
ce67023ae3ad39a77da5361d0187ab6f3f0219cbMark Andrewsdns_peer_getsendcookie(dns_peer_t *peer, isc_boolean_t *retval) {
ce67023ae3ad39a77da5361d0187ab6f3f0219cbMark Andrews if (DNS_BIT_CHECK(SEND_COOKIE_BIT, &peer->bitflags)) {
43b9737b11f4f14b2d378746d0cd5561b1dc24a0Mark Andrewsdns_peer_setrequestexpire(dns_peer_t *peer, isc_boolean_t newval) {
43b9737b11f4f14b2d378746d0cd5561b1dc24a0Mark Andrews existed = DNS_BIT_CHECK(REQUEST_EXPIRE_BIT, &peer->bitflags);
43b9737b11f4f14b2d378746d0cd5561b1dc24a0Mark Andrews DNS_BIT_SET(REQUEST_EXPIRE_BIT, &peer->bitflags);
43b9737b11f4f14b2d378746d0cd5561b1dc24a0Mark Andrews return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS);
43b9737b11f4f14b2d378746d0cd5561b1dc24a0Mark Andrewsdns_peer_getrequestexpire(dns_peer_t *peer, isc_boolean_t *retval) {
43b9737b11f4f14b2d378746d0cd5561b1dc24a0Mark Andrews if (DNS_BIT_CHECK(REQUEST_EXPIRE_BIT, &peer->bitflags)) {
5c5c6d289db78e41f714007426a387498e15963cFrancis Dupontdns_peer_setforcetcp(dns_peer_t *peer, isc_boolean_t newval) {
5c5c6d289db78e41f714007426a387498e15963cFrancis Dupont existed = DNS_BIT_CHECK(FORCE_TCP_BIT, &peer->bitflags);
5c5c6d289db78e41f714007426a387498e15963cFrancis Dupont return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS);
5c5c6d289db78e41f714007426a387498e15963cFrancis Dupontdns_peer_getforcetcp(dns_peer_t *peer, isc_boolean_t *retval) {
5c5c6d289db78e41f714007426a387498e15963cFrancis Dupont if (DNS_BIT_CHECK(FORCE_TCP_BIT, &peer->bitflags)) {
3e42bdfdc901b6b921b02028bd51ca2af8e84adcMark Andrewsdns_peer_settransfers(dns_peer_t *peer, isc_uint32_t newval) {
b3e77535185043f089b346166440402d092030c3David Lawrence existed = DNS_BIT_CHECK(TRANSFERS_BIT, &peer->bitflags);
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS);
3e42bdfdc901b6b921b02028bd51ca2af8e84adcMark Andrewsdns_peer_gettransfers(dns_peer_t *peer, isc_uint32_t *retval) {
b3e77535185043f089b346166440402d092030c3David Lawrence if (DNS_BIT_CHECK(TRANSFERS_BIT, &peer->bitflags)) {
b3e77535185043f089b346166440402d092030c3David Lawrencedns_peer_settransferformat(dns_peer_t *peer, dns_transfer_format_t newval) {
b3e77535185043f089b346166440402d092030c3David Lawrence existed = DNS_BIT_CHECK(SERVER_TRANSFER_FORMAT_BIT,
b3e77535185043f089b346166440402d092030c3David Lawrence DNS_BIT_SET(SERVER_TRANSFER_FORMAT_BIT, &peer->bitflags);
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS);
b3e77535185043f089b346166440402d092030c3David Lawrencedns_peer_gettransferformat(dns_peer_t *peer, dns_transfer_format_t *retval) {
b3e77535185043f089b346166440402d092030c3David Lawrence if (DNS_BIT_CHECK(SERVER_TRANSFER_FORMAT_BIT, &peer->bitflags)) {
b3e77535185043f089b346166440402d092030c3David Lawrencedns_peer_getkey(dns_peer_t *peer, dns_name_t **retval) {
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister return (peer->key == NULL ? ISC_R_NOTFOUND : ISC_R_SUCCESS);
b3e77535185043f089b346166440402d092030c3David Lawrencedns_peer_setkey(dns_peer_t *peer, dns_name_t **keyval) {
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister isc_mem_put(peer->mem, peer->key, sizeof(dns_name_t));
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister return (exists ? ISC_R_EXISTS : ISC_R_SUCCESS);
590f840d3484114576d9f8a7f7d73fbe31228888Brian Wellingtondns_peer_setkeybycharp(dns_peer_t *peer, const char *keyval) {
6f7abb89ec22aef5eda40ed60fcf605a42b78d4dMark Andrews isc_buffer_constinit(&b, keyval, strlen(keyval));
590f840d3484114576d9f8a7f7d73fbe31228888Brian Wellington result = dns_name_fromtext(dns_fixedname_name(&fname), &b,
590f840d3484114576d9f8a7f7d73fbe31228888Brian Wellington name = isc_mem_get(peer->mem, sizeof(dns_name_t));
590f840d3484114576d9f8a7f7d73fbe31228888Brian Wellington result = dns_name_dup(dns_fixedname_name(&fname), peer->mem, name);
590f840d3484114576d9f8a7f7d73fbe31228888Brian Wellington isc_mem_put(peer->mem, name, sizeof(dns_name_t));
590f840d3484114576d9f8a7f7d73fbe31228888Brian Wellington isc_mem_put(peer->mem, name, sizeof(dns_name_t));
600cbd1fcea3c9cc9706dc1ff8fc0d0034ebdeacTatuya JINMEI 神明達哉 isc_mem_put(peer->mem, peer->transfer_source,
600cbd1fcea3c9cc9706dc1ff8fc0d0034ebdeacTatuya JINMEI 神明達哉 peer->transfer_source = isc_mem_get(peer->mem,
600cbd1fcea3c9cc9706dc1ff8fc0d0034ebdeacTatuya JINMEI 神明達哉 *peer->transfer_source = *transfer_source;
600cbd1fcea3c9cc9706dc1ff8fc0d0034ebdeacTatuya JINMEI 神明達哉dns_peer_gettransfersource(dns_peer_t *peer, isc_sockaddr_t *transfer_source) {
600cbd1fcea3c9cc9706dc1ff8fc0d0034ebdeacTatuya JINMEI 神明達哉 *transfer_source = *peer->transfer_source;
7d4a465de03b26bf9f5ef131d03253b8f6afc169Mark Andrewsdns_peer_getnotifysource(dns_peer_t *peer, isc_sockaddr_t *notify_source) {
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrewsdns_peer_setquerysource(dns_peer_t *peer, const isc_sockaddr_t *query_source) {
7d4a465de03b26bf9f5ef131d03253b8f6afc169Mark Andrewsdns_peer_getquerysource(dns_peer_t *peer, isc_sockaddr_t *query_source) {
1c153afce556ff3c687986fb7c4a0b0a7f5e7cd8Mark Andrewsdns_peer_setudpsize(dns_peer_t *peer, isc_uint16_t udpsize) {
1c153afce556ff3c687986fb7c4a0b0a7f5e7cd8Mark Andrews existed = DNS_BIT_CHECK(SERVER_UDPSIZE_BIT, &peer->bitflags);
1c153afce556ff3c687986fb7c4a0b0a7f5e7cd8Mark Andrews DNS_BIT_SET(SERVER_UDPSIZE_BIT, &peer->bitflags);
1c153afce556ff3c687986fb7c4a0b0a7f5e7cd8Mark Andrews return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS);
1c153afce556ff3c687986fb7c4a0b0a7f5e7cd8Mark Andrewsdns_peer_getudpsize(dns_peer_t *peer, isc_uint16_t *udpsize) {
1c153afce556ff3c687986fb7c4a0b0a7f5e7cd8Mark Andrews if (DNS_BIT_CHECK(SERVER_UDPSIZE_BIT, &peer->bitflags)) {
08c90261660649ca7d92065f6f13a61ec5a9a86dMark Andrewsdns_peer_setmaxudp(dns_peer_t *peer, isc_uint16_t maxudp) {
08c90261660649ca7d92065f6f13a61ec5a9a86dMark Andrews existed = DNS_BIT_CHECK(SERVER_MAXUDP_BIT, &peer->bitflags);
08c90261660649ca7d92065f6f13a61ec5a9a86dMark Andrews DNS_BIT_SET(SERVER_MAXUDP_BIT, &peer->bitflags);
08c90261660649ca7d92065f6f13a61ec5a9a86dMark Andrews return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS);
08c90261660649ca7d92065f6f13a61ec5a9a86dMark Andrewsdns_peer_getmaxudp(dns_peer_t *peer, isc_uint16_t *maxudp) {
08c90261660649ca7d92065f6f13a61ec5a9a86dMark Andrews if (DNS_BIT_CHECK(SERVER_MAXUDP_BIT, &peer->bitflags)) {
67adc03ef81fb610f8df093b17f55275ee816754Evan Huntdns_peer_setnotifydscp(dns_peer_t *peer, isc_dscp_t dscp) {
67adc03ef81fb610f8df093b17f55275ee816754Evan Huntdns_peer_getnotifydscp(dns_peer_t *peer, isc_dscp_t *dscpp) {
a920fb9dc2ff16f32dd73e53469d0febcdcc6c11Mark Andrews if (DNS_BIT_CHECK(NOTIFY_DSCP_BIT, &peer->bitflags)) {
67adc03ef81fb610f8df093b17f55275ee816754Evan Huntdns_peer_settransferdscp(dns_peer_t *peer, isc_dscp_t dscp) {
a920fb9dc2ff16f32dd73e53469d0febcdcc6c11Mark Andrews DNS_BIT_SET(TRANSFER_DSCP_BIT, &peer->bitflags);
67adc03ef81fb610f8df093b17f55275ee816754Evan Huntdns_peer_gettransferdscp(dns_peer_t *peer, isc_dscp_t *dscpp) {
a920fb9dc2ff16f32dd73e53469d0febcdcc6c11Mark Andrews if (DNS_BIT_CHECK(TRANSFER_DSCP_BIT, &peer->bitflags)) {
67adc03ef81fb610f8df093b17f55275ee816754Evan Huntdns_peer_setquerydscp(dns_peer_t *peer, isc_dscp_t dscp) {
67adc03ef81fb610f8df093b17f55275ee816754Evan Huntdns_peer_getquerydscp(dns_peer_t *peer, isc_dscp_t *dscpp) {
a920fb9dc2ff16f32dd73e53469d0febcdcc6c11Mark Andrews if (DNS_BIT_CHECK(QUERY_DSCP_BIT, &peer->bitflags)) {
947cf282a721b089c1106780f13ae8e6298bddb1Mark Andrewsdns_peer_setednsversion(dns_peer_t *peer, isc_uint8_t ednsversion) {
947cf282a721b089c1106780f13ae8e6298bddb1Mark Andrews DNS_BIT_SET(EDNS_VERSION_BIT, &peer->bitflags);
947cf282a721b089c1106780f13ae8e6298bddb1Mark Andrewsdns_peer_getednsversion(dns_peer_t *peer, isc_uint8_t *ednsversion) {