OpenVPN
Data Structures | Macros | Functions | Variables
socket.c File Reference
#include "syshead.h"
#include "socket.h"
#include "fdmisc.h"
#include "misc.h"
#include "gremlin.h"
#include "plugin.h"
#include "ps.h"
#include "run_command.h"
#include "manage.h"
#include "openvpn.h"
#include "forward.h"
#include "memdbg.h"
Include dependency graph for socket.c:

Go to the source code of this file.

Data Structures

struct  proto_names
 

Macros

#define IF_NAMESIZE   16
 
#define UINT8_MAX   0xff
 

Functions

static unsigned int sf2gaf (const unsigned int getaddr_flags, const unsigned int sockflags)
 
static int get_addr_generic (sa_family_t af, unsigned int flags, const char *hostname, void *network, unsigned int *netbits, int resolve_retry_seconds, struct signal_info *sig_info, int msglevel)
 
in_addr_t getaddr (unsigned int flags, const char *hostname, int resolve_retry_seconds, bool *succeeded, struct signal_info *sig_info)
 Translate an IPv4 addr or hostname from string form to in_addr_t. More...
 
bool get_ipv6_addr (const char *hostname, struct in6_addr *network, unsigned int *netbits, int msglevel)
 Translate an IPv6 addr or hostname from string form to in6_addr. More...
 
static bool streqnull (const char *a, const char *b)
 
static int get_cached_dns_entry (struct cached_dns_entry *dns_cache, const char *hostname, const char *servname, int ai_family, int resolve_flags, struct addrinfo **ai)
 
static int do_preresolve_host (struct context *c, const char *hostname, const char *servname, const int af, const int flags)
 
void do_preresolve (struct context *c)
 
int openvpn_getaddrinfo (unsigned int flags, const char *hostname, const char *servname, int resolve_retry_seconds, struct signal_info *sig_info, int ai_family, struct addrinfo **res)
 
int openvpn_inet_aton (const char *dotted_quad, struct in_addr *addr)
 
bool ip_addr_dotted_quad_safe (const char *dotted_quad)
 
bool ipv6_addr_safe (const char *ipv6_text_addr)
 
static bool dns_addr_safe (const char *addr)
 
bool ip_or_dns_addr_safe (const char *addr, const bool allow_fqdn)
 
bool mac_addr_safe (const char *mac_addr)
 
static int socket_get_sndbuf (socket_descriptor_t sd)
 
static void socket_set_sndbuf (socket_descriptor_t sd, int size)
 
static int socket_get_rcvbuf (socket_descriptor_t sd)
 
static bool socket_set_rcvbuf (socket_descriptor_t sd, int size)
 
static void socket_set_buffers (socket_descriptor_t fd, const struct socket_buffer_size *sbs)
 
static bool socket_set_tcp_nodelay (socket_descriptor_t sd, int state)
 
static void socket_set_mark (socket_descriptor_t sd, int mark)
 
static bool socket_set_flags (socket_descriptor_t sd, unsigned int sockflags)
 
bool link_socket_update_flags (struct link_socket *ls, unsigned int sockflags)
 
void link_socket_update_buffer_sizes (struct link_socket *ls, int rcvbuf, int sndbuf)
 
socket_descriptor_t create_socket_tcp (struct addrinfo *addrinfo)
 
static socket_descriptor_t create_socket_udp (struct addrinfo *addrinfo, const unsigned int flags)
 
static void bind_local (struct link_socket *sock, const sa_family_t ai_family)
 
static void create_socket (struct link_socket *sock, struct addrinfo *addr)
 
static void socket_do_listen (socket_descriptor_t sd, const struct addrinfo *local, bool do_listen, bool do_set_nonblock)
 
socket_descriptor_t socket_do_accept (socket_descriptor_t sd, struct link_socket_actual *act, const bool nowait)
 
static void tcp_connection_established (const struct link_socket_actual *act)
 
static socket_descriptor_t socket_listen_accept (socket_descriptor_t sd, struct link_socket_actual *act, const char *remote_dynamic, const struct addrinfo *local, bool do_listen, bool nowait, volatile int *signal_received)
 
