1 #ifndef __NETIFD_INTERFACE_H
2 #define __NETIFD_INTERFACE_H
8 struct interface_proto_state;
10 enum interface_event {
17 enum interface_state {
24 enum interface_config_state {
30 struct interface_error {
31 struct list_head list;
33 const char *subsystem;
38 struct interface_user {
39 struct list_head list;
40 struct interface *iface;
41 void (*cb)(struct interface_user *dep, struct interface *iface, enum interface_event ev);
44 struct interface_ip_settings {
45 struct interface *iface;
49 struct vlist_tree addr;
50 struct vlist_tree route;
52 struct vlist_simple_tree dns_servers;
53 struct vlist_simple_tree dns_search;
56 struct interface_data {
58 struct blob_attr data[];
62 * interface configuration
65 struct vlist_node node;
66 struct list_head hotplug_list;
67 enum interface_event hotplug_ev;
74 bool config_autostart;
77 enum interface_state state;
78 enum interface_config_state config_state;
80 struct list_head users;
82 /* main interface that the interface is bound to */
83 struct device_user main_dev;
85 /* interface that layer 3 communication will go through */
86 struct device_user l3_dev;
88 struct blob_attr *config;
90 /* primary protocol state */
91 const struct proto_handler *proto_handler;
92 struct interface_proto_state *proto;
94 struct interface_ip_settings proto_ip;
95 struct interface_ip_settings config_ip;
96 struct vlist_tree host_routes;
100 /* errors/warnings while trying to bring up the interface */
101 struct list_head errors;
103 /* extra data provided by protocol handlers or modules */
104 struct avl_tree data;
106 struct uloop_timeout remove_timer;
107 struct ubus_object ubus;
110 extern struct vlist_tree interfaces;
111 extern const struct config_param_list interface_attr_list;
113 void interface_init(struct interface *iface, const char *name,
114 struct blob_attr *config);
116 void interface_add(struct interface *iface, struct blob_attr *config);
118 void interface_set_proto_state(struct interface *iface, struct interface_proto_state *state);
120 void interface_set_available(struct interface *iface, bool new_state);
121 int interface_set_up(struct interface *iface);
122 int interface_set_down(struct interface *iface);
123 void __interface_set_down(struct interface *iface, bool force);
125 void interface_set_main_dev(struct interface *iface, struct device *dev);
126 void interface_set_l3_dev(struct interface *iface, struct device *dev);
128 void interface_add_user(struct interface_user *dep, struct interface *iface);
129 void interface_remove_user(struct interface_user *dep);
131 int interface_add_link(struct interface *iface, struct device *dev);
132 int interface_remove_link(struct interface *iface, struct device *dev);
134 void interface_add_error(struct interface *iface, const char *subsystem,
135 const char *code, const char **data, int n_data);
137 int interface_add_data(struct interface *iface, const struct blob_attr *data);
139 void interface_update_start(struct interface *iface);
140 void interface_update_complete(struct interface *iface);
142 void interface_queue_event(struct interface *iface, enum interface_event ev);
143 void interface_dequeue_event(struct interface *iface);
145 void interface_start_pending(void);