listen_dnsport.h File Reference

This file has functions to get queries from clients. More...

#include "util/netevent.h"

Data Structures

struct  listen_dnsport
 Listening for queries structure. More...
struct  listen_list
 Single linked list to store event points. More...
struct  listen_port
 Single linked list to store shared ports that have been opened for use by all threads. More...

Enumerations

enum  listen_type { listen_type_udp, listen_type_tcp, listen_type_udpancil }
 type of ports More...

Functions

struct listen_portlistening_ports_open (struct config_file *cfg)
 Create shared listening ports Getaddrinfo, create socket, bind and listen to zero or more interfaces for IP4 and/or IP6, for UDP and/or TCP.
void listening_ports_free (struct listen_port *list)
 Close and delete the (list of) listening ports.
struct listen_dnsportlisten_create (struct comm_base *base, struct listen_port *ports, size_t bufsize, int tcp_accept_count, comm_point_callback_t *cb, void *cb_arg)
 Create commpoints with for this thread for the shared ports.
void listen_pushback (struct listen_dnsport *listen)
 Stop listening to the dnsports.
void listen_resume (struct listen_dnsport *listen)
 Start listening again to the dnsports.
void listen_delete (struct listen_dnsport *listen)
 delete the listening structure
void listen_list_delete (struct listen_list *list)
 delete listen_list of commpoints.
size_t listen_get_mem (struct listen_dnsport *listen)
 get memory size used by the listening structs
int create_udp_sock (int family, int socktype, struct sockaddr *addr, socklen_t addrlen, int v6only, int *inuse, int *noproto)
 Create and bind nonblocking UDP socket.
int create_tcp_accept_sock (struct addrinfo *addr, int v6only, int *noproto)
 Create and bind TCP listening socket.


Detailed Description

This file has functions to get queries from clients.


Enumeration Type Documentation

type of ports

Enumerator:
listen_type_udp  udp type
listen_type_tcp  tcp type
listen_type_udpancil  udp ipv6 (v4mapped) for use with ancillary data


Function Documentation

struct listen_port* listening_ports_open ( struct config_file cfg  )  [read]

Create shared listening ports Getaddrinfo, create socket, bind and listen to zero or more interfaces for IP4 and/or IP6, for UDP and/or TCP.

On the given port number. It creates the sockets.

Parameters:
cfg,: settings on what ports to open.
Returns:
: linked list of ports or NULL on error.

References config_file::do_ip4, config_file::do_ip6, config_file::do_tcp, config_file::do_udp, config_file::if_automatic, config_file::ifs, config_file::incoming_num_tcp, listening_ports_free(), log_warn(), config_file::num_ifs, config_file::port, ports_create_if(), and str_is_ip6().

Referenced by daemon_open_shared_ports().

struct listen_dnsport* listen_create ( struct comm_base base,
struct listen_port ports,
size_t  bufsize,
int  tcp_accept_count,
comm_point_callback_t cb,
void *  cb_arg 
) [read]

Create commpoints with for this thread for the shared ports.

Parameters:
base,: the comm_base that provides event functionality. for default all ifs.
ports,: the list of shared ports.
bufsize,: size of datagram buffer.
tcp_accept_count,: max number of simultaneous TCP connections from clients.
cb,: callback function when a request arrives. It is passed the packet and user argument. Return true to send a reply.
cb_arg,: user data argument for callback function.
Returns:
: the malloced listening structure, ready for use. NULL on error.

References listen_dnsport::base, replay_runtime::bufsize, replay_runtime::callback_query, replay_runtime::cb_arg, comm_point_create_tcp(), comm_point_create_udp(), comm_point_create_udp_ancil(), comm_point_delete(), listen_dnsport::cps, comm_point::do_not_close, listen_port::fd, listen_port::ftype, listen_cp_insert(), listen_delete(), listen_type_tcp, listen_type_udp, listen_type_udpancil, log_err(), listen_port::next, and listen_dnsport::udp_buff.

Referenced by worker_init().

void listen_pushback ( struct listen_dnsport listen  ) 

Stop listening to the dnsports.

Ports are still open but not checked for readability - performs pushback of the load.

Parameters:
listen,: the listening structs to stop listening on. Note that udp and tcp-accept handlers stop, but ongoing tcp-handlers are kept going, since its rude to 'reset connection by peer' them, instead, we keep them and the callback will be called when its ready. It can be dropped at that time. New tcp and udp queries can be served by other threads.

References listen_list::com, comm_point_stop_listening(), listen_dnsport::cps, log_assert, listen_list::next, and comm_point::type.

void listen_resume ( struct listen_dnsport listen  ) 

Start listening again to the dnsports.

Call after the listen_pushback has been called.

Parameters:
listen,: the listening structs to stop listening on.

References listen_list::com, comm_point_start_listening(), listen_dnsport::cps, log_assert, listen_list::next, and comm_point::type.

void listen_delete ( struct listen_dnsport listen  ) 

delete the listening structure

Parameters:
listen,: listening structure.

References listen_dnsport::cps, listen_list_delete(), and listen_dnsport::udp_buff.

Referenced by listen_create(), and worker_delete().

void listen_list_delete ( struct listen_list list  ) 

delete listen_list of commpoints.

Calls commpointdelete() on items. This may close the fds or not depending on flags.

Parameters:
list,: to delete.

References listen_list::com, comm_point_delete(), and listen_list::next.

Referenced by daemon_remote_clear(), and listen_delete().

size_t listen_get_mem ( struct listen_dnsport listen  ) 

get memory size used by the listening structs

Parameters:
listen,: listening structure.
Returns:
: size in bytes.

References listen_dnsport::base, listen_list::com, comm_point_get_mem(), listen_dnsport::cps, listen_list::next, and listen_dnsport::udp_buff.

Referenced by worker_mem_report().

int create_udp_sock ( int  family,
int  socktype,
struct sockaddr *  addr,
socklen_t  addrlen,
int  v6only,
int *  inuse,
int *  noproto 
)

Create and bind nonblocking UDP socket.

Parameters:
family,: for socket call.
socktype,: for socket call.
addr,: for bind call.
addrlen,: for bind call.
v6only,: if enabled, IP6 sockets get IP6ONLY option set. if enabled with value 2 IP6ONLY option is disabled.
inuse,: on error, this is set true if the port was in use.
noproto,: on error, this is set true if cause is that the IPv6 proto (family) is not available.
Returns:
: the socket. -1 on error.

References fd_set_nonblock(), and log_err().

Referenced by make_sock(), and udp_sockport().

int create_tcp_accept_sock ( struct addrinfo *  addr,
int  v6only,
int *  noproto 
)

Create and bind TCP listening socket.

Parameters:
addr,: address info ready to make socket.
v6only,: enable ip6 only flag on ip6 sockets.
noproto,: if error caused by lack of protocol support.
Returns:
: the socket. -1 on error.

References fd_set_nonblock(), log_err(), TCP_BACKLOG, and verbose_print_addr().

Referenced by add_open(), and make_sock().


Generated on Tue Oct 13 06:46:31 2009 for unbound by  doxygen 1.5.9