Communication point to the network These behaviours can be accomplished by setting the flags and passing return values from the callback. More...
#include <netevent.h>
Public Types | |
enum | comm_point_type { comm_udp, comm_tcp_accept, comm_tcp, comm_local, comm_raw } |
is this a UDP, TCP-accept or TCP socket. More... | |
Data Fields | |
struct internal_event * | ev |
behind the scenes structure, with say libevent info. | |
int | fd |
file descriptor for communication point | |
struct timeval * | timeout |
timeout (NULL if it does not). | |
ldns_buffer * | buffer |
buffer pointer. | |
int | tcp_is_reading |
Read/Write state for TCP. | |
size_t | tcp_byte_count |
The current read/write count for TCP. | |
struct comm_point * | tcp_parent |
parent communication point (for TCP sockets) | |
struct comm_reply | repinfo |
sockaddr from peer, for TCP handlers | |
int | max_tcp_count |
the number of TCP handlers for this tcp-accept socket | |
struct comm_point ** | tcp_handlers |
malloced array of tcp handlers for a tcp-accept, of size max_tcp_count. | |
struct comm_point * | tcp_free |
linked list of free tcp_handlers to use for new queries. | |
enum comm_point::comm_point_type | type |
is this a UDP, TCP-accept or TCP socket. | |
int | do_not_close |
if set the connection is NOT closed on delete. | |
int | tcp_do_close |
if set, the connection is closed on error, on timeout, and after read/write completes. | |
int | tcp_do_toggle_rw |
if set, read/write completes: read/write state of tcp is toggled. | |
int | tcp_check_nb_connect |
if set, checks for pending error from nonblocking connect() call. | |
int | inuse |
number of queries outstanding on this socket, used by outside network for udp ports | |
comm_point_callback_t * | callback |
callback when done. | |
void * | cb_arg |
argument to pass to callback. |
Communication point to the network These behaviours can be accomplished by setting the flags and passing return values from the callback.
udp frontside: called after readdone. sendafter. tcp frontside: called readdone, sendafter. close. udp behind: called after readdone. No send after. tcp behind: write done, read done, then called. No send after.
is this a UDP, TCP-accept or TCP socket.
struct internal_event* comm_point::ev |
behind the scenes structure, with say libevent info.
alloced.
Referenced by comm_point_close(), comm_point_create_local(), comm_point_create_raw(), comm_point_create_tcp(), comm_point_create_tcp_handler(), comm_point_create_tcp_out(), comm_point_create_udp(), comm_point_create_udp_ancil(), comm_point_delete(), comm_point_get_mem(), comm_point_listen_for_rw(), comm_point_local_handle_callback(), comm_point_perform_accept(), comm_point_raw_handle_callback(), comm_point_send_reply(), comm_point_start_listening(), comm_point_stop_listening(), comm_point_tcp_accept_callback(), comm_point_tcp_handle_callback(), comm_point_tcp_handle_read(), comm_point_tcp_handle_write(), comm_point_udp_ancil_callback(), comm_point_udp_callback(), and fake_front_query().
struct timeval* comm_point::timeout |
timeout (NULL if it does not).
Malloced.
Referenced by comm_point_create_local(), comm_point_create_raw(), comm_point_create_tcp(), comm_point_create_tcp_handler(), comm_point_create_tcp_out(), comm_point_create_udp(), comm_point_create_udp_ancil(), comm_point_delete(), comm_point_get_mem(), comm_point_listen_for_rw(), and comm_point_start_listening().
ldns_buffer* comm_point::buffer |
buffer pointer.
Either to perthread, or own buffer or NULL
Referenced by answer_callback_from_entry(), answer_from_cache(), answer_norec_from_cache(), comm_point_create_local(), comm_point_create_raw(), comm_point_create_tcp(), comm_point_create_tcp_handler(), comm_point_create_tcp_out(), comm_point_create_udp(), comm_point_create_udp_ancil(), comm_point_delete(), comm_point_drop_reply(), comm_point_get_mem(), comm_point_send_reply(), comm_point_tcp_handle_read(), comm_point_tcp_handle_write(), comm_point_udp_ancil_callback(), comm_point_udp_callback(), delete_replay_answer(), fake_front_query(), fake_pending_callback(), libworker_handle_reply(), libworker_handle_service_reply(), mesh_new_client(), mesh_send_reply(), outnet_tcp_cb(), outnet_tcp_take_into_use(), outnet_udp_cb(), process_response(), server_stats_insquery(), serviced_callbacks(), serviced_tcp_callback(), serviced_udp_callback(), setup_tcp_handler(), tcp_callback_reader(), tcp_callback_writer(), worker_handle_reply(), worker_handle_request(), and worker_handle_service_reply().
struct comm_point** comm_point::tcp_handlers |
malloced array of tcp handlers for a tcp-accept, of size max_tcp_count.
Referenced by comm_point_create_local(), comm_point_create_raw(), comm_point_create_tcp(), comm_point_create_tcp_handler(), comm_point_create_tcp_out(), comm_point_create_udp(), comm_point_create_udp_ancil(), comm_point_delete(), and comm_point_get_mem().
struct comm_point* comm_point::tcp_free |
linked list of free tcp_handlers to use for new queries.
For tcp_accept the first entry, for tcp_handlers the next one.
Referenced by comm_point_create_local(), comm_point_create_raw(), comm_point_create_tcp(), comm_point_create_tcp_handler(), comm_point_create_tcp_out(), comm_point_create_udp(), comm_point_create_udp_ancil(), comm_point_start_listening(), comm_point_tcp_accept_callback(), and reclaim_tcp_handler().
is this a UDP, TCP-accept or TCP socket.
variable with type of socket, UDP,TCP-accept,TCP,pipe
Referenced by answer_callback_from_entry(), answer_check_it(), comm_point_create_local(), comm_point_create_raw(), comm_point_create_tcp(), comm_point_create_tcp_handler(), comm_point_create_tcp_out(), comm_point_create_udp(), comm_point_create_udp_ancil(), comm_point_delete(), comm_point_drop_reply(), comm_point_get_mem(), comm_point_local_handle_callback(), comm_point_raw_handle_callback(), comm_point_send_reply(), comm_point_start_listening(), comm_point_tcp_accept_callback(), comm_point_tcp_handle_callback(), comm_point_tcp_handle_read(), comm_point_tcp_handle_write(), comm_point_udp_ancil_callback(), comm_point_udp_callback(), fake_front_query(), fake_pending_callback(), listen_pushback(), listen_resume(), reclaim_tcp_handler(), server_stats_insquery(), setup_tcp_handler(), tcp_callback_reader(), tcp_callback_writer(), and worker_handle_request().
if set the connection is NOT closed on delete.
Referenced by accept_open(), comm_point_close(), comm_point_create_local(), comm_point_create_raw(), comm_point_create_tcp(), comm_point_create_tcp_handler(), comm_point_create_tcp_out(), comm_point_create_udp(), comm_point_create_udp_ancil(), listen_create(), and remote_accept_callback().
if set, the connection is closed on error, on timeout, and after read/write completes.
No callback is done.
Referenced by comm_point_create_local(), comm_point_create_raw(), comm_point_create_tcp(), comm_point_create_tcp_handler(), comm_point_create_tcp_out(), comm_point_create_udp(), comm_point_create_udp_ancil(), and comm_point_tcp_handle_callback().
if set, read/write completes: read/write state of tcp is toggled.
buffer reset/bytecount reset. this flag cleared. So that when that is done the callback is called.
Referenced by comm_point_create_local(), comm_point_create_raw(), comm_point_create_tcp(), comm_point_create_tcp_handler(), comm_point_create_tcp_out(), comm_point_create_udp(), comm_point_create_udp_ancil(), tcp_callback_reader(), and tcp_callback_writer().
if set, checks for pending error from nonblocking connect() call.
Referenced by comm_point_create_local(), comm_point_create_raw(), comm_point_create_tcp(), comm_point_create_tcp_handler(), comm_point_create_tcp_out(), comm_point_create_udp(), comm_point_create_udp_ancil(), and comm_point_tcp_handle_write().
callback when done.
tcp_accept does not get called back, is NULL then. If a timeout happens, callback with timeout=1 is called. If an error happens, callback is called with error set nonzero. If not NETEVENT_NOERROR, it is an errno value. If the connection is closed (by remote end) then the callback is called with error set to NETEVENT_CLOSED=-1. If a timeout happens on the connection, the error is set to NETEVENT_TIMEOUT=-2. The reply_info can be copied if the reply needs to happen at a later time. It consists of a struct with commpoint and address. It can be passed to a msg send routine some time later. Note the reply information is temporary and must be copied. NULL is passed for_reply info, in cases where error happened.
declare as: int my_callback(struct comm_point* c, void* my_arg, int error, struct comm_reply *reply_info);
if the routine returns 0, nothing is done. Notzero, the buffer will be sent back to client. For UDP this is done without changing the commpoint. In TCP it sets write state.
Referenced by comm_point_create_local(), comm_point_create_raw(), comm_point_create_tcp(), comm_point_create_tcp_handler(), comm_point_create_tcp_out(), comm_point_create_udp(), comm_point_create_udp_ancil(), comm_point_local_handle_callback(), comm_point_raw_handle_callback(), comm_point_tcp_handle_callback(), comm_point_udp_ancil_callback(), comm_point_udp_callback(), and tcp_callback_reader().
void* comm_point::cb_arg |
argument to pass to callback.
Referenced by comm_point_create_local(), comm_point_create_raw(), comm_point_create_tcp(), comm_point_create_tcp_handler(), comm_point_create_tcp_out(), comm_point_create_udp(), comm_point_create_udp_ancil(), comm_point_local_handle_callback(), comm_point_raw_handle_callback(), comm_point_set_cb_arg(), comm_point_tcp_handle_callback(), comm_point_udp_ancil_callback(), comm_point_udp_callback(), fake_pending_callback(), and tcp_callback_reader().