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, enum interface_event ev);
43 * interface configuration
46 struct vlist_node node;
47 struct list_head hotplug_list;
48 enum interface_event hotplug_ev;
55 bool config_autostart;
58 enum interface_state state;
59 enum interface_config_state config_state;
61 struct list_head users;
63 /* main interface that the interface is bound to */
64 struct device_user main_dev;
66 /* interface that layer 3 communication will go through */
67 struct device_user *l3_dev;
69 struct blob_attr *config;
71 /* primary protocol state */
72 const struct proto_handler *proto_handler;
73 struct interface_proto_state *proto;
75 struct vlist_tree proto_addr;
76 struct vlist_tree proto_route;
78 struct list_head proto_dns_servers;
79 struct list_head proto_dns_search;
81 /* errors/warnings while trying to bring up the interface */
82 struct list_head errors;
84 struct uloop_timeout remove_timer;
85 struct ubus_object ubus;
88 extern struct vlist_tree interfaces;
89 extern const struct config_param_list interface_attr_list;
91 void interface_init(struct interface *iface, const char *name,
92 struct blob_attr *config);
94 void interface_add(struct interface *iface, struct blob_attr *config);
96 void interface_set_proto_state(struct interface *iface, struct interface_proto_state *state);
98 void interface_set_available(struct interface *iface, bool new_state);
99 int interface_set_up(struct interface *iface);
100 int interface_set_down(struct interface *iface);
101 void __interface_set_down(struct interface *iface, bool force);
104 void interface_add_user(struct interface_user *dep, struct interface *iface);
105 void interface_remove_user(struct interface_user *dep);
107 int interface_add_link(struct interface *iface, struct device *llif);
108 void interface_remove_link(struct interface *iface, struct device *llif);
110 void interface_add_error(struct interface *iface, const char *subsystem,
111 const char *code, const char **data, int n_data);
113 void interface_queue_event(struct interface *iface, enum interface_event ev);
114 void interface_dequeue_event(struct interface *iface);
116 void interface_start_pending(void);