chiark / gitweb /
networkd: reorder bonding and bridging
[elogind.git] / src / network / networkd.h
index f481ddec5c6bd10b0cc025b2a9cb1bc095d79e36..692b3df9ae0517aeb7ae6c64411489bd53bfa445 100644 (file)
@@ -76,6 +76,7 @@ typedef enum NetDevState {
         NETDEV_STATE_FAILED,
         NETDEV_STATE_CREATING,
         NETDEV_STATE_READY,
+        NETDEV_STATE_LINGER,
         _NETDEV_STATE_MAX,
         _NETDEV_STATE_INVALID = -1,
 } NetDevState;
@@ -83,6 +84,8 @@ typedef enum NetDevState {
 struct NetDev {
         Manager *manager;
 
+        int n_ref;
+
         char *filename;
 
         Condition *match_host;
@@ -192,6 +195,7 @@ typedef enum LinkState {
         LINK_STATE_CONFIGURED,
         LINK_STATE_UNMANAGED,
         LINK_STATE_FAILED,
+        LINK_STATE_LINGER,
         _LINK_STATE_MAX,
         _LINK_STATE_INVALID = -1
 } LinkState;
@@ -199,6 +203,8 @@ typedef enum LinkState {
 struct Link {
         Manager *manager;
 
+        int n_ref;
+
         uint64_t ifindex;
         char *ifname;
         char *state_file;
@@ -206,6 +212,7 @@ struct Link {
         struct udev_device *udev_device;
 
         unsigned flags;
+        uint8_t operstate;
 
         Network *network;
 
@@ -217,6 +224,7 @@ struct Link {
 
         sd_dhcp_client *dhcp_client;
         sd_dhcp_lease *dhcp_lease;
+        char *lease_file;
         uint16_t original_mtu;
         sd_ipv4ll *ipv4ll;
 };
@@ -231,6 +239,8 @@ struct Manager {
         sd_event_source *sigterm_event_source;
         sd_event_source *sigint_event_source;
 
+        char *state_file;
+
         Hashmap *links;
         Hashmap *netdevs;
         LIST_HEAD(Network, networks);
@@ -255,6 +265,7 @@ int manager_udev_listen(Manager *m);
 int manager_bus_listen(Manager *m);
 
 int manager_update_resolv_conf(Manager *m);
+int manager_save(Manager *m);
 
 DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
 #define _cleanup_manager_free_ _cleanup_(manager_freep)
@@ -262,11 +273,13 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
 /* NetDev */
 
 int netdev_load(Manager *manager);
+void netdev_drop(NetDev *netdev);
 
-void netdev_free(NetDev *netdev);
+NetDev *netdev_unref(NetDev *netdev);
+NetDev *netdev_ref(NetDev *netdev);
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(NetDev*, netdev_free);
-#define _cleanup_netdev_free_ _cleanup_(netdev_freep)
+DEFINE_TRIVIAL_CLEANUP_FUNC(NetDev*, netdev_unref);
+#define _cleanup_netdev_unref_ _cleanup_(netdev_unrefp)
 
 int netdev_get(Manager *manager, const char *name, NetDev **ret);
 int netdev_set_ifindex(NetDev *netdev, sd_rtnl_message *newlink);
@@ -299,22 +312,10 @@ int network_get(Manager *manager, struct udev_device *device,
                 Network **ret);
 int network_apply(Manager *manager, Network *network, Link *link);
 
-int config_parse_bridge(const char *unit, const char *filename, unsigned line,
+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_bond(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_vlan(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(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);
 
@@ -366,9 +367,11 @@ int config_parse_label(const char *unit, const char *filename, unsigned line,
 
 /* Link */
 
-void link_free(Link *link);
+Link *link_unref(Link *link);
+Link *link_ref(Link *link);
 int link_get(Manager *m, int ifindex, Link **ret);
 int link_add(Manager *manager, sd_rtnl_message *message, Link **ret);
+void link_drop(Link *link);
 
 int link_update(Link *link, sd_rtnl_message *message);
 
@@ -376,11 +379,13 @@ int link_initialized(Link *link, struct udev_device *device);
 
 int link_save(Link *link);
 
+bool link_has_carrier(unsigned flags, uint8_t operstate);
+
 const char* link_state_to_string(LinkState s) _const_;
 LinkState link_state_from_string(const char *s) _pure_;
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_free);
-#define _cleanup_link_free_ _cleanup_(link_freep)
+DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_unref);
+#define _cleanup_link_unref_ _cleanup_(link_unrefp)
 
 /* Macros which append INTERFACE= to the message */