]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/network/networkd-network.h
network: introduce DHCPv6PrefixDelegation= setting
[thirdparty/systemd.git] / src / network / networkd-network.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 #include <linux/nl80211.h>
5
6 #include "sd-bus.h"
7 #include "sd-device.h"
8
9 #include "bridge.h"
10 #include "condition.h"
11 #include "conf-parser.h"
12 #include "hashmap.h"
13 #include "netdev.h"
14 #include "networkd-brvlan.h"
15 #include "networkd-dhcp-common.h"
16 #include "networkd-dhcp4.h"
17 #include "networkd-dhcp6.h"
18 #include "networkd-dhcp-server.h"
19 #include "networkd-lldp-rx.h"
20 #include "networkd-lldp-tx.h"
21 #include "networkd-ndisc.h"
22 #include "networkd-radv.h"
23 #include "networkd-sysctl.h"
24 #include "networkd-util.h"
25 #include "ordered-set.h"
26 #include "resolve-util.h"
27 #include "socket-netlink.h"
28
29 typedef enum KeepConfiguration {
30 KEEP_CONFIGURATION_NO = 0,
31 KEEP_CONFIGURATION_DHCP_ON_START = 1 << 0,
32 KEEP_CONFIGURATION_DHCP_ON_STOP = 1 << 1,
33 KEEP_CONFIGURATION_DHCP = KEEP_CONFIGURATION_DHCP_ON_START | KEEP_CONFIGURATION_DHCP_ON_STOP,
34 KEEP_CONFIGURATION_STATIC = 1 << 2,
35 KEEP_CONFIGURATION_YES = KEEP_CONFIGURATION_DHCP | KEEP_CONFIGURATION_STATIC,
36 _KEEP_CONFIGURATION_MAX,
37 _KEEP_CONFIGURATION_INVALID = -1,
38 } KeepConfiguration;
39
40 typedef enum IPv6LinkLocalAddressGenMode {
41 IPV6_LINK_LOCAL_ADDRESSS_GEN_MODE_EUI64 = IN6_ADDR_GEN_MODE_EUI64,
42 IPV6_LINK_LOCAL_ADDRESSS_GEN_MODE_NONE = IN6_ADDR_GEN_MODE_NONE,
43 IPV6_LINK_LOCAL_ADDRESSS_GEN_MODE_STABLE_PRIVACY = IN6_ADDR_GEN_MODE_STABLE_PRIVACY,
44 IPV6_LINK_LOCAL_ADDRESSS_GEN_MODE_RANDOM = IN6_ADDR_GEN_MODE_RANDOM,
45 _IPV6_LINK_LOCAL_ADDRESS_GEN_MODE_MAX,
46 _IPV6_LINK_LOCAL_ADDRESS_GEN_MODE_INVALID = -1
47 } IPv6LinkLocalAddressGenMode;
48
49 typedef struct Manager Manager;
50
51 typedef struct NetworkDHCPServerEmitAddress {
52 bool emit;
53 struct in_addr *addresses;
54 size_t n_addresses;
55 } NetworkDHCPServerEmitAddress;
56
57 struct Network {
58 Manager *manager;
59
60 unsigned n_ref;
61
62 char *name;
63 char *filename;
64 usec_t timestamp;
65 char *description;
66
67 /* [Match] section */
68 Set *match_mac;
69 Set *match_permanent_mac;
70 char **match_path;
71 char **match_driver;
72 char **match_type;
73 char **match_name;
74 char **match_property;
75 char **match_wlan_iftype;
76 char **match_ssid;
77 Set *match_bssid;
78 LIST_HEAD(Condition, conditions);
79
80 /* Master or stacked netdevs */
81 NetDev *bridge;
82 NetDev *bond;
83 NetDev *vrf;
84 NetDev *xfrm;
85 Hashmap *stacked_netdevs;
86 char *bridge_name;
87 char *bond_name;
88 char *vrf_name;
89 Hashmap *stacked_netdev_names;
90
91 /* [Link] section */
92 struct ether_addr *mac;
93 uint32_t mtu;
94 uint32_t group;
95 int arp;
96 int multicast;
97 int allmulticast;
98 bool unmanaged;
99 bool required_for_online; /* Is this network required to be considered online? */
100 LinkOperationalStateRange required_operstate_for_online;
101
102 /* misc settings */
103 bool configure_without_carrier;
104 int ignore_carrier_loss;
105 KeepConfiguration keep_configuration;
106 char **bind_carrier;
107 bool default_route_on_device;
108 bool ip_masquerade;
109
110 /* DHCP Client Support */
111 AddressFamily dhcp;
112 DHCPClientIdentifier dhcp_client_identifier;
113 DUID duid;
114 uint32_t iaid;
115 bool iaid_set;
116 char *dhcp_vendor_class_identifier;
117 char *dhcp_mudurl;
118 char **dhcp_user_class;
119 char *dhcp_hostname;
120 uint64_t dhcp_max_attempts;
121 uint32_t dhcp_route_metric;
122 bool dhcp_route_metric_set;
123 uint32_t dhcp_route_table;
124 uint32_t dhcp_fallback_lease_lifetime;
125 uint32_t dhcp_route_mtu;
126 uint16_t dhcp_client_port;
127 int dhcp_critical;
128 int dhcp_ip_service_type;
129 bool dhcp_anonymize;
130 bool dhcp_send_hostname;
131 bool dhcp_broadcast;
132 bool dhcp_use_dns;
133 bool dhcp_use_dns_set;
134 bool dhcp_routes_to_dns;
135 bool dhcp_use_ntp;
136 bool dhcp_use_ntp_set;
137 bool dhcp_use_sip;
138 bool dhcp_use_mtu;
139 bool dhcp_use_routes;
140 int dhcp_use_gateway;
141 bool dhcp_use_timezone;
142 bool dhcp_use_hostname;
143 bool dhcp_route_table_set;
144 bool dhcp_send_release;
145 bool dhcp_send_decline;
146 DHCPUseDomains dhcp_use_domains;
147 Set *dhcp_deny_listed_ip;
148 Set *dhcp_allow_listed_ip;
149 Set *dhcp_request_options;
150 OrderedHashmap *dhcp_client_send_options;
151 OrderedHashmap *dhcp_client_send_vendor_options;
152
153 /* DHCPv6 Client support*/
154 bool dhcp6_use_dns;
155 bool dhcp6_use_dns_set;
156 bool dhcp6_use_ntp;
157 bool dhcp6_use_ntp_set;
158 bool dhcp6_rapid_commit;
159 uint8_t dhcp6_pd_length;
160 uint32_t dhcp6_route_metric;
161 bool dhcp6_route_metric_set;
162 char *dhcp6_mudurl;
163 char **dhcp6_user_class;
164 char **dhcp6_vendor_class;
165 struct in6_addr dhcp6_pd_address;
166 DHCP6ClientStartMode dhcp6_without_ra;
167 OrderedHashmap *dhcp6_client_send_options;
168 OrderedHashmap *dhcp6_client_send_vendor_options;
169 Set *dhcp6_request_options;
170 /* Start DHCPv6 PD also when 'O' RA flag is set, see RFC 7084, WPD-4 */
171 bool dhcp6_force_pd_other_information;
172
173 /* DHCP Server Support */
174 bool dhcp_server;
175 NetworkDHCPServerEmitAddress dhcp_server_emit[_SD_DHCP_LEASE_SERVER_TYPE_MAX];
176 bool dhcp_server_emit_router;
177 bool dhcp_server_emit_timezone;
178 char *dhcp_server_timezone;
179 usec_t dhcp_server_default_lease_time_usec, dhcp_server_max_lease_time_usec;
180 uint32_t dhcp_server_pool_offset;
181 uint32_t dhcp_server_pool_size;
182 OrderedHashmap *dhcp_server_send_options;
183 OrderedHashmap *dhcp_server_send_vendor_options;
184
185 /* link local addressing support */
186 AddressFamily link_local;
187 IPv6LinkLocalAddressGenMode ipv6ll_address_gen_mode;
188 bool ipv4ll_route;
189
190 /* IPv6 prefix delegation support */
191 RADVPrefixDelegation router_prefix_delegation;
192 usec_t router_lifetime_usec;
193 uint8_t router_preference;
194 bool router_managed;
195 bool router_other_information;
196 bool router_emit_dns;
197 bool router_emit_domains;
198 usec_t router_dns_lifetime_usec;
199 struct in6_addr *router_dns;
200 unsigned n_router_dns;
201 OrderedSet *router_search_domains;
202
203 /* DHCPv6 Prefix Delegation support */
204 int dhcp6_pd;
205 bool dhcp6_pd_assign;
206 int64_t dhcp6_pd_subnet_id;
207 union in_addr_union dhcp6_pd_token;
208
209 /* Bridge Support */
210 int use_bpdu;
211 int hairpin;
212 int fast_leave;
213 int allow_port_to_be_root;
214 int unicast_flood;
215 int multicast_flood;
216 int multicast_to_unicast;
217 int neighbor_suppression;
218 int learning;
219 int bridge_proxy_arp;
220 int bridge_proxy_arp_wifi;
221 uint32_t cost;
222 uint16_t priority;
223 MulticastRouter multicast_router;
224
225 /* Bridge VLAN */
226 bool use_br_vlan;
227 uint16_t pvid;
228 uint32_t br_vid_bitmap[BRIDGE_VLAN_BITMAP_LEN];
229 uint32_t br_untagged_bitmap[BRIDGE_VLAN_BITMAP_LEN];
230
231 /* CAN support */
232 uint32_t can_bitrate;
233 unsigned can_sample_point;
234 uint32_t can_data_bitrate;
235 unsigned can_data_sample_point;
236 usec_t can_restart_us;
237 int can_triple_sampling;
238 int can_termination;
239 int can_listen_only;
240 int can_fd_mode;
241 int can_non_iso;
242
243 /* sysctl settings */
244 AddressFamily ip_forward;
245 int ipv4_accept_local;
246 int ipv6_dad_transmits;
247 int ipv6_hop_limit;
248 int proxy_arp;
249 uint32_t ipv6_mtu;
250 IPv6PrivacyExtensions ipv6_privacy_extensions;
251 int ipv6_proxy_ndp;
252 Set *ipv6_proxy_ndp_addresses;
253
254 /* IPv6 accept RA */
255 int ipv6_accept_ra;
256 bool ipv6_accept_ra_use_dns;
257 bool ipv6_accept_ra_use_autonomous_prefix;
258 bool ipv6_accept_ra_use_onlink_prefix;
259 bool active_slave;
260 bool primary_slave;
261 bool ipv6_accept_ra_route_table_set;
262 DHCPUseDomains ipv6_accept_ra_use_domains;
263 IPv6AcceptRAStartDHCP6Client ipv6_accept_ra_start_dhcp6_client;
264 uint32_t ipv6_accept_ra_route_table;
265 Set *ndisc_deny_listed_prefix;
266 OrderedSet *ipv6_tokens;
267
268 /* LLDP support */
269 LLDPMode lldp_mode; /* LLDP reception */
270 LLDPEmit lldp_emit; /* LLDP transmission */
271 char *lldp_mud; /* LLDP MUD URL */
272
273 OrderedHashmap *addresses_by_section;
274 Hashmap *routes_by_section;
275 Hashmap *nexthops_by_section;
276 Hashmap *fdb_entries_by_section;
277 Hashmap *mdb_entries_by_section;
278 Hashmap *neighbors_by_section;
279 Hashmap *address_labels_by_section;
280 Hashmap *prefixes_by_section;
281 Hashmap *route_prefixes_by_section;
282 Hashmap *rules_by_section;
283 OrderedHashmap *tc_by_section;
284 OrderedHashmap *sr_iov_by_section;
285
286 /* All kinds of DNS configuration */
287 struct in_addr_full **dns;
288 unsigned n_dns;
289 OrderedSet *search_domains, *route_domains;
290 int dns_default_route;
291 ResolveSupport llmnr;
292 ResolveSupport mdns;
293 DnssecMode dnssec_mode;
294 DnsOverTlsMode dns_over_tls_mode;
295 Set *dnssec_negative_trust_anchors;
296
297 /* NTP */
298 char **ntp;
299 };
300
301 Network *network_ref(Network *network);
302 Network *network_unref(Network *network);
303 DEFINE_TRIVIAL_CLEANUP_FUNC(Network*, network_unref);
304
305 int network_load(Manager *manager, OrderedHashmap **networks);
306 int network_reload(Manager *manager);
307 int network_load_one(Manager *manager, OrderedHashmap **networks, const char *filename);
308 int network_verify(Network *network);
309
310 int network_get_by_name(Manager *manager, const char *name, Network **ret);
311 int network_get(Manager *manager, unsigned short iftype, sd_device *device,
312 const char *ifname, char * const *alternative_names, const char *driver,
313 const struct ether_addr *mac, const struct ether_addr *permanent_mac,
314 enum nl80211_iftype wlan_iftype, const char *ssid, const struct ether_addr *bssid,
315 Network **ret);
316 int network_apply(Network *network, Link *link);
317 void network_apply_anonymize_if_set(Network *network);
318
319 bool network_has_static_ipv6_configurations(Network *network);
320
321 CONFIG_PARSER_PROTOTYPE(config_parse_stacked_netdev);
322 CONFIG_PARSER_PROTOTYPE(config_parse_tunnel);
323 CONFIG_PARSER_PROTOTYPE(config_parse_domains);
324 CONFIG_PARSER_PROTOTYPE(config_parse_dns);
325 CONFIG_PARSER_PROTOTYPE(config_parse_hostname);
326 CONFIG_PARSER_PROTOTYPE(config_parse_timezone);
327 CONFIG_PARSER_PROTOTYPE(config_parse_dnssec_negative_trust_anchors);
328 CONFIG_PARSER_PROTOTYPE(config_parse_ntp);
329 CONFIG_PARSER_PROTOTYPE(config_parse_required_for_online);
330 CONFIG_PARSER_PROTOTYPE(config_parse_keep_configuration);
331 CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_link_local_address_gen_mode);
332
333 const struct ConfigPerfItem* network_network_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
334
335 const char* keep_configuration_to_string(KeepConfiguration i) _const_;
336 KeepConfiguration keep_configuration_from_string(const char *s) _pure_;
337
338 const char* ipv6_link_local_address_gen_mode_to_string(IPv6LinkLocalAddressGenMode s) _const_;
339 IPv6LinkLocalAddressGenMode ipv6_link_local_address_gen_mode_from_string(const char *s) _pure_;