chiark / gitweb /
networkd: integrate LLDP
[elogind.git] / src / network / networkd.h
index c8d89d212b8fdb04cdc2873429344f53bf2fbe54..7107c5f9321dd47b5a897ff6268b43c9bfc5e97c 100644 (file)
 #include "sd-icmp6-nd.h"
 #include "sd-dhcp6-client.h"
 #include "udev.h"
+#include "sd-lldp.h"
 
 #include "rtnl-util.h"
 #include "hashmap.h"
 #include "list.h"
 #include "set.h"
-#include "condition-util.h"
+#include "condition.h"
 #include "in-addr-util.h"
 
 #define CACHE_INFO_INFINITY_LIFE_TIME 0xFFFFFFFFU
@@ -51,6 +52,7 @@ 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,
@@ -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;
 
@@ -100,16 +112,26 @@ struct Network {
         bool dhcp_broadcast;
         bool dhcp_critical;
         bool dhcp_routes;
+        unsigned dhcp_route_metric;
         bool ipv4ll;
         bool ipv4ll_route;
 
         bool dhcp_server;
 
+        unsigned cost;
+
+        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;
@@ -126,6 +148,7 @@ struct Address {
         int family;
         unsigned char prefixlen;
         unsigned char scope;
+        unsigned char flags;
         char *label;
 
         struct in_addr broadcast;
@@ -143,12 +166,15 @@ 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);
 };
@@ -171,8 +197,6 @@ struct Manager {
         struct udev *udev;
         struct udev_monitor *udev_monitor;
         sd_event_source *udev_event_source;
-        sd_event_source *sigterm_event_source;
-        sd_event_source *sigint_event_source;
 
         char *state_file;
 
@@ -195,6 +219,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);
@@ -258,6 +283,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);
 
@@ -307,6 +343,22 @@ 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);
 
+/* 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)
+
+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 */
 
 const char* dhcp_support_to_string(DHCPSupport i) _const_;
@@ -332,20 +384,3 @@ int address_pool_new_from_string(Manager *m, AddressPool **ret, int family, cons
 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_full_link(level, link, fmt, ...) log_meta_object(level, __FILE__, __LINE__, __func__, "INTERFACE=", link->ifname, "%-*s: " fmt, IFNAMSIZ, link->ifname, ##__VA_ARGS__)
-#define log_debug_link(link, ...)       log_full_link(LOG_DEBUG, link, ##__VA_ARGS__)
-#define log_info_link(link, ...)        log_full_link(LOG_INFO, link, ##__VA_ARGS__)
-#define log_notice_link(link, ...)      log_full_link(LOG_NOTICE, link, ##__VA_ARGS__)
-#define log_warning_link(link, ...)     log_full_link(LOG_WARNING, link, ##__VA_ARGS__)
-#define log_error_link(link, ...)       log_full_link(LOG_ERR, link, ##__VA_ARGS__)
-
-#define log_struct_link(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