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
{
30 enum interface_state
{
37 enum interface_config_state
{
43 struct interface_error
{
44 struct list_head list
;
46 const char *subsystem
;
51 struct interface_user
{
52 struct list_head list
;
53 struct interface
*iface
;
54 void (*cb
)(struct interface_user
*dep
, struct interface
*iface
, enum interface_event ev
);
57 struct interface_ip_settings
{
58 struct interface
*iface
;
63 struct vlist_tree addr
;
64 struct vlist_tree route
;
65 struct vlist_tree prefix
;
67 struct vlist_simple_tree dns_servers
;
68 struct vlist_simple_tree dns_search
;
71 struct interface_data
{
73 struct blob_attr data
[];
76 struct interface_assignment_class
{
77 struct list_head head
;
82 * interface configuration
85 struct vlist_node node
;
86 struct list_head hotplug_list
;
87 enum interface_event hotplug_ev
;
94 bool config_autostart
;
99 enum interface_state state
;
100 enum interface_config_state config_state
;
102 struct list_head users
;
104 const char *parent_ifname
;
105 struct interface_user parent_iface
;
107 /* main interface that the interface is bound to */
108 struct device_user main_dev
;
110 /* interface that layer 3 communication will go through */
111 struct device_user l3_dev
;
113 struct blob_attr
*config
;
115 /* primary protocol state */
116 const struct proto_handler
*proto_handler
;
117 struct interface_proto_state
*proto
;
119 struct interface_ip_settings proto_ip
;
120 struct interface_ip_settings config_ip
;
121 struct vlist_tree host_routes
;
124 unsigned int ip4table
;
125 unsigned int ip6table
;
127 /* IPv6 assignment parameters */
128 uint8_t assignment_length
;
129 int32_t assignment_hint
;
130 struct list_head assignment_classes
;
132 /* errors/warnings while trying to bring up the interface */
133 struct list_head errors
;
135 /* extra data provided by protocol handlers or modules */
136 struct avl_tree data
;
138 struct uloop_timeout remove_timer
;
139 struct ubus_object ubus
;
143 extern struct vlist_tree interfaces
;
144 extern const struct uci_blob_param_list interface_attr_list
;
146 void interface_init(struct interface
*iface
, const char *name
,
147 struct blob_attr
*config
, bool dynamic
);
149 void interface_add(struct interface
*iface
, struct blob_attr
*config
);
150 bool interface_add_alias(struct interface
*iface
, struct blob_attr
*config
);
152 void interface_set_proto_state(struct interface
*iface
, struct interface_proto_state
*state
);
154 void interface_set_available(struct interface
*iface
, bool new_state
);
155 int interface_set_up(struct interface
*iface
);
156 int interface_set_down(struct interface
*iface
);
157 void __interface_set_down(struct interface
*iface
, bool force
);
159 void interface_set_main_dev(struct interface
*iface
, struct device
*dev
);
160 void interface_set_l3_dev(struct interface
*iface
, struct device
*dev
);
162 void interface_add_user(struct interface_user
*dep
, struct interface
*iface
);
163 void interface_remove_user(struct interface_user
*dep
);
165 int interface_add_link(struct interface
*iface
, struct device
*dev
);
166 int interface_remove_link(struct interface
*iface
, struct device
*dev
);
168 void interface_add_error(struct interface
*iface
, const char *subsystem
,
169 const char *code
, const char **data
, int n_data
);
171 int interface_add_data(struct interface
*iface
, const struct blob_attr
*data
);
173 void interface_update_start(struct interface
*iface
);
174 void interface_update_complete(struct interface
*iface
);
176 void interface_start_pending(void);