void socket_bind (socket_descriptor_t sd, struct addrinfo *local, int ai_family, const char *prefix, bool ipv6only)
 
int openvpn_connect (socket_descriptor_t sd, const struct sockaddr *remote, int connect_timeout, volatile int *signal_received)
 
void set_actual_address (struct link_socket_actual *actual, struct addrinfo *ai)
 
static void socket_connect (socket_descriptor_t *sd, const struct sockaddr *dest, const int connect_timeout, struct signal_info *sig_info)
 
static void stream_buf_init (struct stream_buf *sb, struct buffer *buf, const unsigned int sockflags, const int proto)
 
static void stream_buf_close (struct stream_buf *sb)
 
static bool stream_buf_added (struct stream_buf *sb, int length_added)
 
static void socket_frame_init (const struct frame *frame, struct link_socket *sock)
 
static void resolve_bind_local (struct link_socket *sock, const sa_family_t af)
 
static void resolve_remote (struct link_socket *sock, int phase, const char **remote_dynamic, struct signal_info *sig_info)
 
struct link_socketlink_socket_new (void)
 
void link_socket_init_phase1 (struct context *c, int mode)
 
static void phase2_set_socket_flags (struct link_socket *sock)
 
static void linksock_print_addr (struct link_socket *sock)
 
static void phase2_tcp_server (struct link_socket *sock, const char *remote_dynamic, struct signal_info *sig_info)
 
static void phase2_tcp_client (struct link_socket *sock, struct signal_info *sig_info)
 
static void phase2_socks_client (struct link_socket *sock, struct signal_info *sig_info)
 
static void create_socket_dco_win (struct context *c, struct link_socket *sock, struct signal_info *sig_info)
 
void link_socket_init_phase2 (struct context *c)
 
void link_socket_close (struct link_socket *sock)
 
void setenv_trusted (struct env_set *es, const struct link_socket_info *info)
 
static void ipchange_fmt (const bool include_cmd, struct argv *argv, const struct link_socket_info *info, struct gc_arena *gc)
 
void link_socket_connection_initiated (struct link_socket_info *info, const struct link_socket_actual *act, const char *common_name, struct env_set *es)
 
void link_socket_bad_incoming_addr (struct buffer *buf, const struct link_socket_info *info, const struct link_socket_actual *from_addr)
 
void link_socket_bad_outgoing_addr (void)
 
in_addr_t link_socket_current_remote (const struct link_socket_info *info)
 
const struct in6_addr * link_socket_current_remote_ipv6 (const struct link_socket_info *info)
 
const char * socket_stat (const struct link_socket *s, unsigned int rwflags, struct gc_arena *gc)
 
static void stream_buf_reset (struct stream_buf *sb)
 
static void stream_buf_set_next (struct stream_buf *sb)
 
static void stream_buf_get_final (struct stream_buf *sb, struct buffer *buf)
 
static void stream_buf_get_next (struct stream_buf *sb, struct buffer *buf)
 
bool stream_buf_read_setup_dowork (struct link_socket *sock)
 
event_t socket_listen_event_handle (struct link_socket *s)
 
const char * print_sockaddr_ex (const struct sockaddr *sa, const char *separator, const unsigned int flags, struct gc_arena *gc)
 
const char * print_link_socket_actual (const struct link_socket_actual *act, struct gc_arena *gc)
 
const char * print_link_socket_actual_ex (const struct link_socket_actual *act, const char *separator, const unsigned int flags, struct gc_arena *gc)
 
const char * print_in_addr_t (in_addr_t addr, unsigned int flags, struct gc_arena *gc)
 
const char * print_in6_addr (struct in6_addr a6, unsigned int flags, struct gc_arena *gc)
 
const char * print_in_port_t (in_port_t port, struct gc_arena *gc)
 
struct in6_addr add_in6_addr (struct in6_addr base, uint32_t add)
 
void setenv_sockaddr (struct env_set *es, const char *name_prefix, const struct openvpn_sockaddr *addr, const unsigned int flags)
 
void setenv_in_addr_t (struct env_set *es, const char *name_prefix, in_addr_t addr, const unsigned int flags)
 
void setenv_in6_addr (struct env_set *es, const char *name_prefix, const struct in6_addr *addr, const unsigned int flags)
 
