OpenVPN
|
#include "buffer.h"
#include "common.h"
#include "error.h"
#include "proto.h"
#include "mtu.h"
#include "win32.h"
#include "event.h"
#include "proxy.h"
#include "socks.h"
#include "misc.h"
Go to the source code of this file.
Data Structures | |
struct | openvpn_sockaddr |
struct | cached_dns_entry |
struct | link_socket_actual |
struct | link_socket_addr |
struct | link_socket_info |
struct | stream_buf |
struct | socket_buffer_size |
struct | link_socket |
Typedefs | |
typedef uint16_t | packet_size_type |
Enumerations | |
enum | proto_num { PROTO_NONE, PROTO_UDP, PROTO_TCP, PROTO_TCP_SERVER, PROTO_TCP_CLIENT, PROTO_N } |
Functions | |
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) |
struct link_socket * | link_socket_new (void) |
void | socket_bind (socket_descriptor_t sd, struct addrinfo *local, int af_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 | link_socket_init_phase1 (struct context *c, int mode) |
void | link_socket_init_phase2 (struct context *c) |
void | do_preresolve (struct context *c) |
void | socket_adjust_frame_parameters (struct frame *frame, int proto) |
void | frame_adjust_path_mtu (struct frame *frame, int pmtu, int proto) |
void | link_socket_close (struct link_socket *sock) |
void | sd_close (socket_descriptor_t *sd) |
const char * | print_sockaddr_ex (const struct sockaddr *addr, const char *separator, const unsigned int flags, struct gc_arena *gc) |
static const char * | print_openvpn_sockaddr_ex (const struct openvpn_sockaddr *addr, const char *separator, const unsigned int flags, struct gc_arena *gc) |
static const char * | print_openvpn_sockaddr (const struct openvpn_sockaddr *addr, struct gc_arena *gc) |
static const char * | print_sockaddr (const struct sockaddr *addr, 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_link_socket_actual (const struct link_socket_actual *act, 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 addr6, 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) |
void | bad_address_length (int actual, int expected) |
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) |
void | link_socket_connection_initiated (struct link_socket_info *info, const struct link_socket_actual *addr, 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 | set_actual_address (struct link_socket_actual *actual, struct addrinfo *ai) |
void | link_socket_bad_outgoing_addr (void) |
void | setenv_trusted (struct env_set *es, const struct link_socket_info *info) |
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) |
int | openvpn_inet_aton (const char *dotted_quad, struct in_addr *addr) |
bool | ip_addr_dotted_quad_safe (const char *dotted_quad) |
bool | ip_or_dns_addr_safe (const char *addr, const bool allow_fqdn) |
bool | mac_addr_safe (const char *mac_addr) |
bool | ipv6_addr_safe (const char *ipv6_text_addr) |
socket_descriptor_t | create_socket_tcp (struct addrinfo *) |
socket_descriptor_t | socket_do_accept (socket_descriptor_t sd, struct link_socket_actual *act, const bool nowait) |
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... | |
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) |
static bool | proto_is_net (int proto) |
static bool | proto_is_udp (int proto) |
Returns if the protocol being used is UDP. More... | |
static bool | proto_is_dgram (int proto) |
Return if the protocol is datagram (UDP) More... | |
static bool | proto_is_tcp (int proto) |
returns if the proto is a TCP variant (tcp-server, tcp-client or tcp) More... | |
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 * | proto_remote (int proto, bool remote) |
const char * | addr_family_name (int af) |
static int | datagram_overhead (int proto) |
static bool | link_socket_proto_connection_oriented (int proto) |
static bool | link_socket_connection_oriented (const struct link_socket *sock) |
static bool | addr_defined (const struct openvpn_sockaddr *addr) |
static bool | addr_local (const struct sockaddr *addr) |
static bool | addr_defined_ipi (const struct link_socket_actual *lsa) |
static bool | link_socket_actual_defined (const struct link_socket_actual *act) |
static bool | addr_match (const struct openvpn_sockaddr *a1, const struct openvpn_sockaddr *a2) |
static bool | addrlist_match (const struct openvpn_sockaddr *a1, const struct addrinfo *addrlist) |
static in_addr_t | addr_host (const struct openvpn_sockaddr *addr) |
static bool | addrlist_port_match (const struct openvpn_sockaddr *a1, const struct addrinfo *a2) |
static bool | addr_port_match (const struct openvpn_sockaddr *a1, const struct openvpn_sockaddr *a2) |
static bool | addr_match_proto (const struct openvpn_sockaddr *a1, const struct openvpn_sockaddr *a2, const int proto) |
static bool | addrlist_match_proto (const struct openvpn_sockaddr *a1, struct addrinfo *addr_list, const int proto) |
static void | addr_zero_host (struct openvpn_sockaddr *addr) |
static void | addr_copy_sa (struct openvpn_sockaddr *dst, const struct openvpn_sockaddr *src) |
static bool | addr_inet4or6 (struct sockaddr *addr) |
int | addr_guess_family (sa_family_t af, const char *name) |
static int | af_addr_size (sa_family_t af) |
static bool | link_socket_actual_match (const struct link_socket_actual *a1, const struct link_socket_actual *a2) |
static bool | socket_connection_reset (const struct link_socket *sock, int status) |
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_get_outgoing_addr (struct buffer *buf, const struct link_socket_info *info, struct link_socket_actual **act) |
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) |
bool | stream_buf_read_setup_dowork (struct link_socket *sock) |
static bool | stream_buf_read_setup (struct link_socket *sock) |
int | link_socket_read_tcp (struct link_socket *sock, struct buffer *buf) |
static int | link_socket_read_udp_win32 (struct link_socket *sock, struct buffer *buf, struct link_socket_actual *from) |
static int | link_socket_read (struct link_socket *sock, struct buffer *buf, struct link_socket_actual *from) |
int | link_socket_write_tcp (struct link_socket *sock, struct buffer *buf, struct link_socket_actual *to) |
static int | link_socket_write_win32 (struct link_socket *sock, struct buffer *buf, struct link_socket_actual *to) |
static size_t | link_socket_write_udp (struct link_socket *sock, struct buffer *buf, struct link_socket_actual *to) |
static int | link_socket_write (struct link_socket *sock, struct buffer *buf, struct link_socket_actual *to) |
static bool | socket_read_residual (const struct link_socket *s) |
static event_t | socket_event_handle (const struct link_socket *s) |
event_t | socket_listen_event_handle (struct link_socket *s) |
unsigned int | socket_set (struct link_socket *s, struct event_set *es, unsigned int rwflags, void *arg, unsigned int *persistent) |
static void | socket_set_listen_persistent (struct link_socket *s, struct event_set *es, void *arg) |
static void | socket_reset_listen_persistent (struct link_socket *s) |
const char * | socket_stat (const struct link_socket *s, unsigned int rwflags, struct gc_arena *gc) |
Variables | |
const int | proto_overhead [] |
#define GETADDR_CACHE_MASK (GETADDR_DATAGRAM|GETADDR_PASSIVE) |
Definition at line 484 of file socket.h.
Referenced by do_preresolve_host(), and get_cached_dns_entry().
#define GETADDR_DATAGRAM (1<<11) |
Definition at line 482 of file socket.h.
Referenced by do_preresolve(), openvpn_getaddrinfo(), resolve_bind_local(), and resolve_remote().
#define GETADDR_FATAL (1<<1) |
Definition at line 472 of file socket.h.
Referenced by do_preresolve(), get_ip_addr(), init_tun(), man_settings_init(), openvpn_getaddrinfo(), resolve_bind_local(), and resolve_remote().
#define GETADDR_FATAL_ON_SIGNAL (1<<4) |
Definition at line 475 of file socket.h.
Referenced by init_tun(), and openvpn_getaddrinfo().
#define GETADDR_HOST_ORDER (1<<2) |
Definition at line 473 of file socket.h.
Referenced by add_host_route_array(), add_option(), get_adapter_ip_netmask(), get_addr_generic(), get_ip_addr(), ifconfig_pool_read(), init_route(), init_route_list(), init_tun(), ip_addr_string_to_array(), man_kill(), openvpn_getaddrinfo(), option_iroute(), and remove_iroutes_from_push_route_list().
#define GETADDR_MENTION_RESOLVE_RETRY (1<<3) |
Definition at line 474 of file socket.h.
Referenced by do_preresolve(), openvpn_getaddrinfo(), and resolve_remote().
#define GETADDR_MSG_VIRT_OUT (1<<6) |
Definition at line 477 of file socket.h.
Referenced by man_kill(), and openvpn_getaddrinfo().
#define GETADDR_PASSIVE (1<<10) |
Definition at line 481 of file socket.h.
Referenced by do_preresolve(), man_settings_init(), management_post_tunnel_open(), openvpn_getaddrinfo(), and resolve_bind_local().
#define GETADDR_RANDOMIZE (1<<9) |
Definition at line 480 of file socket.h.
Referenced by do_preresolve(), openvpn_getaddrinfo(), and sf2gaf().
#define GETADDR_RESOLVE (1<<0) |
Definition at line 471 of file socket.h.
Referenced by add_option(), do_preresolve(), get_ipv6_addr(), init_route(), init_route_list(), init_tun(), man_settings_init(), openvpn_getaddrinfo(), resolve_bind_local(), and resolve_remote().
#define GETADDR_TRY_ONCE (1<<7) |
Definition at line 478 of file socket.h.
Referenced by openvpn_getaddrinfo(), and resolve_remote().
#define GETADDR_UPDATE_MANAGEMENT_STATE (1<<8) |
Definition at line 479 of file socket.h.
Referenced by do_preresolve(), openvpn_getaddrinfo(), and resolve_remote().
#define GETADDR_WARN_ON_SIGNAL (1<<5) |
Definition at line 476 of file socket.h.
Referenced by init_route(), init_route_list(), man_settings_init(), openvpn_getaddrinfo(), and resolve_bind_local().
#define htonps | ( | x | ) | htons(x) |
Definition at line 58 of file socket.h.
Referenced by link_socket_write_tcp().
#define IA_EMPTY_IF_UNDEF (1<<0) |
Definition at line 357 of file socket.h.
Referenced by do_close_tun(), do_open_tun(), log_entry_print(), mroute_addr_print_ex(), multi_print_status(), print_in6_addr(), and print_in_addr_t().
#define IA_NET_ORDER (1<<1) |
Definition at line 358 of file socket.h.
Referenced by format_route_entry(), mroute_addr_print_ex(), print_client_nat_list(), print_in_addr_t(), print_pkt(), tuntap_dhcp_mask(), and tuntap_set_ptp().
#define IPV4_INVALID_ADDR 0xffffffff |
Definition at line 392 of file socket.h.
Referenced by init_route_list(), link_socket_current_remote(), and redirect_default_route_to_vpn().
#define LS_MODE_DEFAULT 0 |
Definition at line 191 of file socket.h.
Referenced by init_instance(), and phase2_tcp_server().
#define LS_MODE_TCP_ACCEPT_FROM 2 |
Definition at line 193 of file socket.h.
Referenced by init_instance(), link_socket_init_phase1(), linksock_print_addr(), multi_tcp_instance_specific_init(), and phase2_tcp_server().
#define LS_MODE_TCP_LISTEN 1 |
Definition at line 192 of file socket.h.
Referenced by init_instance(), and phase2_tcp_server().
#define MSG_NOSIGNAL 0 |
Definition at line 252 of file socket.h.
Referenced by establish_socks_proxy_passthru(), establish_socks_proxy_udpassoc(), link_socket_read_tcp(), link_socket_write_win32(), man_read(), man_write(), recv_line(), recv_socks_reply(), send_line(), socks_handshake(), and socks_username_password_auth().
#define ntohps | ( | x | ) | ntohs(x) |
Definition at line 61 of file socket.h.
Referenced by stream_buf_added().
#define OIA_ERROR -1 |
Definition at line 425 of file socket.h.
Referenced by openvpn_inet_aton().
#define OIA_HOSTNAME 0 |
Definition at line 423 of file socket.h.
Referenced by openvpn_inet_aton().
#define OIA_IP 1 |
Definition at line 424 of file socket.h.
Referenced by ip_addr_dotted_quad_safe(), and openvpn_inet_aton().
#define openvpn_close_socket | ( | s | ) | closesocket(s) |
Definition at line 257 of file socket.h.
Referenced by link_socket_close(), man_close_socket(), phase2_tcp_client(), sd_close(), socket_connect(), socket_do_accept(), and socket_listen_accept().
#define OPENVPN_PORT "1194" |
Definition at line 41 of file socket.h.
Referenced by init_options().
#define PS_DONT_SHOW_ADDR (1<<3) |
Definition at line 312 of file socket.h.
Referenced by print_sockaddr_ex().
#define PS_DONT_SHOW_FAMILY (1<<4) |
Definition at line 313 of file socket.h.
Referenced by log_entry_print(), and print_sockaddr_ex().
#define PS_SHOW_PKTINFO (1<<2) |
Definition at line 311 of file socket.h.
Referenced by print_link_socket_actual(), and print_link_socket_actual_ex().
#define PS_SHOW_PORT (1<<1) |
Definition at line 310 of file socket.h.
Referenced by ipchange_fmt(), link_socket_bad_incoming_addr(), log_entry_print(), print_link_socket_actual(), print_openvpn_sockaddr(), print_sockaddr(), print_sockaddr_ex(), and socket_bind().
#define PS_SHOW_PORT_IF_DEFINED (1<<0) |
Definition at line 309 of file socket.h.
Referenced by linksock_print_addr(), and print_sockaddr_ex().
#define RESOLV_RETRY_INFINITE 1000000000 |
Definition at line 47 of file socket.h.
Referenced by add_option(), init_options(), and resolve_remote().
#define SA_IP_PORT (1<<0) |
Definition at line 365 of file socket.h.
Referenced by setenv_sockaddr(), setenv_trusted(), and setenv_untrusted().
#define SA_SET_IF_NONZERO (1<<1) |
Definition at line 366 of file socket.h.
Referenced by multi_set_virtual_addr_env(), setenv_in6_addr(), and setenv_in_addr_t().
#define SF_GETADDRINFO_DGRAM (1<<4) |
Definition at line 207 of file socket.h.
Referenced by create_socket().
#define SF_HOST_RANDOMIZE (1<<3) |
Definition at line 206 of file socket.h.
Referenced by add_option(), do_preresolve(), and sf2gaf().
#define SF_PORT_SHARE (1<<2) |
Definition at line 205 of file socket.h.
Referenced by link_socket_init_phase1(), and stream_buf_init().
#define SF_TCP_NODELAY (1<<1) |
Definition at line 204 of file socket.h.
Referenced by add_option(), helper_tcp_nodelay(), and socket_set_flags().
#define SF_USE_IP_PKTINFO (1<<0) |
Definition at line 203 of file socket.h.
Referenced by add_option(), create_socket_udp(), link_socket_read_tcp(), and link_socket_write_win32().
typedef uint16_t packet_size_type |
enum proto_num |
struct in6_addr add_in6_addr | ( | struct in6_addr | base, |
uint32_t | add | ||
) |
Definition at line 2918 of file socket.c.
References add(), and UINT8_MAX.
Referenced by helper_client_server(), ifconfig_pool_acquire(), and ifconfig_pool_handle_to_ipv6_base().
|
inlinestatic |
Definition at line 839 of file socket.h.
References openvpn_sockaddr::addr.
Referenced by link_socket_read().
|
inlinestatic |
Definition at line 620 of file socket.h.
References openvpn_sockaddr::addr, openvpn_sockaddr::in4, openvpn_sockaddr::in6, and openvpn_sockaddr::sa.
Referenced by initialization_sequence_completed(), link_socket_actual_defined(), and log_entry_print().
|
inlinestatic |
Definition at line 658 of file socket.h.
References openvpn_sockaddr::addr, ASSERT, link_socket_actual::dest, and openvpn_sockaddr::sa.
Referenced by link_socket_write_win32(), and print_link_socket_actual_ex().
const char* addr_family_name | ( | int | af | ) |
Definition at line 3130 of file socket.c.
Referenced by link_socket_init_phase2(), proto_is_tcp(), and socket_bind().
int addr_guess_family | ( | sa_family_t | af, |
const char * | name | ||
) |
Referenced by addr_inet4or6().
|
inlinestatic |
Definition at line 735 of file socket.h.
References openvpn_sockaddr::addr, openvpn_sockaddr::in4, and openvpn_sockaddr::sa.
|
inlinestatic |
Definition at line 845 of file socket.h.
References addr_guess_family().
|
inlinestatic |
Definition at line 637 of file socket.h.
Referenced by create_socket().
|
inlinestatic |
Definition at line 691 of file socket.h.
References openvpn_sockaddr::addr, ASSERT, openvpn_sockaddr::in4, openvpn_sockaddr::in6, IN6_ARE_ADDR_EQUAL, and openvpn_sockaddr::sa.
Referenced by addr_match_proto().
|
inlinestatic |
Definition at line 803 of file socket.h.
References addr_match(), addr_port_match(), and link_socket_proto_connection_oriented().
Referenced by link_socket_set_outgoing_addr().
|
inlinestatic |
Definition at line 786 of file socket.h.
References openvpn_sockaddr::addr, ASSERT, openvpn_sockaddr::in4, openvpn_sockaddr::in6, IN6_ARE_ADDR_EQUAL, and openvpn_sockaddr::sa.
Referenced by addr_match_proto(), and link_socket_actual_match().
|
inlinestatic |
Definition at line 824 of file socket.h.
References openvpn_sockaddr::addr, openvpn_sockaddr::in4, openvpn_sockaddr::in6, and openvpn_sockaddr::sa.
Referenced by link_socket_read_tcp(), and phase2_socks_client().
|
inlinestatic |
Definition at line 706 of file socket.h.
References openvpn_sockaddr::addr, ASSERT, openvpn_sockaddr::in4, openvpn_sockaddr::in6, IN6_ARE_ADDR_EQUAL, in_addr_t, and openvpn_sockaddr::sa.
Referenced by addrlist_match_proto(), and socket_listen_accept().
|
inlinestatic |
Definition at line 814 of file socket.h.
References addrlist_match(), addrlist_port_match(), and link_socket_proto_connection_oriented().
Referenced by link_socket_set_outgoing_addr(), and link_socket_verify_incoming_addr().
|
inlinestatic |
Definition at line 751 of file socket.h.
References openvpn_sockaddr::addr, ASSERT, openvpn_sockaddr::in4, openvpn_sockaddr::in6, IN6_ARE_ADDR_EQUAL, and openvpn_sockaddr::sa.
Referenced by addrlist_match_proto().
|
inlinestatic |
Definition at line 853 of file socket.h.
References ASSERT, M_ERR, and msg.
Referenced by link_socket_read_tcp(), link_socket_write_win32(), openvpn_connect(), socket_do_accept(), socket_finalize(), and socket_recv_queue().
sa_family_t ascii2af | ( | const char * | proto_name | ) |
Definition at line 3077 of file socket.c.
References proto_names::proto_af, proto_names::short_form, and SIZE.
Referenced by add_option(), and proto_is_tcp().
int ascii2proto | ( | const char * | proto_name | ) |
Definition at line 3063 of file socket.c.
References proto_names::proto, proto_names::short_form, and SIZE.
Referenced by add_option(), and proto_is_tcp().
void bad_address_length | ( | int | actual, |
int | expected | ||
) |
Definition at line 3182 of file socket.c.
Referenced by link_socket_read_tcp(), socket_finalize(), and socket_recv_queue().
socket_descriptor_t create_socket_tcp | ( | struct addrinfo * | ) |
Definition at line 1010 of file socket.c.
References ASSERT, M_ERR, msg, and set_cloexec().
Referenced by create_socket(), man_connect(), man_listen(), and phase2_tcp_client().
|
inlinestatic |
Definition at line 590 of file socket.h.
References ASSERT, PROTO_N, and proto_overhead.
Referenced by frame_adjust_path_mtu(), and process_outgoing_link().
void do_preresolve | ( | struct context * | c | ) |
Definition at line 341 of file socket.c.
References connection_entry::af, connection_list::array, connection_entry::bind_local, options::connection_list, do_preresolve_host(), flags, GETADDR_DATAGRAM, GETADDR_FATAL, GETADDR_MENTION_RESOLVE_RETRY, GETADDR_PASSIVE, GETADDR_RANDOMIZE, GETADDR_RESOLVE, GETADDR_UPDATE_MANAGEMENT_STATE, connection_entry::http_proxy_options, options::ip_remote_hint, connection_list::len, connection_entry::local, connection_entry::local_port, context::options, http_proxy_options::port, connection_entry::proto, proto_is_dgram(), connection_entry::remote, connection_entry::remote_port, http_proxy_options::server, SF_HOST_RANDOMIZE, SIGHUP, options::sockflags, connection_entry::socks_proxy_port, connection_entry::socks_proxy_server, status, and throw_signal_soft().
Referenced by init_instance().
void frame_adjust_path_mtu | ( | struct frame * | frame, |
int | pmtu, | ||
int | proto | ||
) |
Definition at line 1664 of file socket.c.
References datagram_overhead(), frame_set_mtu_dynamic(), and SET_MTU_UPPER_BOUND.
Referenced by check_fragment().
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(), ifconfig_pool_read(), init_route_ipv6(), ipv6_addr_safe_hexplusbits(), and option_iroute_ipv6().
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().
bool ip_addr_dotted_quad_safe | ( | const char * | dotted_quad | ) |
Definition at line 699 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().
bool ip_or_dns_addr_safe | ( | const char * | addr, |
const bool | allow_fqdn | ||
) |
Definition at line 785 of file socket.c.
References dns_addr_safe(), and ip_addr_dotted_quad_safe().
Referenced by add_option().
bool ipv6_addr_safe | ( | const char * | ipv6_text_addr | ) |
Definition at line 749 of file socket.c.
Referenced by add_option().
|
inlinestatic |
Definition at line 685 of file socket.h.
References addr_defined(), and link_socket_actual::dest.
Referenced by check_ping_restart(), link_socket_current_remote(), link_socket_current_remote_ipv6(), link_socket_get_outgoing_addr(), link_socket_verify_incoming_addr(), process_outgoing_link(), resolve_remote(), tls_multi_process(), tls_update_remote_addr(), and write_control_auth().
|
inlinestatic |
Definition at line 872 of file socket.h.
References addr_port_match(), stream_buf::buf, link_socket_actual::dest, link_socket_connection_oriented(), link_socket::sd, and link_socket::stream_buf.
Referenced by handle_data_channel_packet(), multi_get_create_instance_udp(), tls_pre_decrypt(), and tls_update_remote_addr().
void link_socket_bad_incoming_addr | ( | struct buffer * | buf, |
const struct link_socket_info * | info, | ||
const struct link_socket_actual * | from_addr | ||
) |
Definition at line 2394 of file socket.c.
References openvpn_sockaddr::addr, D_LINK_ERRORS, link_socket_actual::dest, gc_free(), gc_new(), buffer::len, link_socket_info::lsa, msg, print_link_socket_actual(), print_sockaddr_ex(), PS_SHOW_PORT, link_socket_addr::remote_list, and openvpn_sockaddr::sa.
Referenced by process_incoming_link_part1().
void link_socket_bad_outgoing_addr | ( | void | ) |
Definition at line 2423 of file socket.c.
References D_READ_WRITE, dmsg, and in_addr_t.
Referenced by link_socket_get_outgoing_addr().
void link_socket_close | ( | struct link_socket * | sock | ) |
Definition at line 2259 of file socket.c.
References close_net_event_win32(), link_socket::ctrl_sd, D_LOW, free, free_buf(), link_socket::listen_handle, M_ERRNO, M_WARN, msg, openvpn_close_socket, overlapped_io_close(), link_socket::reads, link_socket::sd, socket_defined(), SOCKET_UNDEFINED, link_socket::stream_buf, stream_buf_close(), link_socket::stream_buf_data, and link_socket::writes.
Referenced by do_close_link_socket().
void link_socket_connection_initiated | ( | struct link_socket_info * | info, |
const struct link_socket_actual * | addr, | ||
const char * | common_name, | ||
struct env_set * | es | ||
) |
Definition at line 2343 of file socket.c.
References link_socket_addr::actual, alloc_buf_gc(), argv_free(), argv_new(), BSTR, buf_printf(), link_socket_info::connection_established, gc_free(), gc_new(), link_socket_info::ipchange_command, ipchange_fmt(), link_socket_info::lsa, M_INFO, M_WARN, msg, OPENVPN_PLUGIN_FUNC_SUCCESS, OPENVPN_PLUGIN_IPCHANGE, openvpn_run_script(), plugin_call(), plugin_defined(), link_socket_info::plugins, print_link_socket_actual(), setenv_str(), and setenv_trusted().
Referenced by link_socket_set_outgoing_addr().
|
inlinestatic |
Definition at line 607 of file socket.h.
References link_socket::info, link_socket_proto_connection_oriented(), and link_socket_info::proto.
Referenced by check_tls_errors(), link_socket_actual_match(), process_incoming_link_part1(), socket_connection_reset(), socket_frame_init(), and stream_buf_read_setup().
in_addr_t link_socket_current_remote | ( | const struct link_socket_info * | info | ) |
Definition at line 2429 of file socket.c.
References link_socket_addr::actual, openvpn_sockaddr::addr, link_socket_addr::current_remote, link_socket_actual::dest, openvpn_sockaddr::in4, IPV4_INVALID_ADDR, link_socket_actual_defined(), link_socket_info::lsa, and openvpn_sockaddr::sa.
Referenced by do_init_route_list().
const struct in6_addr* link_socket_current_remote_ipv6 | ( | const struct link_socket_info * | info | ) |
Definition at line 2464 of file socket.c.
References link_socket_addr::actual, openvpn_sockaddr::addr, link_socket_addr::current_remote, link_socket_actual::dest, openvpn_sockaddr::in6, link_socket_actual_defined(), link_socket_info::lsa, and openvpn_sockaddr::sa.
Referenced by do_init_route_ipv6_list().
|
inlinestatic |
Definition at line 951 of file socket.h.
References link_socket_addr::actual, buffer::len, link_socket_actual_defined(), link_socket_bad_outgoing_addr(), and link_socket_info::lsa.
Referenced by encrypt_sign().
void link_socket_init_phase1 | ( | struct context * | c, |
int | mode | ||
) |
Definition at line 1851 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().
void link_socket_init_phase2 | ( | struct context * | c | ) |
Definition at line 2146 of file socket.c.
References link_socket_addr::actual, openvpn_sockaddr::addr, addr_family_name(), link_socket_info::af, ASSERT, link_socket_addr::bind_local, link_socket::bind_local, context::c2, create_socket(), link_socket_addr::current_remote, link_socket_actual::dest, context_2::frame, link_socket::info, context_2::link_socket, linksock_print_addr(), link_socket_info::lsa, M_WARN, msg, phase2_set_socket_flags(), phase2_socks_client(), phase2_tcp_client(), phase2_tcp_server(), link_socket_info::proto, PROTO_TCP_CLIENT, PROTO_TCP_SERVER, PROTO_UDP, link_socket::remote_host, resolve_remote(), link_socket::resolve_retry_seconds, openvpn_sockaddr::sa, link_socket::sd, context::sig, signal_info::signal_received, SIGUSR1, socket_frame_init(), SOCKET_UNDEFINED, and link_socket::socks_proxy.
Referenced by init_instance().
struct link_socket* link_socket_new | ( | void | ) |
Definition at line 1840 of file socket.c.
References ALLOC_OBJ_CLEAR, link_socket::ctrl_sd, link_socket::sd, and SOCKET_UNDEFINED.
Referenced by do_link_socket_new().
|
inlinestatic |
Definition at line 601 of file socket.h.
References proto_is_dgram().
Referenced by addr_match_proto(), addrlist_match_proto(), do_init_crypto_tls(), link_socket_connection_oriented(), and socket_adjust_frame_parameters().
|
inlinestatic |
Definition at line 1036 of file socket.h.
References link_socket_addr::actual, addr_copy_sa(), ASSERT, link_socket_actual::dest, link_socket::info, link_socket_read_tcp(), link_socket_read_udp_win32(), link_socket_write_tcp(), link_socket_info::lsa, link_socket_info::proto, proto_is_tcp(), and proto_is_udp().
Referenced by read_incoming_link().
int link_socket_read_tcp | ( | struct link_socket * | sock, |
struct buffer * | buf | ||
) |
Definition at line 3194 of file socket.c.
References openvpn_sockaddr::addr, addr_zero_host(), link_socket_info::af, af_addr_size(), bad_address_length(), BLEN, BPTR, buf_forward_capacity(), buf_forward_capacity_total(), link_socket_actual::dest, ENABLE_IP_PKTINFO, HAVE_IN_PKTINFO, HAVE_IPI_SPEC_DST, link_socket::info, buffer::len, M_WARN, msg, MSG_NOSIGNAL, link_socket_info::proto, PROTO_UDP, link_socket::reads, stream_buf::residual_fully_formed, openvpn_sockaddr::sa, link_socket::sd, SF_USE_IP_PKTINFO, socket_finalize(), link_socket::sockflags, SOL_IP, link_socket::stream_buf, stream_buf_added(), stream_buf_get_final(), stream_buf_get_next(), stream_buf_reset(), and link_socket::stream_reset.
Referenced by link_socket_read(), and stream_buf_read_setup().
|
inlinestatic |
Definition at line 1019 of file socket.h.
References link_socket::reads, link_socket::sd, and socket_finalize().
Referenced by link_socket_read().
|
inlinestatic |
Definition at line 972 of file socket.h.
References link_socket_addr::actual, addr_match_proto(), addrlist_match_proto(), link_socket_info::connection_established, link_socket_actual::dest, link_socket_connection_initiated(), link_socket_info::lsa, link_socket_info::proto, link_socket_info::remote_float, link_socket_addr::remote_list, and stream_buf_read_setup_dowork().
Referenced by process_incoming_link_part2(), and tls_process().
void link_socket_update_buffer_sizes | ( | struct link_socket * | ls, |
int | rcvbuf, | ||
int | sndbuf | ||
) |
Definition at line 994 of file socket.c.
References socket_buffer_size::rcvbuf, link_socket::sd, socket_buffer_size::sndbuf, link_socket::socket_buffer_sizes, socket_defined(), and socket_set_buffers().
Referenced by do_deferred_options().
bool link_socket_update_flags | ( | struct link_socket * | ls, |
unsigned int | sockflags | ||
) |
Definition at line 981 of file socket.c.
References link_socket::sd, socket_defined(), socket_set_flags(), and link_socket::sockflags.
Referenced by do_deferred_options().
|
inlinestatic |
Definition at line 923 of file socket.h.
References openvpn_sockaddr::addr, addrlist_match_proto(), link_socket_actual::dest, buffer::len, link_socket_actual_defined(), link_socket_info::lsa, link_socket_info::proto, link_socket_info::remote_float, link_socket_addr::remote_list, and openvpn_sockaddr::sa.
Referenced by process_incoming_link_part1().
|
inlinestatic |
Definition at line 1150 of file socket.h.
References ASSERT, BPTR, link_socket::info, link_socket_write_tcp(), link_socket_write_udp(), link_socket_info::proto, proto_is_tcp(), proto_is_udp(), link_socket::sd, and openvpn_iphdr::tos.
Referenced by process_outgoing_link().
int link_socket_write_tcp | ( | struct link_socket * | sock, |
struct buffer * | buf, | ||
struct link_socket_actual * | to | ||
) |
Definition at line 3348 of file socket.c.
References openvpn_sockaddr::addr, ASSERT, BLEN, BPTR, buf_write_prepend(), D_STREAM_DEBUG, link_socket_actual::dest, dmsg, htonps, link_socket_write_win32(), stream_buf::maxlen, buffer::offset, openvpn_sockaddr::sa, link_socket::sd, and SOL_IP.
Referenced by link_socket_read(), and link_socket_write().
|
inlinestatic |
Definition at line 1137 of file socket.h.
References link_socket_write_win32().
Referenced by link_socket_write().
|
inlinestatic |
Definition at line 1075 of file socket.h.
References openvpn_sockaddr::addr, addr_defined_ipi(), af_addr_size(), BLEN, BPTR, link_socket_actual::dest, link_socket::info, MSG_NOSIGNAL, overlapped_io_active(), link_socket_info::proto, proto_is_udp(), openvpn_sockaddr::sa, link_socket::sd, SF_USE_IP_PKTINFO, socket_finalize(), socket_send_queue(), link_socket::sockflags, status, and link_socket::writes.
Referenced by link_socket_write_tcp(), and link_socket_write_udp().
bool mac_addr_safe | ( | const char * | mac_addr | ) |
Definition at line 802 of file socket.c.
Referenced by add_option().
int openvpn_connect | ( | socket_descriptor_t | sd, |
const struct sockaddr * | remote, | ||
int | connect_timeout, | ||
volatile int * | signal_received | ||
) |
Definition at line 1436 of file socket.c.
References af_addr_size(), get_signal(), management_sleep(), openvpn_errno, openvpn_fd_set(), set_nonblock(), and status.
Referenced by man_connect(), and socket_connect().
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 | ||
) |
Definition at line 442 of file socket.c.
References ASSERT, CLEAR, D_RESOLVE_ERRORS, D_SOCKET_DEBUG, dmsg, gc_free(), gc_new(), get_signal(), GETADDR_DATAGRAM, GETADDR_FATAL, GETADDR_FATAL_ON_SIGNAL, GETADDR_HOST_ORDER, GETADDR_MENTION_RESOLVE_RETRY, GETADDR_MSG_VIRT_OUT, GETADDR_PASSIVE, GETADDR_RANDOMIZE, GETADDR_RESOLVE, GETADDR_TRY_ONCE, GETADDR_UPDATE_MANAGEMENT_STATE, GETADDR_WARN_ON_SIGNAL, hostname_randomize(), M_FATAL, M_MSG_VIRT_OUT, M_WARN, management_set_state(), management_sleep(), msg, OPENVPN_STATE_RESOLVE, SIGUSR1, and status.
Referenced by do_preresolve_host(), get_addr_generic(), init_route(), man_settings_init(), management_post_tunnel_open(), resolve_bind_local(), resolve_remote(), and socket_listen_accept().
int openvpn_inet_aton | ( | const char * | dotted_quad, |
struct in_addr * | addr | ||
) |
Definition at line 675 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().
const char* print_in6_addr | ( | struct in6_addr | addr6, |
unsigned int | flags, | ||
struct gc_arena * | gc | ||
) |
Definition at line 2896 of file socket.c.
References alloc_buf_gc(), BSTR, buf_printf(), and IA_EMPTY_IF_UNDEF.
Referenced by add_route_ipv6(), delete_route_ipv6(), do_address_service(), do_ifconfig_ipv6(), do_ifconfig_setenv(), get_default_gateway_ipv6(), helper_client_server(), ifconfig_pool_init(), ifconfig_pool_list(), init_route_ipv6_list(), log_entry_print(), mroute_addr_print_ex(), mroute_extract_addr_ip(), multi_add_iroutes(), multi_client_connect_late_setup(), multi_print_status(), multi_select_virtual_addr(), netsh_delete_address_dns(), netsh_set_dns6_servers(), open_null(), prepare_push_reply(), print_default_gateway(), setenv_route_ipv6(), and show_p2mp_parms().
Definition at line 2876 of file socket.c.
References alloc_buf_gc(), BSTR, buf_printf(), CLEAR, IA_EMPTY_IF_UNDEF, and IA_NET_ORDER.
Referenced by adapter_index_of_ip(), add_route(), add_route_ipapi(), check_addr_clash(), check_subnet_conflict(), delete_route(), dhcp_extract_router_msg(), dhcp_masq_addr(), do_address_service(), do_close_tun(), do_ifconfig_ipv4(), do_ifconfig_setenv(), do_open_tun(), format_route_entry(), get_default_gateway_row(), helper_add_route(), helper_client_server(), ifconfig_options_string(), ifconfig_pool_init(), ifconfig_pool_list(), ifconfig_pool_verify_range(), ifconfig_pool_write(), ifconfig_sanity_check(), ip_addr_string_to_array(), log_entry_print(), man_kill(), man_record_peer_info(), mroute_addr_print_ex(), multi_add_iroutes(), multi_client_connect_late_setup(), multi_print_status(), multi_select_virtual_addr(), netsh_delete_address_dns(), netsh_ifconfig(), netsh_ifconfig_options(), open_null(), prepare_push_reply(), print_client_nat_list(), print_default_gateway(), print_netmask(), print_opt_route(), print_opt_route_gateway(), print_pkt(), route_string(), setenv_route_addr(), show_dhcp_option_addrs(), show_p2mp_parms(), tuntap_dhcp_mask(), tuntap_set_ip_addr(), tuntap_set_ptp(), verify_255_255_255_252(), verify_common_subnet(), and windows_route_find_if_index().
const char* print_link_socket_actual | ( | const struct link_socket_actual * | act, |
struct gc_arena * | gc | ||
) |
Definition at line 2795 of file socket.c.
References print_link_socket_actual_ex(), PS_SHOW_PKTINFO, and PS_SHOW_PORT.
Referenced by drop_if_recursive_routing(), handle_data_channel_packet(), link_socket_bad_incoming_addr(), link_socket_connection_initiated(), multi_process_float(), print_sockaddr(), process_incoming_link_part1(), process_outgoing_link(), read_control_auth(), resolve_remote(), socket_listen_accept(), tcp_connection_established(), tls_multi_process(), tls_pre_decrypt(), tls_pre_decrypt_lite(), and tls_update_remote_addr().
const char* print_link_socket_actual_ex | ( | const struct link_socket_actual * | act, |
const char * | separator, | ||
const unsigned int | flags, | ||
struct gc_arena * | gc | ||
) |
Definition at line 2805 of file socket.c.
References openvpn_sockaddr::addr, addr_defined_ipi(), alloc_buf_gc(), BSTR, buf_printf(), CLEAR, link_socket_actual::dest, IF_NAMESIZE, openvpn_sockaddr::in4, print_sockaddr_ex(), PS_SHOW_PKTINFO, and openvpn_sockaddr::sa.
Referenced by linksock_print_addr(), print_link_socket_actual(), and print_sockaddr().
|
inlinestatic |
Definition at line 332 of file socket.h.
References openvpn_sockaddr::addr, print_sockaddr_ex(), PS_SHOW_PORT, and openvpn_sockaddr::sa.
Referenced by recv_socks_reply().
|
inlinestatic |
Definition at line 322 of file socket.h.
References openvpn_sockaddr::addr, print_sockaddr_ex(), and openvpn_sockaddr::sa.
|
inlinestatic |
Definition at line 340 of file socket.h.
References flags, print_link_socket_actual(), print_link_socket_actual_ex(), print_sockaddr_ex(), and PS_SHOW_PORT.
Referenced by linksock_print_addr(), man_connect(), man_listen(), man_new_connection_post(), socket_connect(), and socket_do_listen().
const char* print_sockaddr_ex | ( | const struct sockaddr * | addr, |
const char * | separator, | ||
const unsigned int | flags, | ||
struct gc_arena * | gc | ||
) |
Definition at line 2714 of file socket.c.
References alloc_buf_gc(), ASSERT, BSTR, buf_printf(), buf_puts(), PS_DONT_SHOW_ADDR, PS_DONT_SHOW_FAMILY, PS_SHOW_PORT, PS_SHOW_PORT_IF_DEFINED, and status.
Referenced by ipchange_fmt(), link_socket_bad_incoming_addr(), log_entry_print(), print_link_socket_actual_ex(), print_openvpn_sockaddr(), print_openvpn_sockaddr_ex(), print_sockaddr(), and socket_bind().
const char* proto2ascii | ( | int | proto, |
sa_family_t | af, | ||
bool | display_form | ||
) |
Definition at line 3091 of file socket.c.
References proto_names::display_form, proto_names::proto_af, proto_names::short_form, and SIZE.
Referenced by ce_management_query_remote(), linksock_print_addr(), process_incoming_link_part1(), process_outgoing_link(), proto_is_tcp(), setenv_connection_entry(), show_connection_entry(), and x_check_status().
const char* proto2ascii_all | ( | struct gc_arena * | gc | ) |
Definition at line 3113 of file socket.c.
References alloc_buf_gc(), BSTR, buf_printf(), and SIZE.
Referenced by add_option(), and proto_is_tcp().
|
inlinestatic |
Return if the protocol is datagram (UDP)
Definition at line 551 of file socket.h.
References proto_is_udp().
Referenced by do_preresolve(), inherit_context_child(), inherit_context_top(), link_socket_proto_connection_oriented(), multi_process_signal(), options_postprocess_verify_ce(), process_received_occ_msg(), resolve_bind_local(), resolve_remote(), tunnel_server(), and update_options_ce_post().
|
inlinestatic |
Definition at line 530 of file socket.h.
References ASSERT, PROTO_N, and PROTO_NONE.
Referenced by options_postprocess_verify_ce().
|
inlinestatic |
returns if the proto is a TCP variant (tcp-server, tcp-client or tcp)
Definition at line 560 of file socket.h.
References addr_family_name(), ascii2af(), ascii2proto(), ASSERT, proto2ascii(), proto2ascii_all(), PROTO_N, proto_remote(), PROTO_TCP_CLIENT, and PROTO_TCP_SERVER.
Referenced by link_socket_read(), link_socket_write(), socket_recv_queue(), and socket_send_queue().
|
inlinestatic |
Returns if the protocol being used is UDP.
Definition at line 540 of file socket.h.
References ASSERT, PROTO_N, and PROTO_UDP.
Referenced by ce_management_query_proxy(), do_deferred_options(), do_setup_fast_io(), link_socket_read(), link_socket_write(), link_socket_write_win32(), options_postprocess_mutate_ce(), options_postprocess_verify_ce(), proto_is_dgram(), socket_recv_queue(), and socket_send_queue().
const char* proto_remote | ( | int | proto, |
bool | remote | ||
) |
Definition at line 3154 of file socket.c.
References ASSERT, PROTO_N, PROTO_TCP_CLIENT, PROTO_TCP_SERVER, and PROTO_UDP.
Referenced by options_string(), and proto_is_tcp().
void sd_close | ( | socket_descriptor_t * | sd | ) |
Definition at line 3837 of file socket.c.
References CLEAR, gc_free(), gc_new(), M_ERR, M_ERRNO, M_FATAL, msg, openvpn_close_socket, openvpn_errno, set_cloexec(), socket_defined(), SOCKET_UNDEFINED, status, and strncpynt().
Referenced by man_accept(), and man_connect().
void set_actual_address | ( | struct link_socket_actual * | actual, |
struct addrinfo * | ai | ||
) |
Definition at line 1532 of file socket.c.
References openvpn_sockaddr::addr, ASSERT, CLEAR, link_socket_actual::dest, openvpn_sockaddr::in4, and openvpn_sockaddr::in6.
Referenced by resolve_remote().
void setenv_in6_addr | ( | struct env_set * | es, |
const char * | name_prefix, | ||
const struct in6_addr * | addr, | ||
const unsigned int | flags | ||
) |
Definition at line 3007 of file socket.c.
References openvpn_sockaddr::addr, CLEAR, openvpn_sockaddr::in6, SA_SET_IF_NONZERO, and setenv_sockaddr().
Referenced by multi_set_virtual_addr_env().
void setenv_in_addr_t | ( | struct env_set * | es, |
const char * | name_prefix, | ||
in_addr_t | addr, | ||
const unsigned int | flags | ||
) |
Definition at line 2994 of file socket.c.
References openvpn_sockaddr::addr, CLEAR, openvpn_sockaddr::in4, SA_SET_IF_NONZERO, and setenv_sockaddr().
Referenced by multi_set_virtual_addr_env().
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 3023 of file socket.c.
References link_socket_actual::dest, and setenv_sockaddr().
Referenced by setenv_trusted(), and setenv_untrusted().
void setenv_sockaddr | ( | struct env_set * | es, |
const char * | name_prefix, | ||
const struct openvpn_sockaddr * | addr, | ||
const unsigned int | flags | ||
) |
Definition at line 2941 of file socket.c.
References openvpn_sockaddr::addr, openvpn_sockaddr::in4, openvpn_sockaddr::in6, openvpn_snprintf(), openvpn_sockaddr::sa, SA_IP_PORT, setenv_int(), and setenv_str().
Referenced by setenv_in6_addr(), setenv_in_addr_t(), and setenv_link_socket_actual().
void setenv_trusted | ( | struct env_set * | es, |
const struct link_socket_info * | info | ||
) |
Definition at line 2321 of file socket.c.
References link_socket_addr::actual, link_socket_info::lsa, SA_IP_PORT, and setenv_link_socket_actual().
Referenced by link_socket_connection_initiated(), multi_client_connect_setenv(), and multi_client_disconnect_setenv().
void socket_adjust_frame_parameters | ( | struct frame * | frame, |
int | proto | ||
) |
Definition at line 2312 of file socket.c.
References frame_add_to_extra_frame(), and link_socket_proto_connection_oriented().
Referenced by do_init_crypto_tls(), and do_init_frame().
void socket_bind | ( | socket_descriptor_t | sd, |
struct addrinfo * | local, | ||
int | af_family, | ||
const char * | prefix, | ||
bool | ipv6only | ||
) |
Definition at line 1382 of file socket.c.
References addr_family_name(), ASSERT, gc_free(), gc_new(), M_ERRNO, M_FATAL, M_INFO, M_NONFATAL, msg, print_sockaddr_ex(), and PS_SHOW_PORT.
Referenced by bind_local(), and man_listen().
|
inlinestatic |
Definition at line 901 of file socket.h.
References stream_buf::error, link_socket_connection_oriented(), openvpn_errno, link_socket::stream_buf, and link_socket::stream_reset.
Referenced by read_incoming_link().
socket_descriptor_t socket_do_accept | ( | socket_descriptor_t | sd, |
struct link_socket_actual * | act, | ||
const bool | nowait | ||
) |
Definition at line 1216 of file socket.c.
References openvpn_sockaddr::addr, af_addr_size(), CLEAR, D_LINK_ERRORS, link_socket_actual::dest, M_ERRNO, msg, openvpn_close_socket, openvpn_sockaddr::sa, set_cloexec(), socket_defined(), and SOCKET_UNDEFINED.
Referenced by man_accept(), phase2_tcp_server(), and socket_listen_accept().
|
inlinestatic |
Definition at line 1211 of file socket.h.
References link_socket::rw_handle, link_socket::sd, socket_listen_event_handle(), and socket_set().
Referenced by multi_tcp_dereference_instance(), and socket_set().
int socket_finalize | ( | SOCKET | s, |
struct overlapped_io * | io, | ||
struct buffer * | buf, | ||
struct link_socket_actual * | from | ||
) |
Definition at line 3668 of file socket.c.
References openvpn_sockaddr::addr, overlapped_io::addr, overlapped_io::addr6, overlapped_io::addr_defined, overlapped_io::addrlen, af_addr_size(), ASSERT, bad_address_length(), overlapped_io::buf, CLEAR, D_WIN32_IO, link_socket_actual::dest, dmsg, overlapped_io::flags, openvpn_sockaddr::in4, openvpn_sockaddr::in6, overlapped_io::iostate, IOSTATE_IMMEDIATE_RETURN, IOSTATE_INITIAL, IOSTATE_QUEUED, buffer::len, M_ERRNO, msg, overlapped_io::overlapped, overlapped_io::size, status, and overlapped_io::status.
Referenced by link_socket_read_tcp(), link_socket_read_udp_win32(), and link_socket_write_win32().
event_t socket_listen_event_handle | ( | struct link_socket * | s | ) |
Definition at line 2696 of file socket.c.
References defined_net_event_win32(), init_net_event_win32(), link_socket::listen_handle, and link_socket::sd.
Referenced by socket_event_handle(), and socket_set_listen_persistent().
|
inlinestatic |
Definition at line 1205 of file socket.h.
References stream_buf::residual_fully_formed, and link_socket::stream_buf.
Referenced by io_wait_dowork(), and multi_tcp_post().
int socket_recv_queue | ( | struct link_socket * | sock, |
int | maxsize | ||
) |
Definition at line 3450 of file socket.c.
References overlapped_io::addr, overlapped_io::addr6, overlapped_io::addr_defined, overlapped_io::addrlen, link_socket_info::af, af_addr_size(), ASSERT, bad_address_length(), BLEN, BSTR, overlapped_io::buf, overlapped_io::buf_init, D_WIN32_IO, dmsg, overlapped_io::flags, gc_free(), gc_new(), link_socket::info, overlapped_io::iostate, IOSTATE_IMMEDIATE_RETURN, IOSTATE_INITIAL, IOSTATE_QUEUED, overlapped_io::overlapped, link_socket_info::proto, proto_is_tcp(), proto_is_udp(), link_socket::reads, link_socket::sd, overlapped_io::size, status, overlapped_io::status, link_socket::stream_buf, stream_buf_get_next(), and strerror_win32().
Referenced by socket_set().
|
inlinestatic |
Definition at line 1242 of file socket.h.
References link_socket::listen_handle, reset_net_event_win32(), link_socket::sd, and socket_stat().
Referenced by multi_tcp_process_io().
int socket_send_queue | ( | struct link_socket * | sock, |
struct buffer * | buf, | ||
const struct link_socket_actual * | to | ||
) |
Definition at line 3560 of file socket.c.
References openvpn_sockaddr::addr, overlapped_io::addr, overlapped_io::addr6, overlapped_io::addr_defined, overlapped_io::addrlen, ASSERT, BLEN, BSTR, overlapped_io::buf, buf_copy(), overlapped_io::buf_init, D_WIN32_IO, link_socket_actual::dest, dmsg, overlapped_io::flags, gc_free(), gc_new(), openvpn_sockaddr::in4, openvpn_sockaddr::in6, link_socket::info, overlapped_io::iostate, IOSTATE_IMMEDIATE_RETURN, IOSTATE_INITIAL, IOSTATE_QUEUED, buffer::len, overlapped_io::overlapped, link_socket_info::proto, proto_is_tcp(), proto_is_udp(), openvpn_sockaddr::sa, link_socket::sd, overlapped_io::size, status, overlapped_io::status, strerror_win32(), and link_socket::writes.
Referenced by link_socket_write_win32().
unsigned int socket_set | ( | struct link_socket * | s, |
struct event_set * | es, | ||
unsigned int | rwflags, | ||
void * | arg, | ||
unsigned int * | persistent | ||
) |
Definition at line 3800 of file socket.c.
References ASSERT, event_ctl(), EVENT_READ, link_socket::rwflags_debug, socket_event_handle(), socket_recv_queue(), and stream_buf_read_setup().
Referenced by io_wait_dowork(), multi_tcp_set_global_rw_flags(), and socket_event_handle().
|
inlinestatic |
Definition at line 1230 of file socket.h.
References event_ctl(), EVENT_READ, link_socket::listen_persistent_queued, and socket_listen_event_handle().
Referenced by multi_tcp_wait().
const char* socket_stat | ( | const struct link_socket * | s, |
unsigned int | rwflags, | ||
struct gc_arena * | gc | ||
) |
Definition at line 2497 of file socket.c.
References alloc_buf_gc(), BSTR, buf_printf(), EVENT_READ, EVENT_WRITE, overlapped_io_state_ascii(), link_socket::reads, link_socket::rwflags_debug, and link_socket::writes.
Referenced by socket_reset_listen_persistent().
|
inlinestatic |
Definition at line 997 of file socket.h.
References link_socket_connection_oriented(), link_socket_read_tcp(), and stream_buf_read_setup_dowork().
Referenced by multi_tcp_dispatch(), and socket_set().
bool stream_buf_read_setup_dowork | ( | struct link_socket * | sock | ) |
Definition at line 2598 of file socket.c.
References ASSERT, stream_buf::buf, buf_copy(), buf_init, D_STREAM_DEBUG, dmsg, buffer::len, stream_buf::residual, stream_buf::residual_fully_formed, link_socket::stream_buf, stream_buf_added(), and stream_buf_set_next().
Referenced by link_socket_set_outgoing_addr(), and stream_buf_read_setup().
const int proto_overhead[] |
Definition at line 47 of file socket.c.
Referenced by datagram_overhead().