Merge branch 'tomato-ND-USBmod' into tomato-RT
[tomato.git] / release / src / router / radvd / radvd.h
blob82cbfbe6f530b0117c53d2ec60082145b3ab846a
1 /*
2 * $Id: radvd.h,v 1.42 2011/04/28 15:08:40 reubenhwk Exp $
4 * Authors:
5 * Pedro Roque <roque@di.fc.ul.pt>
6 * Lars Fenneberg <lf@elemental.net>
8 * This software is Copyright 1996,1997 by the above mentioned author(s),
9 * All Rights Reserved.
11 * The license which is distributed with this software in the file COPYRIGHT
12 * applies to this software. If your distribution is missing this file, you
13 * may request it from <pekkas@netcore.fi>.
17 #ifndef RADV_H
18 #define RADV_H
20 #include "config.h"
21 #include "includes.h"
22 #include "defaults.h"
23 #include "log.h"
25 #define CONTACT_EMAIL "Pekka Savola <pekkas@netcore.fi>"
27 extern int sock;
29 #define min(a,b) (((a) < (b)) ? (a) : (b))
31 struct AdvPrefix;
32 struct Clients;
34 #define HWADDR_MAX 16
35 #define USER_HZ 100
37 struct Interface {
38 char Name[IFNAMSIZ]; /* interface name */
40 struct in6_addr if_addr;
41 unsigned int if_index;
43 uint8_t init_racount; /* Initial RAs */
45 uint8_t if_hwaddr[HWADDR_MAX];
46 int if_hwaddr_len;
47 int if_prefix_len;
48 int if_maxmtu;
50 int cease_adv;
52 struct timeval last_ra_time;
54 int IgnoreIfMissing;
55 int AdvSendAdvert;
56 double MaxRtrAdvInterval;
57 double MinRtrAdvInterval;
58 double MinDelayBetweenRAs;
59 int AdvManagedFlag;
60 int AdvOtherConfigFlag;
61 uint32_t AdvLinkMTU;
62 uint32_t AdvReachableTime;
63 uint32_t AdvRetransTimer;
64 uint8_t AdvCurHopLimit;
65 int32_t AdvDefaultLifetime; /* XXX: really uint16_t but we need to use -1 */
66 int AdvDefaultPreference;
67 int AdvSourceLLAddress;
68 int UnicastOnly;
70 /* Mobile IPv6 extensions */
71 int AdvIntervalOpt;
72 int AdvHomeAgentInfo;
73 int AdvHomeAgentFlag;
74 uint16_t HomeAgentPreference;
75 int32_t HomeAgentLifetime; /* XXX: really uint16_t but we need to use -1 */
77 /* NEMO extensions */
78 int AdvMobRtrSupportFlag;
80 struct AdvPrefix *AdvPrefixList;
81 struct AdvRoute *AdvRouteList;
82 struct AdvRDNSS *AdvRDNSSList;
83 struct AdvDNSSL *AdvDNSSLList;
84 struct Clients *ClientList;
85 struct timeval last_multicast;
86 struct timeval next_multicast;
88 /* Info whether this interface has failed in the past (and may need to be reinitialized) */
89 int HasFailed;
91 struct Interface *next;
94 struct Clients {
95 struct in6_addr Address;
96 struct Clients *next;
99 struct AdvPrefix {
100 struct in6_addr Prefix;
101 uint8_t PrefixLen;
103 int AdvOnLinkFlag;
104 int AdvAutonomousFlag;
105 uint32_t AdvValidLifetime;
106 uint32_t AdvPreferredLifetime;
107 int DeprecatePrefixFlag;
108 int DecrementLifetimesFlag;
110 uint32_t curr_validlft;
111 uint32_t curr_preferredlft;
113 /* Mobile IPv6 extensions */
114 int AdvRouterAddr;
116 /* 6to4 etc. extensions */
117 char if6to4[IFNAMSIZ];
118 int enabled;
119 int AutoSelected;
121 /* Select prefixes from this interface. */
122 char if6[IFNAMSIZ];
124 struct AdvPrefix *next;
127 /* More-Specific Routes extensions */
129 struct AdvRoute {
130 struct in6_addr Prefix;
131 uint8_t PrefixLen;
133 int AdvRoutePreference;
134 uint32_t AdvRouteLifetime;
135 int RemoveRouteFlag;
137 struct AdvRoute *next;
140 /* Options for DNS configuration */
142 struct AdvRDNSS {
143 int AdvRDNSSNumber;
144 uint32_t AdvRDNSSLifetime;
145 int FlushRDNSSFlag;
146 struct in6_addr AdvRDNSSAddr1;
147 struct in6_addr AdvRDNSSAddr2;
148 struct in6_addr AdvRDNSSAddr3;
150 struct AdvRDNSS *next;
153 struct AdvDNSSL {
154 uint32_t AdvDNSSLLifetime;
156 int AdvDNSSLNumber;
157 int FlushDNSSLFlag;
158 char **AdvDNSSLSuffixes;
160 struct AdvDNSSL *next;
163 /* Mobile IPv6 extensions */
165 struct AdvInterval {
166 uint8_t type;
167 uint8_t length;
168 uint16_t reserved;
169 uint32_t adv_ival;
172 struct HomeAgentInfo {
173 uint8_t type;
174 uint8_t length;
175 uint16_t flags_reserved;
176 uint16_t preference;
177 uint16_t lifetime;
181 /* gram.y */
182 int yyparse(void);
184 /* scanner.l */
185 int yylex(void);
187 /* radvd.c */
188 int check_ip6_forwarding(void);
189 void reload_config(void);
190 void reset_prefix_lifetimes(void);
192 /* timer.c */
193 struct timeval next_timeval(double next);
194 int timevaldiff(struct timeval const *a, struct timeval const *b);
195 int next_time_msec(struct Interface const * iface);
196 int expired(struct Interface const * iface);
198 /* device.c */
199 int setup_deviceinfo(struct Interface *);
200 int check_device(struct Interface *);
201 int setup_linklocal_addr(struct Interface *);
202 int setup_allrouters_membership(struct Interface *);
203 int check_allrouters_membership(struct Interface *);
204 int get_v4addr(const char *, unsigned int *);
205 int set_interface_var(const char *, const char *, const char *, uint32_t);
206 int set_interface_linkmtu(const char *, uint32_t);
207 int set_interface_curhlim(const char *, uint8_t);
208 int set_interface_reachtime(const char *, uint32_t);
209 int set_interface_retranstimer(const char *, uint32_t);
211 /* interface.c */
212 void iface_init_defaults(struct Interface *);
213 void prefix_init_defaults(struct AdvPrefix *);
214 void route_init_defaults(struct AdvRoute *, struct Interface *);
215 void rdnss_init_defaults(struct AdvRDNSS *, struct Interface *);
216 void dnssl_init_defaults(struct AdvDNSSL *, struct Interface *);
217 int check_iface(struct Interface *);
219 /* socket.c */
220 int open_icmpv6_socket(void);
222 /* send.c */
223 int send_ra(struct Interface *iface, struct in6_addr *dest);
224 int send_ra_forall(struct Interface *iface, struct in6_addr *dest);
226 /* process.c */
227 void process(struct Interface *, unsigned char *, int,
228 struct sockaddr_in6 *, struct in6_pktinfo *, int);
230 /* recv.c */
231 int recv_rs_ra(unsigned char *, struct sockaddr_in6 *, struct in6_pktinfo **, int *);
233 /* util.c */
234 void mdelay(double);
235 double rand_between(double, double);
236 void print_addr(struct in6_addr *, char *);
237 int check_rdnss_presence(struct AdvRDNSS *, struct in6_addr *);
238 int check_dnssl_presence(struct AdvDNSSL *, const char *);
239 ssize_t readn(int fd, void *buf, size_t count);
240 ssize_t writen(int fd, const void *buf, size_t count);
242 /* privsep.c */
243 int privsep_init(void);
244 int privsep_enabled(void);
245 int privsep_interface_linkmtu(const char *iface, uint32_t mtu);
246 int privsep_interface_curhlim(const char *iface, uint32_t hlim);
247 int privsep_interface_reachtime(const char *iface, uint32_t rtime);
248 int privsep_interface_retranstimer(const char *iface, uint32_t rettimer);
251 * compat hacks in case libc and kernel get out of sync:
253 * glibc 2.4 and uClibc 0.9.29 introduce IPV6_RECVPKTINFO etc. and change IPV6_PKTINFO
254 * This is only supported in Linux kernel >= 2.6.14
256 * This is only an approximation because the kernel version that libc was compiled against
257 * could be older or newer than the one being run. But this should not be a problem --
258 * we just keep using the old kernel interface.
260 * these are placed here because they're needed in all of socket.c, recv.c and send.c
262 #ifdef __linux__
263 # if defined IPV6_RECVHOPLIMIT || defined IPV6_RECVPKTINFO
264 # include <linux/version.h>
265 # if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
266 # if defined IPV6_RECVHOPLIMIT && defined IPV6_2292HOPLIMIT
267 # undef IPV6_RECVHOPLIMIT
268 # define IPV6_RECVHOPLIMIT IPV6_2292HOPLIMIT
269 # endif
270 # if defined IPV6_RECVPKTINFO && defined IPV6_2292PKTINFO
271 # undef IPV6_RECVPKTINFO
272 # undef IPV6_PKTINFO
273 # define IPV6_RECVPKTINFO IPV6_2292PKTINFO
274 # define IPV6_PKTINFO IPV6_2292PKTINFO
275 # endif
276 # endif
277 # endif
278 #endif
280 #endif