void setenv_link_socket_actual (struct env_set *es, const char *name_prefix, const struct link_socket_actual *act, const unsigned int flags)
 
int ascii2proto (const char *proto_name)
 
sa_family_t ascii2af (const char *proto_name)
 
const char * proto2ascii (int proto, sa_family_t af, bool display_form)
 
const char * proto2ascii_all (struct gc_arena *gc)
 
const char * addr_family_name (int af)
 
const char * proto_remote (int proto, bool remote)
 
void bad_address_length (int actual, int expected)
 
int link_socket_read_tcp (struct link_socket *sock, struct buffer *buf)
 
int link_socket_write_tcp (struct link_socket *sock, struct buffer *buf, struct link_socket_actual *to)
 
static int socket_get_last_error (const struct link_socket *sock)
 
int socket_recv_queue (struct link_socket *sock, int maxsize)
 
int socket_send_queue (struct link_socket *sock, struct buffer *buf, const struct link_socket_actual *to)
 
int sockethandle_finalize (sockethandle_t sh, struct overlapped_io *io, struct buffer *buf, struct link_socket_actual *from)
 
unsigned int socket_set (struct link_socket *s, struct event_set *es, unsigned int rwflags, void *arg, unsigned int *persistent)
 
void sd_close (socket_descriptor_t *sd)
 

Variables

static const struct proto_names proto_names []
 

Macro Definition Documentation

◆ IF_NAMESIZE

#define IF_NAMESIZE   16

Definition at line 2829 of file socket.c.

◆ UINT8_MAX

#define UINT8_MAX   0xff

Definition at line 2948 of file socket.c.

Function Documentation

◆ add_in6_addr()

struct in6_addr add_in6_addr ( struct in6_addr  base,
uint32_t  add 
)

Definition at line 2955 of file socket.c.

References UINT8_MAX.

Referenced by helper_client_server(), ifconfig_pool_acquire(), and ifconfig_pool_handle_to_ipv6_base().

◆ addr_family_name()

const char* addr_family_name ( int  af)

Definition at line 3167 of file socket.c.

Referenced by dco_create_socket(), link_socket_init_phase2(), and socket_bind().

◆ ascii2af()

sa_family_t ascii2af ( const char *  proto_name)

Definition at line 3114 of file socket.c.

References proto_names::proto_af, proto_names::short_form, and SIZE.

Referenced by add_option().

◆ ascii2proto()

int ascii2proto ( const char *  proto_name)

Definition at line 3100 of file socket.c.

References proto_names::proto, proto_names::short_form, and SIZE.

Referenced by add_option().

◆ bad_address_length()

void bad_address_length ( int  actual,
int  expected 
)

Definition at line 3219 of file socket.c.

References M_FATAL, and msg.

Referenced by socket_recv_queue(), and sockethandle_finalize().

◆ bind_local()

static void bind_local ( struct link_socket sock,
const sa_family_t  ai_family 
)
static

◆ create_socket()

static void create_socket ( struct link_socket sock,
struct addrinfo *  addr 
)
static

◆ create_socket_dco_win()

static void create_socket_dco_win ( struct context c,
struct link_socket sock,
struct signal_info sig_info 
)
static

◆ create_socket_tcp()

socket_descriptor_t create_socket_tcp ( struct addrinfo *  addrinfo)

Definition at line 999 of file socket.c.

References ASSERT, M_ERR, msg, and set_cloexec().

Referenced by create_socket(), man_connect(), man_listen(), and phase2_tcp_client().

◆ create_socket_udp()

static socket_descriptor_t create_socket_udp ( struct addrinfo *  addrinfo,
const unsigned int  flags 
)
static

Definition at line 1031 of file socket.c.

References ASSERT, M_ERR, msg, set_cloexec(), SF_USE_IP_PKTINFO, and SOL_IP.

Referenced by create_socket().

◆ dns_addr_safe()

static bool dns_addr_safe ( const char *  addr)
static

Definition at line 758 of file socket.c.

References CC_ALNUM, CC_DASH, CC_DOT, and string_class().

Referenced by ip_or_dns_addr_safe().

◆ do_preresolve()

void do_preresolve ( struct context c)

