]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/network/networkd-network.h
network DHCP4: Dont mislead the logs.
[thirdparty/systemd.git] / src / network / networkd-network.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
fc2f9534
LP
2#pragma once
3
634f0f98 4#include "sd-bus.h"
51517f9e 5#include "sd-device.h"
634f0f98 6
fc2f9534 7#include "condition.h"
a2106925 8#include "conf-parser.h"
634f0f98 9#include "hashmap.h"
8e2cb51c 10#include "netdev/bridge.h"
a2106925 11#include "netdev/netdev.h"
95b74ef6 12#include "networkd-address-label.h"
a2106925 13#include "networkd-address.h"
13b498f9 14#include "networkd-brvlan.h"
ca5ad760
YW
15#include "networkd-dhcp-common.h"
16#include "networkd-dhcp4.h"
fc2f9534 17#include "networkd-fdb.h"
a0e5c15d 18#include "networkd-ipv6-proxy-ndp.h"
7f853950 19#include "networkd-lldp-rx.h"
a2106925 20#include "networkd-lldp-tx.h"
e4a71bf3 21#include "networkd-neighbor.h"
6e849e95 22#include "networkd-radv.h"
71d35b6b 23#include "networkd-route.h"
bce67bbe 24#include "networkd-routing-policy-rule.h"
fc2f9534 25#include "networkd-util.h"
5e2a51d5 26#include "ordered-set.h"
a2106925 27#include "resolve-util.h"
fc2f9534 28
fc2f9534
LP
29typedef 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;
37
7da377ef 38typedef enum KeepConfiguration {
95355a28
YW
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,
7da377ef
SS
45 _KEEP_CONFIGURATION_MAX,
46 _KEEP_CONFIGURATION_INVALID = -1,
47} KeepConfiguration;
48
634f0f98
ZJS
49typedef struct Manager Manager;
50
fc2f9534
LP
51struct Network {
52 Manager *manager;
53
54 char *filename;
55 char *name;
56
35ac3b76
YW
57 unsigned n_ref;
58
e90d0374 59 Set *match_mac;
fc2f9534
LP
60 char **match_path;
61 char **match_driver;
62 char **match_type;
63 char **match_name;
44005bfb 64 char **match_property;
1beabe08 65 LIST_HEAD(Condition, conditions);
fc2f9534
LP
66
67 char *description;
68
69 NetDev *bridge;
70 NetDev *bond;
6cb955c6 71 NetDev *vrf;
98d20a17 72 NetDev *xfrm;
fc2f9534 73 Hashmap *stacked_netdevs;
cebe1257
YW
74 char *bridge_name;
75 char *bond_name;
76 char *vrf_name;
77 Hashmap *stacked_netdev_names;
fc2f9534
LP
78
79 /* DHCP Client Support */
2d792895 80 AddressFamily dhcp;
499d555a 81 DHCPClientIdentifier dhcp_client_identifier;
fc2f9534 82 char *dhcp_vendor_class_identifier;
af1c0de0 83 char **dhcp_user_class;
27cb34f5 84 char *dhcp_hostname;
715cedfb 85 uint64_t dhcp_max_attempts;
94e9bd57
LP
86 unsigned dhcp_route_metric;
87 uint32_t dhcp_route_table;
9c77d107 88 uint16_t dhcp_client_port;
7585baa0 89 bool dhcp_anonymize;
27cb34f5 90 bool dhcp_send_hostname;
fc2f9534 91 bool dhcp_broadcast;
7da377ef 92 int dhcp_critical;
94e9bd57 93 bool dhcp_use_dns;
a24e12f0 94 bool dhcp_routes_to_dns;
94e9bd57
LP
95 bool dhcp_use_ntp;
96 bool dhcp_use_mtu;
27cb34f5
LP
97 bool dhcp_use_routes;
98 bool dhcp_use_timezone;
fb5c8216 99 bool rapid_commit;
94e9bd57 100 bool dhcp_use_hostname;
fc1ba79d 101 bool dhcp_route_table_set;
1501b429 102 bool dhcp_send_release;
94e9bd57 103 DHCPUseDomains dhcp_use_domains;
727b5734 104 Set *dhcp_black_listed_ip;
fc2f9534 105
caa8ca42
SS
106 /* DHCPv6 Client support*/
107 bool dhcp6_use_dns;
108 bool dhcp6_use_ntp;
109
fc2f9534
LP
110 /* DHCP Server Support */
111 bool dhcp_server;
1a04db0f
LP
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;
77ff6022 118 bool dhcp_server_emit_router;
fc2f9534 119 bool dhcp_server_emit_timezone;
1a04db0f 120 char *dhcp_server_timezone;
fc2f9534 121 usec_t dhcp_server_default_lease_time_usec, dhcp_server_max_lease_time_usec;
9b3a67c5
TG
122 uint32_t dhcp_server_pool_offset;
123 uint32_t dhcp_server_pool_size;
fc2f9534
LP
124
125 /* IPV4LL Support */
2d792895 126 AddressFamily link_local;
fc2f9534
LP
127 bool ipv4ll_route;
128
5d5003ab
YW
129 bool default_route_on_device;
130
7d5cac19 131 /* IPv6 prefix delegation support */
56a23cb4 132 RADVPrefixDelegation router_prefix_delegation;
7d5cac19
PF
133 usec_t router_lifetime_usec;
134 uint8_t router_preference;
135 bool router_managed;
136 bool router_other_information;
9e25315c
PF
137 bool router_emit_dns;
138 bool router_emit_domains;
88295a05
PF
139 usec_t router_dns_lifetime_usec;
140 struct in6_addr *router_dns;
141 unsigned n_router_dns;
5e2a51d5 142 OrderedSet *router_search_domains;
125f20b4
PF
143 bool dhcp6_force_pd_other_information; /* Start DHCPv6 PD also when 'O'
144 RA flag is set, see RFC 7084,
145 WPD-4 */
7d5cac19 146
fc2f9534 147 /* Bridge Support */
7f9915f0
SS
148 int use_bpdu;
149 int hairpin;
150 int fast_leave;
151 int allow_port_to_be_root;
152 int unicast_flood;
7f15b714 153 int multicast_flood;
d3aa8b49 154 int multicast_to_unicast;
7f15b714
TJ
155 int neighbor_suppression;
156 int learning;
1087623b
SS
157 int bridge_proxy_arp;
158 int bridge_proxy_arp_wifi;
b56be296
DJL
159 uint32_t cost;
160 uint16_t priority;
0fadb2a4 161 MulticastRouter multicast_router;
fc2f9534 162
ffff9abe 163 bool use_br_vlan;
13b498f9
TJ
164 uint16_t pvid;
165 uint32_t br_vid_bitmap[BRIDGE_VLAN_BITMAP_LEN];
166 uint32_t br_untagged_bitmap[BRIDGE_VLAN_BITMAP_LEN];
167
06828bb6
HP
168 /* CAN support */
169 size_t can_bitrate;
170 unsigned can_sample_point;
171 usec_t can_restart_us;
c423be28 172 int can_triple_sampling;
06828bb6 173
2d792895 174 AddressFamily ip_forward;
fc2f9534
LP
175 bool ip_masquerade;
176
4f2e437a 177 int ipv6_accept_ra;
8749cbcd 178 int ipv6_dad_transmits;
b69c3180 179 int ipv6_hop_limit;
465dfe59 180 int ipv6_proxy_ndp;
23d8b221 181 int proxy_arp;
4e964aa0 182 uint32_t ipv6_mtu;
4f2e437a 183
1e7a0e21 184 bool ipv6_accept_ra_use_dns;
062c2eea
SS
185 bool ipv6_accept_ra_use_autonomous_prefix;
186 bool ipv6_accept_ra_use_onlink_prefix;
eb64b435
SS
187 bool active_slave;
188 bool primary_slave;
1e7a0e21 189 DHCPUseDomains ipv6_accept_ra_use_domains;
2ba31d29 190 uint32_t ipv6_accept_ra_route_table;
d5fa3339 191 bool ipv6_accept_ra_route_table_set;
e520ce64 192 Set *ndisc_black_listed_prefix;
1e7a0e21 193
fc2f9534
LP
194 union in_addr_union ipv6_token;
195 IPv6PrivacyExtensions ipv6_privacy_extensions;
196
197 struct ether_addr *mac;
4e964aa0 198 uint32_t mtu;
99d2baa2 199 int arp;
e6ebebbe 200 int multicast;
866e6b7a 201 int allmulticast;
a09dc546 202 bool unmanaged;
dad2d78e 203 bool configure_without_carrier;
93b4dab5 204 bool ignore_carrier_loss;
7da377ef 205 KeepConfiguration keep_configuration;
413708d1 206 uint32_t iaid;
8341a5c3 207 DUID duid;
fc2f9534 208
8217ed5e
TH
209 bool iaid_set;
210
c1a38904 211 bool required_for_online; /* Is this network required to be considered online? */
4ac77d63 212 LinkOperationalState required_operstate_for_online;
c1a38904 213
8e1ad1ea 214 LLDPMode lldp_mode; /* LLDP reception */
7272b25e 215 LLDPEmit lldp_emit; /* LLDP transmission */
fc2f9534
LP
216
217 LIST_HEAD(Address, static_addresses);
218 LIST_HEAD(Route, static_routes);
219 LIST_HEAD(FdbEntry, static_fdb_entries);
a0e5c15d 220 LIST_HEAD(IPv6ProxyNDPAddress, ipv6_proxy_ndp_addresses);
e4a71bf3 221 LIST_HEAD(Neighbor, neighbors);
95b74ef6 222 LIST_HEAD(AddressLabel, address_labels);
057abfd8 223 LIST_HEAD(Prefix, static_prefixes);
bce67bbe 224 LIST_HEAD(RoutingPolicyRule, rules);
fc2f9534 225
8c34b963
LP
226 unsigned n_static_addresses;
227 unsigned n_static_routes;
228 unsigned n_static_fdb_entries;
a0e5c15d 229 unsigned n_ipv6_proxy_ndp_addresses;
e4a71bf3 230 unsigned n_neighbors;
95b74ef6 231 unsigned n_address_labels;
057abfd8 232 unsigned n_static_prefixes;
bce67bbe 233 unsigned n_rules;
8c34b963 234
fc2f9534
LP
235 Hashmap *addresses_by_section;
236 Hashmap *routes_by_section;
237 Hashmap *fdb_entries_by_section;
e4a71bf3 238 Hashmap *neighbors_by_section;
95b74ef6 239 Hashmap *address_labels_by_section;
057abfd8 240 Hashmap *prefixes_by_section;
bce67bbe 241 Hashmap *rules_by_section;
fc2f9534 242
7ece6f58 243 /* All kinds of DNS configuration */
5512a963
LP
244 struct in_addr_data *dns;
245 unsigned n_dns;
5e2a51d5
ZJS
246 OrderedSet *search_domains, *route_domains;
247
7ece6f58 248 int dns_default_route;
fc2f9534 249 ResolveSupport llmnr;
aaa297d4 250 ResolveSupport mdns;
ad6c0475 251 DnssecMode dnssec_mode;
c9299be2 252 DnsOverTlsMode dns_over_tls_mode;
8a516214 253 Set *dnssec_negative_trust_anchors;
fc2f9534 254
7ece6f58
LP
255 char **ntp;
256 char **bind_carrier;
fc2f9534
LP
257};
258
35ac3b76
YW
259Network *network_ref(Network *network);
260Network *network_unref(Network *network);
261DEFINE_TRIVIAL_CLEANUP_FUNC(Network*, network_unref);
fc2f9534
LP
262
263int network_load(Manager *manager);
212bd73c 264int network_load_one(Manager *manager, const char *filename);
96db6412 265int network_verify(Network *network);
fc2f9534
LP
266
267int network_get_by_name(Manager *manager, const char *name, Network **ret);
51517f9e 268int network_get(Manager *manager, sd_device *device, const char *ifname, const struct ether_addr *mac, Network **ret);
7d342c03 269int network_apply(Network *network, Link *link);
add8d07d 270void network_apply_anonymize_if_set(Network *network);
fc2f9534 271
adfeee49 272bool network_has_static_ipv6_configurations(Network *network);
439689c6 273
cebe1257 274CONFIG_PARSER_PROTOTYPE(config_parse_stacked_netdev);
a2106925 275CONFIG_PARSER_PROTOTYPE(config_parse_tunnel);
a2106925
LP
276CONFIG_PARSER_PROTOTYPE(config_parse_ipv6token);
277CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_privacy_extensions);
ca5ad760
YW
278CONFIG_PARSER_PROTOTYPE(config_parse_domains);
279CONFIG_PARSER_PROTOTYPE(config_parse_dns);
a2106925
LP
280CONFIG_PARSER_PROTOTYPE(config_parse_hostname);
281CONFIG_PARSER_PROTOTYPE(config_parse_timezone);
a2106925 282CONFIG_PARSER_PROTOTYPE(config_parse_dnssec_negative_trust_anchors);
a2106925 283CONFIG_PARSER_PROTOTYPE(config_parse_ntp);
4ac77d63 284CONFIG_PARSER_PROTOTYPE(config_parse_required_for_online);
7da377ef 285CONFIG_PARSER_PROTOTYPE(config_parse_keep_configuration);
fc2f9534 286
c9f7b4d3 287const struct ConfigPerfItem* network_network_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
fc2f9534 288
fc2f9534
LP
289const char* ipv6_privacy_extensions_to_string(IPv6PrivacyExtensions i) _const_;
290IPv6PrivacyExtensions ipv6_privacy_extensions_from_string(const char *s) _pure_;
b2a81c0b 291
7da377ef
SS
292const char* keep_configuration_to_string(KeepConfiguration i) _const_;
293KeepConfiguration keep_configuration_from_string(const char *s) _pure_;