OpenVPN
dns.h
Go to the documentation of this file.
1/*
2 * OpenVPN -- An application to securely tunnel IP networks
3 * over a single UDP port, with support for SSL/TLS-based
4 * session authentication and key exchange,
5 * packet encryption, packet authentication, and
6 * packet compression.
7 *
8 * Copyright (C) 2022-2024 OpenVPN Inc <sales@openvpn.net>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2
12 * as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 */
23
24#ifndef DNS_H
25#define DNS_H
26
27#include "buffer.h"
28#include "env_set.h"
29
36
43
44struct dns_domain {
46 const char *name;
47};
48
50{
51 union {
52 struct in_addr a4;
53 struct in6_addr a6;
54 } in;
56 in_port_t port;
57};
58
69
76
85bool dns_server_priority_parse(long *priority, const char *str, bool pulled);
86
95struct dns_server *dns_server_get(struct dns_server **entry, long priority, struct gc_arena *gc);
96
104void dns_domain_list_append(struct dns_domain **entry, char **domains, struct gc_arena *gc);
105
114bool dns_server_addr_parse(struct dns_server *server, const char *addr);
115
123bool dns_options_verify(int msglevel, const struct dns_options *o);
124
132struct dns_options clone_dns_options(const struct dns_options *o,
133 struct gc_arena *gc);
134
141
148
155void setenv_dns_options(const struct dns_options *o, struct env_set *es);
156
162void show_dns_options(const struct dns_options *o);
163
164#endif /* ifndef DNS_H */
bool dns_options_verify(int msglevel, const struct dns_options *o)
Checks validity of DNS options.
Definition dns.c:197
void dns_domain_list_append(struct dns_domain **entry, char **domains, struct gc_arena *gc)
Appends DNS domain parameters to a linked list.
Definition dns.c:141
void dns_options_postprocess_pull(struct dns_options *o)
Merges pulled DNS servers with static ones into an ordered list.
Definition dns.c:271
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...
Definition dns.c:55
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.
Definition dns.c:175
dns_security
Definition dns.h:30
@ DNS_SECURITY_UNSET
Definition dns.h:31
@ DNS_SECURITY_NO
Definition dns.h:32
@ DNS_SECURITY_YES
Definition dns.h:33
@ DNS_SECURITY_OPTIONAL
Definition dns.h:34
bool dns_server_priority_parse(long *priority, const char *str, bool pulled)
Parses a string DNS server priority and validates it.
Definition dns.c:160
dns_server_transport
Definition dns.h:37
@ DNS_TRANSPORT_PLAIN
Definition dns.h:39
@ DNS_TRANSPORT_UNSET
Definition dns.h:38
@ DNS_TRANSPORT_TLS
Definition dns.h:41
@ DNS_TRANSPORT_HTTPS
Definition dns.h:40
struct dns_options clone_dns_options(const struct dns_options *o, struct gc_arena *gc)
Makes a deep copy of the passed DNS options.
Definition dns.c:251
void setenv_dns_options(const struct dns_options *o, struct env_set *es)
Puts the DNS options into an environment set.
Definition dns.c:370
void show_dns_options(const struct dns_options *o)
Prints configured DNS options.
Definition dns.c:432
void dns_options_preprocess_pull(struct dns_options *o)
Saves and resets the server options, so that pulled ones don't mix in.
Definition dns.c:264
struct dns_domain * next
Definition dns.h:45
const char * name
Definition dns.h:46
struct dns_server * servers
Definition dns.h:73
struct dns_server * servers_prepull
Definition dns.h:72
struct gc_arena gc
Definition dns.h:74
struct dns_domain * search_domains
Definition dns.h:71
struct in_addr a4
Definition dns.h:52
union dns_server_addr::@0 in
sa_family_t family
Definition dns.h:55
struct in6_addr a6
Definition dns.h:53
in_port_t port
Definition dns.h:56
struct dns_server_addr addr[8]
Definition dns.h:63
enum dns_security dnssec
Definition dns.h:65
struct dns_server * next
Definition dns.h:60
long priority
Definition dns.h:61
size_t addr_count
Definition dns.h:62
struct dns_domain * domains
Definition dns.h:64
enum dns_server_transport transport
Definition dns.h:66
const char * sni
Definition dns.h:67
Garbage collection arena used to keep track of dynamically allocated memory.
Definition buffer.h:117
unsigned short sa_family_t
Definition syshead.h:395
struct env_set * es
struct gc_arena gc
Definition test_ssl.c:155