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