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 IPV6_V6ONLY   27
 
#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, volatile int *signal_received, int msglevel)
 
in_addr_t getaddr (unsigned int flags, const char *hostname, int resolve_retry_seconds, bool *succeeded, volatile int *signal_received)
 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, volatile int *signal_received, 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 (int sd)
 
static void socket_set_sndbuf (int sd, int size)
 
static int socket_get_rcvbuf (int sd)
 
static bool socket_set_rcvbuf (int sd, int size)
 
static void socket_set_buffers (int fd, const struct socket_buffer_size *sbs)
 
static bool socket_set_tcp_nodelay (int sd, int state)
 
static void socket_set_mark (int sd, int mark)
 
static bool socket_set_flags (int 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)
 
void frame_adjust_path_mtu (struct frame *frame, int pmtu, int proto)
 
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, volatile int *signal_received)
 
struct link_socketlink_socket_new (void)
 
void link_socket_init_phase1 (struct link_socket *sock, const char *local_host, const char *local_port, const char *remote_host, const char *remote_port, struct cached_dns_entry *dns_cache, int proto, sa_family_t af, bool bind_ipv6_only, int mode, const struct link_socket *accept_from, struct http_proxy_info *http_proxy, struct socks_proxy_info *socks_proxy, bool bind_local, bool remote_float, int inetd, struct link_socket_addr *lsa, const char *ipchange_command, const struct plugin_list *plugins, int resolve_retry_seconds, int mtu_discover_type, int rcvbuf, int sndbuf, int mark, struct event_timeout *server_poll_timeout, unsigned int sockflags)
 
static void phase2_inetd (struct link_socket *sock, const struct frame *frame, const char *remote_dynamic, volatile int *signal_received)
 
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, volatile int *signal_received)
 
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)
 
void link_socket_init_phase2 (struct link_socket *sock, const struct frame *frame, struct signal_info *sig_info)
 
void link_socket_close (struct link_socket *sock)
 
void socket_adjust_frame_parameters (struct frame *frame, int proto)
 
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 (const struct buffer *buf, 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)
 
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)
 
bool proto_is_net (int proto)
 
bool proto_is_dgram (int proto)
 
bool proto_is_udp (int proto)
 
bool proto_is_tcp (int proto)
 
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)
 
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 socket_finalize (SOCKET s, 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

const int proto_overhead []
 
static const struct proto_names proto_names []
 

Macro Definition Documentation

◆ IF_NAMESIZE

#define IF_NAMESIZE   16

Definition at line 2898 of file socket.c.

Referenced by print_link_socket_actual_ex().

◆ IPV6_V6ONLY

#define IPV6_V6ONLY   27

Definition at line 1371 of file socket.c.

Referenced by socket_bind().

◆ UINT8_MAX

#define UINT8_MAX   0xff

Definition at line 3007 of file socket.c.

Referenced by add_in6_addr().

Function Documentation

◆ add_in6_addr()

struct in6_addr add_in6_addr ( struct in6_addr  base,
uint32_t  add 
)

Definition at line 3014 of file socket.c.

References add(), and 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 3261 of file socket.c.

Referenced by link_socket_init_phase2(), and socket_bind().

◆ ascii2af()

sa_family_t ascii2af ( const char *  proto_name)

Definition at line 3208 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 3194 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 3313 of file socket.c.

References M_FATAL, and msg.

Referenced by link_socket_read_tcp(), socket_finalize(), and socket_recv_queue().

◆ 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_tcp()

socket_descriptor_t create_socket_tcp ( struct addrinfo *  addrinfo)

Definition at line 1000 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 1032 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 761 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

◆ frame_adjust_path_mtu()

void frame_adjust_path_mtu ( struct frame frame,
int  pmtu,
int  proto 
)

Definition at line 1670 of file socket.c.

References datagram_overhead(), frame_set_mtu_dynamic(), and SET_MTU_UPPER_BOUND.

Referenced by check_fragment_dowork().

◆ 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,
volatile int *  signal_received,
int  msglevel 
)
static

Definition at line 79 of file socket.c.

References free, GETADDR_HOST_ORDER, in_addr_t, 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 224 of file socket.c.

References get_addr_generic(), and GETADDR_RESOLVE.

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

◆ getaddr()

in_addr_t getaddr ( unsigned int  flags,
const char *  hostname,
int  resolve_retry_seconds,
bool succeeded,
volatile int *  signal_received 
)

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 193 of file socket.c.

References get_addr_generic(), in_addr_t, 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 689 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 775 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 739 of file socket.c.

References inet_pton().

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 2520 of file socket.c.

