OpenVPN
Functions
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.

Functions

bool sockets_read_residual (const struct context *c)
 
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, msglvl_t 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.
 
bool get_ipv6_addr (const char *hostname, struct in6_addr *network, unsigned int *netbits, msglvl_t msglevel)
 Translate an IPv6 addr or hostname from string form to in6_addr.
 
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, unsigned int resolve_flags, struct addrinfo **ai)
 
static int do_preresolve_host (struct context *c, const char *hostname, const char *servname, const int af, const unsigned int flags)
 
void do_preresolve (struct context *c)
 
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 void socket_set_rcvbuf (socket_descriptor_t sd, int size)
 
void socket_set_buffers (socket_descriptor_t fd, const struct socket_buffer_size *sbs, bool reduce_size)
 Sets the receive and send buffer sizes of a socket descriptor.
 
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 *sock, unsigned int sockflags)
 
void link_socket_update_buffer_sizes (struct link_socket *sock, 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 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)
 This will determine if sb->buf contains a full packet.
 
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, struct signal_info *sig_info)
 
struct link_socketlink_socket_new (void)
 
void link_socket_init_phase1 (struct context *c, int sock_index, 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, 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, struct link_socket *sock)
 
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)
 resets the stream buffer to be set up for the next round of reassembling a packet
 
static struct buffer stream_buf_get_next (struct stream_buf *sb)
 Return a buffer that is backed by the same backend as sb->buf that determines where the next read should be done by also having the right offset into sb->buf.
 
static void stream_buf_get_final (struct stream_buf *sb, struct buffer *buf)
 Sets the parameter buf to the current buffer of sb->buf.
 
bool stream_buf_read_setup_dowork (struct stream_buf *sb)
 Will try to check if the buffers in stream form a full packet.
 
event_t socket_listen_event_handle (struct link_socket *s)
 
void bad_address_length (int actual, int expected)
 
int link_socket_read_tcp (struct link_socket *sock, struct buffer *buf)
 
ssize_t 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)
 
void read_sockaddr_from_overlapped (struct overlapped_io *io, struct sockaddr *dst, int overlapped_ret)
 
static int read_sockaddr_from_packet (struct buffer *buf, struct sockaddr *dst)
 Extracts a sockaddr from a packet payload.
 
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)
 

Function Documentation

◆ bad_address_length()

void bad_address_length ( int  actual,
int  expected 
)

Definition at line 2258 of file socket.c.

References buffer::len, M_FATAL, and msg.

Referenced by read_sockaddr_from_overlapped(), 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_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 564 of file socket.c.

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

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

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

Referenced by create_socket().

◆ 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 unsigned 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,
msglvl_t  msglevel 
)
static

Definition at line 77 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,
unsigned int  resolve_flags,
struct addrinfo **  ai 
)
static

◆ get_ipv6_addr()

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

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

Definition at line 222 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 195 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().

◆ ipchange_fmt()

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

◆ 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 1949 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  sock_index,
int  mode 
)

Definition at line 1343 of file socket.c.

References context_2::accept_from, connection_entry::af, link_socket_info::af, local_list::array, ASSERT, options::bind_dev, link_socket::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, CM_CHILD_TCP, CM_CHILD_UDP, 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_1::link_socket_addrs, context_2::link_sockets, local_entry::local, link_socket::local_host, connection_entry::local_list, link_socket::local_port, LS_MODE_TCP_ACCEPT_FROM, link_socket_info::lsa, options::mark, link_socket::mark, context::mode, link_socket::mode, connection_entry::mtu_discover_type, link_socket::mtu_discover_type, context::options, http_proxy_info::options, context::plugins, link_socket_info::plugins, local_entry::port, http_proxy_options::port, socks_proxy_info::port, local_entry::proto, connection_entry::proto, link_socket_info::proto, PROTO_TCP_CLIENT, PROTO_TCP_SERVER, link_socket::proxy_dest_host, link_socket::proxy_dest_port, options::rcvbuf, socket_buffer_size::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(), options::resolve_retry_seconds, link_socket::resolve_retry_seconds, link_socket::sd, http_proxy_options::server, socks_proxy_info::server, context_2::server_poll_interval, link_socket::server_poll_timeout, SF_PORT_SHARE, options::sndbuf, socket_buffer_size::sndbuf, link_socket::socket_buffer_sizes, options::sockflags, link_socket::sockflags, context_1::socks_proxy, and link_socket::socks_proxy.

Referenced by do_init_socket_phase1().

◆ link_socket_init_phase2()

void link_socket_init_phase2 ( struct context c,
struct link_socket sock 
)

◆ link_socket_new()

struct link_socket * link_socket_new ( void  )

◆ 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 sock,
int  rcvbuf,
int  sndbuf 
)

◆ link_socket_update_flags()

bool link_socket_update_flags ( struct link_socket sock,
unsigned int  sockflags 
)

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

ssize_t 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

◆ openvpn_connect()

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

◆ 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,
struct signal_info sig_info 
)
static

◆ read_sockaddr_from_overlapped()

void read_sockaddr_from_overlapped ( struct overlapped_io io,
struct sockaddr *  dst,
int  overlapped_ret 
)

