comm_point Struct Reference

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_eventev
 behind the scenes structure, with say libevent info. More...
 
int event_added
 if the event is added or not
 
struct unbound_socketsocket
 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_bufferbuffer
 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_pointtcp_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_pointtcp_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_bufferhttp_temp
 http temp buffer (shared buffer for temporary work)
 
size_t http_stored
 http stored content in buffer
 
struct http2_sessionh2_session
 http2 session
 
int use_h2
 set to 1 if h2 is negotiated to be used (using alpn)
 
struct http2_streamh2_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_listtcp_conn_limit
 if set, check for connection limit on tcp accept.
 
struct tcl_addrtcl_addr
 the entry for the connection.
 
struct tcp_req_infotcp_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_typecallback
 callback when done. More...
 
void * cb_arg
 argument to pass to callback.
 

Detailed Description

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.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

handshake state for init and renegotiate

Enumerator
comm_ssl_shake_none 

no handshake, it has been done

comm_ssl_shake_read 

ssl initial handshake wants to read

comm_ssl_shake_write 

ssl initial handshake wants to write

comm_ssl_shake_hs_read 

ssl_write wants to read

comm_ssl_shake_hs_write 

ssl_read wants to write

◆ anonymous enum

anonymous enum

Do not allow connection to use HTTP version lower than this.

0=no minimum.

◆ comm_point_type

is this a UDP, TCP-accept or TCP socket.

Enumerator
comm_udp 

UDP socket - handle datagrams.

comm_tcp_accept 

TCP accept socket - only creates handlers if readable.

comm_tcp 

TCP handler socket - handle byteperbyte readwrite.

comm_http 

HTTP handler socket.

comm_doq 

DOQ handler socket.

comm_local 

AF_UNIX socket - for internal commands.

comm_raw 

raw - not DNS format - for pipe readers and writers

◆ anonymous enum

anonymous enum

header state for the PROXYv2 header (for TCP)

Enumerator
pp2_header_none 

no header encounter yet

pp2_header_init 

read the static part of the header

pp2_header_done 

read the full header

Field Documentation

◆ ev

◆ timeout

◆ buffer

◆ tcp_free

◆ 

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().

◆ http2_max_streams

uint32_t comm_point::http2_max_streams

maximum number of HTTP/2 streams per connection.

Send in HTTP/2 SETTINGS frame.

◆ tcp_do_close

◆ tcp_write_byte_count

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().

◆ tcp_write_pkt

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().

◆ tcp_more_read_again

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().

◆ tcp_more_write_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().

◆ tcp_do_toggle_rw

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().

◆ callback

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().


The documentation for this struct was generated from the following file: