42 #include <sys/socket.h>
44 static const char* notify_str =
"notify";
46 static void notify_handle_zone(
netio_type* netio,
77 if(t > notify_time(notify) + 10) {
78 time_t extra = t - notify_time(notify);
79 time_t base = extra*9/10;
80 t = notify_time(notify) + base +
81 random()%(extra-base);
99 if (!xfrhandler || !zone) {
105 "allocator_create() failed", notify_str);
111 " allocator_alloc() failed", notify_str);
162 notify_set_timer(notify, notify_time(notify));
201 notify_str, zone->
name);
229 ods_log_debug(
"[%s] zone %s no more secondaries, disable notify",
230 notify_str, zone->
name);
231 notify_disable(notify);
245 ssize_t received = 0;
252 if (received == -1) {
253 ods_log_error(
"[%s] unable to read packet: recvfrom() failed fd %d "
254 "(%s)", notify_str, notify->
handler.
fd, strerror(errno));
281 ods_log_error(
"[%s] zone %s received bad notify reply opcode/qr",
282 notify_str, zone->
name);
287 notify_str, zone->
name);
299 ods_log_debug(
"[%s] zone %s secondary %s notify reply ok", notify_str,
312 struct sockaddr_storage to;
313 socklen_t to_len = 0;
328 fd = socket(family, SOCK_DGRAM, IPPROTO_UDP);
341 (
struct sockaddr*)&to, to_len);
368 ods_log_error(
"[%s] unable to sign notify: tsig unknown algorithm "
385 ods_log_debug(
"[%s] tsig append rr to notify id=%u", notify_str,
426 notify_tsig_sign(notify, xfrhandler->
packet);
431 ods_log_error(
"[%s] unable to send notify retry %u for zone %s to "
432 "%s: notify_send_udp() failed", notify_str, notify->
retry,
436 ods_log_verbose(
"[%s] notify retry %u for zone %s sent to %s", notify_str,
447 notify_handle_zone(
netio_type* ATTR_UNUSED(netio),
466 ods_log_debug(
"[%s] already waiting, skipping notify for zone %s",
467 notify_str, zone->
name);
475 if (notify_udp_read_packet(notify)) {
476 if (notify_handle_reply(notify)) {
506 notify_update_soa(
notify_type* notify, ldns_rr* soa)
512 ldns_rr_free(notify->
soa);
546 notify_update_soa(notify, soa);
548 ods_log_debug(
"[%s] zone %s already on waiting list", notify_str,
553 notify_setup(notify);
570 ods_log_debug(
"[%s] zone %s notify on waiting list", notify_str,
593 ldns_rr_free(notify->
soa);
ldns_pkt_opcode buffer_pkt_opcode(buffer_type *buffer)
void tsig_rr_update(tsig_rr_type *trr, buffer_type *buffer, size_t length)
void notify_enable(notify_type *notify, ldns_rr *soa)
void notify_send(notify_type *notify)
void ods_log_debug(const char *format,...)
notify_type * notify_create(void *xfrhandler, void *zone)
uint16_t buffer_pkt_arcount(buffer_type *buffer)
void * allocator_alloc(allocator_type *allocator, size_t size)
void buffer_flip(buffer_type *buffer)
void buffer_clear(buffer_type *buffer)
enum netio_events_enum netio_events_type
socklen_t xfrd_acl_sockaddr_to(acl_type *acl, struct sockaddr_storage *to)
tsig_algo_type * tsig_lookup_algo(const char *name)
void ods_log_error(const char *format,...)
int buffer_pkt_qr(buffer_type *buffer)
void tsig_rr_reset(tsig_rr_type *trr, tsig_algo_type *algo, tsig_key_type *key)
void tsig_rr_append(tsig_rr_type *trr, buffer_type *buffer)
uint16_t buffer_pkt_id(buffer_type *buffer)
void notify_cleanup(notify_type *notify)
uint8_t * buffer_current(buffer_type *buffer)
adapter_type * adoutbound
void tsig_rr_prepare(tsig_rr_type *trr)
time_t xfrhandler_time(xfrhandler_type *xfrhandler)
void buffer_pkt_set_ancount(buffer_type *buffer, uint16_t count)
void buffer_set_limit(buffer_type *buffer, size_t limit)
allocator_type * allocator_create(void *(*allocator)(size_t size), void(*deallocator)(void *))
notify_type * notify_waiting_first
netio_event_handler_type event_handler
void tsig_rr_cleanup(tsig_rr_type *trr)
void log_dname(ldns_rdf *rdf, const char *pre, int level)
notify_type * notify_waiting_last
allocator_type * allocator
#define NOTIFY_RETRY_TIMEOUT
void buffer_pkt_set_aa(buffer_type *buffer)
tsig_rr_type * tsig_rr_create(allocator_type *allocator)
void ods_log_verbose(const char *format,...)
netio_events_type event_types
void buffer_pkt_notify(buffer_type *buffer, ldns_rdf *qname, ldns_rr_class qclass)
void allocator_cleanup(allocator_type *allocator)
size_t buffer_remaining(buffer_type *buffer)
void ods_log_deeebug(const char *format,...)
int buffer_write_rr(buffer_type *buffer, ldns_rr *rr)
void tsig_rr_sign(tsig_rr_type *trr)
notify_type * waiting_next
void allocator_deallocate(allocator_type *allocator, void *data)
size_t buffer_position(buffer_type *buffer)
void buffer_pkt_set_arcount(buffer_type *buffer, uint16_t count)
netio_handler_type handler
struct timespec * timeout
#define ods_log_assert(x)
void ods_log_warning(const char *format,...)
uint16_t original_query_id
uint8_t * buffer_begin(buffer_type *buffer)
ldns_pkt_rcode buffer_pkt_rcode(buffer_type *buffer)