]>
Commit | Line | Data |
---|---|---|
1 | #pragma once | |
2 | ||
3 | /*** | |
4 | This file is part of systemd. | |
5 | ||
6 | Copyright 2014 Lennart Poettering | |
7 | ||
8 | systemd is free software; you can redistribute it and/or modify it | |
9 | under the terms of the GNU Lesser General Public License as published by | |
10 | the Free Software Foundation; either version 2.1 of the License, or | |
11 | (at your option) any later version. | |
12 | ||
13 | systemd is distributed in the hope that it will be useful, but | |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | Lesser General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU Lesser General Public License | |
19 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
20 | ***/ | |
21 | ||
22 | #include "list.h" | |
23 | ||
24 | typedef struct DnsScope DnsScope; | |
25 | ||
26 | #include "resolved-dns-cache.h" | |
27 | #include "resolved-dns-dnssec.h" | |
28 | #include "resolved-dns-packet.h" | |
29 | #include "resolved-dns-query.h" | |
30 | #include "resolved-dns-search-domain.h" | |
31 | #include "resolved-dns-server.h" | |
32 | #include "resolved-dns-stream.h" | |
33 | #include "resolved-dns-zone.h" | |
34 | #include "resolved-link.h" | |
35 | ||
36 | typedef enum DnsScopeMatch { | |
37 | DNS_SCOPE_NO, | |
38 | DNS_SCOPE_MAYBE, | |
39 | DNS_SCOPE_YES, | |
40 | _DNS_SCOPE_MATCH_MAX, | |
41 | _DNS_SCOPE_INVALID = -1 | |
42 | } DnsScopeMatch; | |
43 | ||
44 | struct DnsScope { | |
45 | Manager *manager; | |
46 | ||
47 | DnsProtocol protocol; | |
48 | int family; | |
49 | DnssecMode dnssec_mode; | |
50 | ||
51 | Link *link; | |
52 | ||
53 | DnsCache cache; | |
54 | DnsZone zone; | |
55 | ||
56 | OrderedHashmap *conflict_queue; | |
57 | sd_event_source *conflict_event_source; | |
58 | ||
59 | RateLimit ratelimit; | |
60 | ||
61 | usec_t resend_timeout; | |
62 | usec_t max_rtt; | |
63 | ||
64 | LIST_HEAD(DnsQueryCandidate, query_candidates); | |
65 | ||
66 | /* Note that we keep track of ongoing transactions in two | |
67 | * ways: once in a hashmap, indexed by the rr key, and once in | |
68 | * a linked list. We use the hashmap to quickly find | |
69 | * transactions we can reuse for a key. But note that there | |
70 | * might be multiple transactions for the same key (because | |
71 | * the zone probing can't reuse a transaction answered from | |
72 | * the zone or the cache), and the hashmap only tracks the | |
73 | * most recent entry. */ | |
74 | Hashmap *transactions_by_key; | |
75 | LIST_HEAD(DnsTransaction, transactions); | |
76 | ||
77 | LIST_FIELDS(DnsScope, scopes); | |
78 | }; | |
79 | ||
80 | int dns_scope_new(Manager *m, DnsScope **ret, Link *l, DnsProtocol p, int family); | |
81 | DnsScope* dns_scope_free(DnsScope *s); | |
82 | ||
83 | void dns_scope_packet_received(DnsScope *s, usec_t rtt); | |
84 | void dns_scope_packet_lost(DnsScope *s, usec_t usec); | |
85 | ||
86 | int dns_scope_emit_udp(DnsScope *s, int fd, DnsPacket *p); | |
87 | int dns_scope_socket_tcp(DnsScope *s, int family, const union in_addr_union *address, DnsServer *server, uint16_t port); | |
88 | int dns_scope_socket_udp(DnsScope *s, DnsServer *server, uint16_t port); | |
89 | ||
90 | DnsScopeMatch dns_scope_good_domain(DnsScope *s, int ifindex, uint64_t flags, const char *domain); | |
91 | bool dns_scope_good_key(DnsScope *s, const DnsResourceKey *key); | |
92 | ||
93 | DnsServer *dns_scope_get_dns_server(DnsScope *s); | |
94 | void dns_scope_next_dns_server(DnsScope *s); | |
95 | ||
96 | int dns_scope_llmnr_membership(DnsScope *s, bool b); | |
97 | int dns_scope_mdns_membership(DnsScope *s, bool b); | |
98 | ||
99 | void dns_scope_process_query(DnsScope *s, DnsStream *stream, DnsPacket *p); | |
100 | ||
101 | DnsTransaction *dns_scope_find_transaction(DnsScope *scope, DnsResourceKey *key, bool cache_ok); | |
102 | ||
103 | int dns_scope_notify_conflict(DnsScope *scope, DnsResourceRecord *rr); | |
104 | void dns_scope_check_conflicts(DnsScope *scope, DnsPacket *p); | |
105 | ||
106 | void dns_scope_dump(DnsScope *s, FILE *f); | |
107 | ||
108 | DnsSearchDomain *dns_scope_get_search_domains(DnsScope *s); | |
109 | ||
110 | bool dns_scope_name_needs_search_domain(DnsScope *s, const char *name); | |
111 | ||
112 | bool dns_scope_network_good(DnsScope *s); | |
113 | ||
114 | int dns_scope_ifindex(DnsScope *s); |