networkd.h revision 4faefc7ff884eae65a80e82313fd9f4bb859d6db
/*-*- 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-rtnl.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 "rtnl-util.h"
#include "hashmap.h"
#include "list.h"
#include "set.h"
#include "condition-util.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 struct netdev_enslave_callback netdev_enslave_callback;
struct netdev_enslave_callback {
};
typedef enum MacVlanMode {
} MacVlanMode;
typedef enum BondMode {
} BondMode;
typedef enum NetDevKind {
_NETDEV_KIND_INVALID = -1
} NetDevKind;
typedef enum NetDevState {
_NETDEV_STATE_INVALID = -1,
} NetDevState;
struct NetDev {
int n_ref;
char *filename;
char *description;
char *ifname;
char *ifname_peer;
char *user_name;
char *group_name;
struct ether_addr *mac;
struct ether_addr *mac_peer;
int ifindex;
bool tunnel_pmtudisc;
bool learning;
bool one_queue;
bool multi_queue;
bool packet_info;
unsigned ttl;
unsigned tos;
unsigned char family;
union in_addr_union local;
union in_addr_union remote;
union in_addr_union group;
};
typedef enum DHCPSupport {
_DHCP_SUPPORT_INVALID = -1,
} DHCPSupport;
struct Network {
char *filename;
struct ether_addr *match_mac;
char *match_path;
char *match_driver;
char *match_type;
char *match_name;
char *description;
bool dhcp_dns;
bool dhcp_ntp;
bool dhcp_mtu;
bool dhcp_hostname;
bool dhcp_domainname;
bool dhcp_sendhost;
bool dhcp_critical;
bool dhcp_routes;
bool ipv4ll;
bool dhcp_server;
};
struct Address {
unsigned char 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;
};
struct Route {
unsigned char family;
unsigned char dst_prefixlen;
unsigned char scope;
union in_addr_union in_addr;
union in_addr_union dst_addr;
};
typedef enum LinkState {
_LINK_STATE_INVALID = -1
} LinkState;
typedef enum LinkOperationalState {
struct Link {
int n_ref;
char *ifname;
char *state_file;
struct ether_addr mac;
struct udev_device *udev_device;
unsigned flags;
unsigned addr_messages;
unsigned route_messages;
unsigned enslaving;
char *lease_file;
};
struct AddressPool {
unsigned family;
unsigned prefixlen;
union in_addr_union in_addr;
};
struct Manager {
struct udev_monitor *udev_monitor;
char *state_file;
};
extern const char* const network_dirs[];
/* Manager */
void manager_free(Manager *m);
int manager_load_config(Manager *m);
bool manager_should_reload(Manager *m);
int manager_rtnl_enumerate_links(Manager *m);
int manager_rtnl_listen(Manager *m);
int manager_udev_listen(Manager *m);
int manager_bus_listen(Manager *m);
int manager_save(Manager *m);
int manager_address_pool_acquire(Manager *m, unsigned family, unsigned prefixlen, union in_addr_union *found);
/* NetDev */
#define VLANID_MAX 4094
int config_parse_netdev_kind(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_macvlan_mode(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_bond_mode(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);
/* gperf */
/* Network */
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);
/* gperf */
/* Route */
/* Address */
/* Link */
/* DHCP support */
/* Address Pool */
int address_pool_new(Manager *m, AddressPool **ret, unsigned family, const union in_addr_union *u, unsigned prefixlen);
int address_pool_new_from_string(Manager *m, AddressPool **ret, unsigned family, const char *p, unsigned prefixlen);
void address_pool_free(AddressPool *p);
/* Macros which append INTERFACE= to the message */
#define log_full_link(level, link, fmt, ...) log_meta_object(level, __FILE__, __LINE__, __func__, "INTERFACE=", link->ifname, "%-*s: " fmt, IFNAMSIZ, link->ifname, ##__VA_ARGS__)
#define log_struct_link(level, link, ...) log_struct(level, "INTERFACE=%s", link->ifname, __VA_ARGS__)
/* More macros which append INTERFACE= to the message */
#define log_full_netdev(level, netdev, fmt, ...) log_meta_object(level, __FILE__, __LINE__, __func__, "INTERFACE=", netdev->ifname, "%-*s: " fmt, IFNAMSIZ, netdev->ifname, ##__VA_ARGS__)
#define log_struct_netdev(level, netdev, ...) log_struct(level, "INTERFACE=%s", netdev->ifname, __VA_ARGS__)
#define ADDRESS_FMT_VAL(address) \