41 static const char* dnsh_str =
"dnshandler";
43 static void dnshandler_handle_xfr(
netio_type* netio,
54 if (!allocator || !interfaces || interfaces->
count <= 0) {
61 "allocator_alloc() failed", dnsh_str);
76 "allocator_alloc() failed", dnsh_str);
83 "netio_create() failed", dnsh_str);
90 "query_create() failed", dnsh_str);
167 ods_log_debug(
"[%s] add udp network handler fd %u", dnsh_str,
168 (
unsigned) handler->
fd);
191 handler = &tcp_accept_handlers[i];
197 ods_log_debug(
"[%s] add tcp network handler fd %u", dnsh_str,
198 (
unsigned) handler->
fd);
205 if (errno != EINTR) {
235 if (dnshandler && dnshandler->
thread_id) {
236 ods_thread_kill(dnshandler->
thread_id, SIGHUP);
252 nb = send(dnshandler->
xfrhandler.
fd, (
const void*) pkt, len, 0);
254 ods_log_error(
"[%s] unable to forward notify: send() failed (%s)",
255 dnsh_str, strerror(errno));
257 ods_log_debug(
"[%s] forwarded notify: %u bytes sent", dnsh_str, nb);
268 dnshandler_handle_xfr(
netio_type* ATTR_UNUSED(netio),
273 ssize_t received = 0;
281 if (received == -1) {
282 ods_log_debug(
"[%s] unable to forward xfr packet: %s", dnsh_str,
query_type * query_create(void)
void query_cleanup(query_type *q)
allocator_type * allocator
void ods_log_debug(const char *format,...)
ods_status dnshandler_listen(dnshandler_type *dnshandler)
void * allocator_alloc(allocator_type *allocator, size_t size)
listener_type * interfaces
enum ods_enum_status ods_status
enum netio_events_enum netio_events_type
void sock_handle_udp(netio_type *ATTR_UNUSED(netio), netio_handler_type *handler, netio_events_type event_types)
void ods_log_error(const char *format,...)
const char * ods_status2str(ods_status status)
void sock_handle_tcp_accept(netio_type *netio, netio_handler_type *handler, netio_events_type event_types)
sock_type udp[MAX_INTERFACES]
void netio_add_handler(netio_type *netio, netio_handler_type *handler)
sock_type tcp[MAX_INTERFACES]
netio_type * netio_create(allocator_type *allocator)
void dnshandler_signal(dnshandler_type *dnshandler)
netio_handler_type * tcp_accept_handlers
size_t tcp_accept_handler_count
netio_event_handler_type event_handler
ods_status sock_listen(socklist_type *sockets, listener_type *listener)
netio_handler_type xfrhandler
dnshandler_type * dnshandler_create(allocator_type *allocator, listener_type *interfaces)
netio_events_type event_types
void ods_log_deeebug(const char *format,...)
void allocator_deallocate(allocator_type *allocator, void *data)
ods_thread_type thread_id
void dnshandler_start(dnshandler_type *dnshandler)
struct timespec * timeout
#define ods_log_assert(x)
void dnshandler_fwd_notify(dnshandler_type *dnshandler, uint8_t *pkt, size_t len)
int netio_dispatch(netio_type *netio, const struct timespec *timeout, const sigset_t *sigmask)
void netio_cleanup(netio_type *netio)
void dnshandler_cleanup(dnshandler_type *dnshandler)