43 static const char* dnsh_str =
"dnshandler";
45 static void dnshandler_handle_xfr(
netio_type* netio,
56 if (!allocator || !interfaces || interfaces->
count <= 0) {
63 "allocator_alloc() failed", dnsh_str);
78 "allocator_alloc() failed", dnsh_str);
85 "netio_create() failed", dnsh_str);
92 "query_create() failed", dnsh_str);
169 ods_log_debug(
"[%s] add udp network handler fd %u", dnsh_str,
170 (
unsigned) handler->
fd);
193 handler = &tcp_accept_handlers[i];
199 ods_log_debug(
"[%s] add tcp network handler fd %u", dnsh_str,
200 (
unsigned) handler->
fd);
207 if (errno != EINTR) {
237 if (dnshandler && dnshandler->
thread_id) {
238 ods_thread_kill(dnshandler->
thread_id, SIGHUP);
254 nb = send(dnshandler->
xfrhandler.
fd, (
const void*) pkt, len, 0);
256 ods_log_error(
"[%s] unable to forward notify: send() failed (%s)",
257 dnsh_str, strerror(errno));
259 ods_log_debug(
"[%s] forwarded notify: %u bytes sent", dnsh_str, nb);
270 dnshandler_handle_xfr(
netio_type* ATTR_UNUSED(netio),
275 ssize_t received = 0;
283 if (received == -1) {
284 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)