X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=device.h;h=2b7fb13c3568e74e415e41042ec4c88127d7b9ec;hp=a3728f3bc1cb38ea4d6706bc64b45a633e9b7816;hb=5fefb43a4151ee99d4c78ebaf1807043e859021a;hpb=10741b4974b85c825036eb0717ddc7112f96f5fb diff --git a/device.h b/device.h index a3728f3..2b7fb13 100644 --- a/device.h +++ b/device.h @@ -16,6 +16,7 @@ enum { DEV_ATTR_MTU, DEV_ATTR_MACADDR, DEV_ATTR_TXQUEUELEN, + DEV_ATTR_ENABLED, __DEV_ATTR_MAX, }; @@ -73,6 +74,13 @@ struct device_user { void (*cb)(struct device_user *, enum device_event); }; +struct device_settings { + unsigned int flags; + unsigned int mtu; + unsigned int txqueuelen; + uint8_t macaddr[6]; +}; + /* * link layer device. typically represents a linux network device. * can be used to support VLANs as well @@ -88,9 +96,11 @@ struct device { struct blob_attr *config; bool config_pending; + bool sys_present; bool present; int active; bool external; + bool disabled; bool current_config; bool default_config; @@ -102,15 +112,12 @@ struct device { struct device_user parent; - /* settings */ - unsigned int flags; - - unsigned int mtu; - unsigned int txqueuelen; - uint8_t macaddr[6]; + struct device_settings orig_settings; + struct device_settings settings; }; struct device_hotplug_ops { + int (*prepare)(struct device *dev); int (*add)(struct device *main, struct device *member); int (*del)(struct device *main, struct device *member); }; @@ -142,17 +149,13 @@ void device_add_user(struct device_user *dep, struct device *iface); void device_remove_user(struct device_user *dep); void device_set_present(struct device *dev, bool state); +void device_set_disabled(struct device *dev, bool value); int device_claim(struct device_user *dep); void device_release(struct device_user *dep); int device_check_state(struct device *dev); void device_dump_status(struct blob_buf *b, struct device *dev); -static inline void -device_free(struct device *dev) -{ - dev->type->free(dev); -} - +void device_free(struct device *dev); void device_free_unused(struct device *dev); struct device *get_vlan_device_chain(const char *ifname, bool create);