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 
35 };
36 
42 };
43 
44 struct dns_domain {
45  struct dns_domain *next;
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 
59 struct dns_server {
60  struct dns_server *next;
61  long priority;
62  size_t addr_count;
63  struct dns_server_addr addr[8];
67  const char *sni;
68 };
69 
70 struct dns_options {
74  struct gc_arena gc;
75 };
76 
85 bool dns_server_priority_parse(long *priority, const char *str, bool pulled);
86 
95 struct dns_server *dns_server_get(struct dns_server **entry, long priority, struct gc_arena *gc);
96 
104 void dns_domain_list_append(struct dns_domain **entry, char **domains, struct gc_arena *gc);
105 
114 bool dns_server_addr_parse(struct dns_server *server, const char *addr);
115 
123 bool dns_options_verify(int msglevel, const struct dns_options *o);
124 
132 struct dns_options clone_dns_options(const struct dns_options o, struct gc_arena *gc);
133 
140 
147 
154 void setenv_dns_options(const struct dns_options *o, struct env_set *es);
155 
161 void show_dns_options(const struct dns_options *o);
162 
163 #endif /* ifndef DNS_H */
DNS_TRANSPORT_UNSET
@ DNS_TRANSPORT_UNSET
Definition: dns.h:38
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.
Definition: dns.c:141
dns_server_addr::port
in_port_t port
Definition: dns.h:56
dns_security
dns_security
Definition: dns.h:30
dns_domain::next
struct dns_domain * next
Definition: dns.h:45
DNS_SECURITY_OPTIONAL
@ DNS_SECURITY_OPTIONAL
Definition: dns.h:34
es
struct env_set * es
Definition: test_pkcs11.c:133
dns_server_transport
dns_server_transport
Definition: dns.h:37
dns_server::dnssec
enum dns_security dnssec
Definition: dns.h:65
setenv_dns_options
void setenv_dns_options(const struct dns_options *o, struct env_set *es)
Puts the DNS options into an environment set.
Definition: dns.c:368
dns_server::transport
enum dns_server_transport transport
Definition: dns.h:66
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.
Definition: dns.c:262
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 re...
Definition: dns.c:55
dns_options::gc
struct gc_arena gc
Definition: dns.h:74
dns_options::servers
struct dns_server * servers
Definition: dns.h:73
dns_options::servers_prepull
struct dns_server * servers_prepull
Definition: dns.h:72
sa_family_t
unsigned short sa_family_t
Definition: syshead.h:385
DNS_TRANSPORT_HTTPS
@ DNS_TRANSPORT_HTTPS
Definition: dns.h:40
dns_server::priority
long priority
Definition: dns.h:61
dns_options_verify
bool dns_options_verify(int msglevel, const struct dns_options *o)
Checks validity of DNS options.
Definition: dns.c:197
env_set.h
dns_domain::name
const char * name
Definition: dns.h:46
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.
Definition: dns.c:160
dns_server_addr::in
union dns_server_addr::@0 in
dns_server
Definition: dns.h:59
dns_server::domains
struct dns_domain * domains
Definition: dns.h:64
DNS_SECURITY_NO
@ DNS_SECURITY_NO
Definition: dns.h:32
dns_domain
Definition: dns.h:44
dns_options::search_domains
struct dns_domain * search_domains
Definition: dns.h:71
dns_server::addr_count
size_t addr_count
Definition: dns.h:62
DNS_TRANSPORT_PLAIN
@ DNS_TRANSPORT_PLAIN
Definition: dns.h:39
dns_server::addr
struct dns_server_addr addr[8]
Definition: dns.h:63
buffer.h
gc_arena
Garbage collection arena used to keep track of dynamically allocated memory.
Definition: buffer.h:116
DNS_TRANSPORT_TLS
@ DNS_TRANSPORT_TLS
Definition: dns.h:41
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.
Definition: dns.c:175
env_set
Definition: env_set.h:42
DNS_SECURITY_YES
@ DNS_SECURITY_YES
Definition: dns.h:33
show_dns_options
void show_dns_options(const struct dns_options *o)
Prints configured DNS options.
Definition: dns.c:430
dns_server_addr::family
sa_family_t family
Definition: dns.h:55
dns_options
Definition: dns.h:70
dns_server_addr
Definition: dns.h:49
dns_server::sni
const char * sni
Definition: dns.h:67
dns_server::next
struct dns_server * next
Definition: dns.h:60
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.
Definition: dns.c:251
dns_server_addr::a6
struct in6_addr a6
Definition: dns.h:53
DNS_SECURITY_UNSET
@ DNS_SECURITY_UNSET
Definition: dns.h:31
dns_server_addr::a4
struct in_addr a4
Definition: dns.h:52
dns_options_postprocess_pull
void dns_options_postprocess_pull(struct dns_options *o)
Merges pulled DNS servers with static ones into an ordered list.
Definition: dns.c:269