|
unbound 0.1
|
This program listens on a DNSTAP socket for logged messages. More...
#include "config.h"#include <signal.h>#include <stdlib.h>#include <unistd.h>#include <ctype.h>#include <openssl/ssl.h>#include <openssl/rand.h>#include <openssl/err.h>#include "dnstap/dtstream.h"#include "dnstap/dnstap_fstrm.h"#include "util/log.h"#include "util/ub_event.h"#include "util/net_help.h"#include "services/listen_dnsport.h"#include "sldns/sbuffer.h"#include "sldns/wire2str.h"#include "sldns/pkthdr.h"#include "util/config_file.h"#include "util/data/packed_rrset.h"#include "daemon/worker.h"#include "daemon/remote.h"#include "util/fptr_wlist.h"#include "libunbound/context.h"Data Structures | |
| struct | main_tap_data |
| main tap callback data More... | |
| struct | tap_data_list |
| struct | tap_data |
| tap callback variables More... | |
| struct | tap_socket_list |
| list of sockets More... | |
| struct | tap_socket |
| tap socket More... | |
| struct | order_id |
| keep track of lock id in lock-verify application More... | |
Macros | |
| #define | LISTEN_BACKLOG 16 |
| listen backlog on TCP connections for dnstap logs | |
| #define | unit_tap_datas_max 5 |
Functions | |
| static void | usage (char *argv[]) |
| usage information for streamtcp | |
| static void | tap_data_list_try_to_free_tail (struct tap_data_list *list) |
| try to delete tail entries from the list if all of them have no data | |
| static void | tap_data_free (struct tap_data *data, int free_tail) |
| delete the tap structure | |
| static int | tap_data_list_insert (struct tap_data_list **liststart, struct tap_data *d) |
| insert tap_data in the tap_data_list | |
| static void | tap_data_list_delete (struct tap_data_list *list) |
| delete the tap_data_list and free any remaining tap_data | |
| static void | tap_socket_delev (struct tap_socket *s) |
| del the tap event | |
| static void | tap_socket_close (struct tap_socket *s) |
| close the tap socket | |
| static void | tap_socket_delete (struct tap_socket *s) |
| delete tap socket | |
| static struct tap_socket * | tap_socket_new_local (char *socketpath, void(*ev_cb)(int, short, void *), void *data) |
| create new socket (unconnected, not base-added), or NULL malloc fail | |
| static struct tap_socket * | tap_socket_new_tcpaccept (char *ip, void(*ev_cb)(int, short, void *), void *data) |
| create new socket (unconnected, not base-added), or NULL malloc fail | |
| static struct tap_socket * | tap_socket_new_tlsaccept (char *ip, void(*ev_cb)(int, short, void *), void *data, char *server_key, char *server_cert, char *verifypem, char *tls_protocols) |
| create new socket (unconnected, not base-added), or NULL malloc fail | |
| static int | make_tcp_accept (char *ip) |
| setup tcp accept socket on IP string | |
| static int | tap_socket_setup (struct tap_socket *s, struct ub_event_base *base) |
| setup socket on event base | |
| static int | tap_socket_list_insert (struct tap_socket_list **liststart, struct tap_socket *s) |
| add tap socket to list | |
| static void | tap_socket_list_delete (struct tap_socket_list *list) |
| delete the list | |
| static int | tap_socket_list_addevs (struct tap_socket_list *list, struct ub_event_base *base) |
| setup accept events | |
| static ssize_t | receive_bytes (struct tap_data *data, int fd, void *buf, size_t len) |
| receive bytes from fd, prints errors if bad, returns 0: closed/error, -1: continue, >0 number of bytes | |
| static ssize_t | tap_receive (struct tap_data *data, void *buf, size_t len) |
| receive bytes on the tap connection, prints errors if bad, returns 0: closed/error, -1: continue, >0 number of bytes | |
| static int | reply_with_accept (struct tap_data *data) |
| reply with ACCEPT control frame to bidirectional client, returns 0 on error | |
| static int | reply_with_finish (struct tap_data *data) |
| reply with FINISH control frame to bidirectional client, returns 0 on error | |
| void | dtio_tap_callback (int ATTR_UNUSED(fd), short ATTR_UNUSED(bits), void *arg) |
| callback for dnstap listener | |
| void | dtio_mainfdcallback (int fd, short ATTR_UNUSED(bits), void *arg) |
| callback for main listening file descriptor | |
| static void | setup_local_list (struct main_tap_data *maindata, struct config_strlist_head *local_list) |
| setup local accept sockets | |
| static void | setup_tcp_list (struct main_tap_data *maindata, struct config_strlist_head *tcp_list) |
| setup tcp accept sockets | |
| static void | setup_tls_list (struct main_tap_data *maindata, struct config_strlist_head *tls_list, char *server_key, char *server_cert, char *verifypem, char *tls_protocols) |
| setup tls accept sockets | |
| static RETSIGTYPE | main_sigh (int sig) |
| signal handler for user quit | |
| static void | setup_and_run (struct config_strlist_head *local_list, struct config_strlist_head *tcp_list, struct config_strlist_head *tls_list, char *server_key, char *server_cert, char *verifypem, char *tls_protocols) |
| setup and run the server to listen to DNSTAP messages | |
| static int | internal_unittest () |
| int | main (int argc, char **argv) |
| main program for streamtcp | |
| 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)) |
| int | worker_handle_request (struct comm_point *ATTR_UNUSED(c), void *ATTR_UNUSED(arg), int ATTR_UNUSED(error), struct comm_reply *ATTR_UNUSED(repinfo)) |
| 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)) |
| int | remote_accept_callback (struct comm_point *ATTR_UNUSED(c), void *ATTR_UNUSED(arg), int ATTR_UNUSED(error), struct comm_reply *ATTR_UNUSED(repinfo)) |
| int | remote_control_callback (struct comm_point *ATTR_UNUSED(c), void *ATTR_UNUSED(arg), int ATTR_UNUSED(error), struct comm_reply *ATTR_UNUSED(repinfo)) |
| void | worker_sighandler (int ATTR_UNUSED(sig), void *ATTR_UNUSED(arg)) |
| 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), int ATTR_UNUSED(check_ratelimit), struct sockaddr_storage *ATTR_UNUSED(addr), socklen_t ATTR_UNUSED(addrlen), uint8_t *ATTR_UNUSED(zone), size_t ATTR_UNUSED(zonelen), int ATTR_UNUSED(tcp_upstream), int ATTR_UNUSED(ssl_upstream), char *ATTR_UNUSED(tls_auth_name), struct module_qstate *ATTR_UNUSED(q), int *ATTR_UNUSED(was_ratelimited), int *ATTR_UNUSED(ratelimit_incremented)) |
| void | worker_alloc_cleanup (void *ATTR_UNUSED(arg)) |
| 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), int ATTR_UNUSED(check_ratelimit), struct sockaddr_storage *ATTR_UNUSED(addr), socklen_t ATTR_UNUSED(addrlen), uint8_t *ATTR_UNUSED(zone), size_t ATTR_UNUSED(zonelen), int ATTR_UNUSED(tcp_upstream), int ATTR_UNUSED(ssl_upstream), char *ATTR_UNUSED(tls_auth_name), struct module_qstate *ATTR_UNUSED(q), int *ATTR_UNUSED(was_ratelimited), int *ATTR_UNUSED(ratelimit_incremented)) |
| 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)) |
| 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)) |
| 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)) |
| 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)) |
| 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)) |
| void | libworker_alloc_cleanup (void *ATTR_UNUSED(arg)) |
| int | context_query_cmp (const void *ATTR_UNUSED(a), const void *ATTR_UNUSED(b)) |
| void | worker_stat_timer_cb (void *ATTR_UNUSED(arg)) |
| void | worker_probe_timer_cb (void *ATTR_UNUSED(arg)) |
| void | worker_start_accept (void *ATTR_UNUSED(arg)) |
| void | worker_stop_accept (void *ATTR_UNUSED(arg)) |
| int | order_lock_cmp (const void *e1, const void *e2) |
| Due to module breakage by fptr wlist, these test app declarations are presented here. | |
| int | codeline_cmp (const void *a, const void *b) |
| compare two codeline structs for rbtree from memstats test app | |
| int | replay_var_compare (const void *ATTR_UNUSED(a), const void *ATTR_UNUSED(b)) |
| void | remote_get_opt_ssl (char *ATTR_UNUSED(str), void *ATTR_UNUSED(arg)) |
| void | fast_reload_service_cb (int ATTR_UNUSED(fd), short ATTR_UNUSED(ev), void *ATTR_UNUSED(arg)) |
| int | fast_reload_client_callback (struct comm_point *ATTR_UNUSED(c), void *ATTR_UNUSED(arg), int ATTR_UNUSED(error), struct comm_reply *ATTR_UNUSED(repinfo)) |
Variables | |
| static int | longformat = 0 |
| long format option, for multiline printout per message | |
| static struct ub_event_base * | sig_base = NULL |
| signal variable | |
| int | sig_quit = 0 |
| do we have to quit | |
| int | optind |
| getopt global, in case header files fail to declare it. | |
| char * | optarg |
| getopt global, in case header files fail to declare it. | |
This program listens on a DNSTAP socket for logged messages.
| #define LISTEN_BACKLOG 16 |
listen backlog on TCP connections for dnstap logs
Referenced by make_tcp_accept().
|
static |
usage information for streamtcp
References usage().
|
static |
try to delete tail entries from the list if all of them have no data
References tap_data_list::d, log_assert, tap_data_list::next, and tap_data_list_try_to_free_tail().
Referenced by tap_data_free(), and tap_data_list_try_to_free_tail().
|
static |
delete the tap structure
References tap_data_list::d, tap_data::data_list, tap_data::ev, tap_data::fd, tap_data::frame, tap_data::id, sock_close(), tap_data::ssl, tap_data_free(), tap_data_list_try_to_free_tail(), ub_event_del(), and ub_event_free().
Referenced by dtio_tap_callback(), tap_data_free(), and tap_data_list_delete().
|
static |
insert tap_data in the tap_data_list
References tap_data_list::d, tap_data::data_list, entry::next, and tap_data_list_insert().
Referenced by dtio_mainfdcallback(), and tap_data_list_insert().
|
static |
delete the tap_data_list and free any remaining tap_data
References tap_data_list::d, tap_data_list::next, tap_data_free(), and tap_data_list_delete().
Referenced by tap_data_list_delete(), and tap_socket_delete().
|
static |
del the tap event
References tap_socket::ev, tap_socket::ev_added, tap_socket_delev(), and ub_event_del().
Referenced by tap_socket_delev(), and tap_socket_list_delete().
|
static |
close the tap socket
References tap_socket::fd, sock_close(), and tap_socket_close().
Referenced by tap_socket_close(), and tap_socket_list_delete().
|
static |
delete tap socket
References tap_socket::data_list, tap_socket::ev, tap_socket::ip, tap_socket::socketpath, tap_socket::sslctx, tap_data_list_delete(), tap_socket_delete(), and ub_event_free().
Referenced by tap_socket_delete(), and tap_socket_list_delete().
|
static |
create new socket (unconnected, not base-added), or NULL malloc fail
References tap_socket::data, tap_socket::ev_cb, tap_socket::fd, log_err(), tap_socket::socketpath, and tap_socket_new_local().
Referenced by setup_local_list(), and tap_socket_new_local().
|
static |
create new socket (unconnected, not base-added), or NULL malloc fail
References tap_socket::data, tap_socket::ev_cb, tap_socket::fd, tap_socket::ip, log_err(), and tap_socket_new_tcpaccept().
Referenced by setup_tcp_list(), and tap_socket_new_tcpaccept().
|
static |
create new socket (unconnected, not base-added), or NULL malloc fail
References tap_socket::data, tap_socket::ev_cb, tap_socket::fd, tap_socket::ip, listen_sslctx_create(), log_err(), tap_socket::sslctx, and tap_socket_new_tlsaccept().
Referenced by setup_tls_list(), and tap_socket_new_tlsaccept().
|
static |
setup tcp accept socket on IP string
References extstrtoaddr(), fd_set_nonblock(), LISTEN_BACKLOG, log_err(), log_err_addr(), make_tcp_accept(), sock_close(), and sock_strerror().
Referenced by make_tcp_accept(), and tap_socket_setup().
|
static |
setup socket on event base
References create_local_accept_sock(), tap_socket::ev, tap_socket::ev_added, tap_socket::ev_cb, tap_socket::fd, tap_socket::ip, log_err(), make_tcp_accept(), tap_socket::socketpath, tap_socket::sslctx, tap_socket_setup(), UB_EV_PERSIST, UB_EV_READ, ub_event_add(), and ub_event_new().
Referenced by tap_socket_list_addevs(), and tap_socket_setup().
|
static |
add tap socket to list
References entry::next, tap_socket_list::s, and tap_socket_list_insert().
Referenced by setup_local_list(), setup_tcp_list(), setup_tls_list(), and tap_socket_list_insert().
|
static |
delete the list
References tap_socket_list::next, tap_socket_list::s, tap_socket_close(), tap_socket_delete(), tap_socket_delev(), and tap_socket_list_delete().
Referenced by setup_and_run(), and tap_socket_list_delete().
|
static |
setup accept events
References log_err(), entry::next, tap_socket_list_addevs(), and tap_socket_setup().
Referenced by setup_and_run(), and tap_socket_list_addevs().
|
static |
receive bytes from fd, prints errors if bad, returns 0: closed/error, -1: continue, >0 number of bytes
References tap_data::ev, tap_data::id, log_err(), log_info(), MSG_DONTWAIT, receive_bytes(), sock_strerror(), UB_EV_READ, ub_winsock_tcp_wouldblock(), and verbosity.
|
static |
receive bytes on the tap connection, prints errors if bad, returns 0: closed/error, -1: continue, >0 number of bytes
References tap_data::fd, receive_bytes(), tap_data::ssl, and tap_receive().
Referenced by dtio_tap_callback(), and tap_receive().
|
static |
reply with ACCEPT control frame to bidirectional client, returns 0 on error
References DNSTAP_CONTENT_TYPE, tap_data::fd, fd_set_block(), fd_set_nonblock(), fstrm_create_control_frame_accept(), log_crypto_err_io(), log_err(), log_info(), reply_with_accept(), sock_strerror(), tap_data::ssl, and verbosity.
Referenced by dtio_tap_callback(), and reply_with_accept().
|
static |
reply with FINISH control frame to bidirectional client, returns 0 on error
References tap_data::fd, fd_set_block(), fd_set_nonblock(), fstrm_create_control_frame_finish(), log_crypto_err_io(), log_err(), log_info(), reply_with_finish(), sock_strerror(), tap_data::ssl, and verbosity.
Referenced by dtio_tap_callback(), and reply_with_finish().
| void dtio_tap_callback | ( | int | ATTR_UNUSEDfd, |
| short | ATTR_UNUSEDbits, | ||
| void * | arg ) |
callback for dnstap listener
References tap_data::control_frame, tap_data::data_done, dtio_tap_callback(), tap_data::frame, FSTRM_CONTROL_FRAME_READY, FSTRM_CONTROL_FRAME_STOP, tap_data::is_bidirectional, tap_data::len, tap_data::len_done, log_err(), log_info(), reply_with_accept(), reply_with_finish(), tap_data::ssl, tap_data::ssl_brief_write, tap_data::ssl_handshake_done, tap_data_free(), tap_receive(), and verbosity.
| void dtio_mainfdcallback | ( | int | fd, |
| short | ATTR_UNUSEDbits, | ||
| void * | arg ) |
callback for main listening file descriptor
References addr_to_str(), main_tap_data::base, tap_socket::data, tap_socket::data_list, dtio_mainfdcallback(), dtio_tap_callback(), tap_data::ev, fatal_exit(), tap_data::fd, fd_set_nonblock(), tap_data::id, incoming_ssl_fd(), log_err_addr(), log_info(), sock_strerror(), tap_data::ssl, tap_socket::sslctx, tap_data_list_insert(), UB_EV_PERSIST, UB_EV_READ, ub_event_add(), ub_event_new(), ub_winsock_tcp_wouldblock(), and verbosity.
|
static |
setup local accept sockets
References main_tap_data::acceptlist, dtio_mainfdcallback(), fatal_exit(), config_strlist_head::first, config_strlist::next, setup_local_list(), config_strlist::str, tap_socket_list_insert(), and tap_socket_new_local().
Referenced by setup_and_run(), and setup_local_list().
|
static |
setup tcp accept sockets
References main_tap_data::acceptlist, dtio_mainfdcallback(), fatal_exit(), config_strlist_head::first, config_strlist::next, setup_tcp_list(), config_strlist::str, tap_socket_list_insert(), and tap_socket_new_tcpaccept().
Referenced by setup_and_run(), and setup_tcp_list().
|
static |
setup tls accept sockets
References main_tap_data::acceptlist, dtio_mainfdcallback(), fatal_exit(), config_strlist_head::first, config_strlist::next, setup_tls_list(), config_strlist::str, tap_socket_list_insert(), and tap_socket_new_tlsaccept().
Referenced by setup_and_run(), and setup_tls_list().
|
static |
signal handler for user quit
References main_sigh(), sig_base, sig_quit, and ub_event_base_loopexit().
Referenced by main(), and main_sigh().
|
static |
setup and run the server to listen to DNSTAP messages
References main_tap_data::acceptlist, main_tap_data::base, fatal_exit(), log_info(), setup_and_run(), setup_local_list(), setup_tcp_list(), setup_tls_list(), sig_base, sig_quit, tap_socket_list_addevs(), tap_socket_list_delete(), ub_default_event_base(), ub_event_base_dispatch(), ub_event_base_free(), ub_get_event_sys(), and verbosity.
Referenced by main(), and setup_and_run().
| int main | ( | int | argc, |
| char ** | argv ) |
main program for streamtcp
References cfg_strlist_append(), config_delstrlist(), fatal_exit(), config_strlist_head::first, log_get_lock(), log_ident_set(), log_init(), longformat, main, main_sigh(), optarg, setup_and_run(), usage(), and verbosity.
| int order_lock_cmp | ( | const void * | e1, |
| const void * | e2 ) |
Due to module breakage by fptr wlist, these test app declarations are presented here.
compare two order_ids from lock-verify test app
References order_id::instance, and order_id::thr.
| int codeline_cmp | ( | const void * | a, |
| const void * | b ) |
compare two codeline structs for rbtree from memstats test app
| a | codeline |
| b | codeline |
|
static |
long format option, for multiline printout per message
Referenced by main().
|
static |
signal variable
Referenced by main_sigh(), and setup_and_run().
| int sig_quit = 0 |
do we have to quit
Referenced by main_sigh(), and setup_and_run().