mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 23:00:56 -05:00
dnstap io, fixup fptr_wlist for unbound_dnstap_socket tool.
This commit is contained in:
parent
85c4e58831
commit
b63032b4dd
7 changed files with 271 additions and 7 deletions
|
|
@ -235,7 +235,7 @@ IPSET_SRC=@IPSET_SRC@
|
||||||
IPSET_OBJ=@IPSET_OBJ@
|
IPSET_OBJ=@IPSET_OBJ@
|
||||||
DNSTAP_SOCKET_SRC=dnstap/unbound-dnstap-socket.c
|
DNSTAP_SOCKET_SRC=dnstap/unbound-dnstap-socket.c
|
||||||
DNSTAP_SOCKET_OBJ=unbound-dnstap-socket.lo
|
DNSTAP_SOCKET_OBJ=unbound-dnstap-socket.lo
|
||||||
DNSTAP_SOCKET_OBJ_LINK=$(DNSTAP_SOCKET_OBJ) worker_cb.lo $(COMMON_OBJ) \
|
DNSTAP_SOCKET_OBJ_LINK=$(DNSTAP_SOCKET_OBJ) $(COMMON_OBJ) \
|
||||||
$(COMPAT_OBJ) $(SLDNS_OBJ)
|
$(COMPAT_OBJ) $(SLDNS_OBJ)
|
||||||
LIBUNBOUND_SRC=libunbound/context.c libunbound/libunbound.c \
|
LIBUNBOUND_SRC=libunbound/context.c libunbound/libunbound.c \
|
||||||
libunbound/libworker.c
|
libunbound/libworker.c
|
||||||
|
|
|
||||||
|
|
@ -2124,3 +2124,18 @@ int codeline_cmp(const void* ATTR_UNUSED(a), const void* ATTR_UNUSED(b))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_DNSTAP
|
||||||
|
void dtio_tap_callback(int ATTR_UNUSED(fd), short ATTR_UNUSED(ev),
|
||||||
|
void* ATTR_UNUSED(arg))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_DNSTAP
|
||||||
|
void dtio_mainfdcallback(int ATTR_UNUSED(fd), short ATTR_UNUSED(ev),
|
||||||
|
void* ATTR_UNUSED(arg))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -296,4 +296,10 @@ void dtio_stop_timer_cb(int fd, short bits, void* arg);
|
||||||
/** callback for the output when the thread stops and wants to finish up */
|
/** callback for the output when the thread stops and wants to finish up */
|
||||||
void dtio_stop_ev_cb(int fd, short bits, void* arg);
|
void dtio_stop_ev_cb(int fd, short bits, void* arg);
|
||||||
|
|
||||||
|
/** callback for unbound-dnstap-socket */
|
||||||
|
void dtio_tap_callback(int fd, short bits, void* arg);
|
||||||
|
|
||||||
|
/** callback for unbound-dnstap-socket */
|
||||||
|
void dtio_mainfdcallback(int fd, short bits, void* arg);
|
||||||
|
|
||||||
#endif /* DTSTREAM_H */
|
#endif /* DTSTREAM_H */
|
||||||
|
|
|
||||||
|
|
@ -940,7 +940,7 @@ static int tap_handshake(struct tap_data* data)
|
||||||
#endif /* HAVE_SSL */
|
#endif /* HAVE_SSL */
|
||||||
|
|
||||||
/** callback for dnstap listener */
|
/** callback for dnstap listener */
|
||||||
static void tap_callback(int fd, short ATTR_UNUSED(bits), void* arg)
|
void dtio_tap_callback(int fd, short ATTR_UNUSED(bits), void* arg)
|
||||||
{
|
{
|
||||||
struct tap_data* data = (struct tap_data*)arg;
|
struct tap_data* data = (struct tap_data*)arg;
|
||||||
if(verbosity>=3) log_info("tap callback");
|
if(verbosity>=3) log_info("tap callback");
|
||||||
|
|
@ -1037,7 +1037,7 @@ static void tap_callback(int fd, short ATTR_UNUSED(bits), void* arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** callback for main listening file descriptor */
|
/** callback for main listening file descriptor */
|
||||||
void mainfdcallback(int fd, short ATTR_UNUSED(bits), void* arg)
|
void dtio_mainfdcallback(int fd, short ATTR_UNUSED(bits), void* arg)
|
||||||
{
|
{
|
||||||
struct tap_socket* tap_sock = (struct tap_socket*)arg;
|
struct tap_socket* tap_sock = (struct tap_socket*)arg;
|
||||||
struct main_tap_data* maindata = (struct main_tap_data*)
|
struct main_tap_data* maindata = (struct main_tap_data*)
|
||||||
|
|
@ -1114,7 +1114,7 @@ void mainfdcallback(int fd, short ATTR_UNUSED(bits), void* arg)
|
||||||
if(!data->ssl) fatal_exit("could not SSL_new");
|
if(!data->ssl) fatal_exit("could not SSL_new");
|
||||||
}
|
}
|
||||||
data->ev = ub_event_new(maindata->base, s, UB_EV_READ | UB_EV_PERSIST,
|
data->ev = ub_event_new(maindata->base, s, UB_EV_READ | UB_EV_PERSIST,
|
||||||
&tap_callback, data);
|
&dtio_tap_callback, data);
|
||||||
if(!data->ev) fatal_exit("could not ub_event_new");
|
if(!data->ev) fatal_exit("could not ub_event_new");
|
||||||
if(ub_event_add(data->ev, NULL) != 0) fatal_exit("could not ub_event_add");
|
if(ub_event_add(data->ev, NULL) != 0) fatal_exit("could not ub_event_add");
|
||||||
}
|
}
|
||||||
|
|
@ -1126,7 +1126,7 @@ static void setup_local_list(struct main_tap_data* maindata,
|
||||||
struct config_strlist* item;
|
struct config_strlist* item;
|
||||||
for(item = local_list->first; item; item = item->next) {
|
for(item = local_list->first; item; item = item->next) {
|
||||||
struct tap_socket* s;
|
struct tap_socket* s;
|
||||||
s = tap_socket_new_local(item->str, &mainfdcallback,
|
s = tap_socket_new_local(item->str, &dtio_mainfdcallback,
|
||||||
maindata);
|
maindata);
|
||||||
if(!s) fatal_exit("out of memory");
|
if(!s) fatal_exit("out of memory");
|
||||||
if(!tap_socket_list_insert(&maindata->acceptlist, s))
|
if(!tap_socket_list_insert(&maindata->acceptlist, s))
|
||||||
|
|
@ -1141,7 +1141,7 @@ static void setup_tcp_list(struct main_tap_data* maindata,
|
||||||
struct config_strlist* item;
|
struct config_strlist* item;
|
||||||
for(item = tcp_list->first; item; item = item->next) {
|
for(item = tcp_list->first; item; item = item->next) {
|
||||||
struct tap_socket* s;
|
struct tap_socket* s;
|
||||||
s = tap_socket_new_tcpaccept(item->str, &mainfdcallback,
|
s = tap_socket_new_tcpaccept(item->str, &dtio_mainfdcallback,
|
||||||
maindata);
|
maindata);
|
||||||
if(!s) fatal_exit("out of memory");
|
if(!s) fatal_exit("out of memory");
|
||||||
if(!tap_socket_list_insert(&maindata->acceptlist, s))
|
if(!tap_socket_list_insert(&maindata->acceptlist, s))
|
||||||
|
|
@ -1157,7 +1157,7 @@ static void setup_tls_list(struct main_tap_data* maindata,
|
||||||
struct config_strlist* item;
|
struct config_strlist* item;
|
||||||
for(item = tls_list->first; item; item = item->next) {
|
for(item = tls_list->first; item; item = item->next) {
|
||||||
struct tap_socket* s;
|
struct tap_socket* s;
|
||||||
s = tap_socket_new_tlsaccept(item->str, &mainfdcallback,
|
s = tap_socket_new_tlsaccept(item->str, &dtio_mainfdcallback,
|
||||||
maindata, server_key, server_cert, verifypem);
|
maindata, server_key, server_cert, verifypem);
|
||||||
if(!s) fatal_exit("out of memory");
|
if(!s) fatal_exit("out of memory");
|
||||||
if(!tap_socket_list_insert(&maindata->acceptlist, s))
|
if(!tap_socket_list_insert(&maindata->acceptlist, s))
|
||||||
|
|
@ -1351,3 +1351,212 @@ int main(int argc, char** argv)
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***--- definitions to make fptr_wlist work. ---***/
|
||||||
|
/* These are callbacks, similar to smallapp callbacks, except the debug
|
||||||
|
* tool callbacks are not in it */
|
||||||
|
struct tube;
|
||||||
|
struct query_info;
|
||||||
|
#include "util/data/packed_rrset.h"
|
||||||
|
|
||||||
|
void worker_handle_control_cmd(struct tube* ATTR_UNUSED(tube),
|
||||||
|
uint8_t* ATTR_UNUSED(buffer), size_t ATTR_UNUSED(len),
|
||||||
|
int ATTR_UNUSED(error), void* ATTR_UNUSED(arg))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int worker_handle_request(struct comm_point* ATTR_UNUSED(c),
|
||||||
|
void* ATTR_UNUSED(arg), int ATTR_UNUSED(error),
|
||||||
|
struct comm_reply* ATTR_UNUSED(repinfo))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int worker_handle_reply(struct comm_point* ATTR_UNUSED(c),
|
||||||
|
void* ATTR_UNUSED(arg), int ATTR_UNUSED(error),
|
||||||
|
struct comm_reply* ATTR_UNUSED(reply_info))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int worker_handle_service_reply(struct comm_point* ATTR_UNUSED(c),
|
||||||
|
void* ATTR_UNUSED(arg), int ATTR_UNUSED(error),
|
||||||
|
struct comm_reply* ATTR_UNUSED(reply_info))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int remote_accept_callback(struct comm_point* ATTR_UNUSED(c),
|
||||||
|
void* ATTR_UNUSED(arg), int ATTR_UNUSED(error),
|
||||||
|
struct comm_reply* ATTR_UNUSED(repinfo))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int remote_control_callback(struct comm_point* ATTR_UNUSED(c),
|
||||||
|
void* ATTR_UNUSED(arg), int ATTR_UNUSED(error),
|
||||||
|
struct comm_reply* ATTR_UNUSED(repinfo))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void worker_sighandler(int ATTR_UNUSED(sig), void* ATTR_UNUSED(arg))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct outbound_entry* worker_send_query(
|
||||||
|
struct query_info* ATTR_UNUSED(qinfo), uint16_t ATTR_UNUSED(flags),
|
||||||
|
int ATTR_UNUSED(dnssec), int ATTR_UNUSED(want_dnssec),
|
||||||
|
int ATTR_UNUSED(nocaps), struct sockaddr_storage* ATTR_UNUSED(addr),
|
||||||
|
socklen_t ATTR_UNUSED(addrlen), uint8_t* ATTR_UNUSED(zone),
|
||||||
|
size_t ATTR_UNUSED(zonelen), int ATTR_UNUSED(ssl_upstream),
|
||||||
|
char* ATTR_UNUSED(tls_auth_name), struct module_qstate* ATTR_UNUSED(q))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef UB_ON_WINDOWS
|
||||||
|
void
|
||||||
|
worker_win_stop_cb(int ATTR_UNUSED(fd), short ATTR_UNUSED(ev), void*
|
||||||
|
ATTR_UNUSED(arg)) {
|
||||||
|
log_assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
wsvc_cron_cb(void* ATTR_UNUSED(arg))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
}
|
||||||
|
#endif /* UB_ON_WINDOWS */
|
||||||
|
|
||||||
|
void
|
||||||
|
worker_alloc_cleanup(void* ATTR_UNUSED(arg))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct outbound_entry* libworker_send_query(
|
||||||
|
struct query_info* ATTR_UNUSED(qinfo), uint16_t ATTR_UNUSED(flags),
|
||||||
|
int ATTR_UNUSED(dnssec), int ATTR_UNUSED(want_dnssec),
|
||||||
|
int ATTR_UNUSED(nocaps), struct sockaddr_storage* ATTR_UNUSED(addr),
|
||||||
|
socklen_t ATTR_UNUSED(addrlen), uint8_t* ATTR_UNUSED(zone),
|
||||||
|
size_t ATTR_UNUSED(zonelen), int ATTR_UNUSED(ssl_upstream),
|
||||||
|
char* ATTR_UNUSED(tls_auth_name), struct module_qstate* ATTR_UNUSED(q))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int libworker_handle_reply(struct comm_point* ATTR_UNUSED(c),
|
||||||
|
void* ATTR_UNUSED(arg), int ATTR_UNUSED(error),
|
||||||
|
struct comm_reply* ATTR_UNUSED(reply_info))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int libworker_handle_service_reply(struct comm_point* ATTR_UNUSED(c),
|
||||||
|
void* ATTR_UNUSED(arg), int ATTR_UNUSED(error),
|
||||||
|
struct comm_reply* ATTR_UNUSED(reply_info))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void libworker_handle_control_cmd(struct tube* ATTR_UNUSED(tube),
|
||||||
|
uint8_t* ATTR_UNUSED(buffer), size_t ATTR_UNUSED(len),
|
||||||
|
int ATTR_UNUSED(error), void* ATTR_UNUSED(arg))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void libworker_fg_done_cb(void* ATTR_UNUSED(arg), int ATTR_UNUSED(rcode),
|
||||||
|
struct sldns_buffer* ATTR_UNUSED(buf), enum sec_status ATTR_UNUSED(s),
|
||||||
|
char* ATTR_UNUSED(why_bogus), int ATTR_UNUSED(was_ratelimited))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void libworker_bg_done_cb(void* ATTR_UNUSED(arg), int ATTR_UNUSED(rcode),
|
||||||
|
struct sldns_buffer* ATTR_UNUSED(buf), enum sec_status ATTR_UNUSED(s),
|
||||||
|
char* ATTR_UNUSED(why_bogus), int ATTR_UNUSED(was_ratelimited))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void libworker_event_done_cb(void* ATTR_UNUSED(arg), int ATTR_UNUSED(rcode),
|
||||||
|
struct sldns_buffer* ATTR_UNUSED(buf), enum sec_status ATTR_UNUSED(s),
|
||||||
|
char* ATTR_UNUSED(why_bogus), int ATTR_UNUSED(was_ratelimited))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int context_query_cmp(const void* ATTR_UNUSED(a), const void* ATTR_UNUSED(b))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void worker_stat_timer_cb(void* ATTR_UNUSED(arg))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void worker_probe_timer_cb(void* ATTR_UNUSED(arg))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void worker_start_accept(void* ATTR_UNUSED(arg))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void worker_stop_accept(void* ATTR_UNUSED(arg))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** keep track of lock id in lock-verify application */
|
||||||
|
struct order_id {
|
||||||
|
/** the thread id that created it */
|
||||||
|
int thr;
|
||||||
|
/** the instance number of creation */
|
||||||
|
int instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
int order_lock_cmp(const void* e1, const void* e2)
|
||||||
|
{
|
||||||
|
const struct order_id* o1 = e1;
|
||||||
|
const struct order_id* o2 = e2;
|
||||||
|
if(o1->thr < o2->thr) return -1;
|
||||||
|
if(o1->thr > o2->thr) return 1;
|
||||||
|
if(o1->instance < o2->instance) return -1;
|
||||||
|
if(o1->instance > o2->instance) return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
codeline_cmp(const void* a, const void* b)
|
||||||
|
{
|
||||||
|
return strcmp(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
int replay_var_compare(const void* ATTR_UNUSED(a), const void* ATTR_UNUSED(b))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void remote_get_opt_ssl(char* ATTR_UNUSED(str), void* ATTR_UNUSED(arg))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1047,3 +1047,19 @@ wsvc_cron_cb(void* ATTR_UNUSED(arg))
|
||||||
log_assert(0);
|
log_assert(0);
|
||||||
}
|
}
|
||||||
#endif /* UB_ON_WINDOWS */
|
#endif /* UB_ON_WINDOWS */
|
||||||
|
|
||||||
|
#ifdef USE_DNSTAP
|
||||||
|
void dtio_tap_callback(int ATTR_UNUSED(fd), short ATTR_UNUSED(ev),
|
||||||
|
void* ATTR_UNUSED(arg))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_DNSTAP
|
||||||
|
void dtio_mainfdcallback(int ATTR_UNUSED(fd), short ATTR_UNUSED(ev),
|
||||||
|
void* ATTR_UNUSED(arg))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -248,3 +248,19 @@ void remote_get_opt_ssl(char* ATTR_UNUSED(str), void* ATTR_UNUSED(arg))
|
||||||
{
|
{
|
||||||
log_assert(0);
|
log_assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_DNSTAP
|
||||||
|
void dtio_tap_callback(int ATTR_UNUSED(fd), short ATTR_UNUSED(ev),
|
||||||
|
void* ATTR_UNUSED(arg))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_DNSTAP
|
||||||
|
void dtio_mainfdcallback(int ATTR_UNUSED(fd), short ATTR_UNUSED(ev),
|
||||||
|
void* ATTR_UNUSED(arg))
|
||||||
|
{
|
||||||
|
log_assert(0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,8 @@ fptr_whitelist_event(void (*fptr)(int, short, void *))
|
||||||
else if(fptr == &dtio_reconnect_timeout_cb) return 1;
|
else if(fptr == &dtio_reconnect_timeout_cb) return 1;
|
||||||
else if(fptr == &dtio_stop_timer_cb) return 1;
|
else if(fptr == &dtio_stop_timer_cb) return 1;
|
||||||
else if(fptr == &dtio_stop_ev_cb) return 1;
|
else if(fptr == &dtio_stop_ev_cb) return 1;
|
||||||
|
else if(fptr == &dtio_tap_callback) return 1;
|
||||||
|
else if(fptr == &dtio_mainfdcallback) return 1;
|
||||||
#endif
|
#endif
|
||||||
#ifdef UB_ON_WINDOWS
|
#ifdef UB_ON_WINDOWS
|
||||||
else if(fptr == &worker_win_stop_cb) return 1;
|
else if(fptr == &worker_win_stop_cb) return 1;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue