|
OpenVPN
|
#include "syshead.h"#include "buffer.h"#include "crypto.h"#include "manage.h"#include "openvpn.h"#include "socket.h"#include "socket_util.h"#include "resolve.h"
Go to the source code of this file.
Macros | |
| #define | n_rnd_bytes 6 |
Functions | |
| unsigned int | sf2gaf (const unsigned int getaddr_flags, const unsigned int sockflags) |
| Convert sockflags/getaddr_flags into getaddr_flags. | |
| static const char * | getaddrinfo_addr_family_name (int af) |
| Small helper function for openvpn_getaddrinfo to print the address family when resolving fails. | |
| static const char * | hostname_randomize (const char *hostname, struct gc_arena *gc) |
| int | openvpn_getaddrinfo (unsigned int flags, const char *hostname, const char *servname, int resolve_retry_seconds, struct signal_info *sig_info, int ai_family, struct addrinfo **res) |
| 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. | |
| in_addr_t | get_ip_addr (const char *ip_string, msglvl_t msglevel, bool *error) |
| 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. | |
| 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) |
| get_cached_dns_entry return 0 on success and -1 otherwise. | |
| 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) |
| #define n_rnd_bytes 6 |
Referenced by hostname_randomize().
| void do_preresolve | ( | struct context * | c | ) |
Definition at line 573 of file resolve.c.
References connection_entry::af, connection_list::array, local_list::array, connection_entry::bind_local, options::connection_list, do_preresolve_host(), connection_entry::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, local_list::len, local_entry::local, connection_entry::local_list, context::options, http_proxy_options::port, local_entry::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().
|
static |
Definition at line 529 of file resolve.c.
References cached_dns_entry::ai, ALLOC_OBJ_CLEAR_GC, context::c1, context_1::dns_cache, cached_dns_entry::flags, context::gc, gc_addspecial(), gc_freeaddrinfo_callback(), get_cached_dns_entry(), GETADDR_CACHE_MASK, cached_dns_entry::hostname, cached_dns_entry::next, openvpn_getaddrinfo(), context::options, options::resolve_retry_seconds, cached_dns_entry::servname, and status.
Referenced by do_preresolve().
|
static |
Definition at line 324 of file resolve.c.
References GETADDR_HOST_ORDER, M_ERRNO, M_NONFATAL, M_WARN, msg, and openvpn_getaddrinfo().
Referenced by get_ipv6_addr(), and getaddr().
| 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 ) |
get_cached_dns_entry return 0 on success and -1 otherwise.
(like getaddrinfo())
Definition at line 506 of file resolve.c.
References cached_dns_entry::ai, cached_dns_entry::ai_family, cached_dns_entry::flags, GETADDR_CACHE_MASK, cached_dns_entry::hostname, cached_dns_entry::next, cached_dns_entry::servname, and streqnull().
Referenced by do_preresolve_host(), resolve_bind_local(), and resolve_remote().
Definition at line 469 of file resolve.c.
References getaddr(), GETADDR_FATAL, GETADDR_HOST_ORDER, and M_FATAL.
Referenced by add_option(), and dhcp_option_address_parse().
| 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 489 of file resolve.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().
| 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 442 of file resolve.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().
|
static |
Small helper function for openvpn_getaddrinfo to print the address family when resolving fails.
Definition at line 63 of file resolve.c.
Referenced by openvpn_getaddrinfo().
|
static |
Definition at line 82 of file resolve.c.
References alloc_buf_gc(), BSTR, buf_printf(), format_hex_ex(), gc, n_rnd_bytes, and prng_bytes().
Referenced by openvpn_getaddrinfo().
| int openvpn_getaddrinfo | ( | unsigned int | flags, |
| const char * | hostname, | ||
| const char * | servname, | ||
| int | resolve_retry_seconds, | ||
| struct signal_info * | sig_info, | ||
| int | ai_family, | ||
| struct addrinfo ** | res ) |
Definition at line 102 of file resolve.c.
References ASSERT, CLEAR, D_RESOLVE_ERRORS, D_SOCKET_DEBUG, dmsg, gc, 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, getaddrinfo_addr_family_name(), hostname_randomize(), M_FATAL, M_MSG_VIRT_OUT, M_WARN, management_set_state(), management_sleep(), msg, OPENVPN_STATE_RESOLVE, signal_info::signal_received, signal_reset(), SIGUSR1, and status.
Referenced by dns_server_addr_parse(), do_preresolve_host(), get_addr_generic(), init_route(), man_settings_init(), management_post_tunnel_open(), resolve_bind_local(), and resolve_remote().
| unsigned int sf2gaf | ( | const unsigned int | getaddr_flags, |
| const unsigned int | sockflags ) |
Convert sockflags/getaddr_flags into getaddr_flags.
Definition at line 42 of file resolve.c.
References GETADDR_RANDOMIZE, and SF_HOST_RANDOMIZE.
Referenced by resolve_remote().