1 #ifndef __NETIFD_INTERFACE_H
2 #define __NETIFD_INTERFACE_H
8 struct interface_proto_state;
10 enum interface_event {
15 enum interface_state {
22 enum interface_config_state {
28 struct interface_error {
29 struct list_head list;
31 const char *subsystem;
36 struct interface_user {
37 struct list_head list;
38 struct interface *iface;
39 void (*cb)(struct interface_user *dep, struct interface *iface, enum interface_event ev);
42 struct interface_ip_settings {
43 struct interface *iface;
47 struct vlist_tree addr;
48 struct vlist_tree route;
50 struct vlist_simple_tree dns_servers;
51 struct vlist_simple_tree dns_search;
54 struct interface_data {
56 struct blob_attr data[];
60 * interface configuration
63 struct vlist_node node;
64 struct list_head hotplug_list;
65 enum interface_event hotplug_ev;
72 bool config_autostart;
75 enum interface_state state;
76 enum interface_config_state config_state;
78 struct list_head users;
80 /* main interface that the interface is bound to */
81 struct device_user main_dev;
83 /* interface that layer 3 communication will go through */
84 struct device_user l3_dev;
86 struct blob_attr *config;
88 /* primary protocol state */
89 const struct proto_handler *proto_handler;
90 struct interface_proto_state *proto;
92 struct interface_ip_settings proto_ip;
93 struct interface_ip_settings config_ip;
94 struct vlist_tree host_routes;
98 /* errors/warnings while trying to bring up the interface */
99 struct list_head errors;
101 /* extra data provided by protocol handlers or modules */
102 struct avl_tree data;
104 struct uloop_timeout remove_timer;
105 struct ubus_object ubus;
108 extern struct vlist_tree interfaces;
109 extern const struct config_param_list interface_attr_list;
111 void interface_init(struct interface *iface, const char *name,
112 struct blob_attr *config);
114 void interface_add(struct interface *iface, struct blob_attr *config);
116 void interface_set_proto_state(struct interface *iface, struct interface_proto_state *state);
118 void interface_set_available(struct interface *iface, bool new_state);
119 int interface_set_up(struct interface *iface);
120 int interface_set_down(struct interface *iface);
121 void __interface_set_down(struct interface *iface, bool force);
123 void interface_set_main_dev(struct interface *iface, struct device *dev);
124 void interface_set_l3_dev(struct interface *iface, struct device *dev);
126 void interface_add_user(struct interface_user *dep, struct interface *iface);
127 void interface_remove_user(struct interface_user *dep);
129 int interface_add_link(struct interface *iface, struct device *dev);
130 int interface_remove_link(struct interface *iface, struct device *dev);
132 void interface_add_error(struct interface *iface, const char *subsystem,
133 const char *code, const char **data, int n_data);
135 int interface_add_data(struct interface *iface, const struct blob_attr *data);
137 void interface_update_start(struct interface *iface);
138 void interface_update_complete(struct interface *iface);
140 void interface_queue_event(struct interface *iface, enum interface_event ev);
141 void interface_dequeue_event(struct interface *iface);
143 void interface_start_pending(void);