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
);
72 Hashmap
*stacked_netdevs
;
76 Hashmap
*stacked_netdev_names
;
78 /* DHCP Client Support */
79 AddressFamilyBoolean dhcp
;
80 DHCPClientIdentifier dhcp_client_identifier
;
81 char *dhcp_vendor_class_identifier
;
82 char **dhcp_user_class
;
84 uint64_t dhcp_max_attempts
;
85 unsigned dhcp_route_metric
;
86 uint32_t dhcp_route_table
;
87 uint16_t dhcp_client_port
;
89 bool dhcp_send_hostname
;
96 bool dhcp_use_timezone
;
98 bool dhcp_use_hostname
;
99 bool dhcp_route_table_set
;
100 bool dhcp_send_release
;
101 DHCPUseDomains dhcp_use_domains
;
102 Set
*dhcp_black_listed_ip
;
104 /* DHCP Server Support */
106 bool dhcp_server_emit_dns
;
107 struct in_addr
*dhcp_server_dns
;
108 unsigned n_dhcp_server_dns
;
109 bool dhcp_server_emit_ntp
;
110 struct in_addr
*dhcp_server_ntp
;
111 unsigned n_dhcp_server_ntp
;
112 bool dhcp_server_emit_router
;
113 bool dhcp_server_emit_timezone
;
114 char *dhcp_server_timezone
;
115 usec_t dhcp_server_default_lease_time_usec
, dhcp_server_max_lease_time_usec
;
116 uint32_t dhcp_server_pool_offset
;
117 uint32_t dhcp_server_pool_size
;
120 AddressFamilyBoolean link_local
;
123 bool default_route_on_device
;
125 /* IPv6 prefix delegation support */
126 RADVPrefixDelegation router_prefix_delegation
;
127 usec_t router_lifetime_usec
;
128 uint8_t router_preference
;
130 bool router_other_information
;
131 bool router_emit_dns
;
132 bool router_emit_domains
;
133 usec_t router_dns_lifetime_usec
;
134 struct in6_addr
*router_dns
;
135 unsigned n_router_dns
;
136 OrderedSet
*router_search_domains
;
137 bool dhcp6_force_pd_other_information
; /* Start DHCPv6 PD also when 'O'
138 RA flag is set, see RFC 7084,
145 int allow_port_to_be_root
;
148 int multicast_to_unicast
;
149 int neighbor_suppression
;
151 int bridge_proxy_arp
;
152 int bridge_proxy_arp_wifi
;
155 MulticastRouter multicast_router
;
159 uint32_t br_vid_bitmap
[BRIDGE_VLAN_BITMAP_LEN
];
160 uint32_t br_untagged_bitmap
[BRIDGE_VLAN_BITMAP_LEN
];
164 unsigned can_sample_point
;
165 usec_t can_restart_us
;
166 int can_triple_sampling
;
168 AddressFamilyBoolean ip_forward
;
172 int ipv6_dad_transmits
;
178 bool ipv6_accept_ra_use_dns
;
179 bool ipv6_accept_ra_use_autonomous_prefix
;
180 bool ipv6_accept_ra_use_onlink_prefix
;
183 DHCPUseDomains ipv6_accept_ra_use_domains
;
184 uint32_t ipv6_accept_ra_route_table
;
185 bool ipv6_accept_ra_route_table_set
;
186 Set
*ndisc_black_listed_prefix
;
188 union in_addr_union ipv6_token
;
189 IPv6PrivacyExtensions ipv6_privacy_extensions
;
191 struct ether_addr
*mac
;
197 bool configure_without_carrier
;
198 bool ignore_carrier_loss
;
199 KeepConfiguration keep_configuration
;
205 bool required_for_online
; /* Is this network required to be considered online? */
206 LinkOperationalState required_operstate_for_online
;
208 LLDPMode lldp_mode
; /* LLDP reception */
209 LLDPEmit lldp_emit
; /* LLDP transmission */
211 LIST_HEAD(Address
, static_addresses
);
212 LIST_HEAD(Route
, static_routes
);
213 LIST_HEAD(FdbEntry
, static_fdb_entries
);
214 LIST_HEAD(IPv6ProxyNDPAddress
, ipv6_proxy_ndp_addresses
);
215 LIST_HEAD(Neighbor
, neighbors
);
216 LIST_HEAD(AddressLabel
, address_labels
);
217 LIST_HEAD(Prefix
, static_prefixes
);
218 LIST_HEAD(RoutingPolicyRule
, rules
);
220 unsigned n_static_addresses
;
221 unsigned n_static_routes
;
222 unsigned n_static_fdb_entries
;
223 unsigned n_ipv6_proxy_ndp_addresses
;
224 unsigned n_neighbors
;
225 unsigned n_address_labels
;
226 unsigned n_static_prefixes
;
229 Hashmap
*addresses_by_section
;
230 Hashmap
*routes_by_section
;
231 Hashmap
*fdb_entries_by_section
;
232 Hashmap
*neighbors_by_section
;
233 Hashmap
*address_labels_by_section
;
234 Hashmap
*prefixes_by_section
;
235 Hashmap
*rules_by_section
;
237 /* All kinds of DNS configuration */
238 struct in_addr_data
*dns
;
240 OrderedSet
*search_domains
, *route_domains
;
242 int dns_default_route
;
243 ResolveSupport llmnr
;
245 DnssecMode dnssec_mode
;
246 DnsOverTlsMode dns_over_tls_mode
;
247 Set
*dnssec_negative_trust_anchors
;
253 Network
*network_ref(Network
*network
);
254 Network
*network_unref(Network
*network
);
255 DEFINE_TRIVIAL_CLEANUP_FUNC(Network
*, network_unref
);
257 int network_load(Manager
*manager
);
258 int network_load_one(Manager
*manager
, const char *filename
);
259 int network_verify(Network
*network
);
261 int network_get_by_name(Manager
*manager
, const char *name
, Network
**ret
);
262 int network_get(Manager
*manager
, sd_device
*device
, const char *ifname
, const struct ether_addr
*mac
, Network
**ret
);
263 int network_apply(Network
*network
, Link
*link
);
264 void network_apply_anonymize_if_set(Network
*network
);
266 bool network_has_static_ipv6_addresses(Network
*network
);
268 CONFIG_PARSER_PROTOTYPE(config_parse_stacked_netdev
);
269 CONFIG_PARSER_PROTOTYPE(config_parse_tunnel
);
270 CONFIG_PARSER_PROTOTYPE(config_parse_ipv6token
);
271 CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_privacy_extensions
);
272 CONFIG_PARSER_PROTOTYPE(config_parse_domains
);
273 CONFIG_PARSER_PROTOTYPE(config_parse_dns
);
274 CONFIG_PARSER_PROTOTYPE(config_parse_hostname
);
275 CONFIG_PARSER_PROTOTYPE(config_parse_timezone
);
276 CONFIG_PARSER_PROTOTYPE(config_parse_dnssec_negative_trust_anchors
);
277 CONFIG_PARSER_PROTOTYPE(config_parse_ntp
);
278 CONFIG_PARSER_PROTOTYPE(config_parse_required_for_online
);
279 CONFIG_PARSER_PROTOTYPE(config_parse_keep_configuration
);
281 const struct ConfigPerfItem
* network_network_gperf_lookup(const char *key
, GPERF_LEN_TYPE length
);
283 const char* ipv6_privacy_extensions_to_string(IPv6PrivacyExtensions i
) _const_
;
284 IPv6PrivacyExtensions
ipv6_privacy_extensions_from_string(const char *s
) _pure_
;
286 const char* keep_configuration_to_string(KeepConfiguration i
) _const_
;
287 KeepConfiguration
keep_configuration_from_string(const char *s
) _pure_
;