1 /* SPDX-License-Identifier: LGPL-2.1+ */
8 #include "conf-parser.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-radv.h"
23 #include "networkd-route.h"
24 #include "networkd-routing-policy-rule.h"
25 #include "networkd-util.h"
26 #include "ordered-set.h"
27 #include "resolve-util.h"
29 typedef enum IPv6PrivacyExtensions
{
30 /* The values map to the kernel's /proc/sys/net/ipv6/conf/xxx/use_tempaddr values */
31 IPV6_PRIVACY_EXTENSIONS_NO
,
32 IPV6_PRIVACY_EXTENSIONS_PREFER_PUBLIC
,
33 IPV6_PRIVACY_EXTENSIONS_YES
, /* aka prefer-temporary */
34 _IPV6_PRIVACY_EXTENSIONS_MAX
,
35 _IPV6_PRIVACY_EXTENSIONS_INVALID
= -1,
36 } IPv6PrivacyExtensions
;
38 typedef enum KeepConfiguration
{
39 KEEP_CONFIGURATION_NO
= 0,
40 KEEP_CONFIGURATION_DHCP_ON_START
= 1 << 0,
41 KEEP_CONFIGURATION_DHCP_ON_STOP
= 1 << 1,
42 KEEP_CONFIGURATION_DHCP
= KEEP_CONFIGURATION_DHCP_ON_START
| KEEP_CONFIGURATION_DHCP_ON_STOP
,
43 KEEP_CONFIGURATION_STATIC
= 1 << 2,
44 KEEP_CONFIGURATION_YES
= KEEP_CONFIGURATION_DHCP
| KEEP_CONFIGURATION_STATIC
,
45 _KEEP_CONFIGURATION_MAX
,
46 _KEEP_CONFIGURATION_INVALID
= -1,
49 typedef struct Manager Manager
;
64 char **match_property
;
65 LIST_HEAD(Condition
, conditions
);
73 Hashmap
*stacked_netdevs
;
77 Hashmap
*stacked_netdev_names
;
79 /* DHCP Client Support */
81 DHCPClientIdentifier dhcp_client_identifier
;
82 char *dhcp_vendor_class_identifier
;
83 char **dhcp_user_class
;
85 uint64_t dhcp_max_attempts
;
86 unsigned dhcp_route_metric
;
87 uint32_t dhcp_route_table
;
88 uint16_t dhcp_client_port
;
90 bool dhcp_send_hostname
;
94 bool dhcp_routes_to_dns
;
98 bool dhcp_use_timezone
;
100 bool dhcp_use_hostname
;
101 bool dhcp_route_table_set
;
102 bool dhcp_send_release
;
103 DHCPUseDomains dhcp_use_domains
;
104 Set
*dhcp_black_listed_ip
;
106 /* DHCPv6 Client support*/
110 /* DHCP Server Support */
112 bool dhcp_server_emit_dns
;
113 struct in_addr
*dhcp_server_dns
;
114 unsigned n_dhcp_server_dns
;
115 bool dhcp_server_emit_ntp
;
116 struct in_addr
*dhcp_server_ntp
;
117 unsigned n_dhcp_server_ntp
;
118 bool dhcp_server_emit_router
;
119 bool dhcp_server_emit_timezone
;
120 char *dhcp_server_timezone
;
121 usec_t dhcp_server_default_lease_time_usec
, dhcp_server_max_lease_time_usec
;
122 uint32_t dhcp_server_pool_offset
;
123 uint32_t dhcp_server_pool_size
;
126 AddressFamily link_local
;
129 bool default_route_on_device
;
131 /* IPv6 prefix delegation support */
132 RADVPrefixDelegation router_prefix_delegation
;
133 usec_t router_lifetime_usec
;
134 uint8_t router_preference
;
136 bool router_other_information
;
137 bool router_emit_dns
;
138 bool router_emit_domains
;
139 usec_t router_dns_lifetime_usec
;
140 struct in6_addr
*router_dns
;
141 unsigned n_router_dns
;
142 OrderedSet
*router_search_domains
;
143 bool dhcp6_force_pd_other_information
; /* Start DHCPv6 PD also when 'O'
144 RA flag is set, see RFC 7084,
151 int allow_port_to_be_root
;
154 int multicast_to_unicast
;
155 int neighbor_suppression
;
157 int bridge_proxy_arp
;
158 int bridge_proxy_arp_wifi
;
161 MulticastRouter multicast_router
;
165 uint32_t br_vid_bitmap
[BRIDGE_VLAN_BITMAP_LEN
];
166 uint32_t br_untagged_bitmap
[BRIDGE_VLAN_BITMAP_LEN
];
170 unsigned can_sample_point
;
171 usec_t can_restart_us
;
172 int can_triple_sampling
;
174 AddressFamily ip_forward
;
178 int ipv6_dad_transmits
;
184 bool ipv6_accept_ra_use_dns
;
185 bool ipv6_accept_ra_use_autonomous_prefix
;
186 bool ipv6_accept_ra_use_onlink_prefix
;
189 DHCPUseDomains ipv6_accept_ra_use_domains
;
190 uint32_t ipv6_accept_ra_route_table
;
191 bool ipv6_accept_ra_route_table_set
;
192 Set
*ndisc_black_listed_prefix
;
194 union in_addr_union ipv6_token
;
195 IPv6PrivacyExtensions ipv6_privacy_extensions
;
197 struct ether_addr
*mac
;
203 bool configure_without_carrier
;
204 bool ignore_carrier_loss
;
205 KeepConfiguration keep_configuration
;
211 bool required_for_online
; /* Is this network required to be considered online? */
212 LinkOperationalState required_operstate_for_online
;
214 LLDPMode lldp_mode
; /* LLDP reception */
215 LLDPEmit lldp_emit
; /* LLDP transmission */
217 LIST_HEAD(Address
, static_addresses
);
218 LIST_HEAD(Route
, static_routes
);
219 LIST_HEAD(FdbEntry
, static_fdb_entries
);
220 LIST_HEAD(IPv6ProxyNDPAddress
, ipv6_proxy_ndp_addresses
);
221 LIST_HEAD(Neighbor
, neighbors
);
222 LIST_HEAD(AddressLabel
, address_labels
);
223 LIST_HEAD(Prefix
, static_prefixes
);
224 LIST_HEAD(RoutingPolicyRule
, rules
);
226 unsigned n_static_addresses
;
227 unsigned n_static_routes
;
228 unsigned n_static_fdb_entries
;
229 unsigned n_ipv6_proxy_ndp_addresses
;
230 unsigned n_neighbors
;
231 unsigned n_address_labels
;
232 unsigned n_static_prefixes
;
235 Hashmap
*addresses_by_section
;
236 Hashmap
*routes_by_section
;
237 Hashmap
*fdb_entries_by_section
;
238 Hashmap
*neighbors_by_section
;
239 Hashmap
*address_labels_by_section
;
240 Hashmap
*prefixes_by_section
;
241 Hashmap
*rules_by_section
;
243 /* All kinds of DNS configuration */
244 struct in_addr_data
*dns
;
246 OrderedSet
*search_domains
, *route_domains
;
248 int dns_default_route
;
249 ResolveSupport llmnr
;
251 DnssecMode dnssec_mode
;
252 DnsOverTlsMode dns_over_tls_mode
;
253 Set
*dnssec_negative_trust_anchors
;
259 Network
*network_ref(Network
*network
);
260 Network
*network_unref(Network
*network
);
261 DEFINE_TRIVIAL_CLEANUP_FUNC(Network
*, network_unref
);
263 int network_load(Manager
*manager
);
264 int network_load_one(Manager
*manager
, const char *filename
);
265 int network_verify(Network
*network
);
267 int network_get_by_name(Manager
*manager
, const char *name
, Network
**ret
);
268 int network_get(Manager
*manager
, sd_device
*device
, const char *ifname
, const struct ether_addr
*mac
, Network
**ret
);
269 int network_apply(Network
*network
, Link
*link
);
270 void network_apply_anonymize_if_set(Network
*network
);
272 bool network_has_static_ipv6_configurations(Network
*network
);
274 CONFIG_PARSER_PROTOTYPE(config_parse_stacked_netdev
);
275 CONFIG_PARSER_PROTOTYPE(config_parse_tunnel
);
276 CONFIG_PARSER_PROTOTYPE(config_parse_ipv6token
);
277 CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_privacy_extensions
);
278 CONFIG_PARSER_PROTOTYPE(config_parse_domains
);
279 CONFIG_PARSER_PROTOTYPE(config_parse_dns
);
280 CONFIG_PARSER_PROTOTYPE(config_parse_hostname
);
281 CONFIG_PARSER_PROTOTYPE(config_parse_timezone
);
282 CONFIG_PARSER_PROTOTYPE(config_parse_dnssec_negative_trust_anchors
);
283 CONFIG_PARSER_PROTOTYPE(config_parse_ntp
);
284 CONFIG_PARSER_PROTOTYPE(config_parse_required_for_online
);
285 CONFIG_PARSER_PROTOTYPE(config_parse_keep_configuration
);
287 const struct ConfigPerfItem
* network_network_gperf_lookup(const char *key
, GPERF_LEN_TYPE length
);
289 const char* ipv6_privacy_extensions_to_string(IPv6PrivacyExtensions i
) _const_
;
290 IPv6PrivacyExtensions
ipv6_privacy_extensions_from_string(const char *s
) _pure_
;
292 const char* keep_configuration_to_string(KeepConfiguration i
) _const_
;
293 KeepConfiguration
keep_configuration_from_string(const char *s
) _pure_
;