• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/netifd/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 overrides the default interface mtu */
 32         DEVROUTE_MTU            = (1 << 4),
 33 
 34         /* route overrides the default proto type */
 35         DEVROUTE_PROTO          = (1 << 5),
 36 
 37         /* address is off-link (no subnet-route) */
 38         DEVADDR_OFFLINK         = (1 << 6),
 39 
 40         /* route resides in different table */
 41         DEVROUTE_TABLE          = (1 << 7),
 42 
 43         /* route resides in default source-route table */
 44         DEVROUTE_SRCTABLE       = (1 << 8),
 45 
 46         /* route is on-link */
 47         DEVROUTE_ONLINK         = (1 << 9),
 48 
 49         /* route overrides the default route type */
 50         DEVROUTE_TYPE           = (1 << 10),
 51 
 52         /* neighbor mac address */
 53         DEVNEIGH_MAC            = (1 << 11),
 54 
 55         /* route specifies no device */
 56         DEVROUTE_NODEV          = (1 << 12),
 57 };
 58 
 59 union if_addr {
 60         struct in_addr in;
 61         struct in6_addr in6;
 62 };
 63 
 64 struct device_prefix_assignment {
 65         struct list_head head;
 66         int32_t assigned;
 67         uint8_t length;
 68         int weight;
 69         struct in6_addr addr;
 70         bool enabled;
 71         char name[];
 72 };
 73 
 74 struct device_prefix {
 75         struct vlist_node node;
 76         struct list_head head;
 77         struct list_head assignments;
 78         struct interface *iface;
 79         time_t valid_until;
 80         time_t preferred_until;
 81 
 82         struct in6_addr excl_addr;
 83         uint8_t excl_length;
 84 
 85         struct in6_addr addr;
 86         uint8_t length;
 87 
 88         char pclass[];
 89 };
 90 
 91 struct device_route {
 92         struct vlist_node node;
 93         struct interface *iface;
 94 
 95         bool enabled;
 96         bool keep;
 97         bool failed;
 98 
 99         union if_addr nexthop;
100         int mtu;
101         unsigned int type;
102         unsigned int proto;
103         time_t valid_until;
104 
105         /* must be last */
106         enum device_addr_flags flags;
107         int metric; /* there can be multiple routes to the same target */
108         unsigned int table;
109         unsigned int mask;
110         unsigned int sourcemask;
111         union if_addr addr;
112         union if_addr source;
113 };
114 
115 struct device_neighbor {
116         struct vlist_node node;
117 
118         bool failed;
119         bool proxy;
120         bool keep;
121         bool enabled;
122         bool router;
123 
124         uint8_t macaddr[6];
125         enum device_addr_flags flags;
126         union if_addr addr;
127 };
128 
129 struct device_addr {
130         struct vlist_node node;
131         bool enabled;
132         bool failed;
133         int index;
134         unsigned int policy_table;
135 
136         struct device_route subnet;
137 
138         /* ipv4 only */
139         uint32_t broadcast;
140         uint32_t point_to_point;
141 
142         /* ipv6 only */
143         time_t valid_until;
144         time_t preferred_until;
145         char *pclass;
146 
147         /* must be last */
148         enum device_addr_flags flags;
149         unsigned int mask;
150         union if_addr addr;
151 };
152 
153 struct device_source_table {
154         struct list_head head;
155         uint32_t table;
156         uint16_t refcount;
157         uint8_t v6;
158         uint8_t mask;
159         union if_addr addr;
160 };
161 
162 struct dns_server {
163         struct vlist_simple_node node;
164         int af;
165         union if_addr addr;
166 };
167 
168 struct dns_search_domain {
169         struct vlist_simple_node node;
170         char name[];
171 };
172 
173 extern const struct uci_blob_param_list route_attr_list;
174 extern const struct uci_blob_param_list neighbor_attr_list;
175 extern struct list_head prefixes;
176 
177 void interface_ip_init(struct interface *iface);
178 void interface_add_dns_server_list(struct interface_ip_settings *ip, struct blob_attr *list);
179 void interface_add_dns_search_list(struct interface_ip_settings *ip, struct blob_attr *list);
180 void interface_write_resolv_conf(const char *jail);
181 
182 void interface_ip_add_route(struct interface *iface, struct blob_attr *attr, bool v6);
183 void interface_ip_add_neighbor(struct interface *iface, struct blob_attr *attr, bool v6);
184 void interface_ip_update_start(struct interface_ip_settings *ip);
185 void interface_ip_update_complete(struct interface_ip_settings *ip);
186 void interface_ip_flush(struct interface_ip_settings *ip);
187 void interface_ip_set_enabled(struct interface_ip_settings *ip, bool enabled);
188 void interface_ip_update_metric(struct interface_ip_settings *ip, int metric);
189 
190 struct interface *interface_ip_add_target_route(union if_addr *addr, bool v6, struct interface *iface,
191                                                 bool exclude);
192 
193 struct device_prefix* interface_ip_add_device_prefix(struct interface *iface,
194                 struct in6_addr *addr, uint8_t length, time_t valid_until, time_t preferred_until,
195                 struct in6_addr *excl_addr, uint8_t excl_length, const char *pclass);
196 void interface_ip_set_ula_prefix(const char *prefix);
197 void interface_refresh_assignments(bool hint);
198 void interface_update_prefix_delegation(struct interface_ip_settings *ip);
199 
200 #endif
201 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt