1 /* SPDX-License-Identifier: LGPL-2.1+ */
7 typedef struct DnsQueryCandidate DnsQueryCandidate
;
8 typedef struct DnsScope DnsScope
;
10 #include "resolved-dns-cache.h"
11 #include "resolved-dns-dnssec.h"
12 #include "resolved-dns-packet.h"
14 #include "resolved-dns-search-domain.h"
15 #include "resolved-dns-server.h"
16 #include "resolved-dns-stream.h"
17 #include "resolved-dns-zone.h"
19 typedef enum DnsScopeMatch
{
22 DNS_SCOPE_YES_BASE
, /* Add the number of matching labels to this */
23 DNS_SCOPE_YES_END
= DNS_SCOPE_YES_BASE
+ DNS_N_LABELS_MAX
,
25 _DNS_SCOPE_MATCH_INVALID
= -1
34 /* Copied at scope creation time from the link/manager */
35 DnssecMode dnssec_mode
;
36 DnsOverTlsMode dns_over_tls_mode
;
43 OrderedHashmap
*conflict_queue
;
44 sd_event_source
*conflict_event_source
;
47 sd_event_source
*announce_event_source
;
51 usec_t resend_timeout
;
54 LIST_HEAD(DnsQueryCandidate
, query_candidates
);
56 /* Note that we keep track of ongoing transactions in two
57 * ways: once in a hashmap, indexed by the rr key, and once in
58 * a linked list. We use the hashmap to quickly find
59 * transactions we can reuse for a key. But note that there
60 * might be multiple transactions for the same key (because
61 * the zone probing can't reuse a transaction answered from
62 * the zone or the cache), and the hashmap only tracks the
63 * most recent entry. */
64 Hashmap
*transactions_by_key
;
65 LIST_HEAD(DnsTransaction
, transactions
);
67 LIST_FIELDS(DnsScope
, scopes
);
70 int dns_scope_new(Manager
*m
, DnsScope
**ret
, Link
*l
, DnsProtocol p
, int family
);
71 DnsScope
* dns_scope_free(DnsScope
*s
);
73 void dns_scope_packet_received(DnsScope
*s
, usec_t rtt
);
74 void dns_scope_packet_lost(DnsScope
*s
, usec_t usec
);
76 int dns_scope_emit_udp(DnsScope
*s
, int fd
, DnsPacket
*p
);
77 int dns_scope_socket_tcp(DnsScope
*s
, int family
, const union in_addr_union
*address
, DnsServer
*server
, uint16_t port
, union sockaddr_union
*ret_socket_address
);
78 int dns_scope_socket_udp(DnsScope
*s
, DnsServer
*server
, uint16_t port
);
80 DnsScopeMatch
dns_scope_good_domain(DnsScope
*s
, int ifindex
, uint64_t flags
, const char *domain
);
81 bool dns_scope_good_key(DnsScope
*s
, const DnsResourceKey
*key
);
83 DnsServer
*dns_scope_get_dns_server(DnsScope
*s
);
84 unsigned dns_scope_get_n_dns_servers(DnsScope
*s
);
85 void dns_scope_next_dns_server(DnsScope
*s
);
87 int dns_scope_llmnr_membership(DnsScope
*s
, bool b
);
88 int dns_scope_mdns_membership(DnsScope
*s
, bool b
);
90 int dns_scope_make_reply_packet(DnsScope
*s
, uint16_t id
, int rcode
, DnsQuestion
*q
, DnsAnswer
*answer
, DnsAnswer
*soa
, bool tentative
, DnsPacket
**ret
);
91 void dns_scope_process_query(DnsScope
*s
, DnsStream
*stream
, DnsPacket
*p
);
93 DnsTransaction
*dns_scope_find_transaction(DnsScope
*scope
, DnsResourceKey
*key
, bool cache_ok
);
95 int dns_scope_notify_conflict(DnsScope
*scope
, DnsResourceRecord
*rr
);
96 void dns_scope_check_conflicts(DnsScope
*scope
, DnsPacket
*p
);
98 void dns_scope_dump(DnsScope
*s
, FILE *f
);
100 DnsSearchDomain
*dns_scope_get_search_domains(DnsScope
*s
);
102 bool dns_scope_name_needs_search_domain(DnsScope
*s
, const char *name
);
104 bool dns_scope_network_good(DnsScope
*s
);
106 int dns_scope_ifindex(DnsScope
*s
);
108 int dns_scope_announce(DnsScope
*scope
, bool goodbye
);
110 int dns_scope_add_dnssd_services(DnsScope
*scope
);
111 int dns_scope_remove_dnssd_services(DnsScope
*scope
);
113 bool dns_scope_is_default_route(DnsScope
*scope
);