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