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