1 /* $NetBSD: peer.h,v 1.5 2014/12/10 04:37:58 christos Exp $ */ 2 3 /* 4 * Copyright (C) 2004-2009, 2013, 2014 Internet Systems Consortium, Inc. ("ISC") 5 * Copyright (C) 2000, 2001, 2003 Internet Software Consortium. 6 * 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. 10 * 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. 18 */ 19 20 /* Id: peer.h,v 1.35 2009/01/17 23:47:43 tbox Exp */ 21 22 #ifndef DNS_PEER_H 23 #define DNS_PEER_H 1 24 25 /***** 26 ***** Module Info 27 *****/ 28 29 /*! \file dns/peer.h 30 * \brief 31 * Data structures for peers (e.g. a 'server' config file statement) 32 */ 33 34 /*** 35 *** Imports 36 ***/ 37 38 #include <isc/lang.h> 39 #include <isc/magic.h> 40 #include <isc/netaddr.h> 41 42 #include <dns/types.h> 43 44 #define DNS_PEERLIST_MAGIC ISC_MAGIC('s','e','R','L') 45 #define DNS_PEER_MAGIC ISC_MAGIC('S','E','r','v') 46 47 #define DNS_PEERLIST_VALID(ptr) ISC_MAGIC_VALID(ptr, DNS_PEERLIST_MAGIC) 48 #define DNS_PEER_VALID(ptr) ISC_MAGIC_VALID(ptr, DNS_PEER_MAGIC) 49 50 /*** 51 *** Types 52 ***/ 53 54 struct dns_peerlist { 55 unsigned int magic; 56 isc_uint32_t refs; 57 58 isc_mem_t *mem; 59 60 ISC_LIST(dns_peer_t) elements; 61 }; 62 63 struct dns_peer { 64 unsigned int magic; 65 isc_uint32_t refs; 66 67 isc_mem_t *mem; 68 69 isc_netaddr_t address; 70 unsigned int prefixlen; 71 isc_boolean_t bogus; 72 dns_transfer_format_t transfer_format; 73 isc_uint32_t transfers; 74 isc_boolean_t support_ixfr; 75 isc_boolean_t provide_ixfr; 76 isc_boolean_t request_ixfr; 77 isc_boolean_t support_edns; 78 isc_boolean_t request_nsid; 79 isc_boolean_t request_sit; 80 dns_name_t *key; 81 isc_sockaddr_t *transfer_source; 82 isc_dscp_t transfer_dscp; 83 isc_sockaddr_t *notify_source; 84 isc_dscp_t notify_dscp; 85 isc_sockaddr_t *query_source; 86 isc_dscp_t query_dscp; 87 isc_uint16_t udpsize; /* receive size */ 88 isc_uint16_t maxudp; /* transmit size */ 89 90 isc_uint32_t bitflags; 91 92 ISC_LINK(dns_peer_t) next; 93 }; 94 95 /*** 96 *** Functions 97 ***/ 98 99 ISC_LANG_BEGINDECLS 100 101 isc_result_t 102 dns_peerlist_new(isc_mem_t *mem, dns_peerlist_t **list); 103 104 void 105 dns_peerlist_attach(dns_peerlist_t *source, dns_peerlist_t **target); 106 107 void 108 dns_peerlist_detach(dns_peerlist_t **list); 109 110 /* 111 * After return caller still holds a reference to peer. 112 */ 113 void 114 dns_peerlist_addpeer(dns_peerlist_t *peers, dns_peer_t *peer); 115 116 /* 117 * Ditto. */ 118 isc_result_t 119 dns_peerlist_peerbyaddr(dns_peerlist_t *peers, isc_netaddr_t *addr, 120 dns_peer_t **retval); 121 122 /* 123 * What he said. 124 */ 125 isc_result_t 126 dns_peerlist_currpeer(dns_peerlist_t *peers, dns_peer_t **retval); 127 128 isc_result_t 129 dns_peer_new(isc_mem_t *mem, isc_netaddr_t *ipaddr, dns_peer_t **peer); 130 131 isc_result_t 132 dns_peer_newprefix(isc_mem_t *mem, isc_netaddr_t *ipaddr, 133 unsigned int prefixlen, dns_peer_t **peer); 134 135 void 136 dns_peer_attach(dns_peer_t *source, dns_peer_t **target); 137 138 void 139 dns_peer_detach(dns_peer_t **list); 140 141 isc_result_t 142 dns_peer_setbogus(dns_peer_t *peer, isc_boolean_t newval); 143 144 isc_result_t 145 dns_peer_getbogus(dns_peer_t *peer, isc_boolean_t *retval); 146 147 isc_result_t 148 dns_peer_setrequestixfr(dns_peer_t *peer, isc_boolean_t newval); 149 150 isc_result_t 151 dns_peer_getrequestixfr(dns_peer_t *peer, isc_boolean_t *retval); 152 153 isc_result_t 154 dns_peer_setprovideixfr(dns_peer_t *peer, isc_boolean_t newval); 155 156 isc_result_t 157 dns_peer_getprovideixfr(dns_peer_t *peer, isc_boolean_t *retval); 158 159 isc_result_t 160 dns_peer_setrequestnsid(dns_peer_t *peer, isc_boolean_t newval); 161 162 isc_result_t 163 dns_peer_getrequestnsid(dns_peer_t *peer, isc_boolean_t *retval); 164 165 isc_result_t 166 dns_peer_setrequestsit(dns_peer_t *peer, isc_boolean_t newval); 167 168 isc_result_t 169 dns_peer_getrequestsit(dns_peer_t *peer, isc_boolean_t *retval); 170 171 isc_result_t 172 dns_peer_setsupportedns(dns_peer_t *peer, isc_boolean_t newval); 173 174 isc_result_t 175 dns_peer_getsupportedns(dns_peer_t *peer, isc_boolean_t *retval); 176 177 isc_result_t 178 dns_peer_settransfers(dns_peer_t *peer, isc_uint32_t newval); 179 180 isc_result_t 181 dns_peer_gettransfers(dns_peer_t *peer, isc_uint32_t *retval); 182 183 isc_result_t 184 dns_peer_settransferformat(dns_peer_t *peer, dns_transfer_format_t newval); 185 186 isc_result_t 187 dns_peer_gettransferformat(dns_peer_t *peer, dns_transfer_format_t *retval); 188 189 isc_result_t 190 dns_peer_setkeybycharp(dns_peer_t *peer, const char *keyval); 191 192 isc_result_t 193 dns_peer_getkey(dns_peer_t *peer, dns_name_t **retval); 194 195 isc_result_t 196 dns_peer_setkey(dns_peer_t *peer, dns_name_t **keyval); 197 198 isc_result_t 199 dns_peer_settransfersource(dns_peer_t *peer, 200 const isc_sockaddr_t *transfer_source); 201 202 isc_result_t 203 dns_peer_gettransfersource(dns_peer_t *peer, isc_sockaddr_t *transfer_source); 204 205 isc_result_t 206 dns_peer_setudpsize(dns_peer_t *peer, isc_uint16_t udpsize); 207 208 isc_result_t 209 dns_peer_getudpsize(dns_peer_t *peer, isc_uint16_t *udpsize); 210 211 isc_result_t 212 dns_peer_setmaxudp(dns_peer_t *peer, isc_uint16_t maxudp); 213 214 isc_result_t 215 dns_peer_getmaxudp(dns_peer_t *peer, isc_uint16_t *maxudp); 216 217 isc_result_t 218 dns_peer_setnotifysource(dns_peer_t *peer, const isc_sockaddr_t *notify_source); 219 220 isc_result_t 221 dns_peer_getnotifysource(dns_peer_t *peer, isc_sockaddr_t *notify_source); 222 223 isc_result_t 224 dns_peer_setquerysource(dns_peer_t *peer, const isc_sockaddr_t *query_source); 225 226 isc_result_t 227 dns_peer_getquerysource(dns_peer_t *peer, isc_sockaddr_t *query_source); 228 229 isc_result_t 230 dns_peer_setnotifydscp(dns_peer_t *peer, isc_dscp_t dscp); 231 232 isc_result_t 233 dns_peer_getnotifydscp(dns_peer_t *peer, isc_dscp_t *dscpp); 234 235 isc_result_t 236 dns_peer_settransferdscp(dns_peer_t *peer, isc_dscp_t dscp); 237 238 isc_result_t 239 dns_peer_gettransferdscp(dns_peer_t *peer, isc_dscp_t *dscpp); 240 241 isc_result_t 242 dns_peer_setquerydscp(dns_peer_t *peer, isc_dscp_t dscp); 243 244 isc_result_t 245 dns_peer_getquerydscp(dns_peer_t *peer, isc_dscp_t *dscpp); 246 ISC_LANG_ENDDECLS 247 248 #endif /* DNS_PEER_H */ 249