]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/network/networkd-network.h
Merge pull request #14337 from yuwata/network-tc-fq-more
[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-address-label.h"
15 #include "networkd-address.h"
16 #include "networkd-brvlan.h"
17 #include "networkd-dhcp-common.h"
18 #include "networkd-dhcp4.h"
19 #include "networkd-dhcp-server.h"
20 #include "networkd-fdb.h"
21 #include "networkd-ipv6-proxy-ndp.h"
22 #include "networkd-lldp-rx.h"
23 #include "networkd-lldp-tx.h"
24 #include "networkd-neighbor.h"
25 #include "networkd-nexthop.h"
26 #include "networkd-radv.h"
27 #include "networkd-route.h"
28 #include "networkd-routing-policy-rule.h"
29 #include "networkd-util.h"
30 #include "ordered-set.h"
31 #include "qdisc.h"
32 #include "resolve-util.h"
33
34 typedef enum IPv6PrivacyExtensions {
35 /* The values map to the kernel's /proc/sys/net/ipv6/conf/xxx/use_tempaddr values */
36 IPV6_PRIVACY_EXTENSIONS_NO,
37 IPV6_PRIVACY_EXTENSIONS_PREFER_PUBLIC,
38 IPV6_PRIVACY_EXTENSIONS_YES, /* aka prefer-temporary */
39 _IPV6_PRIVACY_EXTENSIONS_MAX,
40 _IPV6_PRIVACY_EXTENSIONS_INVALID = -1,
41 } IPv6PrivacyExtensions;
42
43 typedef enum KeepConfiguration {
44 KEEP_CONFIGURATION_NO = 0,
45 KEEP_CONFIGURATION_DHCP_ON_START = 1 << 0,
46 KEEP_CONFIGURATION_DHCP_ON_STOP = 1 << 1,
47 KEEP_CONFIGURATION_DHCP = KEEP_CONFIGURATION_DHCP_ON_START | KEEP_CONFIGURATION_DHCP_ON_STOP,
48 KEEP_CONFIGURATION_STATIC = 1 << 2,
49 KEEP_CONFIGURATION_YES = KEEP_CONFIGURATION_DHCP | KEEP_CONFIGURATION_STATIC,
50 _KEEP_CONFIGURATION_MAX,
51 _KEEP_CONFIGURATION_INVALID = -1,
52 } KeepConfiguration;
53
54 typedef struct Manager Manager;
55
56 struct Network {
57 Manager *manager;
58
59 char *filename;
60 char *name;
61 usec_t timestamp;
62
63 unsigned n_ref;
64
65 Set *match_mac;
66 char **match_path;
67 char **match_driver;
68 char **match_type;
69 char **match_name;
70 char **match_property;
71 char **match_wlan_iftype;
72 char **match_ssid;
73 Set *match_bssid;
74 LIST_HEAD(Condition, conditions);
75
76 char *description;
77
78 NetDev *bridge;
79 NetDev *bond;
80 NetDev *vrf;
81 NetDev *xfrm;
82 Hashmap *stacked_netdevs;
83 char *bridge_name;
84 char *bond_name;
85 char *vrf_name;
86 Hashmap *stacked_netdev_names;
87
88 /* DHCP Client Support */
89 AddressFamily dhcp;
90 DHCPClientIdentifier dhcp_client_identifier;
91 char *dhcp_vendor_class_identifier;
92 char **dhcp_user_class;
93 char *dhcp_hostname;
94 uint64_t dhcp_max_attempts;
95 unsigned dhcp_route_metric;
96 uint32_t dhcp_route_table;
97 uint16_t dhcp_client_port;
98 int dhcp_critical;
99 int ip_service_type;
100 bool dhcp_anonymize;
101 bool dhcp_send_hostname;
102 bool dhcp_broadcast;
103 bool dhcp_use_dns;
104 bool dhcp_routes_to_dns;
105 bool dhcp_use_ntp;
106 bool dhcp_use_sip;
107 bool dhcp_use_mtu;
108 bool dhcp_use_routes;
109 bool dhcp_use_timezone;
110 bool rapid_commit;
111 bool dhcp_use_hostname;
112 bool dhcp_route_table_set;
113 bool dhcp_send_release;
114 DHCPUseDomains dhcp_use_domains;
115 Set *dhcp_black_listed_ip;
116 Set *dhcp_request_options;
117 OrderedHashmap *dhcp_client_send_options;
118 OrderedHashmap *dhcp_server_send_options;
119
120 /* DHCPv6 Client support*/
121 bool dhcp6_use_dns;
122 bool dhcp6_use_ntp;
123 uint8_t dhcp6_pd_length;
124 struct in6_addr dhcp6_pd_address;
125
126 /* DHCP Server Support */
127 bool dhcp_server;
128
129 bool dhcp_server_emit_dns;
130 struct in_addr *dhcp_server_dns;
131 unsigned n_dhcp_server_dns;
132
133 bool dhcp_server_emit_ntp;
134 struct in_addr *dhcp_server_ntp;
135 unsigned n_dhcp_server_ntp;
136
137 bool dhcp_server_emit_sip;
138 struct in_addr *dhcp_server_sip;
139 unsigned n_dhcp_server_sip;
140
141 bool dhcp_server_emit_router;
142 bool dhcp_server_emit_timezone;
143 char *dhcp_server_timezone;
144 usec_t dhcp_server_default_lease_time_usec, dhcp_server_max_lease_time_usec;
145 uint32_t dhcp_server_pool_offset;
146 uint32_t dhcp_server_pool_size;
147
148 /* IPV4LL Support */
149 AddressFamily link_local;
150 bool ipv4ll_route;
151
152 bool default_route_on_device;
153
154 /* IPv6 prefix delegation support */
155 RADVPrefixDelegation router_prefix_delegation;
156 usec_t router_lifetime_usec;
157 uint8_t router_preference;
158 bool router_managed;
159 bool router_other_information;
160 bool router_emit_dns;
161 bool router_emit_domains;
162 usec_t router_dns_lifetime_usec;
163 struct in6_addr *router_dns;
164 unsigned n_router_dns;
165 OrderedSet *router_search_domains;
166 bool dhcp6_force_pd_other_information; /* Start DHCPv6 PD also when 'O'
167 RA flag is set, see RFC 7084,
168 WPD-4 */
169
170 /* Bridge Support */
171 int use_bpdu;
172 int hairpin;
173 int fast_leave;
174 int allow_port_to_be_root;
175 int unicast_flood;
176 int multicast_flood;
177 int multicast_to_unicast;
178 int neighbor_suppression;
179 int learning;
180 int bridge_proxy_arp;
181 int bridge_proxy_arp_wifi;
182 uint32_t cost;
183 uint16_t priority;
184 MulticastRouter multicast_router;
185
186 bool use_br_vlan;
187 uint16_t pvid;
188 uint32_t br_vid_bitmap[BRIDGE_VLAN_BITMAP_LEN];
189 uint32_t br_untagged_bitmap[BRIDGE_VLAN_BITMAP_LEN];
190
191 /* CAN support */
192 size_t can_bitrate;
193 unsigned can_sample_point;
194 usec_t can_restart_us;
195 int can_triple_sampling;
196
197 AddressFamily ip_forward;
198 bool ip_masquerade;
199
200 int ipv6_accept_ra;
201 int ipv6_dad_transmits;
202 int ipv6_hop_limit;
203 int ipv6_proxy_ndp;
204 int proxy_arp;
205 uint32_t ipv6_mtu;
206
207 bool ipv6_accept_ra_use_dns;
208 bool ipv6_accept_ra_use_autonomous_prefix;
209 bool ipv6_accept_ra_use_onlink_prefix;
210 bool active_slave;
211 bool primary_slave;
212 DHCPUseDomains ipv6_accept_ra_use_domains;
213 uint32_t ipv6_accept_ra_route_table;
214 bool ipv6_accept_ra_route_table_set;
215 Set *ndisc_black_listed_prefix;
216
217 union in_addr_union ipv6_token;
218 IPv6PrivacyExtensions ipv6_privacy_extensions;
219
220 struct ether_addr *mac;
221 uint32_t mtu;
222 int arp;
223 int multicast;
224 int allmulticast;
225 bool unmanaged;
226 bool configure_without_carrier;
227 bool ignore_carrier_loss;
228 KeepConfiguration keep_configuration;
229 uint32_t iaid;
230 DUID duid;
231
232 bool iaid_set;
233
234 bool required_for_online; /* Is this network required to be considered online? */
235 LinkOperationalState required_operstate_for_online;
236
237 LLDPMode lldp_mode; /* LLDP reception */
238 LLDPEmit lldp_emit; /* LLDP transmission */
239
240 LIST_HEAD(Address, static_addresses);
241 LIST_HEAD(Route, static_routes);
242 LIST_HEAD(NextHop, static_nexthops);
243 LIST_HEAD(FdbEntry, static_fdb_entries);
244 LIST_HEAD(IPv6ProxyNDPAddress, ipv6_proxy_ndp_addresses);
245 LIST_HEAD(Neighbor, neighbors);
246 LIST_HEAD(AddressLabel, address_labels);
247 LIST_HEAD(Prefix, static_prefixes);
248 LIST_HEAD(RoutePrefix, static_route_prefixes);
249 LIST_HEAD(RoutingPolicyRule, rules);
250
251 unsigned n_static_addresses;
252 unsigned n_static_routes;
253 unsigned n_static_nexthops;
254 unsigned n_static_fdb_entries;
255 unsigned n_ipv6_proxy_ndp_addresses;
256 unsigned n_neighbors;
257 unsigned n_address_labels;
258 unsigned n_static_prefixes;
259 unsigned n_static_route_prefixes;
260 unsigned n_rules;
261
262 Hashmap *addresses_by_section;
263 Hashmap *routes_by_section;
264 Hashmap *nexthops_by_section;
265 Hashmap *fdb_entries_by_section;
266 Hashmap *neighbors_by_section;
267 Hashmap *address_labels_by_section;
268 Hashmap *prefixes_by_section;
269 Hashmap *route_prefixes_by_section;
270 Hashmap *rules_by_section;
271 OrderedHashmap *qdiscs_by_section;
272
273 /* All kinds of DNS configuration */
274 struct in_addr_data *dns;
275 unsigned n_dns;
276 OrderedSet *search_domains, *route_domains;
277
278 int dns_default_route;
279 ResolveSupport llmnr;
280 ResolveSupport mdns;
281 DnssecMode dnssec_mode;
282 DnsOverTlsMode dns_over_tls_mode;
283 Set *dnssec_negative_trust_anchors;
284
285 char **ntp;
286 char **sip;
287 char **bind_carrier;
288 };
289
290 Network *network_ref(Network *network);
291 Network *network_unref(Network *network);
292 DEFINE_TRIVIAL_CLEANUP_FUNC(Network*, network_unref);
293
294 int network_load(Manager *manager, OrderedHashmap **networks);
295 int network_reload(Manager *manager);
296 int network_load_one(Manager *manager, OrderedHashmap **networks, const char *filename);
297 int network_verify(Network *network);
298
299 int network_get_by_name(Manager *manager, const char *name, Network **ret);
300 int network_get(Manager *manager, sd_device *device, const char *ifname, char * const *alternative_names,
301 const struct ether_addr *mac, enum nl80211_iftype wlan_iftype, const char *ssid,
302 const struct ether_addr *bssid, Network **ret);
303 int network_apply(Network *network, Link *link);
304 void network_apply_anonymize_if_set(Network *network);
305
306 bool network_has_static_ipv6_configurations(Network *network);
307
308 CONFIG_PARSER_PROTOTYPE(config_parse_stacked_netdev);
309 CONFIG_PARSER_PROTOTYPE(config_parse_tunnel);
310 CONFIG_PARSER_PROTOTYPE(config_parse_ipv6token);
311 CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_privacy_extensions);
312 CONFIG_PARSER_PROTOTYPE(config_parse_domains);
313 CONFIG_PARSER_PROTOTYPE(config_parse_dns);
314 CONFIG_PARSER_PROTOTYPE(config_parse_hostname);
315 CONFIG_PARSER_PROTOTYPE(config_parse_timezone);
316 CONFIG_PARSER_PROTOTYPE(config_parse_dnssec_negative_trust_anchors);
317 CONFIG_PARSER_PROTOTYPE(config_parse_ntp);
318 CONFIG_PARSER_PROTOTYPE(config_parse_required_for_online);
319 CONFIG_PARSER_PROTOTYPE(config_parse_keep_configuration);
320
321 const struct ConfigPerfItem* network_network_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
322
323 const char* ipv6_privacy_extensions_to_string(IPv6PrivacyExtensions i) _const_;
324 IPv6PrivacyExtensions ipv6_privacy_extensions_from_string(const char *s) _pure_;
325
326 const char* keep_configuration_to_string(KeepConfiguration i) _const_;
327 KeepConfiguration keep_configuration_from_string(const char *s) _pure_;