4 #include <libubox/avl.h>
7 struct device_hotplug_ops;
9 typedef int (*device_state_cb)(struct device *, bool up);
14 void (*dump_status)(struct device *, struct blob_buf *buf);
15 int (*check_state)(struct device *);
16 void (*free)(struct device *);
20 DEV_OPT_MTU = (1 << 0),
21 DEV_OPT_MACADDR = (1 << 1),
22 DEV_OPT_TXQUEUELEN = (1 << 2)
26 * link layer device. typically represents a linux network device.
27 * can be used to support VLANs as well
30 const struct device_type *type;
33 struct list_head users;
35 char ifname[IFNAMSIZ + 1];
41 /* set interface up or down */
42 device_state_cb set_state;
44 const struct device_hotplug_ops *hotplug_ops;
50 unsigned int txqueuelen;
56 /* events broadcasted to all users of a device */
71 * device dependency with callbacks
74 struct list_head list;
77 void (*cb)(struct device_user *, enum device_event);
80 struct device_hotplug_ops {
81 int (*add)(struct device *main, struct device *member);
82 int (*del)(struct device *main, struct device *member);
86 free_device(struct device *dev)
91 void init_virtual_device(struct device *dev, const struct device_type *type, const char *name);
92 int init_device(struct device *iface, const struct device_type *type, const char *ifname);
93 void cleanup_device(struct device *iface);
94 struct device *get_device(const char *name, bool create);
95 void add_device_user(struct device_user *dep, struct device *iface);
96 void remove_device_user(struct device_user *dep);
98 void set_device_present(struct device *dev, bool state);
99 int claim_device(struct device *dev);
100 void release_device(struct device *dev);
101 int check_device_state(struct device *dev);
103 void cleanup_devices(void);
105 struct device *get_vlan_device_chain(const char *ifname, bool create);
106 struct device *bridge_create(const char *name, struct uci_section *s);