2 * netifd - network interface daemon
3 * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2
7 * as published by the Free Software Foundation
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 #ifndef __NETIFD_INTERFACE_H
15 #define __NETIFD_INTERFACE_H
21 struct interface_proto_state
;
23 enum interface_event
{
31 enum interface_state
{
38 enum interface_config_state
{
44 struct interface_error
{
45 struct list_head list
;
47 const char *subsystem
;
52 struct interface_user
{
53 struct list_head list
;
54 struct interface
*iface
;
55 void (*cb
)(struct interface_user
*dep
, struct interface
*iface
, enum interface_event ev
);
58 struct interface_ip_settings
{
59 struct interface
*iface
;
65 struct vlist_tree addr
;
66 struct vlist_tree route
;
67 struct vlist_tree prefix
;
69 struct vlist_simple_tree dns_servers
;
70 struct vlist_simple_tree dns_search
;
73 struct interface_data
{
75 struct blob_attr data
[];
78 struct interface_assignment_class
{
79 struct list_head head
;
84 * interface configuration
87 struct vlist_node node
;
88 struct list_head hotplug_list
;
89 enum interface_event hotplug_ev
;
96 bool config_autostart
;
103 enum interface_state state
;
104 enum interface_config_state config_state
;
106 struct list_head users
;
108 const char *parent_ifname
;
109 struct interface_user parent_iface
;
111 /* main interface that the interface is bound to */
112 struct device_user main_dev
;
114 /* interface that layer 3 communication will go through */
115 struct device_user l3_dev
;
117 struct blob_attr
*config
;
119 /* primary protocol state */
120 const struct proto_handler
*proto_handler
;
121 struct interface_proto_state
*proto
;
123 struct interface_ip_settings proto_ip
;
124 struct interface_ip_settings config_ip
;
125 struct vlist_tree host_routes
;
128 unsigned int ip4table
;
129 unsigned int ip6table
;
131 /* IPv6 assignment parameters */
132 uint8_t assignment_length
;
133 int32_t assignment_hint
;
134 struct list_head assignment_classes
;
136 /* errors/warnings while trying to bring up the interface */
137 struct list_head errors
;
139 /* extra data provided by protocol handlers or modules */
140 struct avl_tree data
;
142 struct uloop_timeout remove_timer
;
143 struct ubus_object ubus
;
147 extern struct vlist_tree interfaces
;
148 extern const struct uci_blob_param_list interface_attr_list
;
150 struct interface
*interface_alloc(const char *name
, struct blob_attr
*config
);
152 void interface_set_dynamic(struct interface
*iface
);
154 void interface_add(struct interface
*iface
, struct blob_attr
*config
);
155 bool interface_add_alias(struct interface
*iface
, struct blob_attr
*config
);
157 void interface_set_proto_state(struct interface
*iface
, struct interface_proto_state
*state
);
159 void interface_set_available(struct interface
*iface
, bool new_state
);
160 int interface_set_up(struct interface
*iface
);
161 int interface_set_down(struct interface
*iface
);
162 void __interface_set_down(struct interface
*iface
, bool force
);
164 void interface_set_main_dev(struct interface
*iface
, struct device
*dev
);
165 void interface_set_l3_dev(struct interface
*iface
, struct device
*dev
);
167 void interface_add_user(struct interface_user
*dep
, struct interface
*iface
);
168 void interface_remove_user(struct interface_user
*dep
);
170 int interface_add_link(struct interface
*iface
, struct device
*dev
);
171 int interface_remove_link(struct interface
*iface
, struct device
*dev
);
172 int interface_handle_link(struct interface
*iface
, const char *name
, bool add
);
174 void interface_add_error(struct interface
*iface
, const char *subsystem
,
175 const char *code
, const char **data
, int n_data
);
177 int interface_add_data(struct interface
*iface
, const struct blob_attr
*data
);
179 void interface_update_start(struct interface
*iface
);
180 void interface_update_complete(struct interface
*iface
);
182 void interface_start_pending(void);