References D_READ_WRITE, dmsg, and in_addr_t.

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 ( const struct buffer buf,
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 link_socket sock,
const char *  local_host,
const char *  local_port,
const char *  remote_host,
const char *  remote_port,
struct cached_dns_entry dns_cache,
int  proto,
sa_family_t  af,
bool  bind_ipv6_only,
int  mode,
const struct link_socket accept_from,
struct http_proxy_info http_proxy,
struct socks_proxy_info socks_proxy,
bool  bind_local,
bool  remote_float,
int  inetd,
struct link_socket_addr lsa,
const char *  ipchange_command,
const struct plugin_list plugins,
int  resolve_retry_seconds,
int  mtu_discover_type,
int  rcvbuf,
int  sndbuf,
int  mark,
struct event_timeout server_poll_timeout,
unsigned int  sockflags 
)

◆ link_socket_init_phase2()

void link_socket_init_phase2 ( struct link_socket sock,
const struct frame frame,
struct signal_info sig_info 
)

◆ link_socket_new()

struct link_socket* link_socket_new ( void  )

Definition at line 1845 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 971 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 792 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,
volatile int *  signal_received,
int  ai_family,
struct addrinfo **  res 
)

◆ openvpn_inet_aton()

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

Definition at line 665 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_inetd()

static void phase2_inetd ( struct link_socket sock,
const struct frame frame,
const char *  remote_dynamic,
volatile int *  signal_received 
)
static

◆ 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,
volatile int *  signal_received 
)
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_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 3244 of file socket.c.

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

Referenced by add_option().

◆ proto_is_dgram()

bool proto_is_dgram ( int  proto)

◆ proto_is_net()

bool proto_is_net ( int  proto)

Definition at line 3159 of file socket.c.

References ASSERT, PROTO_N, and PROTO_NONE.

Referenced by options_postprocess_verify_ce().

◆ proto_is_tcp()

bool proto_is_tcp ( int  proto)

◆ proto_is_udp()

bool proto_is_udp ( int  proto)

◆ proto_remote()

const char* proto_remote ( int  proto,
bool  remote 
)

Definition at line 3285 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,
volatile int *  signal_received 
)
static

◆ sd_close()

void sd_close ( socket_descriptor_t sd)

◆ 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 3119 of file socket.c.

References link_socket_actual::dest, 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 62 of file socket.c.

References GETADDR_RANDOMIZE, and SF_HOST_RANDOMIZE.

Referenced by resolve_remote().

◆ socket_adjust_frame_parameters()

void socket_adjust_frame_parameters ( struct frame frame,
int  proto 
)

◆ 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 1167 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_finalize()

int socket_finalize ( SOCKET  s,
struct overlapped_io io,
struct buffer buf,
struct link_socket_actual from 
)

◆ socket_frame_init()

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

◆ socket_get_rcvbuf()

static int socket_get_rcvbuf ( int  sd)
static

Definition at line 867 of file socket.c.

Referenced by socket_set_buffers().

◆ socket_get_sndbuf()

static int socket_get_sndbuf ( int  sd)
static

Definition at line 839 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 ( int  fd,
const struct socket_buffer_size sbs 
)
static

◆ socket_set_flags()

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

Definition at line 958 of file socket.c.

References 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 ( int  sd,
int  mark 
)
inlinestatic

Definition at line 947 of file socket.c.

References M_WARN, and msg.

Referenced by create_socket().

◆ socket_set_rcvbuf()

static bool socket_set_rcvbuf ( int  sd,
int  size 
)
static

Definition at line 884 of file socket.c.

References M_WARN, and msg.

Referenced by socket_set_buffers().

◆ socket_set_sndbuf()

static void socket_set_sndbuf ( int  sd,
int  size 
)
static

Definition at line 856 of file socket.c.

References M_WARN, and msg.

Referenced by socket_set_buffers().

◆ socket_set_tcp_nodelay()

static bool socket_set_tcp_nodelay ( int  sd,
int  state 
)
static

Definition at line 927 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 
)

◆ 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 2782 of file socket.c.

References free_buf(), and stream_buf::residual.

Referenced by link_socket_close(), and socket_connect().

◆ stream_buf_get_final()

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

Definition at line 2677 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 2686 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 237 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 1265 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 3139 of file socket.c.

◆ proto_overhead

const int proto_overhead[]
Initial value:
= {
0,
}
#define IPv6_UDP_HEADER_SIZE
Definition: socket.h:595
#define IPv6_TCP_HEADER_SIZE
Definition: socket.h:596
#define IPv4_UDP_HEADER_SIZE
Definition: socket.h:593
#define IPv4_TCP_HEADER_SIZE
Definition: socket.h:594

Definition at line 47 of file socket.c.

Referenced by datagram_overhead().