42#define OPENVPN_PORT "1194"
48#define RESOLV_RETRY_INFINITE 1000000000
59#define htonps(x) htons(x)
62#define ntohps(x) ntohs(x)
179#define LS_MODE_DEFAULT 0
180#define LS_MODE_TCP_LISTEN 1
181#define LS_MODE_TCP_ACCEPT_FROM 2
191#define SF_USE_IP_PKTINFO (1 << 0)
192#define SF_TCP_NODELAY (1 << 1)
193#define SF_PORT_SHARE (1 << 2)
194#define SF_HOST_RANDOMIZE (1 << 3)
195#define SF_GETADDRINFO_DGRAM (1 << 4)
196#define SF_DCO_WIN (1 << 5)
197#define SF_PREPEND_SA (1 << 6)
222#if PASSTOS_CAPABILITY
224#if defined(TARGET_LINUX)
242#define MSG_NOSIGNAL 0
247#define openvpn_close_socket(s) closesocket(s)
279 return sh.
is_handle ? (int)GetLastError() : WSAGetLastError();
285 sh.
is_handle ? SetLastError(err) : WSASetLastError(err);
291 sh.
is_handle ? SetLastError(ERROR_INVALID_FUNCTION) : WSASetLastError(WSAEINVAL);
296#define openvpn_close_socket(s) close(s)
306 volatile int *signal_received);
327#define IPV4_INVALID_ADDR 0xffffffff
334 const char *common_name,
struct env_set *
es);
362void socket_bind_unix(
socket_descriptor_t sd,
struct sockaddr_un *local,
const char *prefix);
368void sockaddr_unix_init(
struct sockaddr_un *local,
const char *path);
370const char *sockaddr_unix_name(
const struct sockaddr_un *local,
const char *null);
372void socket_delete_unix(
const struct sockaddr_un *local);
394socket_foreign_protocol_detected(
const struct link_socket *sock)
399static inline const struct buffer *
442 switch (
from_addr->dest.addr.sa.sa_family)
485 const char *common_name,
struct env_set *
es)
569 res = link_socket_read_udp_posix(sock, buf, from);
637ssize_t link_socket_write_udp_posix_sendmsg(
struct link_socket *sock,
struct buffer *buf,
649 return link_socket_write_udp_posix_sendmsg(sock, buf, to);
671 return link_socket_write_udp_posix(sock, buf, to);
695#if PASSTOS_CAPABILITY
706 sock->ptos = iph->
tos;
707 sock->ptos_defined =
true;
718 if (sock && sock->ptos_defined)
720 setsockopt(sock->
sd, IPPROTO_IP, IP_TOS, (
const void *)&sock->ptos,
sizeof(sock->ptos));
750 void *arg,
unsigned int *persistent);
static bool buf_write_prepend(struct buffer *dest, const void *src, int size)
static void event_ctl(struct event_set *es, event_t event, unsigned int rwflags, void *arg)
static SERVICE_STATUS status
void link_socket_init_phase1(struct context *c, int sock_index, int mode)
static event_t socket_event_handle(const struct link_socket *sock)
const char * socket_stat(const struct link_socket *sock, unsigned int rwflags, struct gc_arena *gc)
static BOOL SocketHandleGetOverlappedResult(sockethandle_t sh, struct overlapped_io *io)
void link_socket_init_phase2(struct context *c, struct link_socket *sock)
int socket_send_queue(struct link_socket *sock, struct buffer *buf, const struct link_socket_actual *to)
ssize_t link_socket_write_tcp(struct link_socket *sock, struct buffer *buf, struct link_socket_actual *to)
void link_socket_update_buffer_sizes(struct link_socket *sock, int rcvbuf, int sndbuf)
event_t socket_listen_event_handle(struct link_socket *sock)
const struct in6_addr * link_socket_current_remote_ipv6(const struct link_socket_info *info)
void set_actual_address(struct link_socket_actual *actual, struct addrinfo *ai)
static ssize_t link_socket_write(struct link_socket *sock, struct buffer *buf, struct link_socket_actual *to)
static void socket_set_listen_persistent(struct link_socket *sock, struct event_set *es, void *arg)
void bad_address_length(int actual, int expected)
static bool link_socket_connection_oriented(const struct link_socket *sock)
static bool stream_buf_read_setup(struct link_socket *sock)
void sd_close(socket_descriptor_t *sd)
static void socket_reset_listen_persistent(struct link_socket *sock)
static int link_socket_read_udp_win32(struct link_socket *sock, struct buffer *buf, struct link_socket_actual *from)
static void SocketHandleSetLastError(sockethandle_t sh, DWORD err)
static bool socket_connection_reset(const struct link_socket *sock, int status)
socket_descriptor_t create_socket_tcp(struct addrinfo *)
static int SocketHandleGetLastError(sockethandle_t sh)
static void SocketHandleSetInvalError(sockethandle_t sh)
bool stream_buf_read_setup_dowork(struct link_socket *sock)
socket_descriptor_t socket_do_accept(socket_descriptor_t sd, struct link_socket_actual *act, const bool nowait)
int socket_recv_queue(struct link_socket *sock, int maxsize)
void link_socket_close(struct link_socket *sock)
static bool link_socket_verify_incoming_addr(struct buffer *buf, const struct link_socket_info *info, const struct link_socket_actual *from_addr)
static void link_socket_set_outgoing_addr(struct link_socket_info *info, const struct link_socket_actual *act, const char *common_name, struct env_set *es)
static int link_socket_read(struct link_socket *sock, struct buffer *buf, struct link_socket_actual *from)
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 void link_socket_get_outgoing_addr(struct buffer *buf, const struct link_socket_info *info, struct link_socket_actual **act)
#define SF_USE_IP_PKTINFO
uint16_t packet_size_type
void link_socket_bad_outgoing_addr(void)
static bool socket_is_dco_win(const struct link_socket *s)
Returns true if we are on Windows and this link is running on DCO-WIN.
int sockethandle_finalize(sockethandle_t sh, struct overlapped_io *io, struct buffer *buf, struct link_socket_actual *from)
in_addr_t link_socket_current_remote(const struct link_socket_info *info)
int link_socket_read_tcp(struct link_socket *sock, struct buffer *buf)
int openvpn_connect(socket_descriptor_t sd, const struct sockaddr *remote, int connect_timeout, volatile int *signal_received)
void do_preresolve(struct context *c)
void link_socket_bad_incoming_addr(struct buffer *buf, const struct link_socket_info *info, const struct link_socket_actual *from_addr)
unsigned int socket_set(struct link_socket *sock, struct event_set *es, unsigned int rwflags, void *arg, unsigned int *persistent)
static ssize_t link_socket_write_udp(struct link_socket *sock, struct buffer *buf, struct link_socket_actual *to)
void socket_bind(socket_descriptor_t sd, struct addrinfo *local, int af_family, const char *prefix, bool ipv6only)
static int link_socket_write_win32(struct link_socket *sock, struct buffer *buf, struct link_socket_actual *to)
struct link_socket * link_socket_new(void)
void link_socket_connection_initiated(struct link_socket_info *info, const struct link_socket_actual *addr, const char *common_name, struct env_set *es)
bool sockets_read_residual(const struct context *c)
void setenv_trusted(struct env_set *es, const struct link_socket_info *info)
bool link_socket_update_flags(struct link_socket *sock, unsigned int sockflags)
static bool link_socket_actual_defined(const struct link_socket_actual *act)
static bool addr_match_proto(const struct openvpn_sockaddr *a1, const struct openvpn_sockaddr *a2, const int proto)
static bool proto_is_udp(int proto)
Returns if the protocol being used is UDP.
static bool proto_is_tcp(int proto)
returns if the proto is a TCP variant (tcp-server, tcp-client or tcp)
static bool addr_defined_ipi(const struct link_socket_actual *lsa)
static int af_addr_size(sa_family_t af)
static bool link_socket_proto_connection_oriented(int proto)
static bool addrlist_match_proto(const struct openvpn_sockaddr *a1, struct addrinfo *addr_list, const int proto)
Wrapper structure for dynamically allocated memory.
int len
Length in bytes of the actual content within the allocated memory.
struct cached_dns_entry * next
Contains all state information for one tunnel.
Garbage collection arena used to keep track of dynamically allocated memory.
struct openvpn_sockaddr dest
struct link_socket_actual actual
struct addrinfo * remote_list
struct addrinfo * bind_local
struct addrinfo * current_remote
bool connection_established
struct link_socket_addr * lsa
const char * ipchange_command
const struct plugin_list * plugins
struct event_timeout * server_poll_timeout
unsigned int rwflags_debug
struct socket_buffer_size socket_buffer_sizes
struct link_socket_actual socks_relay
struct rw_handle listen_handle
struct link_socket_info info
const char * proxy_dest_port
struct rw_handle rw_handle
struct overlapped_io writes
bool listen_persistent_queued
socket_descriptor_t ctrl_sd
struct stream_buf stream_buf
struct socks_proxy_info * socks_proxy
int resolve_retry_seconds
const char * proxy_dest_host
struct http_proxy_info * http_proxy
struct cached_dns_entry * dns_cache
struct buffer stream_buf_data
struct event_arg ev_arg
this struct will store a pointer to either mi or link_socket, depending on the event type,...
struct overlapped_io reads
union openvpn_sockaddr::@27 addr
bool residual_fully_formed
unsigned short sa_family_t
SOCKET socket_descriptor_t
long reset_net_event_win32(struct rw_handle *event, socket_descriptor_t sd)
static bool overlapped_io_active(struct overlapped_io *o)