4 #include <libubox/avl.h>
5 #include <netinet/in.h>
8 struct device_hotplug_ops;
10 typedef int (*device_state_cb)(struct device *, bool up);
22 enum dev_change_type {
29 struct list_head list;
32 const struct config_param_list *config_params;
34 struct device *(*create)(struct blob_attr *attr);
35 void (*config_init)(struct device *);
36 enum dev_change_type (*reload)(struct device *, struct blob_attr *);
37 void (*dump_status)(struct device *, struct blob_buf *buf);
38 int (*check_state)(struct device *);
39 void (*free)(struct device *);
43 DEV_OPT_MTU = (1 << 0),
44 DEV_OPT_MACADDR = (1 << 1),
45 DEV_OPT_TXQUEUELEN = (1 << 2)
49 * link layer device. typically represents a linux network device.
50 * can be used to support VLANs as well
53 const struct device_type *type;
56 struct list_head users;
58 char ifname[IFNAMSIZ + 1];
61 struct blob_attr *config;
69 /* set interface up or down */
70 device_state_cb set_state;
72 const struct device_hotplug_ops *hotplug_ops;
78 unsigned int txqueuelen;
82 /* events broadcasted to all users of a device */
97 * device dependency with callbacks
100 struct list_head list;
104 void (*cb)(struct device_user *, enum device_event);
107 struct device_hotplug_ops {
108 int (*add)(struct device *main, struct device *member);
109 int (*del)(struct device *main, struct device *member);
112 extern const struct config_param_list device_attr_list;
113 extern const struct device_type simple_device_type;
114 extern const struct device_type bridge_device_type;
116 struct device *device_create(const char *name, const struct device_type *type,
117 struct blob_attr *config);
118 void device_init_settings(struct device *dev, struct blob_attr **tb);
119 void device_init_pending(void);
121 void device_reset_config(void);
122 void device_reset_old(void);
124 void device_init_virtual(struct device *dev, const struct device_type *type, const char *name);
125 int device_init(struct device *iface, const struct device_type *type, const char *ifname);
126 void device_cleanup(struct device *iface);
127 struct device *device_get(const char *name, bool create);
128 void device_add_user(struct device_user *dep, struct device *iface);
129 void device_remove_user(struct device_user *dep);
131 void device_set_present(struct device *dev, bool state);
132 int device_claim(struct device_user *dep);
133 void device_release(struct device_user *dep);
134 int device_check_state(struct device *dev);
137 device_free(struct device *dev)
139 dev->type->free(dev);
142 void device_free_unused(struct device *dev);
144 struct device *get_vlan_device_chain(const char *ifname, bool create);