networkd.h revision a94d64d256d1a2b73c578116f341824eb5d0fab1
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2013 Tom Gundersen <teg@jklm.no>
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#pragma once
#include "sd-event.h"
#include "sd-netlink.h"
#include "sd-bus.h"
#include "sd-dhcp-client.h"
#include "sd-dhcp-server.h"
#include "sd-ipv4ll.h"
#include "sd-icmp6-nd.h"
#include "sd-dhcp6-client.h"
#include "udev.h"
#include "sd-lldp.h"
#include "netlink-util.h"
#include "hashmap.h"
#include "list.h"
#include "set.h"
#include "condition.h"
#include "in-addr-util.h"
#define CACHE_INFO_INFINITY_LIFE_TIME 0xFFFFFFFFU
#define DHCP_ROUTE_METRIC 1024
#define IPV4LL_ROUTE_METRIC 2048
typedef struct AddressPool AddressPool;
typedef enum AddressFamilyBoolean {
/* This is a bitmask, though it usually doesn't feel that way! */
ADDRESS_FAMILY_NO = 0,
ADDRESS_FAMILY_IPV4 = 1,
ADDRESS_FAMILY_IPV6 = 2,
ADDRESS_FAMILY_YES = 3,
typedef enum LLMNRSupport {
_LLMNR_SUPPORT_INVALID = -1,
} LLMNRSupport;
typedef enum LinkOperationalState {
typedef enum DCHPClientIdentifier {
_DHCP_CLIENT_ID_INVALID = -1,
typedef enum IPv6PrivacyExtensions {
IPV6_PRIVACY_EXTENSIONS_YES, /* aka prefer-temporary */
struct FdbEntry {
unsigned section;
struct ether_addr *mac_addr;
};
struct Network {
char *filename;
char *name;
struct ether_addr *match_mac;
char **match_path;
char **match_driver;
char **match_type;
char **match_name;
char *description;
char *dhcp_vendor_class_identifier;
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;
unsigned dhcp_route_metric;
bool ipv4ll_route;
union in_addr_union ipv6_token;
bool dhcp_server;
unsigned cost;
bool ip_masquerade;
struct ether_addr *mac;
unsigned mtu;
bool lldp;
bool wildcard_domain;
};
struct Address {
unsigned section;
int family;
unsigned char prefixlen;
unsigned char scope;
char *label;
struct ifa_cacheinfo cinfo;
union in_addr_union in_addr;
union in_addr_union in_addr_peer;
bool ip_masquerade_done;
};
struct Route {
unsigned section;
int family;
unsigned char dst_prefixlen;
unsigned char src_prefixlen;
unsigned char scope;
unsigned char protocol; /* RTPROT_* */
union in_addr_union in_addr;
union in_addr_union dst_addr;
union in_addr_union src_addr;
union in_addr_union prefsrc_addr;
};
struct AddressPool {
int family;
unsigned prefixlen;
union in_addr_union in_addr;
};
struct Manager {
struct udev_monitor *udev_monitor;
bool enumerating;
char *state_file;
};
extern const char* const network_dirs[];
/* Manager */
extern const sd_bus_vtable manager_vtable[];
void manager_free(Manager *m);
int manager_connect_bus(Manager *m);
int manager_run(Manager *m);
int manager_load_config(Manager *m);
bool manager_should_reload(Manager *m);
int manager_rtnl_enumerate_links(Manager *m);
int manager_rtnl_enumerate_addresses(Manager *m);
int manager_save(Manager *m);
int manager_address_pool_acquire(Manager *m, int family, unsigned prefixlen, union in_addr_union *found);
/* Network */
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_tunnel_address(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);
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);
/* gperf */
/* Route */
/* Address */
/* Forwarding database table. */
/* DHCP support */
/* IPv4LL support (legacy) */
/* IPv6 support */
/* LLMNR support */
/* Address Pool */
int address_pool_new(Manager *m, AddressPool **ret, int family, const union in_addr_union *u, unsigned prefixlen);
int address_pool_new_from_string(Manager *m, AddressPool **ret, int family, const char *p, unsigned prefixlen);
void address_pool_free(AddressPool *p);
int config_parse_address_family_boolean(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);
/* IPForwarding parser */
int config_parse_address_family_boolean_with_kernel(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);
/* Operational State */
/* IPv6 privacy extensions support */
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);