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);
23 struct list_head list;
26 const struct config_param_list *config_params;
28 struct device *(*create)(struct blob_attr *attr);
29 void (*dump_status)(struct device *, struct blob_buf *buf);
30 int (*check_state)(struct device *);
31 void (*free)(struct device *);
35 DEV_OPT_MTU = (1 << 0),
36 DEV_OPT_MACADDR = (1 << 1),
37 DEV_OPT_TXQUEUELEN = (1 << 2)
40 enum device_addr_flags {
41 /* address family for routes and addresses */
42 DEVADDR_INET4 = (0 << 0),
43 DEVADDR_INET6 = (1 << 0),
44 DEVADDR_FAMILY = DEVADDR_INET4 | DEVADDR_INET6,
46 /* device route (no gateway) */
47 DEVADDR_DEVICE = (1 << 1),
56 struct list_head list;
59 enum device_addr_flags flags;
66 struct list_head list;
69 enum device_addr_flags flags;
73 union if_addr nexthop;
77 * link layer device. typically represents a linux network device.
78 * can be used to support VLANs as well
81 const struct device_type *type;
84 struct list_head users;
86 char ifname[IFNAMSIZ + 1];
92 /* set interface up or down */
93 device_state_cb set_state;
95 const struct device_hotplug_ops *hotplug_ops;
101 unsigned int txqueuelen;
104 uint32_t config_hash;
107 /* events broadcasted to all users of a device */
122 * device dependency with callbacks
125 struct list_head list;
129 void (*cb)(struct device_user *, enum device_event);
132 struct device_hotplug_ops {
133 int (*add)(struct device *main, struct device *member);
134 int (*del)(struct device *main, struct device *member);
137 extern const struct config_param_list device_attr_list;
138 extern const struct device_type simple_device_type;
139 extern const struct device_type bridge_device_type;
141 void device_init_settings(struct device *dev, struct blob_attr **tb);
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, bool 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 int device_claim(struct device_user *dep);
152 void device_release(struct device_user *dep);
153 int check_device_state(struct device *dev);
156 device_free(struct device *dev)
158 dev->type->free(dev);
161 void device_free_all(void);
163 struct device *get_vlan_device_chain(const char *ifname, bool create);