4 #include <libubox/avl.h>
5 #include <netinet/in.h>
9 struct device_hotplug_ops;
11 typedef int (*device_state_cb)(struct device *, bool up);
23 enum dev_change_type {
30 struct list_head list;
33 const struct config_param_list *config_params;
35 struct device *(*create)(const char *name, struct blob_attr *attr);
36 void (*config_init)(struct device *);
37 enum dev_change_type (*reload)(struct device *, struct blob_attr *);
38 void (*dump_info)(struct device *, struct blob_buf *buf);
39 void (*dump_stats)(struct device *, struct blob_buf *buf);
40 int (*check_state)(struct device *);
41 void (*free)(struct device *);
45 DEV_OPT_MTU = (1 << 0),
46 DEV_OPT_MACADDR = (1 << 1),
47 DEV_OPT_TXQUEUELEN = (1 << 2)
50 /* events broadcasted to all users of a device */
65 * device dependency with callbacks
68 struct list_head list;
74 void (*cb)(struct device_user *, enum device_event);
77 struct device_settings {
80 unsigned int txqueuelen;
85 * link layer device. typically represents a linux network device.
86 * can be used to support VLANs as well
89 const struct device_type *type;
92 struct list_head users;
94 char ifname[IFNAMSIZ + 1];
97 struct blob_attr *config;
108 /* set interface up or down */
109 device_state_cb set_state;
111 const struct device_hotplug_ops *hotplug_ops;
113 struct device_user parent;
115 struct device_settings settings;
118 struct device_hotplug_ops {
119 int (*prepare)(struct device *dev);
120 int (*add)(struct device *main, struct device *member);
121 int (*del)(struct device *main, struct device *member);
124 extern const struct config_param_list device_attr_list;
125 extern const struct device_type simple_device_type;
126 extern const struct device_type bridge_device_type;
128 void device_lock(void);
129 void device_unlock(void);
131 struct device *device_create(const char *name, const struct device_type *type,
132 struct blob_attr *config);
133 void device_init_settings(struct device *dev, struct blob_attr **tb);
134 void device_init_pending(void);
137 device_set_config(struct device *dev, const struct device_type *type,
138 struct blob_attr *attr);
140 void device_reset_config(void);
141 void device_reset_old(void);
143 void device_init_virtual(struct device *dev, const struct device_type *type, const char *name);
144 int device_init(struct device *iface, const struct device_type *type, const char *ifname);
145 void device_cleanup(struct device *iface);
146 struct device *device_get(const char *name, int create);
147 void device_add_user(struct device_user *dep, struct device *iface);
148 void device_remove_user(struct device_user *dep);
150 void device_set_present(struct device *dev, bool state);
151 void device_set_disabled(struct device *dev, bool value);
152 int device_claim(struct device_user *dep);
153 void device_release(struct device_user *dep);
154 int device_check_state(struct device *dev);
155 void device_dump_status(struct blob_buf *b, struct device *dev);
157 void device_free(struct device *dev);
158 void device_free_unused(struct device *dev);
160 struct device *get_vlan_device_chain(const char *ifname, bool create);
161 void alias_notify_device(const char *name, struct device *dev);