networkd-network.h revision 4f2e437ad7b04bc0690d1f8202577cbf47acb215
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering#pragma once
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering/***
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering This file is part of systemd.
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering Copyright 2013 Tom Gundersen <teg@jklm.no>
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering systemd is free software; you can redistribute it and/or modify it
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering under the terms of the GNU Lesser General Public License as published by
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering the Free Software Foundation; either version 2.1 of the License, or
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering (at your option) any later version.
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering systemd is distributed in the hope that it will be useful, but
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering Lesser General Public License for more details.
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering You should have received a copy of the GNU Lesser General Public License
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering***/
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering#include "condition.h"
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poetteringtypedef struct Network Network;
b5efdb8af40ea759a1ea584c1bc44ecc81dd00ceLennart Poettering
3ffd4af22052963e7a29431721ee204e634bea75Lennart Poettering#include "networkd.h"
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering#include "networkd-netdev.h"
3ffd4af22052963e7a29431721ee204e634bea75Lennart Poettering#include "networkd-address.h"
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering#include "networkd-route.h"
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering#include "networkd-fdb.h"
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering#include "networkd-util.h"
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering#define DHCP_ROUTE_METRIC 1024
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering#define IPV4LL_ROUTE_METRIC 2048
ae3dde801253b1d5f7363bb9fb06bcb230f00eb8Lennart Poettering
ae3dde801253b1d5f7363bb9fb06bcb230f00eb8Lennart Poetteringtypedef enum DCHPClientIdentifier {
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering DHCP_CLIENT_ID_MAC,
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering DHCP_CLIENT_ID_DUID,
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering _DHCP_CLIENT_ID_MAX,
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering _DHCP_CLIENT_ID_INVALID = -1,
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering} DCHPClientIdentifier;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poetteringtypedef enum IPv6PrivacyExtensions {
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering /* The values map to the kernel's /proc/sys/net/ipv6/conf/xxx/use_tempaddr values */
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering IPV6_PRIVACY_EXTENSIONS_NO,
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering IPV6_PRIVACY_EXTENSIONS_PREFER_PUBLIC,
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering IPV6_PRIVACY_EXTENSIONS_YES, /* aka prefer-temporary */
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering _IPV6_PRIVACY_EXTENSIONS_MAX,
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering _IPV6_PRIVACY_EXTENSIONS_INVALID = -1,
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering} IPv6PrivacyExtensions;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poetteringstruct Network {
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering Manager *manager;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering char *filename;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering char *name;
ae3dde801253b1d5f7363bb9fb06bcb230f00eb8Lennart Poettering
9b15b7846d4de01bb5d9700a24077787e984e8abLennart Poettering struct ether_addr *match_mac;
9b15b7846d4de01bb5d9700a24077787e984e8abLennart Poettering char **match_path;
9b15b7846d4de01bb5d9700a24077787e984e8abLennart Poettering char **match_driver;
9b15b7846d4de01bb5d9700a24077787e984e8abLennart Poettering char **match_type;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering char **match_name;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering Condition *match_host;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering Condition *match_virt;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering Condition *match_kernel;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering Condition *match_arch;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering char *description;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering NetDev *bridge;
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering NetDev *bond;
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering Hashmap *stacked_netdevs;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering /* DHCP Client Support */
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering AddressFamilyBoolean dhcp;
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering DCHPClientIdentifier dhcp_client_identifier;
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering char *dhcp_vendor_class_identifier;
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering char *hostname;
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering bool dhcp_dns;
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering bool dhcp_ntp;
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering bool dhcp_mtu;
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering bool dhcp_hostname;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering bool dhcp_domains;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering bool dhcp_sendhost;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering bool dhcp_broadcast;
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering bool dhcp_critical;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering bool dhcp_routes;
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering bool dhcp_timezone;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering unsigned dhcp_route_metric;
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering /* DHCP Server Support */
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering bool dhcp_server;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering bool dhcp_server_emit_dns;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering struct in_addr *dhcp_server_dns;
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering unsigned n_dhcp_server_dns;
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering bool dhcp_server_emit_ntp;
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering struct in_addr *dhcp_server_ntp;
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering unsigned n_dhcp_server_ntp;
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering bool dhcp_server_emit_timezone;
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering char *dhcp_server_timezone;
ae3dde801253b1d5f7363bb9fb06bcb230f00eb8Lennart Poettering usec_t dhcp_server_default_lease_time_usec, dhcp_server_max_lease_time_usec;
ae3dde801253b1d5f7363bb9fb06bcb230f00eb8Lennart Poettering uint32_t dhcp_server_pool_offset;
ae3dde801253b1d5f7363bb9fb06bcb230f00eb8Lennart Poettering uint32_t dhcp_server_pool_size;
ae3dde801253b1d5f7363bb9fb06bcb230f00eb8Lennart Poettering
ae3dde801253b1d5f7363bb9fb06bcb230f00eb8Lennart Poettering /* IPV4LL Support */
ae3dde801253b1d5f7363bb9fb06bcb230f00eb8Lennart Poettering AddressFamilyBoolean link_local;
ae3dde801253b1d5f7363bb9fb06bcb230f00eb8Lennart Poettering bool ipv4ll_route;
ae3dde801253b1d5f7363bb9fb06bcb230f00eb8Lennart Poettering
ae3dde801253b1d5f7363bb9fb06bcb230f00eb8Lennart Poettering /* Bridge Support */
ae3dde801253b1d5f7363bb9fb06bcb230f00eb8Lennart Poettering bool use_bpdu;
ae3dde801253b1d5f7363bb9fb06bcb230f00eb8Lennart Poettering bool hairpin;
ae3dde801253b1d5f7363bb9fb06bcb230f00eb8Lennart Poettering bool fast_leave;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering bool allow_port_to_be_root;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering bool unicast_flood;
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering unsigned cost;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering AddressFamilyBoolean ip_forward;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering bool ip_masquerade;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering int ipv6_accept_ra;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering union in_addr_union ipv6_token;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering IPv6PrivacyExtensions ipv6_privacy_extensions;
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering struct ether_addr *mac;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering unsigned mtu;
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering bool lldp;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering LIST_HEAD(Address, static_addresses);
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering LIST_HEAD(Route, static_routes);
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering LIST_HEAD(FdbEntry, static_fdb_entries);
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering Hashmap *addresses_by_section;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering Hashmap *routes_by_section;
56f64d95763a799ba4475daf44d8e9f72a1bd474Michal Schmidt Hashmap *fdb_entries_by_section;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering bool wildcard_domain;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering char **domains, **dns, **ntp, **bind_carrier;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering ResolveSupport llmnr;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering LIST_FIELDS(Network, networks);
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering};
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poetteringvoid network_free(Network *network);
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart PoetteringDEFINE_TRIVIAL_CLEANUP_FUNC(Network*, network_free);
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering#define _cleanup_network_free_ _cleanup_(network_freep)
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poetteringint network_load(Manager *manager);
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poetteringint network_get_by_name(Manager *manager, const char *name, Network **ret);
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poetteringint network_get(Manager *manager, struct udev_device *device, const char *ifname, const struct ether_addr *mac, Network **ret);
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poetteringint network_apply(Manager *manager, Network *network, Link *link);
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poetteringint 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);
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poetteringint 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);
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poetteringint 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);
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poetteringint 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);
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poetteringint 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);
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poetteringint 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);
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poetteringint 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);
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poetteringint 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);
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poetteringint 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);
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poetteringint 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);
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poetteringint 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);
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering/* Legacy IPv4LL support */
56f64d95763a799ba4475daf44d8e9f72a1bd474Michal Schmidtint 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);
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poetteringconst struct ConfigPerfItem* network_network_gperf_lookup(const char *key, unsigned length);
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poetteringextern const sd_bus_vtable network_vtable[];
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poetteringint network_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error);
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poetteringint network_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error);
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poetteringconst char* ipv6_privacy_extensions_to_string(IPv6PrivacyExtensions i) _const_;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart PoetteringIPv6PrivacyExtensions ipv6_privacy_extensions_from_string(const char *s) _pure_;
4ba93280223ceb5de1bcedb196c38252f334521aLennart Poettering