◆ do_preresolve_host()

static int do_preresolve_host ( struct context c,
const char *  hostname,
const char *  servname,
const int  af,
const int  flags 
)
static

◆ get_addr_generic()

static int get_addr_generic ( sa_family_t  af,
unsigned int  flags,
const char *  hostname,
void *  network,
unsigned int *  netbits,
int  resolve_retry_seconds,
struct signal_info sig_info,
int  msglevel 
)
static

Definition at line 66 of file socket.c.

References GETADDR_HOST_ORDER, M_ERRNO, M_NONFATAL, M_WARN, msg, and openvpn_getaddrinfo().

Referenced by get_ipv6_addr(), and getaddr().

◆ get_cached_dns_entry()

static int get_cached_dns_entry ( struct cached_dns_entry dns_cache,
const char *  hostname,
const char *  servname,
int  ai_family,
int  resolve_flags,
struct addrinfo **  ai 
)
static

◆ get_ipv6_addr()

bool get_ipv6_addr ( const char *  hostname,
struct in6_addr *  network,
unsigned int *  netbits,
int  msglevel 
)

Translate an IPv6 addr or hostname from string form to in6_addr.

Definition at line 211 of file socket.c.

References get_addr_generic(), and GETADDR_RESOLVE.

Referenced by add_option(), dhcp_option_dns6_parse(), ifconfig_pool_read(), init_route_ipv6(), ipv6_addr_safe_hexplusbits(), option_iroute_ipv6(), and remove_iroutes_from_push_route_list().

◆ getaddr()

in_addr_t getaddr ( unsigned int  flags,
const char *  hostname,
int  resolve_retry_seconds,
bool *  succeeded,
struct signal_info sig_info 
)

Translate an IPv4 addr or hostname from string form to in_addr_t.

In case of resolve error, it will try again for resolve_retry_seconds seconds.

Definition at line 180 of file socket.c.

References get_addr_generic(), M_WARN, and status.

Referenced by add_client_nat_to_option_list(), add_host_route_array(), add_option(), get_adapter_ip_netmask(), get_ip_addr(), ifconfig_pool_read(), init_route(), init_route_list(), init_tun(), ip_addr_string_to_array(), man_kill(), option_iroute(), and remove_iroutes_from_push_route_list().

◆ ip_addr_dotted_quad_safe()

bool ip_addr_dotted_quad_safe ( const char *  dotted_quad)

Definition at line 686 of file socket.c.

References OIA_IP, and openvpn_inet_aton().

Referenced by add_option(), dhcp_option_address_parse(), and ip_or_dns_addr_safe().

◆ ip_or_dns_addr_safe()

bool ip_or_dns_addr_safe ( const char *  addr,
const bool  allow_fqdn 
)

Definition at line 772 of file socket.c.

References dns_addr_safe(), and ip_addr_dotted_quad_safe().

Referenced by add_option().

◆ ipchange_fmt()

static void ipchange_fmt ( const bool  include_cmd,
struct argv argv,
const struct link_socket_info info,
struct gc_arena gc 
)
static

◆ ipv6_addr_safe()

bool ipv6_addr_safe ( const char *  ipv6_text_addr)

Definition at line 736 of file socket.c.

Referenced by add_option().

◆ link_socket_bad_incoming_addr()

void link_socket_bad_incoming_addr ( struct buffer buf,
const struct link_socket_info info,
const struct link_socket_actual from_addr 
)

◆ link_socket_bad_outgoing_addr()

void link_socket_bad_outgoing_addr ( void  )

Definition at line 2451 of file socket.c.

References D_READ_WRITE, and dmsg.

Referenced by link_socket_get_outgoing_addr().

◆ link_socket_close()

void link_socket_close ( struct link_socket sock)

◆ link_socket_connection_initiated()

void link_socket_connection_initiated ( struct link_socket_info info,
const struct link_socket_actual act,
const char *  common_name,
struct env_set es 
)

◆ link_socket_current_remote()

in_addr_t link_socket_current_remote ( const struct link_socket_info info)

◆ link_socket_current_remote_ipv6()

const struct in6_addr* link_socket_current_remote_ipv6 ( const struct link_socket_info info)

◆ link_socket_init_phase1()

