]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/network/networkd-network.h
cb3a50d9badb59cbb48e448a41386f02736c0d8c
[thirdparty/systemd.git] / src / network / networkd-network.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #pragma once
4
5 /***
6 This file is part of systemd.
7
8 Copyright 2013 Tom Gundersen <teg@jklm.no>
9
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 ***/
23
24 #include "condition.h"
25
26 typedef struct Network Network;
27
28 #include "networkd-address.h"
29 #include "networkd-fdb.h"
30 #include "networkd-netdev.h"
31 #include "networkd-route.h"
32 #include "networkd-util.h"
33 #include "networkd.h"
34
35 #define DHCP_ROUTE_METRIC 1024
36 #define IPV4LL_ROUTE_METRIC 2048
37
38 typedef enum DCHPClientIdentifier {
39 DHCP_CLIENT_ID_MAC,
40 DHCP_CLIENT_ID_DUID,
41 _DHCP_CLIENT_ID_MAX,
42 _DHCP_CLIENT_ID_INVALID = -1,
43 } DCHPClientIdentifier;
44
45 typedef enum IPv6PrivacyExtensions {
46 /* The values map to the kernel's /proc/sys/net/ipv6/conf/xxx/use_tempaddr values */
47 IPV6_PRIVACY_EXTENSIONS_NO,
48 IPV6_PRIVACY_EXTENSIONS_PREFER_PUBLIC,
49 IPV6_PRIVACY_EXTENSIONS_YES, /* aka prefer-temporary */
50 _IPV6_PRIVACY_EXTENSIONS_MAX,
51 _IPV6_PRIVACY_EXTENSIONS_INVALID = -1,
52 } IPv6PrivacyExtensions;
53
54 struct Network {
55 Manager *manager;
56
57 char *filename;
58 char *name;
59
60 struct ether_addr *match_mac;
61 char **match_path;
62 char **match_driver;
63 char **match_type;
64 char **match_name;
65
66 Condition *match_host;
67 Condition *match_virt;
68 Condition *match_kernel;
69 Condition *match_arch;
70
71 char *description;
72
73 NetDev *bridge;
74 NetDev *bond;
75 Hashmap *stacked_netdevs;
76
77 /* DHCP Client Support */
78 AddressFamilyBoolean dhcp;
79 DCHPClientIdentifier dhcp_client_identifier;
80 char *dhcp_vendor_class_identifier;
81 char *hostname;
82 bool dhcp_dns;
83 bool dhcp_ntp;
84 bool dhcp_mtu;
85 bool dhcp_hostname;
86 bool dhcp_domains;
87 bool dhcp_sendhost;
88 bool dhcp_broadcast;
89 bool dhcp_critical;
90 bool dhcp_routes;
91 bool dhcp_timezone;
92 unsigned dhcp_route_metric;
93
94 /* DHCP Server Support */
95 bool dhcp_server;
96 bool dhcp_server_emit_dns;
97 struct in_addr *dhcp_server_dns;
98 unsigned n_dhcp_server_dns;
99 bool dhcp_server_emit_ntp;
100 struct in_addr *dhcp_server_ntp;
101 unsigned n_dhcp_server_ntp;
102 bool dhcp_server_emit_timezone;
103 char *dhcp_server_timezone;
104 usec_t dhcp_server_default_lease_time_usec, dhcp_server_max_lease_time_usec;
105 uint32_t dhcp_server_pool_offset;
106 uint32_t dhcp_server_pool_size;
107
108 /* IPV4LL Support */
109 AddressFamilyBoolean link_local;
110 bool ipv4ll_route;
111
112 /* Bridge Support */
113 bool use_bpdu;
114 bool hairpin;
115 bool fast_leave;
116 bool allow_port_to_be_root;
117 bool unicast_flood;
118 unsigned cost;
119
120 AddressFamilyBoolean ip_forward;
121 bool ip_masquerade;
122
123 int ipv6_accept_ra;
124 int ipv6_dad_transmits;
125 int ipv6_hop_limit;
126
127 union in_addr_union ipv6_token;
128 IPv6PrivacyExtensions ipv6_privacy_extensions;
129
130 struct ether_addr *mac;
131 unsigned mtu;
132
133 bool lldp;
134
135 LIST_HEAD(Address, static_addresses);
136 LIST_HEAD(Route, static_routes);
137 LIST_HEAD(FdbEntry, static_fdb_entries);
138
139 Hashmap *addresses_by_section;
140 Hashmap *routes_by_section;
141 Hashmap *fdb_entries_by_section;
142
143 bool wildcard_domain;
144 char **domains, **dns, **ntp, **bind_carrier;
145
146 ResolveSupport llmnr;
147
148 LIST_FIELDS(Network, networks);
149 };
150
151 void network_free(Network *network);
152
153 DEFINE_TRIVIAL_CLEANUP_FUNC(Network*, network_free);
154 #define _cleanup_network_free_ _cleanup_(network_freep)
155
156 int network_load(Manager *manager);
157
158 int network_get_by_name(Manager *manager, const char *name, Network **ret);
159 int network_get(Manager *manager, struct udev_device *device, const char *ifname, const struct ether_addr *mac, Network **ret);
160 int network_apply(Manager *manager, Network *network, Link *link);
161
162 int config_parse_netdev(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
163 int config_parse_domains(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
164 int config_parse_tunnel(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
165 int config_parse_dhcp(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
166 int config_parse_dhcp_client_identifier(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
167 int config_parse_ipv6token(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
168 int config_parse_ipv6_privacy_extensions(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
169 int config_parse_hostname(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
170 int config_parse_timezone(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
171 int config_parse_dhcp_server_dns(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
172 int config_parse_dhcp_server_ntp(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
173
174 /* Legacy IPv4LL support */
175 int config_parse_ipv4ll(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
176
177 const struct ConfigPerfItem* network_network_gperf_lookup(const char *key, unsigned length);
178
179 extern const sd_bus_vtable network_vtable[];
180
181 int network_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error);
182 int network_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error);
183
184 const char* ipv6_privacy_extensions_to_string(IPv6PrivacyExtensions i) _const_;
185 IPv6PrivacyExtensions ipv6_privacy_extensions_from_string(const char *s) _pure_;