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
);
15 void (*dump_status
)(struct device
*, struct blob_buf
*buf
);
16 int (*check_state
)(struct device
*);
17 void (*free
)(struct device
*);
21 DEV_OPT_MTU
= (1 << 0),
22 DEV_OPT_MACADDR
= (1 << 1),
23 DEV_OPT_TXQUEUELEN
= (1 << 2)
26 enum device_addr_flags
{
27 /* address family for routes and addresses */
28 DEVADDR_INET4
= (0 << 0),
29 DEVADDR_INET6
= (1 << 0),
30 DEVADDR_FAMILY
= DEVADDR_INET4
| DEVADDR_INET6
,
32 /* device route (no gateway) */
33 DEVADDR_DEVICE
= (1 << 1),
42 struct list_head list
;
45 enum device_addr_flags flags
;
52 struct list_head list
;
55 enum device_addr_flags flags
;
59 union if_addr nexthop
;
63 * link layer device. typically represents a linux network device.
64 * can be used to support VLANs as well
67 const struct device_type
*type
;
70 struct list_head users
;
72 char ifname
[IFNAMSIZ
+ 1];
78 /* set interface up or down */
79 device_state_cb set_state
;
81 const struct device_hotplug_ops
*hotplug_ops
;
87 unsigned int txqueuelen
;
93 /* events broadcasted to all users of a device */
108 * device dependency with callbacks
111 struct list_head list
;
114 void (*cb
)(struct device_user
*, enum device_event
);
117 struct device_hotplug_ops
{
118 int (*add
)(struct device
*main
, struct device
*member
);
119 int (*del
)(struct device
*main
, struct device
*member
);
123 device_free(struct device
*dev
)
125 dev
->type
->free(dev
);
128 extern const struct config_param_list device_attr_list
;
130 struct device
*device_create(struct blob_attr
*attr
, struct uci_section
*s
);
132 void device_init_virtual(struct device
*dev
, const struct device_type
*type
, const char *name
);
133 int device_init(struct device
*iface
, const struct device_type
*type
, const char *ifname
);
134 void device_cleanup(struct device
*iface
);
135 struct device
*device_get(const char *name
, bool create
);
136 void device_add_user(struct device_user
*dep
, struct device
*iface
);
137 void device_remove_user(struct device_user
*dep
);
139 void device_set_present(struct device
*dev
, bool state
);
140 int claim_device(struct device
*dev
);
141 void release_device(struct device
*dev
);
142 int check_device_state(struct device
*dev
);
144 void device_free_all(void);
146 struct device
*get_vlan_device_chain(const char *ifname
, bool create
);
147 struct device
*bridge_create(const char *name
, struct uci_section
*s
);