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
);
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
;
55 * interface configuration
58 struct vlist_node node
;
59 struct list_head hotplug_list
;
60 enum interface_event hotplug_ev
;
67 bool config_autostart
;
70 enum interface_state state
;
71 enum interface_config_state config_state
;
73 struct list_head users
;
75 /* main interface that the interface is bound to */
76 struct device_user main_dev
;
78 /* interface that layer 3 communication will go through */
79 struct device_user
*l3_dev
;
81 struct blob_attr
*config
;
83 /* primary protocol state */
84 const struct proto_handler
*proto_handler
;
85 struct interface_proto_state
*proto
;
87 struct interface_ip_settings proto_ip
;
88 struct interface_ip_settings config_ip
;
90 /* errors/warnings while trying to bring up the interface */
91 struct list_head errors
;
93 struct uloop_timeout remove_timer
;
94 struct ubus_object ubus
;
97 extern struct vlist_tree interfaces
;
98 extern const struct config_param_list interface_attr_list
;
100 void interface_init(struct interface
*iface
, const char *name
,
101 struct blob_attr
*config
);
103 void interface_add(struct interface
*iface
, struct blob_attr
*config
);
105 void interface_set_proto_state(struct interface
*iface
, struct interface_proto_state
*state
);
107 void interface_set_available(struct interface
*iface
, bool new_state
);
108 int interface_set_up(struct interface
*iface
);
109 int interface_set_down(struct interface
*iface
);
110 void __interface_set_down(struct interface
*iface
, bool force
);
113 void interface_add_user(struct interface_user
*dep
, struct interface
*iface
);
114 void interface_remove_user(struct interface_user
*dep
);
116 int interface_add_link(struct interface
*iface
, struct device
*dev
);
117 int interface_remove_link(struct interface
*iface
, struct device
*dev
);
119 void interface_add_error(struct interface
*iface
, const char *subsystem
,
120 const char *code
, const char **data
, int n_data
);
122 void interface_update_start(struct interface
*iface
);
123 void interface_update_complete(struct interface
*iface
);
125 void interface_queue_event(struct interface
*iface
, enum interface_event ev
);
126 void interface_dequeue_event(struct interface
*iface
);
128 void interface_start_pending(void);