]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/resolve/resolved-link.h
71f92039d573392fec1f397ec88320975e0becf2
[thirdparty/systemd.git] / src / resolve / resolved-link.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include <sys/stat.h>
5
6 #include "in-addr-util.h"
7 #include "list.h"
8 #include "network-util.h"
9 #include "resolve-util.h"
10 #include "resolved-forward.h"
11
12 #define LINK_SEARCH_DOMAINS_MAX 256
13 #define LINK_DNS_SERVERS_MAX 256
14
15 typedef struct LinkAddress {
16 Link *link;
17
18 int family;
19 union in_addr_union in_addr;
20 union in_addr_union in_addr_broadcast;
21 unsigned char prefixlen;
22
23 unsigned char scope;
24 uint32_t flags;
25
26 DnsResourceRecord *llmnr_address_rr;
27 DnsResourceRecord *llmnr_ptr_rr;
28 DnsResourceRecord *mdns_address_rr;
29 DnsResourceRecord *mdns_ptr_rr;
30
31 LIST_FIELDS(LinkAddress, addresses);
32 } LinkAddress;
33
34 typedef struct Link {
35 Manager *manager;
36
37 int ifindex;
38 unsigned flags;
39
40 LIST_HEAD(LinkAddress, addresses);
41 unsigned n_addresses;
42
43 LIST_HEAD(DnsServer, dns_servers);
44 DnsServer *current_dns_server;
45 unsigned n_dns_servers;
46
47 LIST_HEAD(DnsSearchDomain, search_domains);
48 unsigned n_search_domains;
49
50 int default_route;
51
52 ResolveSupport llmnr_support;
53 ResolveSupport mdns_support;
54 DnsOverTlsMode dns_over_tls_mode;
55 DnssecMode dnssec_mode;
56 Set *dnssec_negative_trust_anchors;
57
58 DnsScope *unicast_scope;
59 DnsScope *llmnr_ipv4_scope;
60 DnsScope *llmnr_ipv6_scope;
61 DnsScope *mdns_ipv4_scope;
62 DnsScope *mdns_ipv6_scope;
63
64 struct stat networkd_state_file_stat;
65 LinkOperationalState networkd_operstate;
66 bool is_managed;
67
68 char *ifname;
69 uint32_t mtu;
70 uint8_t operstate;
71
72 bool loaded;
73 char *state_file;
74
75 bool unicast_relevant;
76 } Link;
77
78 int link_new(Manager *m, Link **ret, int ifindex);
79 Link *link_free(Link *l);
80 int link_process_rtnl(Link *l, sd_netlink_message *m);
81 int link_update(Link *l);
82 bool link_relevant(Link *l, int family, bool local_multicast);
83 LinkAddress* link_find_address(Link *l, int family, const union in_addr_union *in_addr);
84 void link_add_rrs(Link *l, bool force_remove);
85
86 void link_flush_settings(Link *l);
87 void link_set_dnssec_mode(Link *l, DnssecMode mode);
88 void link_set_dns_over_tls_mode(Link *l, DnsOverTlsMode mode);
89 void link_allocate_scopes(Link *l);
90
91 DnsServer* link_set_dns_server(Link *l, DnsServer *s);
92 DnsServer* link_get_dns_server(Link *l);
93 void link_next_dns_server(Link *l, DnsServer *if_current);
94 void link_set_default_route(Link *l, bool b);
95
96 DnssecMode link_get_dnssec_mode(Link *l);
97 bool link_dnssec_supported(Link *l);
98
99 DnsOverTlsMode link_get_dns_over_tls_mode(Link *l);
100
101 ResolveSupport link_get_llmnr_support(Link *link);
102 ResolveSupport link_get_mdns_support(Link *link);
103
104 bool link_get_default_route(Link *l);
105
106 int link_save_user(Link *l);
107 int link_load_user(Link *l);
108 void link_remove_user(Link *l);
109
110 int link_address_new(Link *l,
111 LinkAddress **ret,
112 int family,
113 const union in_addr_union *in_addr,
114 const union in_addr_union *in_addr_broadcast);
115 LinkAddress *link_address_free(LinkAddress *a);
116 int link_address_update_rtnl(LinkAddress *a, sd_netlink_message *m);
117 bool link_address_relevant(LinkAddress *l, bool allow_link_local);
118 void link_address_add_rrs(LinkAddress *a, bool force_remove);
119
120 bool link_negative_trust_anchor_lookup(Link *l, const char *name);
121
122 DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_free);