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)
41 * link layer device. typically represents a linux network device.
42 * can be used to support VLANs as well
45 const struct device_type
*type
;
48 struct list_head users
;
50 char ifname
[IFNAMSIZ
+ 1];
56 /* set interface up or down */
57 device_state_cb set_state
;
59 const struct device_hotplug_ops
*hotplug_ops
;
65 unsigned int txqueuelen
;
71 /* events broadcasted to all users of a device */
86 * device dependency with callbacks
89 struct list_head list
;
93 void (*cb
)(struct device_user
*, enum device_event
);
96 struct device_hotplug_ops
{
97 int (*add
)(struct device
*main
, struct device
*member
);
98 int (*del
)(struct device
*main
, struct device
*member
);
101 extern const struct config_param_list device_attr_list
;
102 extern const struct device_type simple_device_type
;
103 extern const struct device_type bridge_device_type
;
105 void device_init_settings(struct device
*dev
, struct blob_attr
**tb
);
107 void device_init_virtual(struct device
*dev
, const struct device_type
*type
, const char *name
);
108 int device_init(struct device
*iface
, const struct device_type
*type
, const char *ifname
);
109 void device_cleanup(struct device
*iface
);
110 struct device
*device_get(const char *name
, bool create
);
111 void device_add_user(struct device_user
*dep
, struct device
*iface
);
112 void device_remove_user(struct device_user
*dep
);
114 void device_set_present(struct device
*dev
, bool state
);
115 int device_claim(struct device_user
*dep
);
116 void device_release(struct device_user
*dep
);
117 int check_device_state(struct device
*dev
);
120 device_free(struct device
*dev
)
122 dev
->type
->free(dev
);
125 void device_free_unused(struct device
*dev
);
127 struct device
*get_vlan_device_chain(const char *ifname
, bool create
);