1 #ifndef __NETIFD_INTERFACE_H
2 #define __NETIFD_INTERFACE_H
4 #include <netinet/in.h>
8 struct interface_proto_state;
10 enum interface_event {
15 enum interface_state {
22 struct interface_error {
23 struct list_head list;
25 const char *subsystem;
30 enum interface_addr_flags {
31 /* address family for routes and addresses */
32 IFADDR_INET4 = (0 << 0),
33 IFADDR_INET6 = (1 << 0),
34 IFADDR_FAMILY = IFADDR_INET4 | IFADDR_INET6,
36 /* device route (no gateway) */
37 IFADDR_DEVICE = (1 << 1),
45 struct interface_addr {
46 struct list_head list;
49 enum interface_addr_flags flags;
55 struct interface_route {
56 struct list_head list;
59 enum interface_addr_flags flags;
63 union if_addr nexthop;
67 * interface configuration
70 struct list_head list;
77 enum interface_state state;
79 /* main interface that the interface is bound to */
80 struct device_user main_dev;
82 /* interface that layer 3 communication will go through */
83 struct device_user *l3_iface;
85 /* primary protocol state */
86 struct interface_proto_state *proto;
88 struct list_head address, routes;
90 /* errors/warnings while trying to bring up the interface */
91 struct list_head errors;
93 struct ubus_object ubus;
96 struct interface *get_interface(const char *name);
97 struct interface *alloc_interface(const char *name, struct uci_section *s);
98 void free_interface(struct interface *iface);
100 void interface_set_proto_state(struct interface *iface, struct interface_proto_state *state);
102 int set_interface_up(struct interface *iface);
103 int set_interface_down(struct interface *iface);
105 int interface_add_link(struct interface *iface, struct device *llif);
106 void interface_remove_link(struct interface *iface, struct device *llif);
108 void interface_add_error(struct interface *iface, const char *subsystem,
109 const char *code, const char **data, int n_data);
111 int interface_attach_bridge(struct interface *iface, struct uci_section *s);
113 int interface_add_address(struct interface *iface, struct interface_addr *addr);
114 void interface_del_address(struct interface *iface, struct interface_addr *addr);
115 void interface_del_ctx_addr(struct interface *iface, void *ctx);
117 void start_pending_interfaces(void);