41static const char* dnsh_str =
"dnshandler";
43static void dnshandler_handle_xfr(
netio_type* netio,
54 if (!interfaces || interfaces->
count <= 0) {
59 ods_log_error(
"[%s] unable to create dnshandler: "
60 "allocator_alloc() failed", dnsh_str);
73 ods_log_error(
"[%s] unable to create socklist: "
74 "allocator_alloc() failed", dnsh_str);
80 ods_log_error(
"[%s] unable to create dnshandler: "
81 "netio_create() failed", dnsh_str);
87 ods_log_error(
"[%s] unable to create dnshandler: "
88 "query_create() failed", dnsh_str);
108 ods_status status = ODS_STATUS_OK;
109 ods_log_assert(dnshandler);
111 if (status != ODS_STATUS_OK) {
112 ods_log_error(
"[%s] unable to start: sock_listen() "
113 "failed (%s)", dnsh_str, ods_status2str(status));
130 ods_log_assert(dnshandler);
131 ods_log_assert(dnshandler->
engine);
132 ods_log_debug(
"[%s] start", dnsh_str);
134 engine = dnshandler->
engine;
141 ods_log_error(
"[%s] unable to start: allocator_alloc() "
152 ods_log_error(
"[%s] unable to start: allocator_alloc() "
165 ods_log_debug(
"[%s] add udp network handler fd %u", dnsh_str,
166 (
unsigned) handler->
fd);
176 ods_log_error(
"[%s] unable to start: allocator_alloc() "
193 ods_log_debug(
"[%s] add tcp network handler fd %u", dnsh_str,
194 (
unsigned) handler->
fd);
199 ods_log_deeebug(
"[%s] netio dispatch", dnsh_str);
201 if (errno != EINTR) {
202 ods_log_error(
"[%s] unable to dispatch netio: %s", dnsh_str,
209 ods_log_debug(
"[%s] shutdown", dnsh_str);
220 if (dnshandler && dnshandler->
thread_id) {
221 janitor_thread_signal(dnshandler->
thread_id);
234 ods_log_assert(dnshandler);
236 nb = send(dnshandler->
xfrhandler.
fd, (
const void*) pkt, len, 0);
238 ods_log_error(
"[%s] unable to forward notify: send() failed (%s)",
239 dnsh_str, strerror(errno));
241 ods_log_debug(
"[%s] forwarded notify: %ld bytes sent", dnsh_str, (
long)nb);
251dnshandler_handle_xfr(
netio_type* ATTR_UNUSED(netio),
256 ssize_t received = 0;
263 ods_log_debug(
"[%s] read forwarded xfr packet: %d bytes received",
264 dnsh_str, (
int) received);
265 if (received == -1) {
266 ods_log_error(
"[%s] unable to forward xfr packet: %s", dnsh_str,
void dnshandler_signal(dnshandler_type *dnshandler)
dnshandler_type * dnshandler_create(listener_type *interfaces)
ods_status dnshandler_listen(dnshandler_type *dnshandler)
void dnshandler_start(dnshandler_type *dnshandler)
void dnshandler_cleanup(dnshandler_type *dnshandler)
void dnshandler_fwd_notify(dnshandler_type *dnshandler, uint8_t *pkt, size_t len)
void netio_cleanup(netio_type *netio)
int netio_dispatch(netio_type *netio, const struct timespec *timeout, const sigset_t *sigmask)
void netio_add_handler(netio_type *netio, netio_handler_type *handler)
netio_type * netio_create()
enum netio_events_enum netio_events_type
query_type * query_create(void)
void query_cleanup(query_type *q)
void sock_handle_udp(netio_type *ATTR_UNUSED(netio), netio_handler_type *handler, netio_events_type event_types)
void sock_handle_tcp_accept(netio_type *netio, netio_handler_type *handler, netio_events_type event_types)
ods_status sock_listen(socklist_type *sockets, listener_type *listener)
netio_handler_type xfrhandler
netio_handler_type * tcp_accept_handlers
janitor_thread_t thread_id
listener_type * interfaces
struct timespec * timeout
netio_events_type event_types
netio_event_handler_type event_handler
sock_type udp[MAX_INTERFACES]
sock_type tcp[MAX_INTERFACES]
netio_handler_type * tcp_accept_handlers
size_t tcp_accept_handler_count