Go to the documentation of this file.
45 unsigned long tmp = strtoul(port_str, &endptr, 10);
46 if (errno || *endptr !=
'\0' || tmp == 0 || tmp > UINT16_MAX)
50 *port = (in_port_t)tmp;
62 char addrcopy[INET6_ADDRSTRLEN] = {0};
67 char *first_colon = strchr(addr,
':');
68 char *last_colon = strrchr(addr,
':');
70 if (!first_colon || first_colon == last_colon)
79 copylen = first_colon - addr;
89 char *bracket = last_colon - 1;
94 copylen = bracket - addr;
102 if (copylen >=
sizeof(addrcopy))
106 strncpy(addrcopy, addr, copylen);
110 struct addrinfo *ai = NULL;
121 if (ai->ai_family == AF_INET)
123 struct sockaddr_in *sin = (
struct sockaddr_in *)ai->ai_addr;
128 struct sockaddr_in6 *sin6 = (
struct sockaddr_in6 *)ai->ai_addr;
146 entry = &((*entry)->next);
154 new->
name = *domains++;
163 const long min = pulled ? 0 : INT8_MIN;
164 const long max = INT8_MAX;
165 long prio = strtol(str, &endptr, 10);
166 if (*endptr !=
'\0' || prio < min || prio > max)
183 (*entry)->next = obj;
205 msg(msglevel,
"ERROR: dns server %ld does not have an address assigned", server->
priority);
208 server = server->
next;
223 *new_domain = *domain;
224 new_entry = &new_domain->
next;
225 domain = domain->
next;
241 *new_server = *server;
243 new_entry = &new_server->
next;
244 server = server->
next;
254 memset(&clone, 0,
sizeof(clone));
275 while (server && server_pp)
281 server_pp->
next = server;
289 server_pp = server_pp->
next;
291 entry = &server->
next;
344 const char *format,
int i,
int j,
348 bool name_ok =
false;
352 name_ok = snprintf(name,
sizeof(name), format, i);
356 name_ok = snprintf(name,
sizeof(name), format, i, j);
361 msg(
M_WARN,
"WARNING: dns option setenv name buffer overflow");
380 for (i = 1, s = o->
servers; s != NULL; i++, s = s->
next)
403 for (j = 1, d = s->
domains; d != NULL; j++, d = d->
next)
443 const char *fmt_port;
447 fmt_port =
" address = %s:%s";
452 fmt_port =
" address = [%s]:%s";
487 domain = domain->
next;
491 server = server->
next;
498 while (search_domain)
501 search_domain = search_domain->
next;
static const char * dnssec_value(const enum dns_security dnssec)
static struct gc_arena gc_new(void)
static struct dns_server * clone_dns_servers(const struct dns_server *server, struct gc_arena *gc)
void dns_options_postprocess_pull(struct dns_options *o)
Merges pulled DNS servers with static ones into an ordered list.
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.
void dns_domain_list_append(struct dns_domain **entry, char **domains, struct gc_arena *gc)
Appends DNS domain parameters to a linked list.
bool dns_options_verify(int msglevel, const struct dns_options *o)
Checks validity of DNS options.
static const char * transport_value(const enum dns_server_transport transport)
enum dns_server_transport transport
static void setenv_dns_option(struct env_set *es, const char *format, int i, int j, const char *value)
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)
struct dns_server * servers
struct dns_server * servers_prepull
unsigned short sa_family_t
const char * print_in6_addr(struct in6_addr a6, unsigned int flags, struct gc_arena *gc)
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 re...
union dns_server_addr::@0 in
void dns_options_preprocess_pull(struct dns_options *o)
Saves and resets the server options, so that pulled ones don't mix in.
#define ALLOC_OBJ_CLEAR_GC(dptr, type, gc)
struct dns_domain * domains
static bool dns_server_port_parse(in_port_t *port, char *port_str)
Parses a string as port and stores it.
struct dns_domain * search_domains
struct dns_server_addr addr[8]
const char * print_in_addr_t(in_addr_t addr, unsigned int flags, struct gc_arena *gc)
Garbage collection arena used to keep track of dynamically allocated memory.
void setenv_str(struct env_set *es, const char *name, const char *value)
const char * print_in_port_t(in_port_t port, struct gc_arena *gc)
struct dns_options clone_dns_options(const struct dns_options o, struct gc_arena *gc)
Makes a deep copy of the passed DNS options.
void setenv_dns_options(const struct dns_options *o, struct env_set *es)
Puts the DNS options into an environment set.
static void gc_free(struct gc_arena *a)
void show_dns_options(const struct dns_options *o)
Prints configured DNS options.
bool dns_server_priority_parse(long *priority, const char *str, bool pulled)
Parses a string DNS server priority and validates it.
static struct dns_domain * clone_dns_domains(const struct dns_domain *domain, struct gc_arena *gc)