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#include "tun.h"
30
37
44
45struct dns_domain {
47 const char *name;
48};
49
51{
52 union {
53 struct in_addr a4;
54 struct in6_addr a6;
55 } in;
57 in_port_t port;
58};
59
70
77
86bool dns_server_priority_parse(long *priority, const char *str, bool pulled);
87
96struct dns_server *dns_server_get(struct dns_server **entry, long priority, struct gc_arena *gc);
97
105void dns_domain_list_append(struct dns_domain **entry, char **domains, struct gc_arena *gc);
106
115bool dns_server_addr_parse(struct dns_server *server, const char *addr);
116
124bool dns_options_verify(int msglevel, const struct dns_options *o);
125
133struct dns_options clone_dns_options(const struct dns_options *o,
134 struct gc_arena *gc);
135
142
149
156void run_dns_up_down(bool up, struct options *o, const struct tuntap *tt);
157
164void setenv_dns_options(const struct dns_options *o, struct env_set *es);
165
171void show_dns_options(const struct dns_options *o);
172
173#endif /* ifndef DNS_H */
bool dns_options_verify(int msglevel, const struct dns_options *o)
Checks validity of DNS options.
Definition dns.c:203
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:147
void dns_options_postprocess_pull(struct dns_options *o)
Merges pulled DNS servers with static ones into an ordered list.
Definition dns.c:277
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:61
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:181
dns_security
Definition dns.h:31
@ DNS_SECURITY_UNSET
Definition dns.h:32
@ DNS_SECURITY_NO
Definition dns.h:33
@ DNS_SECURITY_YES
Definition dns.h:34
@ DNS_SECURITY_OPTIONAL
Definition dns.h:35
void run_dns_up_down(bool up, struct options *o, const struct tuntap *tt)
Invokes the action associated with bringing DNS up or down.
Definition dns.c:633
bool dns_server_priority_parse(long *priority, const char *str, bool pulled)
Parses a string DNS server priority and validates it.
Definition dns.c:166
dns_server_transport
Definition dns.h:38
@ DNS_TRANSPORT_PLAIN
Definition dns.h:40
@ DNS_TRANSPORT_UNSET
Definition dns.h:39
@ DNS_TRANSPORT_TLS
Definition dns.h:42
@ DNS_TRANSPORT_HTTPS
Definition dns.h:41
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:257
void setenv_dns_options(const struct dns_options *o, struct env_set *es)
Puts the DNS options into an environment set.
Definition dns.c:376
void show_dns_options(const struct dns_options *o)
Prints configured DNS options.
Definition dns.c:554
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:270
struct dns_domain * next
Definition dns.h:46
const char * name
Definition dns.h:47
struct dns_server * servers
Definition dns.h:74
struct dns_server * servers_prepull
Definition dns.h:73
struct gc_arena gc
Definition dns.h:75
struct dns_domain * search_domains
Definition dns.h:72
struct in_addr a4
Definition dns.h:53
union dns_server_addr::@0 in
sa_family_t family
Definition dns.h:56
struct in6_addr a6
Definition dns.h:54
in_port_t port
Definition dns.h:57
struct dns_server_addr addr[8]
Definition dns.h:64
enum dns_security dnssec
Definition dns.h:66
struct dns_server * next
Definition dns.h:61
long priority
Definition dns.h:62
size_t addr_count
Definition dns.h:63
struct dns_domain * domains
Definition dns.h:65
enum dns_server_transport transport
Definition dns.h:67
const char * sni
Definition dns.h:68
Garbage collection arena used to keep track of dynamically allocated memory.
Definition buffer.h:117
Definition tun.h:181
unsigned short sa_family_t
Definition syshead.h:395
struct env_set * es
struct gc_arena gc
Definition test_ssl.c:155