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