X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fnetwork%2Fnetworkd.h;h=b36590e2d6ca70779a92cd096c4d639799028a60;hp=263cc61eefb41597eb09cde56d1ec65c70635032;hb=cb9fc36a1211967e8c58b0502a26c42552ac8060;hpb=79008bddf679a5e0900369950eb346c9fa687107 diff --git a/src/network/networkd.h b/src/network/networkd.h index 263cc61ee..b36590e2d 100644 --- a/src/network/networkd.h +++ b/src/network/networkd.h @@ -32,6 +32,7 @@ #include "sd-icmp6-nd.h" #include "sd-dhcp6-client.h" #include "udev.h" +#include "sd-lldp.h" #include "rtnl-util.h" #include "hashmap.h" @@ -51,15 +52,16 @@ typedef struct Address Address; typedef struct Route Route; typedef struct Manager Manager; typedef struct AddressPool AddressPool; +typedef struct FdbEntry FdbEntry; -typedef enum DHCPSupport { - DHCP_SUPPORT_NONE, - DHCP_SUPPORT_BOTH, - DHCP_SUPPORT_V4, - DHCP_SUPPORT_V6, - _DHCP_SUPPORT_MAX, - _DHCP_SUPPORT_INVALID = -1, -} DHCPSupport; +typedef enum AddressFamilyBoolean { + ADDRESS_FAMILY_NO, + ADDRESS_FAMILY_YES, + ADDRESS_FAMILY_IPV4, + ADDRESS_FAMILY_IPV6, + _ADDRESS_FAMILY_BOOLEAN_MAX, + _ADDRESS_FAMILY_BOOLEAN_INVALID = -1, +} AddressFamilyBoolean; typedef enum LLMNRSupport { LLMNR_SUPPORT_NO, @@ -69,6 +71,16 @@ typedef enum LLMNRSupport { _LLMNR_SUPPORT_INVALID = -1, } LLMNRSupport; +struct FdbEntry { + Network *network; + unsigned section; + + struct ether_addr *mac_addr; + uint16_t vlan_id; + + LIST_FIELDS(FdbEntry, static_fdb_entries); +}; + struct Network { Manager *manager; @@ -90,7 +102,7 @@ struct Network { NetDev *bridge; NetDev *bond; Hashmap *stacked_netdevs; - DHCPSupport dhcp; + AddressFamilyBoolean dhcp; bool dhcp_dns; bool dhcp_ntp; bool dhcp_mtu; @@ -106,11 +118,23 @@ struct Network { bool dhcp_server; + unsigned cost; + + bool ip_masquerade; + bool ip_forward; + + 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; @@ -136,6 +160,8 @@ struct Address { union in_addr_union in_addr; union in_addr_union in_addr_peer; + bool ip_forward_done; + LIST_FIELDS(Address, addresses); }; @@ -145,12 +171,14 @@ struct Route { int family; unsigned char dst_prefixlen; + unsigned char src_prefixlen; unsigned char scope; uint32_t metrics; 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; LIST_FIELDS(Route, routes); @@ -196,6 +224,7 @@ 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_rtnl_listen(Manager *m); int manager_udev_listen(Manager *m); @@ -259,6 +288,17 @@ int config_parse_tunnel_address(const char *unit, void *data, void *userdata); +int config_parse_vxlan_group_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 */ const struct ConfigPerfItem* network_network_gperf_lookup(const char *key, unsigned length); @@ -291,6 +331,8 @@ void address_free(Address *address); int address_configure(Address *address, Link *link, sd_rtnl_message_handler_t callback); int address_update(Address *address, Link *link, sd_rtnl_message_handler_t callback); int address_drop(Address *address, Link *link, sd_rtnl_message_handler_t callback); +int address_establish(Address *address, Link *link); +int address_release(Address *address, Link *link); bool address_equal(Address *a1, Address *a2); DEFINE_TRIVIAL_CLEANUP_FUNC(Address*, address_free); @@ -308,10 +350,23 @@ int config_parse_label(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); -/* DHCP support */ +/* Forwarding database table. */ +int fdb_entry_configure(sd_rtnl *const rtnl, FdbEntry *const fdb_entry, const int ifindex); +void fdb_entry_free(FdbEntry *fdb_entry); +int fdb_entry_new_static(Network *const network, const unsigned section, FdbEntry **ret); + +DEFINE_TRIVIAL_CLEANUP_FUNC(FdbEntry*, fdb_entry_free); +#define _cleanup_fdbentry_free_ _cleanup_(fdb_entry_freep) -const char* dhcp_support_to_string(DHCPSupport i) _const_; -DHCPSupport dhcp_support_from_string(const char *s) _pure_; +int config_parse_fdb_hwaddr(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_fdb_vlan_id(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); + +/* DHCP support */ int config_parse_dhcp(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, @@ -334,19 +389,5 @@ void address_pool_free(AddressPool *p); int address_pool_acquire(AddressPool *p, unsigned prefixlen, union in_addr_union *found); -/* Macros which append INTERFACE= to the message */ - -#define log_link_full(level, link, fmt, ...) log_object_internal(level, 0, __FILE__, __LINE__, __func__, "INTERFACE=", link->ifname, "%-*s: " fmt, IFNAMSIZ, link->ifname, ##__VA_ARGS__) -#define log_link_debug(link, ...) log_link_full(LOG_DEBUG, link, ##__VA_ARGS__) -#define log_link_info(link, ...) log_link_full(LOG_INFO, link, ##__VA_ARGS__) -#define log_link_notice(link, ...) log_link_full(LOG_NOTICE, link, ##__VA_ARGS__) -#define log_link_warning(link, ...) log_link_full(LOG_WARNING, link, ##__VA_ARGS__) -#define log_link_error(link, ...) log_link_full(LOG_ERR, link, ##__VA_ARGS__) - -#define log_link_struct(level, link, ...) log_struct(level, "INTERFACE=%s", link->ifname, __VA_ARGS__) - -#define ADDRESS_FMT_VAL(address) \ - (address).s_addr & 0xFF, \ - ((address).s_addr >> 8) & 0xFF, \ - ((address).s_addr >> 16) & 0xFF, \ - (address).s_addr >> 24 +const char *address_family_boolean_to_string(AddressFamilyBoolean b) _const_; +AddressFamilyBoolean address_family_boolean_from_string(const char *s) _const_;