NETDEV_STATE_FAILED,
NETDEV_STATE_CREATING,
NETDEV_STATE_READY,
+ NETDEV_STATE_LINGER,
_NETDEV_STATE_MAX,
_NETDEV_STATE_INVALID = -1,
} NetDevState;
struct NetDev {
Manager *manager;
+ int n_ref;
+
char *filename;
Condition *match_host;
LINK_STATE_CONFIGURED,
LINK_STATE_UNMANAGED,
LINK_STATE_FAILED,
+ LINK_STATE_LINGER,
_LINK_STATE_MAX,
_LINK_STATE_INVALID = -1
} LinkState;
struct Link {
Manager *manager;
+ int n_ref;
+
uint64_t ifindex;
char *ifname;
char *state_file;
struct udev_device *udev_device;
unsigned flags;
+ uint8_t operstate;
Network *network;
sd_dhcp_client *dhcp_client;
sd_dhcp_lease *dhcp_lease;
+ char *lease_file;
uint16_t original_mtu;
sd_ipv4ll *ipv4ll;
};
sd_event_source *sigterm_event_source;
sd_event_source *sigint_event_source;
+ char *state_file;
+
Hashmap *links;
Hashmap *netdevs;
LIST_HEAD(Network, networks);
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)
/* 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);
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);
/* 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);
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 */