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