◆ read_sockaddr_from_packet()

static int read_sockaddr_from_packet ( struct buffer buf,
struct sockaddr *  dst 
)
static

Extracts a sockaddr from a packet payload.

Reads a sockaddr structure from the start of the packet buffer and writes it to dst.

Parameters
[in]bufPacket buffer containing the payload.
[out]dstDestination buffer for the extracted sockaddr.
Returns
Length of the extracted sockaddr

Definition at line 2815 of file socket.c.

References BPTR, buf_advance(), buf_len(), M_FATAL, and msg.

Referenced by sockethandle_finalize().

◆ 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,
struct signal_info sig_info 
)
static

◆ sd_close()

void sd_close ( socket_descriptor_t sd)

Definition at line 2983 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_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 61 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 759 of file socket.c.

References ASSERT, gc, 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 2543 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 440 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 418 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 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()

void socket_set_buffers ( socket_descriptor_t  fd,
const struct socket_buffer_size sbs,
bool  reduce_size 
)

Sets the receive and send buffer sizes of a socket descriptor.

Parameters
fdThe socket to modify
sbsnew sizes.
reduce_sizeapply the new size even if smaller than current one

Definition at line 462 of file socket.c.

References D_OSBUF, msg, socket_buffer_size::rcvbuf, socket_buffer_size::sndbuf, socket_get_rcvbuf(), socket_get_sndbuf(), socket_set_rcvbuf(), and socket_set_sndbuf().

Referenced by create_socket(), link_socket_update_buffer_sizes(), and open_tun_afunix().

◆ socket_set_flags()

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

Definition at line 520 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 509 of file socket.c.

References M_WARN, and msg.

Referenced by create_socket().

◆ socket_set_rcvbuf()

static void socket_set_rcvbuf ( socket_descriptor_t  sd,
int  size 
)
static

Definition at line 453 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 431 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 489 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 
)

◆ sockets_read_residual()

bool sockets_read_residual ( const struct context c)

◆ stream_buf_added()

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

This will determine if sb->buf contains a full packet.

It will also move anything in sb->buf beyond a full packet to sb->residual.

The first time the function is called with a valid buffer and port sharing is enabled, the function will also determine if the buffer contains OpenVPN protocol data and store the result in sb->port_share_state.

If a packet outside the allowed range is detected, the error state on sb is set.

Since the buffer in sb->buf is modified from the outside (via stream_buf_get_next) the parameter length_added needs to be set to the amount of bytes that have been written to this buffer. If the buffer was not modified but should still be analysed and potentially split to sb->residual, the parameter length_added should be 0.

Parameters
sbthe stream buffer
length_addedThe length that has been added to sb->buf
Returns
true if sb->buf contains fully reassembled packet

Definition at line 2162 of file socket.c.

References ASSERT, BLEN, buf_copy_excess(), buf_init, buf_read(), D_PS_PROXY, D_STREAM_DEBUG, dmsg, buffer::len, M_WARN, msg, ntohps, and stream_buf_reset().

Referenced by link_socket_read_tcp(), and stream_buf_read_setup_dowork().

◆ stream_buf_close()

static void stream_buf_close ( struct stream_buf sb)
static

Definition at line 2228 of file socket.c.

References free_buf(), and buffer::len.

Referenced by link_socket_close().

◆ stream_buf_get_final()

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

Sets the parameter buf to the current buffer of sb->buf.

This function assumes that caller already checked if the packet in sb->buf is fully assembled.

Parameters
sbstream buffer to operate on
bufbuffer to point to the contents of buf

Definition at line 2118 of file socket.c.

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

Referenced by link_socket_read_tcp().

◆ stream_buf_get_next()

static struct buffer stream_buf_get_next ( struct stream_buf sb)
inlinestatic

Return a buffer that is backed by the same backend as sb->buf that determines where the next read should be done by also having the right offset into sb->buf.

Parameters
sbthe stream buffer from which to construct the next buffer

Definition at line 2095 of file socket.c.

References ASSERT, buf_safe(), D_STREAM_DEBUG, dmsg, buffer::len, and buffer::offset.

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 stream_buf sb)

Will try to check if the buffers in stream form a full packet.

Will return true if further reads are required and false otherwise. (full packet is ready)

With UDP we always return true as there is no reassembly.

Parameters
sbthe stream buffer that should be worked on
Returns
true if more reads are required.

Definition at line 2126 of file socket.c.

References ASSERT, buf_copy(), buf_init, D_STREAM_DEBUG, dmsg, buffer::len, and stream_buf_added().

Referenced by stream_buf_read_setup().

◆ stream_buf_reset()

static void stream_buf_reset ( struct stream_buf sb)
inlinestatic

resets the stream buffer to be set up for the next round of reassembling a packet

But still leaves the current packet in sb->buf to be potentially read.

Definition at line 2062 of file socket.c.

References D_STREAM_DEBUG, dmsg, and buffer::len.

Referenced by link_socket_read_tcp(), stream_buf_added(), and stream_buf_init().

◆ streqnull()

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

Definition at line 235 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 847 of file socket.c.

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

Referenced by phase2_tcp_server(), and socket_listen_accept().