reset iface->config_state when handling it
[project/netifd.git] / interface-ip.h
1 /*
2 * netifd - network interface daemon
3 * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
4 *
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
8 *
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.
13 */
14 #ifndef __INTERFACE_IP_H
15 #define __INTERFACE_IP_H
16
17 #include "interface.h"
18
19 enum device_addr_flags {
20 /* address family for routes and addresses */
21 DEVADDR_INET4 = (0 << 0),
22 DEVADDR_INET6 = (1 << 0),
23 DEVADDR_FAMILY = DEVADDR_INET4 | DEVADDR_INET6,
24
25 /* externally added address */
26 DEVADDR_EXTERNAL = (1 << 2),
27
28 /* route overrides the default interface metric */
29 DEVROUTE_METRIC = (1 << 3),
30
31 /* route automatically added by kernel */
32 DEVADDR_KERNEL = (1 << 4),
33 };
34
35 union if_addr {
36 struct in_addr in;
37 struct in6_addr in6;
38 };
39
40 struct device_addr {
41 struct vlist_node node;
42 bool enabled;
43
44 /* ipv4 only */
45 uint32_t broadcast;
46 uint32_t point_to_point;
47
48 /* must be last */
49 enum device_addr_flags flags;
50 unsigned int mask;
51 union if_addr addr;
52 };
53
54 struct device_route {
55 struct vlist_node node;
56 struct interface *iface;
57
58 bool enabled;
59 bool keep;
60
61 union if_addr nexthop;
62 int metric;
63 int mtu;
64
65 /* must be last */
66 enum device_addr_flags flags;
67 unsigned int mask;
68 union if_addr addr;
69 };
70
71 struct dns_server {
72 struct vlist_simple_node node;
73 int af;
74 union if_addr addr;
75 };
76
77 struct dns_search_domain {
78 struct vlist_simple_node node;
79 char name[];
80 };
81
82 extern const struct config_param_list route_attr_list;
83
84 void interface_ip_init(struct interface *iface);
85 void interface_add_dns_server(struct interface_ip_settings *ip, const char *str);
86 void interface_add_dns_server_list(struct interface_ip_settings *ip, struct blob_attr *list);
87 void interface_add_dns_search_list(struct interface_ip_settings *ip, struct blob_attr *list);
88 void interface_write_resolv_conf(void);
89
90 void interface_ip_add_route(struct interface *iface, struct blob_attr *attr, bool v6);
91
92 void interface_ip_update_start(struct interface_ip_settings *ip);
93 void interface_ip_update_complete(struct interface_ip_settings *ip);
94 void interface_ip_flush(struct interface_ip_settings *ip);
95 void interface_ip_set_enabled(struct interface_ip_settings *ip, bool enabled);
96 void interface_ip_update_metric(struct interface_ip_settings *ip, int metric);
97
98 struct interface *interface_ip_add_target_route(union if_addr *addr, bool v6);
99
100 #endif