]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/network/networkd-network.h
networkd:add support to configure ipv6 acceprt ra
[thirdparty/systemd.git] / src / network / networkd-network.h
CommitLineData
fc2f9534
LP
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
26typedef struct Network Network;
27
28#include "networkd.h"
29#include "networkd-netdev.h"
30#include "networkd-address.h"
31#include "networkd-route.h"
32#include "networkd-fdb.h"
33#include "networkd-util.h"
34
35#define DHCP_ROUTE_METRIC 1024
36#define IPV4LL_ROUTE_METRIC 2048
37
38typedef 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
45typedef 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
54struct 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;
1a04db0f
LP
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;
fc2f9534 102 bool dhcp_server_emit_timezone;
1a04db0f 103 char *dhcp_server_timezone;
fc2f9534 104 usec_t dhcp_server_default_lease_time_usec, dhcp_server_max_lease_time_usec;
9b3a67c5
TG
105 uint32_t dhcp_server_pool_offset;
106 uint32_t dhcp_server_pool_size;
fc2f9534
LP
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
4f2e437a
SS
123 int ipv6_accept_ra;
124
fc2f9534
LP
125 union in_addr_union ipv6_token;
126 IPv6PrivacyExtensions ipv6_privacy_extensions;
127
128 struct ether_addr *mac;
129 unsigned mtu;
130
131 bool lldp;
132
133 LIST_HEAD(Address, static_addresses);
134 LIST_HEAD(Route, static_routes);
135 LIST_HEAD(FdbEntry, static_fdb_entries);
136
137 Hashmap *addresses_by_section;
138 Hashmap *routes_by_section;
139 Hashmap *fdb_entries_by_section;
140
141 bool wildcard_domain;
142 char **domains, **dns, **ntp, **bind_carrier;
143
144 ResolveSupport llmnr;
145
146 LIST_FIELDS(Network, networks);
147};
148
149void network_free(Network *network);
150
151DEFINE_TRIVIAL_CLEANUP_FUNC(Network*, network_free);
152#define _cleanup_network_free_ _cleanup_(network_freep)
153
154int network_load(Manager *manager);
155
156int network_get_by_name(Manager *manager, const char *name, Network **ret);
157int network_get(Manager *manager, struct udev_device *device, const char *ifname, const struct ether_addr *mac, Network **ret);
158int network_apply(Manager *manager, Network *network, Link *link);
159
160int 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);
161int 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);
162int 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);
163int 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);
164int 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);
165int 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);
166int 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);
167int 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);
168int 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);
1a04db0f
LP
169int 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);
170int 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);
fc2f9534
LP
171
172/* Legacy IPv4LL support */
173int 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);
174
175const struct ConfigPerfItem* network_network_gperf_lookup(const char *key, unsigned length);
176
177extern const sd_bus_vtable network_vtable[];
178
179int network_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error);
180int network_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error);
181
182const char* ipv6_privacy_extensions_to_string(IPv6PrivacyExtensions i) _const_;
183IPv6PrivacyExtensions ipv6_privacy_extensions_from_string(const char *s) _pure_;