1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6 This file is part of systemd.
8 Copyright 2013 Tom Gundersen <teg@jklm.no>
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.
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.
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/>.
24 #include "condition.h"
25 #include "resolve-util.h"
27 typedef struct Network Network
;
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"
36 #define DHCP_ROUTE_METRIC 1024
37 #define IPV4LL_ROUTE_METRIC 2048
39 typedef enum DCHPClientIdentifier
{
43 _DHCP_CLIENT_ID_INVALID
= -1,
44 } DCHPClientIdentifier
;
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
;
61 struct ether_addr
*match_mac
;
67 Condition
*match_host
;
68 Condition
*match_virt
;
69 Condition
*match_kernel
;
70 Condition
*match_arch
;
76 Hashmap
*stacked_netdevs
;
78 /* DHCP Client Support */
79 AddressFamilyBoolean dhcp
;
80 DCHPClientIdentifier dhcp_client_identifier
;
81 char *dhcp_vendor_class_identifier
;
86 bool dhcp_use_hostname
;
87 bool dhcp_use_domains
;
88 bool dhcp_send_hostname
;
92 bool dhcp_use_timezone
;
93 unsigned dhcp_route_metric
;
95 /* DHCP Server Support */
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
;
110 AddressFamilyBoolean link_local
;
117 bool allow_port_to_be_root
;
121 AddressFamilyBoolean ip_forward
;
125 int ipv6_dad_transmits
;
128 union in_addr_union ipv6_token
;
129 IPv6PrivacyExtensions ipv6_privacy_extensions
;
131 struct ether_addr
*mac
;
136 LIST_HEAD(Address
, static_addresses
);
137 LIST_HEAD(Route
, static_routes
);
138 LIST_HEAD(FdbEntry
, static_fdb_entries
);
140 Hashmap
*addresses_by_section
;
141 Hashmap
*routes_by_section
;
142 Hashmap
*fdb_entries_by_section
;
144 char **search_domains
, **route_domains
, **dns
, **ntp
, **bind_carrier
;
146 ResolveSupport llmnr
;
148 DnssecMode dnssec_mode
;
149 Set
*dnssec_negative_trust_anchors
;
151 LIST_FIELDS(Network
, networks
);
154 void network_free(Network
*network
);
156 DEFINE_TRIVIAL_CLEANUP_FUNC(Network
*, network_free
);
157 #define _cleanup_network_free_ _cleanup_(network_freep)
159 int network_load(Manager
*manager
);
161 int network_get_by_name(Manager
*manager
, const char *name
, Network
**ret
);
162 int network_get(Manager
*manager
, struct udev_device
*device
, const char *ifname
, const struct ether_addr
*mac
, Network
**ret
);
163 int network_apply(Manager
*manager
, Network
*network
, Link
*link
);
165 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
);
166 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
);
167 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
);
168 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
);
169 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
);
170 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
);
171 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
);
172 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
);
173 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
);
174 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
);
175 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
);
176 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 /* Legacy IPv4LL support */
179 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 const struct ConfigPerfItem
* network_network_gperf_lookup(const char *key
, unsigned length
);
183 extern const sd_bus_vtable network_vtable
[];
185 int network_node_enumerator(sd_bus
*bus
, const char *path
, void *userdata
, char ***nodes
, sd_bus_error
*error
);
186 int network_object_find(sd_bus
*bus
, const char *path
, const char *interface
, void *userdata
, void **found
, sd_bus_error
*error
);
188 const char* ipv6_privacy_extensions_to_string(IPv6PrivacyExtensions i
) _const_
;
189 IPv6PrivacyExtensions
ipv6_privacy_extensions_from_string(const char *s
) _pure_
;