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);
78 * link layer device. typically represents a linux network device.
79 * can be used to support VLANs as well
82 const struct device_type *type;
85 struct list_head users;
87 char ifname[IFNAMSIZ + 1];
90 struct blob_attr *config;
101 /* set interface up or down */
102 device_state_cb set_state;
104 const struct device_hotplug_ops *hotplug_ops;
106 struct device_user parent;
112 unsigned int txqueuelen;
116 struct device_hotplug_ops {
117 int (*prepare)(struct device *dev);
118 int (*add)(struct device *main, struct device *member);
119 int (*del)(struct device *main, struct device *member);
122 extern const struct config_param_list device_attr_list;
123 extern const struct device_type simple_device_type;
124 extern const struct device_type bridge_device_type;
126 void device_lock(void);
127 void device_unlock(void);
129 struct device *device_create(const char *name, const struct device_type *type,
130 struct blob_attr *config);
131 void device_init_settings(struct device *dev, struct blob_attr **tb);
132 void device_init_pending(void);
135 device_set_config(struct device *dev, const struct device_type *type,
136 struct blob_attr *attr);
138 void device_reset_config(void);
139 void device_reset_old(void);
141 void device_init_virtual(struct device *dev, const struct device_type *type, const char *name);
142 int device_init(struct device *iface, const struct device_type *type, const char *ifname);
143 void device_cleanup(struct device *iface);
144 struct device *device_get(const char *name, int create);
145 void device_add_user(struct device_user *dep, struct device *iface);
146 void device_remove_user(struct device_user *dep);
148 void device_set_present(struct device *dev, bool state);
149 void device_set_disabled(struct device *dev, bool value);
150 int device_claim(struct device_user *dep);
151 void device_release(struct device_user *dep);
152 int device_check_state(struct device *dev);
153 void device_dump_status(struct blob_buf *b, struct device *dev);
155 void device_free(struct device *dev);
156 void device_free_unused(struct device *dev);
158 struct device *get_vlan_device_chain(const char *ifname, bool create);
159 void alias_notify_device(const char *name, struct device *dev);