]>
Commit | Line | Data |
---|---|---|
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 | 26 | typedef struct DnsServer DnsServer; |
74b2466e | 27 | |
4e945a6f LP |
28 | typedef enum DnsServerType { |
29 | DNS_SERVER_SYSTEM, | |
30 | DNS_SERVER_FALLBACK, | |
31 | DNS_SERVER_LINK, | |
32 | } DnsServerType; | |
33 | ||
3e684349 LP |
34 | #include "resolved-link.h" |
35 | ||
74b2466e LP |
36 | struct DnsServer { |
37 | Manager *manager; | |
74b2466e | 38 | |
91b14d6f TG |
39 | unsigned n_ref; |
40 | ||
4e945a6f LP |
41 | DnsServerType type; |
42 | ||
3c0cf502 LP |
43 | Link *link; |
44 | ||
0dd25fb9 | 45 | int family; |
74b2466e LP |
46 | union in_addr_union address; |
47 | ||
9df3ba6c TG |
48 | usec_t resend_timeout; |
49 | usec_t max_rtt; | |
50 | ||
3c0cf502 | 51 | bool marked:1; |
74b2466e | 52 | |
0eac4623 LP |
53 | /* If linked is set, then this server appears in the servers linked list */ |
54 | bool linked:1; | |
74b2466e LP |
55 | LIST_FIELDS(DnsServer, servers); |
56 | }; | |
57 | ||
58 | int dns_server_new( | |
59 | Manager *m, | |
60 | DnsServer **s, | |
4e945a6f | 61 | DnsServerType type, |
74b2466e | 62 | Link *l, |
0dd25fb9 | 63 | int family, |
3c0cf502 | 64 | const union in_addr_union *address); |
74b2466e | 65 | |
91b14d6f TG |
66 | DnsServer* dns_server_ref(DnsServer *s); |
67 | DnsServer* dns_server_unref(DnsServer *s); | |
87f5a193 | 68 | |
0eac4623 LP |
69 | void dns_server_unlink(DnsServer *s); |
70 | ||
9df3ba6c TG |
71 | void dns_server_packet_received(DnsServer *s, usec_t rtt); |
72 | void dns_server_packet_lost(DnsServer *s, usec_t usec); | |
73 | ||
0eac4623 | 74 | DnsServer *manager_get_first_dns_server(Manager *m, DnsServerType t); |
f2f1dbe5 | 75 | |
636e813d LP |
76 | void manager_flush_dns_servers(Manager *m, DnsServerType t); |
77 | void manager_flush_marked_dns_servers(Manager *m, DnsServerType type); | |
78 | void manager_mark_dns_servers(Manager *m, DnsServerType type); | |
79 | ||
0eac4623 LP |
80 | DnsServer *manager_set_dns_server(Manager *m, DnsServer *s); |
81 | DnsServer *manager_find_dns_server(Manager *m, DnsServerType t, int family, const union in_addr_union *in_addr); | |
82 | DnsServer *manager_get_dns_server(Manager *m); | |
83 | void manager_next_dns_server(Manager *m); | |
84 | ||
8300ba21 TG |
85 | DEFINE_TRIVIAL_CLEANUP_FUNC(DnsServer*, dns_server_unref); |
86 | ||
d5099efc | 87 | extern const struct hash_ops dns_server_hash_ops; |