OpenVPN
Data Structures | Enumerations | Functions
dns.h File Reference
#include "buffer.h"
#include "env_set.h"
Include dependency graph for dns.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  dns_domain
 
struct  dns_server
 
struct  dns_options
 

Enumerations

enum  dns_domain_type { DNS_DOMAINS_UNSET, DNS_RESOLVE_DOMAINS, DNS_EXCLUDE_DOMAINS }
 
enum  dns_security { DNS_SECURITY_UNSET, DNS_SECURITY_NO, DNS_SECURITY_YES, DNS_SECURITY_OPTIONAL }
 
enum  dns_server_transport { DNS_TRANSPORT_UNSET, DNS_TRANSPORT_PLAIN, DNS_TRANSPORT_HTTPS, DNS_TRANSPORT_TLS }
 

Functions

bool dns_server_priority_parse (long *priority, const char *str, bool pulled)
 Parses a string DNS server priority and validates it. More...
 
struct dns_serverdns_server_get (struct dns_server **entry, long priority, struct gc_arena *gc)
 Find or create DNS server with priority in a linked list. More...
 
void dns_domain_list_append (struct dns_domain **entry, char **domains, struct gc_arena *gc)
 Appends DNS domain parameters to a linked list. More...
 
bool dns_server_addr_parse (struct dns_server *server, const char *addr)
 Parses a string IPv4 or IPv6 address and optional colon separated port, into a in_addr or in6_addr respectively plus a in_port_t port. More...
 
bool dns_options_verify (int msglevel, const struct dns_options *o)
 Checks validity of DNS options. More...
 
struct dns_options clone_dns_options (const struct dns_options o, struct gc_arena *gc)
 Makes a deep copy of the passed DNS options. More...
 
void dns_options_preprocess_pull (struct dns_options *o)
 Saves and resets the server options, so that pulled ones don't mix in. More...
 
void dns_options_postprocess_pull (struct dns_options *o)
 Merges pulled DNS servers with static ones into an ordered list. More...
 
void setenv_dns_options (const struct dns_options *o, struct env_set *es)
 Puts the DNS options into an environment set. More...
 
void show_dns_options (const struct dns_options *o)
 Prints configured DNS options. More...
 

Enumeration Type Documentation

◆ dns_domain_type

Enumerator
DNS_DOMAINS_UNSET 
DNS_RESOLVE_DOMAINS 
DNS_EXCLUDE_DOMAINS 

Definition at line 30 of file dns.h.

◆ dns_security

Enumerator
DNS_SECURITY_UNSET 
DNS_SECURITY_NO 
DNS_SECURITY_YES 
DNS_SECURITY_OPTIONAL 

Definition at line 36 of file dns.h.

◆ dns_server_transport

Enumerator
DNS_TRANSPORT_UNSET 
DNS_TRANSPORT_PLAIN 
DNS_TRANSPORT_HTTPS 
DNS_TRANSPORT_TLS 

Definition at line 43 of file dns.h.

Function Documentation

◆ clone_dns_options()

struct dns_options clone_dns_options ( const struct dns_options  o,
struct gc_arena gc 
)

Makes a deep copy of the passed DNS options.

Parameters
oPointer to the DNS options to clone
gcPointer to the gc_arena to use for the clone
Returns
The dns_options clone

Definition at line 248 of file dns.c.

References clone_dns_domains(), clone_dns_servers(), dns_options::gc, dns_options::search_domains, dns_options::servers, and dns_options::servers_prepull.

Referenced by pre_connect_restore(), and pre_connect_save().

◆ dns_domain_list_append()

void dns_domain_list_append ( struct dns_domain **  entry,
char **  domains,
struct gc_arena gc 
)

Appends DNS domain parameters to a linked list.

Parameters
entryAddress of the first list entry pointer
domainsAddress of the first domain parameter
gcThe gc the new list items should be allocated in

Definition at line 138 of file dns.c.

References ALLOC_OBJ_CLEAR_GC, dns_domain::name, and dns_domain::next.

Referenced by add_option().

◆ dns_options_postprocess_pull()

void dns_options_postprocess_pull ( struct dns_options o)

Merges pulled DNS servers with static ones into an ordered list.

Parameters
oPointer to the DNS options to modify

Definition at line 266 of file dns.c.

References dns_server::next, dns_server::priority, dns_options::servers, and dns_options::servers_prepull.

Referenced by options_postprocess_pull().

◆ dns_options_preprocess_pull()

void dns_options_preprocess_pull ( struct dns_options o)

Saves and resets the server options, so that pulled ones don't mix in.

Parameters
oPointer to the DNS options to modify

Definition at line 259 of file dns.c.

References dns_options::servers, and dns_options::servers_prepull.

Referenced by options_postprocess_mutate().

◆ dns_options_verify()

bool dns_options_verify ( int  msglevel,
const struct dns_options o 
)

Checks validity of DNS options.

Parameters
msglevelThe message level to log errors with
oPointer to the DNS options to validate
Returns
True if no error was found

Definition at line 194 of file dns.c.

References dns_server::addr4_defined, dns_server::addr6_defined, msg, dns_server::next, dns_server::priority, dns_options::servers, and dns_options::servers_prepull.

Referenced by options_postprocess_pull(), and options_postprocess_verify().

◆ dns_server_addr_parse()

bool dns_server_addr_parse ( struct dns_server server,
const char *  addr 
)

Parses a string IPv4 or IPv6 address and optional colon separated port, into a in_addr or in6_addr respectively plus a in_port_t port.

Parameters
serverPointer to DNS server the address is parsed for
addrAddress as string
Returns
True if parsing was successful

Definition at line 57 of file dns.c.

References dns_server::addr4, dns_server::addr4_defined, dns_server::addr6, dns_server::addr6_defined, dns_server_port_parse(), openvpn_getaddrinfo(), dns_server::port4, and dns_server::port6.

Referenced by add_option().

◆ dns_server_get()

struct dns_server* dns_server_get ( struct dns_server **  entry,
long  priority,
struct gc_arena gc 
)

Find or create DNS server with priority in a linked list.

The list is ordered by priority.

Parameters
entryAddress of the first list entry pointer
priorityPriority of the DNS server to find / create
gcThe gc new list items should be allocated in

Definition at line 172 of file dns.c.

References ALLOC_OBJ_CLEAR_GC, dns_server::next, and dns_server::priority.

Referenced by add_option().

◆ dns_server_priority_parse()

bool dns_server_priority_parse ( long *  priority,
const char *  str,
bool  pulled 
)

Parses a string DNS server priority and validates it.

Parameters
priorityPointer to where the priority should be stored
strPriority string to parse
pulledWhether this was pulled from a server
Returns
True if priority in string is valid

Definition at line 157 of file dns.c.

Referenced by add_option().

◆ setenv_dns_options()

void setenv_dns_options ( const struct dns_options o,
struct env_set es 
)

◆ show_dns_options()

void show_dns_options ( const struct dns_options o)