]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
dnstap io, fixup fptr_wlist for unbound_dnstap_socket tool.
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Fri, 28 Feb 2020 07:55:10 +0000 (08:55 +0100)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Fri, 28 Feb 2020 07:55:10 +0000 (08:55 +0100)
Makefile.in
daemon/worker.c
dnstap/dtstream.h
dnstap/unbound-dnstap-socket.c
libunbound/libworker.c
smallapp/worker_cb.c
util/fptr_wlist.c

index 2636ed4d249f513e9305775b25925801f798e1d2..4373dd66a527cc095009d394e940dc21c6d0be75 100644 (file)
@@ -235,7 +235,7 @@ IPSET_SRC=@IPSET_SRC@
 IPSET_OBJ=@IPSET_OBJ@
 DNSTAP_SOCKET_SRC=dnstap/unbound-dnstap-socket.c
 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)
 LIBUNBOUND_SRC=libunbound/context.c libunbound/libunbound.c \
 libunbound/libworker.c
index 56002039be8bd8168ec2319d9c0e15e476b830a2..cec6bcd667caf689aca90b47df372d15b09cabdb 100644 (file)
@@ -2124,3 +2124,18 @@ int codeline_cmp(const void* ATTR_UNUSED(a), const void* ATTR_UNUSED(b))
        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
index 5bf84757af17a9a9fdeb06385e908b5d4cfa2ec5..4bb027d5b92e04dbd1455ee1d6e741847b1da194 100644 (file)
@@ -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 */
 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 */
index f7974f319311a5a8650687a0c4118668037bd664..f7d713b539745dc50e47c1fd886ea5ab22e40b30 100644 (file)
@@ -940,7 +940,7 @@ static int tap_handshake(struct tap_data* data)
 #endif /* HAVE_SSL */
 
 /** 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;
        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 */
-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 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");
        }
        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(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;
        for(item = local_list->first; item; item = item->next) {
                struct tap_socket* s;
-               s = tap_socket_new_local(item->str, &mainfdcallback,
+               s = tap_socket_new_local(item->str, &dtio_mainfdcallback,
                        maindata);
                if(!s) fatal_exit("out of memory");
                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;
        for(item = tcp_list->first; item; item = item->next) {
                struct tap_socket* s;
-               s = tap_socket_new_tcpaccept(item->str, &mainfdcallback,
+               s = tap_socket_new_tcpaccept(item->str, &dtio_mainfdcallback,
                        maindata);
                if(!s) fatal_exit("out of memory");
                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;
        for(item = tls_list->first; item; item = item->next) {
                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);
                if(!s) fatal_exit("out of memory");
                if(!tap_socket_list_insert(&maindata->acceptlist, s))
@@ -1351,3 +1351,212 @@ int main(int argc, char** argv)
 #endif
        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);
+}
index 6cb97ff1fd4a58d35ec7197944e83ac95c16a4cc..0ed778903e56aa929ccace0318f5c0d0a56e1ad6 100644 (file)
@@ -1047,3 +1047,19 @@ wsvc_cron_cb(void* ATTR_UNUSED(arg))
         log_assert(0);
 }
 #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
index 6c3bd004908269d2548cd47ab89e02f460813f06..78d921a3c6e9755259c9a1e593a5b34926e95977 100644 (file)
@@ -248,3 +248,19 @@ void remote_get_opt_ssl(char* ATTR_UNUSED(str), void* ATTR_UNUSED(arg))
 {
         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
index cf07a7aff93de2fbfba2dccbe1dd520ed88aead0..b124e7169ea9a4586ae6f65df5bcfe4a853967c7 100644 (file)
@@ -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_stop_timer_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
 #ifdef UB_ON_WINDOWS
        else if(fptr == &worker_win_stop_cb) return 1;