rename "active" to "available"
[project/netifd.git] / interface.h
1 #ifndef __NETIFD_INTERFACE_H
2 #define __NETIFD_INTERFACE_H
3
4 #include "device.h"
5 #include "config.h"
6
7 struct interface;
8 struct interface_proto_state;
9
10 enum interface_event {
11 IFEV_UP,
12 IFEV_DOWN,
13 };
14
15 enum interface_state {
16 IFS_SETUP,
17 IFS_UP,
18 IFS_TEARDOWN,
19 IFS_DOWN,
20 };
21
22 struct interface_error {
23 struct list_head list;
24
25 const char *subsystem;
26 const char *code;
27 const char *data[];
28 };
29
30 /*
31 * interface configuration
32 */
33 struct interface {
34 struct list_head list;
35
36 char name[IFNAMSIZ];
37
38 bool available;
39 bool autostart;
40
41 enum interface_state state;
42
43 /* main interface that the interface is bound to */
44 struct device_user main_dev;
45
46 /* interface that layer 3 communication will go through */
47 struct device_user *l3_iface;
48
49 struct config_state config;
50
51 /* primary protocol state */
52 const struct proto_handler *proto_handler;
53 struct interface_proto_state *proto;
54
55 struct vlist_tree proto_addr;
56 struct vlist_tree proto_route;
57
58 /* errors/warnings while trying to bring up the interface */
59 struct list_head errors;
60
61 struct ubus_object ubus;
62 };
63
64 extern const struct config_param_list interface_attr_list;
65
66 struct interface *interface_get(const char *name);
67 struct interface *interface_alloc(const char *name, struct blob_attr *attr);
68 void interface_free(struct interface *iface);
69
70 void interface_set_proto_state(struct interface *iface, struct interface_proto_state *state);
71
72 int interface_set_up(struct interface *iface);
73 int interface_set_down(struct interface *iface);
74
75 int interface_add_link(struct interface *iface, struct device *llif);
76 void interface_remove_link(struct interface *iface, struct device *llif);
77
78 void interface_add_error(struct interface *iface, const char *subsystem,
79 const char *code, const char **data, int n_data);
80
81 void interface_start_pending(void);
82
83 #endif