]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/resolve/resolved-dns-zone.h
resolved: rework parsing of /etc/hosts
[thirdparty/systemd.git] / src / resolve / resolved-dns-zone.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 #include "hashmap.h"
5
6 typedef struct DnsZone {
7 Hashmap *by_key;
8 Hashmap *by_name;
9 } DnsZone;
10
11 typedef struct DnsZoneItem DnsZoneItem;
12 typedef enum DnsZoneItemState DnsZoneItemState;
13
14 #include "resolved-dns-answer.h"
15 #include "resolved-dns-question.h"
16 #include "resolved-dns-rr.h"
17 #include "resolved-dns-transaction.h"
18
19 /* RFC 4795 Section 2.8. suggests a TTL of 30s by default */
20 #define LLMNR_DEFAULT_TTL (30)
21
22 /* RFC 6762 Section 10. suggests a TTL of 120s by default */
23 #define MDNS_DEFAULT_TTL (120)
24
25 enum DnsZoneItemState {
26 DNS_ZONE_ITEM_PROBING,
27 DNS_ZONE_ITEM_ESTABLISHED,
28 DNS_ZONE_ITEM_VERIFYING,
29 DNS_ZONE_ITEM_WITHDRAWN,
30 };
31
32 struct DnsZoneItem {
33 DnsScope *scope;
34 DnsResourceRecord *rr;
35
36 DnsZoneItemState state;
37
38 unsigned block_ready;
39
40 bool probing_enabled;
41
42 LIST_FIELDS(DnsZoneItem, by_key);
43 LIST_FIELDS(DnsZoneItem, by_name);
44
45 DnsTransaction *probe_transaction;
46 };
47
48 void dns_zone_flush(DnsZone *z);
49
50 int dns_zone_put(DnsZone *z, DnsScope *s, DnsResourceRecord *rr, bool probe);
51 DnsZoneItem* dns_zone_get(DnsZone *z, DnsResourceRecord *rr);
52 void dns_zone_remove_rr(DnsZone *z, DnsResourceRecord *rr);
53 int dns_zone_remove_rrs_by_key(DnsZone *z, DnsResourceKey *key);
54
55 int dns_zone_lookup(DnsZone *z, DnsResourceKey *key, int ifindex, DnsAnswer **answer, DnsAnswer **soa, bool *tentative);
56
57 void dns_zone_item_conflict(DnsZoneItem *i);
58 void dns_zone_item_notify(DnsZoneItem *i);
59
60 int dns_zone_check_conflicts(DnsZone *zone, DnsResourceRecord *rr);
61 int dns_zone_verify_conflicts(DnsZone *zone, DnsResourceKey *key);
62
63 void dns_zone_verify_all(DnsZone *zone);
64
65 void dns_zone_item_probe_stop(DnsZoneItem *i);
66
67 void dns_zone_dump(DnsZone *zone, FILE *f);
68 bool dns_zone_is_empty(DnsZone *zone);
69 bool dns_zone_contains_name(DnsZone *z, const char *name);