void link_socket_init_phase1 ( struct context c,
int  mode 
)

Definition at line 1834 of file socket.c.

References context_2::accept_from, connection_entry::af, link_socket_info::af, ASSERT, link_socket::bind_dev, options::bind_dev, connection_entry::bind_ipv6_only, link_socket_info::bind_ipv6_only, connection_entry::bind_local, link_socket::bind_local, context::c1, context::c2, options::ce, context_1::dns_cache, link_socket::dns_cache, context_1::http_proxy, link_socket::http_proxy, link_socket::info, options::ipchange, link_socket_info::ipchange_command, context_2::link_socket, context_1::link_socket_addr, connection_entry::local, link_socket::local_host, connection_entry::local_port, link_socket::local_port, LS_MODE_TCP_ACCEPT_FROM, link_socket_info::lsa, link_socket::mark, options::mark, link_socket::mode, options::mode, connection_entry::mtu_discover_type, link_socket::mtu_discover_type, http_proxy_info::options, context::options, link_socket_info::plugins, context::plugins, socks_proxy_info::port, http_proxy_options::port, connection_entry::proto, link_socket_info::proto, PROTO_TCP_CLIENT, PROTO_TCP_SERVER, link_socket::proxy_dest_host, link_socket::proxy_dest_port, socket_buffer_size::rcvbuf, options::rcvbuf, connection_entry::remote, connection_entry::remote_float, link_socket_info::remote_float, link_socket::remote_host, connection_entry::remote_port, link_socket::remote_port, resolve_bind_local(), resolve_remote(), link_socket::resolve_retry_seconds, options::resolve_retry_seconds, link_socket::sd, socks_proxy_info::server, http_proxy_options::server, context_2::server_poll_interval, link_socket::server_poll_timeout, SF_PORT_SHARE, socket_buffer_size::sndbuf, options::sndbuf, link_socket::socket_buffer_sizes, link_socket::sockflags, options::sockflags, context_1::socks_proxy, and link_socket::socks_proxy.

Referenced by init_instance().

◆ link_socket_init_phase2()

void link_socket_init_phase2 ( struct context c)

◆ link_socket_new()

struct link_socket* link_socket_new ( void  )

Definition at line 1823 of file socket.c.

References ALLOC_OBJ_CLEAR, link_socket::ctrl_sd, link_socket::sd, and SOCKET_UNDEFINED.

Referenced by do_link_socket_new().

◆ link_socket_read_tcp()

int link_socket_read_tcp ( struct link_socket sock,
struct buffer buf 
)

◆ link_socket_update_buffer_sizes()

void link_socket_update_buffer_sizes ( struct link_socket ls,
int  rcvbuf,
int  sndbuf 
)

◆ link_socket_update_flags()

bool link_socket_update_flags ( struct link_socket ls,
unsigned int  sockflags 
)

Definition at line 969 of file socket.c.

References link_socket::sd, socket_defined(), socket_set_flags(), and link_socket::sockflags.

Referenced by do_deferred_options().

◆ link_socket_write_tcp()

int link_socket_write_tcp ( struct link_socket sock,
struct buffer buf,
struct link_socket_actual to 
)

◆ linksock_print_addr()

static void linksock_print_addr ( struct link_socket sock)
static

◆ mac_addr_safe()

bool mac_addr_safe ( const char *  mac_addr)

Definition at line 789 of file socket.c.

Referenced by add_option().

◆ openvpn_connect()

int openvpn_connect ( socket_descriptor_t  sd,
const struct sockaddr *  remote,
int  connect_timeout,
volatile int *  signal_received 
)

◆ openvpn_getaddrinfo()

int openvpn_getaddrinfo ( unsigned int  flags,
const char *  hostname,
const char *  servname,
int  resolve_retry_seconds,
struct signal_info sig_info,
int  ai_family,
struct addrinfo **  res 
)

◆ openvpn_inet_aton()

int openvpn_inet_aton ( const char *  dotted_quad,
struct in_addr *  addr 
)

Definition at line 662 of file socket.c.

References CC_DIGIT, CC_DOT, CLEAR, OIA_ERROR, OIA_HOSTNAME, OIA_IP, and string_class().

