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 * link layer device. typically represents a linux network device.
21 * can be used to support VLANs as well
24 const struct device_type
*type
;
27 struct list_head users
;
29 char ifname
[IFNAMSIZ
+ 1];
35 /* set interface up or down */
36 device_state_cb set_state
;
38 const struct device_hotplug_ops
*hotplug_ops
;
41 /* events broadcasted to all users of a device */
43 /* device has been added to the system and can be brought up */
46 /* device has been removed */
49 /* device is being brought up */
52 /* device is being brought down */
55 /* device has been brought up */
58 /* device has been brought down */
61 /* device has changed its link state to up */
64 /* device has changed its link state to down */
69 * device dependency with callbacks
72 struct list_head list
;
75 void (*cb
)(struct device_user
*, enum device_event
);
78 struct device_hotplug_ops
{
79 int (*add
)(struct device
*main
, struct device
*member
);
80 int (*del
)(struct device
*main
, struct device
*member
);
83 void init_virtual_device(struct device
*dev
, const struct device_type
*type
, const char *name
);
84 int init_device(struct device
*iface
, const struct device_type
*type
, const char *ifname
);
85 void cleanup_device(struct device
*iface
);
86 struct device
*get_device(const char *name
, bool create
);
87 void add_device_user(struct device_user
*dep
, struct device
*iface
);
88 void remove_device_user(struct device_user
*dep
);
90 void set_device_present(struct device
*dev
, bool state
);
91 int claim_device(struct device
*dev
);
92 void release_device(struct device
*dev
);
93 int check_device_state(struct device
*dev
);
95 struct device
*get_vlan_device_chain(const char *ifname
, bool create
);