]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/network/networkd-network.h
Merge pull request #2080 from chaloulo/split-mode-host-remove-port-from-journal-filename
[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 #include "resolve-util.h"
26
27 typedef struct Network Network;
28
29 #include "networkd-address.h"
30 #include "networkd-fdb.h"
31 #include "networkd-netdev.h"
32 #include "networkd-route.h"
33 #include "networkd-util.h"
34 #include "networkd.h"
35
36 #define DHCP_ROUTE_METRIC 1024
37 #define IPV4LL_ROUTE_METRIC 2048
38
39 typedef enum DCHPClientIdentifier {
40 DHCP_CLIENT_ID_MAC,
41 DHCP_CLIENT_ID_DUID,
42 _DHCP_CLIENT_ID_MAX,
43 _DHCP_CLIENT_ID_INVALID = -1,
44 } DCHPClientIdentifier;
45
46 typedef enum IPv6PrivacyExtensions {
47 /* The values map to the kernel's /proc/sys/net/ipv6/conf/xxx/use_tempaddr values */
48 IPV6_PRIVACY_EXTENSIONS_NO,
49 IPV6_PRIVACY_EXTENSIONS_PREFER_PUBLIC,
50 IPV6_PRIVACY_EXTENSIONS_YES, /* aka prefer-temporary */
51 _IPV6_PRIVACY_EXTENSIONS_MAX,
52 _IPV6_PRIVACY_EXTENSIONS_INVALID = -1,
53 } IPv6PrivacyExtensions;
54
55 struct Network {
56 Manager *manager;
57
58 char *filename;
59 char *name;
60
61 struct ether_addr *match_mac;
62 char **match_path;
63 char **match_driver;
64 char **match_type;
65 char **match_name;
66
67 Condition *match_host;
68 Condition *match_virt;
69 Condition *match_kernel;
70 Condition *match_arch;
71
72 char *description;
73
74 NetDev *bridge;
75 NetDev *bond;
76 Hashmap *stacked_netdevs;
77
78 /* DHCP Client Support */
79 AddressFamilyBoolean dhcp;
80 DCHPClientIdentifier dhcp_client_identifier;
81 char *dhcp_vendor_class_identifier;
82 char *hostname;
83 bool dhcp_dns;
84 bool dhcp_ntp;
85 bool dhcp_mtu;
86 bool dhcp_hostname;
87 bool dhcp_domains;
88 bool dhcp_sendhost;
89 bool dhcp_broadcast;
90 bool dhcp_critical;
91 bool dhcp_routes;
92 bool dhcp_timezone;
93 unsigned dhcp_route_metric;
94
95 /* DHCP Server Support */
96 bool dhcp_server;
97 bool dhcp_server_emit_dns;
98 struct in_addr *dhcp_server_dns;
99 unsigned n_dhcp_server_dns;
100 bool dhcp_server_emit_ntp;
101 struct in_addr *dhcp_server_ntp;
102 unsigned n_dhcp_server_ntp;
103 bool dhcp_server_emit_timezone;
104 char *dhcp_server_timezone;
105 usec_t dhcp_server_default_lease_time_usec, dhcp_server_max_lease_time_usec;
106 uint32_t dhcp_server_pool_offset;
107 uint32_t dhcp_server_pool_size;
108
109 /* IPV4LL Support */
110 AddressFamilyBoolean link_local;
111 bool ipv4ll_route;
112
113 /* Bridge Support */
114 bool use_bpdu;
115 bool hairpin;
116 bool fast_leave;
117 bool allow_port_to_be_root;
118 bool unicast_flood;
119 unsigned cost;
120
121 AddressFamilyBoolean ip_forward;
122 bool ip_masquerade;
123
124 int ipv6_accept_ra;
125 int ipv6_dad_transmits;
126 int ipv6_hop_limit;
127
128 union in_addr_union ipv6_token;
129 IPv6PrivacyExtensions ipv6_privacy_extensions;
130
131 struct ether_addr *mac;
132 unsigned mtu;
133
134 bool lldp;
135
136 LIST_HEAD(Address, static_addresses);
137 LIST_HEAD(Route, static_routes);
138 LIST_HEAD(FdbEntry, static_fdb_entries);
139
140 Hashmap *addresses_by_section;
141 Hashmap *routes_by_section;
142 Hashmap *fdb_entries_by_section;
143
144 bool wildcard_domain;
145 char **domains, **dns, **ntp, **bind_carrier;
146
147 ResolveSupport llmnr;
148 ResolveSupport mdns;
149 DnssecMode dnssec_mode;
150 Set *dnssec_negative_trust_anchors;
151
152 LIST_FIELDS(Network, networks);
153 };
154
155 void network_free(Network *network);
156
157 DEFINE_TRIVIAL_CLEANUP_FUNC(Network*, network_free);
158 #define _cleanup_network_free_ _cleanup_(network_freep)
159
160 int network_load(Manager *manager);
161
162 int network_get_by_name(Manager *manager, const char *name, Network **ret);
163 int network_get(Manager *manager, struct udev_device *device, const char *ifname, const struct ether_addr *mac, Network **ret);
164 int network_apply(Manager *manager, Network *network, Link *link);
165
166 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);
167 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);
168 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);
169 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);
170 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);
171 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);
172 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);
173 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);
174 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);
175 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);
176 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);
177 int config_parse_dnssec_negative_trust_anchors(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);
178
179 /* Legacy IPv4LL support */
180 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);
181
182 const struct ConfigPerfItem* network_network_gperf_lookup(const char *key, unsigned length);
183
184 extern const sd_bus_vtable network_vtable[];
185
186 int network_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error);
187 int network_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error);
188
189 const char* ipv6_privacy_extensions_to_string(IPv6PrivacyExtensions i) _const_;
190 IPv6PrivacyExtensions ipv6_privacy_extensions_from_string(const char *s) _pure_;