rename config_init_interfaces to config_init_all
[project/netifd.git] / interface-ip.h
1 #ifndef __INTERFACE_IP_H
2 #define __INTERFACE_IP_H
3
4 #include "interface.h"
5
6 enum device_addr_flags {
7 /* address family for routes and addresses */
8 DEVADDR_INET4 = (0 << 0),
9 DEVADDR_INET6 = (1 << 0),
10 DEVADDR_FAMILY = DEVADDR_INET4 | DEVADDR_INET6,
11
12 /* device route (no gateway) */
13 DEVADDR_DEVICE = (1 << 1),
14
15 /* externally added address */
16 DEVADDR_EXTERNAL = (1 << 2),
17 };
18
19 union if_addr {
20 struct in_addr in;
21 struct in6_addr in6;
22 };
23
24 struct device_addr {
25 struct vlist_node node;
26
27 enum device_addr_flags flags;
28 bool enabled;
29
30 struct device *device;
31
32 /* must be last */
33 unsigned int mask;
34 union if_addr addr;
35 };
36
37 struct device_route {
38 struct vlist_node node;
39
40 enum device_addr_flags flags;
41 bool enabled;
42 bool keep;
43
44 union if_addr nexthop;
45 struct device *device;
46 int metric;
47 int mtu;
48
49 /* must be last */
50 unsigned int mask;
51 union if_addr addr;
52 };
53
54 struct dns_server {
55 struct list_head list;
56 int af;
57 union if_addr addr;
58 };
59
60 struct dns_search_domain {
61 struct list_head list;
62 char name[];
63 };
64
65 void interface_ip_init(struct interface_ip_settings *ip, struct interface *iface);
66 void interface_add_dns_server(struct interface_ip_settings *ip, const char *str);
67 void interface_add_dns_server_list(struct interface_ip_settings *ip, struct blob_attr *list);
68 void interface_add_dns_search_list(struct interface_ip_settings *ip, struct blob_attr *list);
69 void interface_write_resolv_conf(void);
70
71 void interface_ip_add_route(struct interface *iface, struct blob_attr *attr, bool v6);
72
73 void interface_ip_update_start(struct interface_ip_settings *ip);
74 void interface_ip_update_complete(struct interface_ip_settings *ip);
75 void interface_ip_flush(struct interface_ip_settings *ip);
76 void interface_ip_set_enabled(struct interface_ip_settings *ip, bool enabled);
77
78
79 #endif