Referenced by ip_addr_dotted_quad_safe().

◆ phase2_set_socket_flags()

static void phase2_set_socket_flags ( struct link_socket sock)
static

◆ phase2_socks_client()

static void phase2_socks_client ( struct link_socket sock,
struct signal_info sig_info 
)
static

◆ phase2_tcp_client()

static void phase2_tcp_client ( struct link_socket sock,
struct signal_info sig_info 
)
static

◆ phase2_tcp_server()

static void phase2_tcp_server ( struct link_socket sock,
const char *  remote_dynamic,
struct signal_info sig_info 
)
static

◆ print_in6_addr()

const char* print_in6_addr ( struct in6_addr  a6,
unsigned int  flags,
struct gc_arena gc 
)

◆ print_in_addr_t()

const char* print_in_addr_t ( in_addr_t  addr,
unsigned int  flags,
struct gc_arena gc 
)

◆ print_in_port_t()

const char* print_in_port_t ( in_port_t  port,
struct gc_arena gc 
)

Definition at line 2940 of file socket.c.

References alloc_buf_gc(), BSTR, and buf_printf().

Referenced by setenv_dns_options(), and show_dns_options().

◆ print_link_socket_actual()

const char* print_link_socket_actual ( const struct link_socket_actual act,
struct gc_arena gc 
)

◆ print_link_socket_actual_ex()

const char* print_link_socket_actual_ex ( const struct link_socket_actual act,
const char *  separator,
const unsigned int  flags,
struct gc_arena gc 
)

◆ print_sockaddr_ex()

const char* print_sockaddr_ex ( const struct sockaddr *  sa,
const char *  separator,
const unsigned int  flags,
struct gc_arena gc 
)

◆ proto2ascii()

const char* proto2ascii ( int  proto,
sa_family_t  af,
bool  display_form 
)

◆ proto2ascii_all()

const char* proto2ascii_all ( struct gc_arena gc)

Definition at line 3150 of file socket.c.

References alloc_buf_gc(), BSTR, buf_printf(), and SIZE.

Referenced by add_option().

◆ proto_remote()

const char* proto_remote ( int  proto,
bool  remote 
)

Definition at line 3191 of file socket.c.

References ASSERT, PROTO_N, PROTO_TCP_CLIENT, PROTO_TCP_SERVER, and PROTO_UDP.

Referenced by options_string().

◆ resolve_bind_local()

static void resolve_bind_local ( struct link_socket sock,
const sa_family_t  af 
)
static

◆ resolve_remote()

static void resolve_remote ( struct link_socket sock,
int  phase,
const char **  remote_dynamic,
struct signal_info sig_info 
)
static

◆ sd_close()

void sd_close ( socket_descriptor_t sd)

Definition at line 3915 of file socket.c.

References openvpn_close_socket, socket_defined(), and SOCKET_UNDEFINED.

Referenced by man_accept(), and man_connect().

◆ set_actual_address()

void set_actual_address ( struct link_socket_actual actual,
struct addrinfo *  ai 
)

◆ setenv_in6_addr()

void setenv_in6_addr ( struct env_set es,
const char *  name_prefix,
const struct in6_addr *  addr,
const unsigned int  flags 
)

◆ setenv_in_addr_t()

void setenv_in_addr_t ( struct env_set es,
const char *  name_prefix,
in_addr_t  addr,
const unsigned int  flags 
)

◆ setenv_link_socket_actual()

void setenv_link_socket_actual ( struct env_set es,
const char *  name_prefix,
const struct link_socket_actual act,
const unsigned int  flags 
)

Definition at line 3060 of file socket.c.

References link_socket_actual::dest, es, and setenv_sockaddr().

Referenced by setenv_trusted(), and setenv_untrusted().

◆ setenv_sockaddr()

void setenv_sockaddr ( struct env_set es,
const char *  name_prefix,
const struct openvpn_sockaddr addr,
const unsigned int  flags 
)

◆ setenv_trusted()

void setenv_trusted ( struct env_set es,
const struct link_socket_info info 
)

◆ sf2gaf()

static unsigned int sf2gaf ( const unsigned int  getaddr_flags,
const unsigned int  sockflags 
)
static

Definition at line 49 of file socket.c.

References GETADDR_RANDOMIZE, and SF_HOST_RANDOMIZE.

Referenced by resolve_remote().

◆ socket_bind()

void socket_bind ( socket_descriptor_t  sd,
struct addrinfo *  local,
int  ai_family,
const char *  prefix,
bool  ipv6only 
)

◆ socket_connect()

static void socket_connect ( socket_descriptor_t sd,
const struct sockaddr *  dest,
const int  connect_timeout,
struct signal_info sig_info 
)
static

◆ socket_do_accept()

socket_descriptor_t socket_do_accept ( socket_descriptor_t  sd,
struct link_socket_actual act,
const bool  nowait 
)

◆ socket_do_listen()

static void socket_do_listen ( socket_descriptor_t  sd,
const struct addrinfo *  local,
bool  do_listen,
bool  do_set_nonblock 
)
static

Definition at line 1187 of file socket.c.

References ASSERT, gc_free(), gc_new(), M_ERR, M_INFO, msg, print_sockaddr(), and set_nonblock().

Referenced by phase2_tcp_server(), and socket_listen_accept().

◆ socket_frame_init()

static void socket_frame_init ( const struct frame frame,
struct link_socket sock 
)
static

◆ socket_get_last_error()

static int socket_get_last_error ( const struct link_socket sock)
static

Definition at line 3505 of file socket.c.

References socket_is_dco_win().

Referenced by socket_recv_queue(), and socket_send_queue().

◆ socket_get_rcvbuf()

static int socket_get_rcvbuf ( socket_descriptor_t  sd)
static

Definition at line 864 of file socket.c.

Referenced by socket_set_buffers().

◆ socket_get_sndbuf()

static int socket_get_sndbuf ( socket_descriptor_t  sd)
static

Definition at line 836 of file socket.c.

Referenced by socket_set_buffers().

◆ socket_listen_accept()

static socket_descriptor_t socket_listen_accept ( socket_descriptor_t  sd,
struct link_socket_actual act,
const char *  remote_dynamic,
const struct addrinfo *  local,
bool  do_listen,
bool  nowait,
volatile int *  signal_received 
)
static

◆ socket_listen_event_handle()

event_t socket_listen_event_handle ( struct link_socket s)

◆ socket_recv_queue()

int socket_recv_queue ( struct link_socket sock,
int  maxsize 
)

◆ socket_send_queue()

int socket_send_queue ( struct link_socket sock,
struct buffer buf,
const struct link_socket_actual to 
)

◆ socket_set()

unsigned int socket_set ( struct link_socket s,
struct event_set es,
unsigned int  rwflags,
void *  arg,
unsigned int *  persistent 
)

◆ socket_set_buffers()

static void socket_set_buffers ( socket_descriptor_t  fd,
const struct socket_buffer_size sbs 
)
static

◆ socket_set_flags()

static bool socket_set_flags ( socket_descriptor_t  sd,
unsigned int  sockflags 
)
static

Definition at line 955 of file socket.c.

References SF_DCO_WIN, SF_TCP_NODELAY, and socket_set_tcp_nodelay().

Referenced by link_socket_update_flags(), and phase2_set_socket_flags().

◆ socket_set_mark()

static void socket_set_mark ( socket_descriptor_t  sd,
int  mark 
)
inlinestatic

Definition at line 944 of file socket.c.

References M_WARN, and msg.

Referenced by create_socket().

◆ socket_set_rcvbuf()

static bool socket_set_rcvbuf ( socket_descriptor_t  sd,
int  size 
)
static

Definition at line 881 of file socket.c.

References M_WARN, and msg.

Referenced by socket_set_buffers().

◆ socket_set_sndbuf()

static void socket_set_sndbuf ( socket_descriptor_t  sd,
int  size 
)
static

Definition at line 853 of file socket.c.

References M_WARN, and msg.

Referenced by socket_set_buffers().

◆ socket_set_tcp_nodelay()

static bool socket_set_tcp_nodelay ( socket_descriptor_t  sd,
int  state 
)
static

Definition at line 924 of file socket.c.

References D_OSBUF, dmsg, M_WARN, and msg.

Referenced by socket_set_flags().

