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_ssl_shake_none = 0 , comm_ssl_shake_read , comm_ssl_shake_write , comm_ssl_shake_hs_read , comm_ssl_shake_hs_write } |
handshake state for init and renegotiate More... | |
enum | { http_version_none = 0 , http_version_2 = 2 } |
Do not allow connection to use HTTP version lower than this. More... | |
enum | comm_point_type { comm_udp , comm_tcp_accept , comm_tcp , comm_http , comm_doq , comm_local , comm_raw } |
is this a UDP, TCP-accept or TCP socket. More... | |
enum | { pp2_header_none = 0 , pp2_header_init , pp2_header_done } |
header state for the PROXYv2 header (for TCP) More... | |
Data Fields | |
struct internal_event * | ev |
behind the scenes structure, with say libevent info. More... | |
int | event_added |
if the event is added or not | |
struct unbound_socket * | socket |
Reference to struct that is part of the listening ports, where for listening ports information is kept about the address. | |
int | fd |
file descriptor for communication point | |
struct timeval * | timeout |
timeout (NULL if it does not). More... | |
struct sldns_buffer * | buffer |
buffer pointer. More... | |
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 | |
int | cur_tcp_count |
current number of tcp handler in-use for this 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. More... | |
void * | ssl |
the SSL object with rw bio (owned) or for commaccept ctx ref | |
enum comm_point:: { ... } | ssl_shake_state |
handshake state for init and renegotiate | |
enum comm_point:: { ... } | http_min_version |
Do not allow connection to use HTTP version lower than this. More... | |
char * | http_endpoint |
http endpoint | |
int | http_in_headers |
Currently reading in http headers. | |
int | http_in_chunk_headers |
Currently reading in chunk headers, 0=not, 1=firstline, 2=unused (more lines), 3=trailer headers after chunk. | |
int | http_is_chunked |
chunked transfer | |
struct sldns_buffer * | http_temp |
http temp buffer (shared buffer for temporary work) | |
size_t | http_stored |
http stored content in buffer | |
struct http2_session * | h2_session |
http2 session | |
int | use_h2 |
set to 1 if h2 is negotiated to be used (using alpn) | |
struct http2_stream * | h2_stream |
stream currently being handled | |
size_t | http2_stream_max_qbuffer_size |
maximum allowed query buffer size, per stream | |
uint32_t | http2_max_streams |
maximum number of HTTP/2 streams per connection. More... | |
struct dt_env * | dtenv |
the dnstap environment | |
enum comm_point::comm_point_type | type |
variable with type of socket, UDP,TCP-accept,TCP,pipe | |
int | pp2_enabled |
if set, PROXYv2 is expected on this connection | |
enum comm_point:: { ... } | pp2_header_state |
header state for the PROXYv2 header (for TCP) | |
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. More... | |
int | tcp_write_and_read |
flag that indicates the stream is both written and read from. | |
size_t | tcp_write_byte_count |
byte count for written length over write channel, for when tcp_write_and_read is enabled. More... | |
uint8_t * | tcp_write_pkt |
packet to write currently over the write channel. More... | |
size_t | tcp_write_pkt_len |
length of tcp_write_pkt in bytes | |
int * | tcp_more_read_again |
if set try to read another packet again (over connection with multiple packets), once set, tries once, then zero again, so set it in the packet complete section. More... | |
int * | tcp_more_write_again |
if set try to write another packet (over connection with multiple packets), once set, tries once, then zero again, so set it in the packet complete section. More... | |
int | tcp_do_toggle_rw |
if set, read/write completes: read/write state of tcp is toggled. More... | |
int | tcp_timeout_msec |
timeout in msec for TCP wait times for this connection | |
int | tcp_keepalive |
if set, tcp keepalive is enabled on this connection | |
int | tcp_check_nb_connect |
if set, checks for pending error from nonblocking connect() call. | |
struct tcl_list * | tcp_conn_limit |
if set, check for connection limit on tcp accept. | |
struct tcl_addr * | tcl_addr |
the entry for the connection. | |
struct tcp_req_info * | tcp_req_info |
the structure to keep track of open requests on this channel | |
int | inuse |
number of queries outstanding on this socket, used by outside network for udp ports | |
struct timeval | recv_tv |
the timestamp when the packet was received by the kernel | |
comm_point_callback_type * | callback |
callback when done. More... | |
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.
anonymous enum |
handshake state for init and renegotiate
anonymous enum |
Do not allow connection to use HTTP version lower than this.
0=no minimum.
is this a UDP, TCP-accept or TCP socket.
anonymous enum |
struct internal_event* comm_point::ev |
behind the scenes structure, with say libevent info.
alloced.
Referenced by comm_point_close(), comm_point_create_doq(), comm_point_create_http_out(), 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_delete(), comm_point_get_mem(), comm_point_http_handle_callback(), comm_point_listen_for_rw(), comm_point_local_handle_callback(), comm_point_perform_accept(), comm_point_send_reply(), comm_point_send_udp_msg(), comm_point_send_udp_msg_if(), comm_point_start_listening(), comm_point_stop_listening(), comm_point_tcp_accept_callback(), comm_point_tcp_handle_callback(), comm_point_tcp_handle_write(), comm_point_udp_callback(), http_check_connect(), http_read_more(), http_write_more(), ssl_handle_read(), and ssl_handle_write().
struct timeval* comm_point::timeout |
timeout (NULL if it does not).
Malloced.
Referenced by comm_point_create_doq(), comm_point_create_http_out(), 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_delete(), comm_point_get_mem(), comm_point_listen_for_rw(), and comm_point_start_listening().
struct sldns_buffer* comm_point::buffer |
buffer pointer.
Either to perthread, or own buffer or NULL
Referenced by answer_callback_from_entry(), auth_xfer_probe_udp_callback(), auth_xfer_transfer_http_callback(), comm_point_create_doq(), comm_point_create_http_out(), 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_delete(), comm_point_drop_reply(), comm_point_get_mem(), comm_point_http_handle_read(), comm_point_http_handle_write(), comm_point_send_reply(), comm_point_tcp_handle_callback(), comm_point_tcp_handle_read(), comm_point_tcp_handle_write(), comm_point_udp_callback(), delete_replay_answer(), dnsc_handle_curved_request(), http_chunked_segment(), http_nonchunk_segment(), http_process_chunk_header(), http_process_initial_header(), http_read_more(), http_write_more(), mesh_new_client(), outnet_udp_cb(), reclaim_tcp_handler(), reply_and_prefetch(), reuse_tcp_setup_read_and_timeout(), server_stats_insquery(), serviced_callbacks(), serviced_tcp_callback(), setup_tcp_handler(), ssl_handle_read(), ssl_handle_write(), ssl_http_read_more(), ssl_http_write_more(), tcp_callback_reader(), tcp_callback_writer(), tcp_req_info_handle_writedone(), tcp_req_info_send_reply(), and tcp_req_info_start_write_buf().
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_doq(), comm_point_create_http_out(), 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_start_listening(), comm_point_tcp_accept_callback(), listen_start_accept(), listen_stop_accept(), reclaim_http_handler(), and reclaim_tcp_handler().
enum { ... } comm_point::http_min_version |
Do not allow connection to use HTTP version lower than this.
0=no minimum.
Referenced by comm_point_http_handle_read(), and comm_point_http_handle_write().
uint32_t comm_point::http2_max_streams |
maximum number of HTTP/2 streams per connection.
Send in HTTP/2 SETTINGS frame.
int comm_point::tcp_do_close |
if set, the connection is closed on error, on timeout, and after read/write completes.
No callback is done.
Referenced by comm_point_create_doq(), comm_point_create_http_out(), 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_http_handle_callback(), comm_point_tcp_handle_callback(), outnet_tcp_take_into_use(), tcp_more_read_again(), tcp_more_write_again(), and tcp_req_info_read_again().
size_t comm_point::tcp_write_byte_count |
byte count for written length over write channel, for when tcp_write_and_read is enabled.
When tcp_write_and_read is enabled, this is the counter for writing, the one for reading is in the commpoint.buffer sldns buffer. The counter counts from 0 to 2+tcp_write_pkt_len, and includes the tcp length bytes.
Referenced by comm_point_tcp_handle_write(), outnet_tcp_take_query_setup(), and ssl_handle_write().
uint8_t* comm_point::tcp_write_pkt |
packet to write currently over the write channel.
for when tcp_write_and_read is enabled. When tcp_write_and_read is enabled, this is the buffer for the written packet, the commpoint.buffer sldns buffer is the buffer for the received packet.
Referenced by comm_point_tcp_handle_write(), outnet_tcp_cb(), outnet_tcp_take_query_setup(), reuse_move_writewait_away(), and ssl_handle_write().
int* comm_point::tcp_more_read_again |
if set try to read another packet again (over connection with multiple packets), once set, tries once, then zero again, so set it in the packet complete section.
The pointer itself has to be set before the callback is invoked, when you set things up, and continue to exist also after the commpoint is closed and deleted in your callback. So that after the callback cleans up netevent can see what it has to do. Or leave NULL if it is not used at all.
Referenced by comm_point_close(), comm_point_tcp_handle_callback(), reclaim_tcp_handler(), and tcp_more_read_again().
int* comm_point::tcp_more_write_again |
if set try to write another packet (over connection with multiple packets), once set, tries once, then zero again, so set it in the packet complete section.
The pointer itself has to be set before the callback is invoked, when you set things up, and continue to exist also after the commpoint is closed and deleted in your callback. So that after the callback cleans up netevent can see what it has to do. Or leave NULL if it is not used at all.
Referenced by comm_point_close(), comm_point_tcp_handle_callback(), reclaim_tcp_handler(), and tcp_more_write_again().
int comm_point::tcp_do_toggle_rw |
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_doq(), comm_point_create_http_out(), 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_http_handle_write(), outnet_tcp_take_into_use(), tcp_callback_reader(), and tcp_callback_writer().
comm_point_callback_type* comm_point::callback |
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_doq(), comm_point_create_http_out(), 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_http_handle_callback(), comm_point_local_handle_callback(), comm_point_tcp_handle_callback(), comm_point_udp_callback(), http_chunked_segment(), http_nonchunk_segment(), http_process_chunk_header(), tcp_callback_reader(), tcp_callback_writer(), tcp_more_read_again(), tcp_more_write_again(), tcp_req_info_handle_readdone(), and tcp_req_info_read_again().