4 #include <libubox/avl.h>
7 struct device_hotplug_ops
;
9 typedef int (*device_state_cb
)(struct device
*, bool up
);
14 int (*check_state
)(struct device
*);
15 void (*free
)(struct device
*);
19 * link layer device. typically represents a linux network device.
20 * can be used to support VLANs as well
23 const struct device_type
*type
;
26 struct list_head users
;
28 char ifname
[IFNAMSIZ
+ 1];
34 /* set interface up or down */
35 device_state_cb set_state
;
37 const struct device_hotplug_ops
*hotplug_ops
;
40 /* events broadcasted to all users of a device */
42 /* device has been added to the system and can be brought up */
45 /* device has been removed */
48 /* device is being brought up */
51 /* device is being brought down */
54 /* device has been brought up */
57 /* device has been brought down */
60 /* device has changed its link state to up */
63 /* device has changed its link state to down */
68 * device dependency with callbacks
71 struct list_head list
;
74 void (*cb
)(struct device_user
*, enum device_event
);
77 struct device_hotplug_ops
{
78 int (*add
)(struct device
*main
, struct device
*member
);
79 int (*del
)(struct device
*main
, struct device
*member
);
82 int init_device(struct device
*iface
, const struct device_type
*type
, const char *ifname
);
83 void cleanup_device(struct device
*iface
);
84 struct device
*get_device(const char *name
, bool create
);
85 void add_device_user(struct device_user
*dep
, struct device
*iface
);
86 void remove_device_user(struct device_user
*dep
);
88 void set_device_present(struct device
*dev
, bool state
);
89 int claim_device(struct device
*dev
);
90 void release_device(struct device
*dev
);
91 int check_device_state(struct device
*dev
);
93 struct device
*get_vlan_device_chain(const char *ifname
, bool create
);