◆ socket_stat()

const char* socket_stat ( const struct link_socket s,
unsigned int  rwflags,
struct gc_arena gc 
)

◆ sockethandle_finalize()

int sockethandle_finalize ( sockethandle_t  sh,
struct overlapped_io io,
struct buffer buf,
struct link_socket_actual from 
)

◆ stream_buf_added()

static bool stream_buf_added ( struct stream_buf sb,
int  length_added 
)
static

◆ stream_buf_close()

static void stream_buf_close ( struct stream_buf sb)
static

Definition at line 2713 of file socket.c.

References free_buf(), and stream_buf::residual.

Referenced by link_socket_close().

◆ stream_buf_get_final()

static void stream_buf_get_final ( struct stream_buf sb,
struct buffer buf 
)
inlinestatic

Definition at line 2608 of file socket.c.

References ASSERT, stream_buf::buf, buf_defined(), D_STREAM_DEBUG, dmsg, and buffer::len.

Referenced by link_socket_read_tcp().

◆ stream_buf_get_next()

static void stream_buf_get_next ( struct stream_buf sb,
struct buffer buf 
)
inlinestatic

Definition at line 2617 of file socket.c.

References ASSERT, buf_defined(), D_STREAM_DEBUG, dmsg, buffer::len, and stream_buf::next.

Referenced by link_socket_read_tcp(), and socket_recv_queue().

◆ stream_buf_init()

static void stream_buf_init ( struct stream_buf sb,
struct buffer buf,
const unsigned int  sockflags,
const int  proto 
)
static

◆ stream_buf_read_setup_dowork()

bool stream_buf_read_setup_dowork ( struct link_socket sock)

◆ stream_buf_reset()

static void stream_buf_reset ( struct stream_buf sb)
inlinestatic

◆ stream_buf_set_next()

static void stream_buf_set_next ( struct stream_buf sb)
inlinestatic

◆ streqnull()

static bool streqnull ( const char *  a,
const char *  b 
)
inlinestatic

Definition at line 224 of file socket.c.

References streq.

Referenced by get_cached_dns_entry().

◆ tcp_connection_established()

static void tcp_connection_established ( const struct link_socket_actual act)
static

Definition at line 1278 of file socket.c.

References gc_free(), gc_new(), M_INFO, msg, and print_link_socket_actual().

Referenced by phase2_tcp_server(), and socket_listen_accept().

Variable Documentation

◆ proto_names

const struct proto_names proto_names[]
static
Initial value:
= {
{"proto-uninitialized", "proto-NONE", AF_UNSPEC, PROTO_NONE},
{"udp", "UDP", AF_UNSPEC, PROTO_UDP},
{"tcp-server", "TCP_SERVER", AF_UNSPEC, PROTO_TCP_SERVER},
{"tcp-client", "TCP_CLIENT", AF_UNSPEC, PROTO_TCP_CLIENT},
{"tcp", "TCP", AF_UNSPEC, PROTO_TCP},
{"udp4", "UDPv4", AF_INET, PROTO_UDP},
{"tcp4-server", "TCPv4_SERVER", AF_INET, PROTO_TCP_SERVER},
{"tcp4-client", "TCPv4_CLIENT", AF_INET, PROTO_TCP_CLIENT},
{"tcp4", "TCPv4", AF_INET, PROTO_TCP},
{"udp6", "UDPv6", AF_INET6, PROTO_UDP},
{"tcp6-server", "TCPv6_SERVER", AF_INET6, PROTO_TCP_SERVER},
{"tcp6-client", "TCPv6_CLIENT", AF_INET6, PROTO_TCP_CLIENT},
{"tcp6", "TCPv6", AF_INET6, PROTO_TCP},
}

Definition at line 3080 of file socket.c.

PROTO_TCP_SERVER
@ PROTO_TCP_SERVER
Definition: socket.h:557
PROTO_TCP_CLIENT
@ PROTO_TCP_CLIENT
Definition: socket.h:558
PROTO_NONE
@ PROTO_NONE
Definition: socket.h:554
PROTO_UDP
@ PROTO_UDP
Definition: socket.h:555
PROTO_TCP
@ PROTO_TCP
Definition: socket.h:556