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