]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/resolve/resolved-dns-server.h
resolved: cache stringified transaction key once per transaction
[thirdparty/systemd.git] / src / resolve / resolved-dns-server.h
CommitLineData
74b2466e
LP
1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3#pragma once
4
5/***
6 This file is part of systemd.
7
8 Copyright 2014 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22***/
23
3c0cf502
LP
24#include "in-addr-util.h"
25
74b2466e 26typedef struct DnsServer DnsServer;
74b2466e 27
4e945a6f
LP
28typedef enum DnsServerType {
29 DNS_SERVER_SYSTEM,
30 DNS_SERVER_FALLBACK,
31 DNS_SERVER_LINK,
32} DnsServerType;
33
be808ea0
TG
34typedef enum DnsServerFeatureLevel {
35 DNS_SERVER_FEATURE_LEVEL_TCP,
36 DNS_SERVER_FEATURE_LEVEL_UDP,
9c5e12a4 37 DNS_SERVER_FEATURE_LEVEL_EDNS0,
7586f4d1 38 DNS_SERVER_FEATURE_LEVEL_DO,
d74fb368 39 DNS_SERVER_FEATURE_LEVEL_LARGE,
be808ea0
TG
40 _DNS_SERVER_FEATURE_LEVEL_MAX,
41 _DNS_SERVER_FEATURE_LEVEL_INVALID = -1
42} DnsServerFeatureLevel;
43
44#define DNS_SERVER_FEATURE_LEVEL_WORST 0
45#define DNS_SERVER_FEATURE_LEVEL_BEST (_DNS_SERVER_FEATURE_LEVEL_MAX - 1)
46
47const char* dns_server_feature_level_to_string(int i) _const_;
48int dns_server_feature_level_from_string(const char *s) _pure_;
49
3e684349 50#include "resolved-link.h"
be808ea0 51#include "resolved-manager.h"
3e684349 52
74b2466e
LP
53struct DnsServer {
54 Manager *manager;
74b2466e 55
91b14d6f
TG
56 unsigned n_ref;
57
4e945a6f 58 DnsServerType type;
3c0cf502
LP
59 Link *link;
60
0dd25fb9 61 int family;
74b2466e
LP
62 union in_addr_union address;
63
24710c48
LP
64 bool marked:1;
65
9df3ba6c
TG
66 usec_t resend_timeout;
67 usec_t max_rtt;
68
be808ea0
TG
69 DnsServerFeatureLevel verified_features;
70 DnsServerFeatureLevel possible_features;
d74fb368 71 size_t received_udp_packet_max;
be808ea0
TG
72 unsigned n_failed_attempts;
73 usec_t verified_usec;
74 usec_t features_grace_period_usec;
74b2466e 75
0eac4623
LP
76 /* If linked is set, then this server appears in the servers linked list */
77 bool linked:1;
74b2466e
LP
78 LIST_FIELDS(DnsServer, servers);
79};
80
81int dns_server_new(
82 Manager *m,
0b58db65 83 DnsServer **ret,
4e945a6f 84 DnsServerType type,
0b58db65 85 Link *link,
0dd25fb9 86 int family,
3c0cf502 87 const union in_addr_union *address);
74b2466e 88
91b14d6f
TG
89DnsServer* dns_server_ref(DnsServer *s);
90DnsServer* dns_server_unref(DnsServer *s);
87f5a193 91
0eac4623 92void dns_server_unlink(DnsServer *s);
0b58db65 93void dns_server_move_back_and_unmark(DnsServer *s);
0eac4623 94
d74fb368 95void dns_server_packet_received(DnsServer *s, DnsServerFeatureLevel features, usec_t rtt, size_t size);
be808ea0 96void dns_server_packet_lost(DnsServer *s, DnsServerFeatureLevel features, usec_t usec);
4e0b8b17 97void dns_server_packet_failed(DnsServer *s, DnsServerFeatureLevel features);
9df3ba6c 98
4b95f179
LP
99DnsServer *dns_server_find(DnsServer *first, int family, const union in_addr_union *in_addr);
100
101void dns_server_unlink_all(DnsServer *first);
102void dns_server_unlink_marked(DnsServer *first);
103void dns_server_mark_all(DnsServer *first);
f2f1dbe5 104
4b95f179 105DnsServer *manager_get_first_dns_server(Manager *m, DnsServerType t);
636e813d 106
0eac4623 107DnsServer *manager_set_dns_server(Manager *m, DnsServer *s);
0eac4623
LP
108DnsServer *manager_get_dns_server(Manager *m);
109void manager_next_dns_server(Manager *m);
110
8300ba21
TG
111DEFINE_TRIVIAL_CLEANUP_FUNC(DnsServer*, dns_server_unref);
112
be808ea0
TG
113DnsServerFeatureLevel dns_server_possible_features(DnsServer *s);
114
d5099efc 115extern const struct hash_ops dns_server_hash_ops;