2 * $Id: radvd.h,v 1.42 2011/04/28 15:08:40 reubenhwk Exp $
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),
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>.
25 #define CONTACT_EMAIL "Pekka Savola <pekkas@netcore.fi>"
29 #define min(a,b) (((a) < (b)) ? (a) : (b))
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
];
52 struct timeval last_ra_time
;
56 double MaxRtrAdvInterval
;
57 double MinRtrAdvInterval
;
58 double MinDelayBetweenRAs
;
60 int AdvOtherConfigFlag
;
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
;
70 /* Mobile IPv6 extensions */
74 uint16_t HomeAgentPreference
;
75 int32_t HomeAgentLifetime
; /* XXX: really uint16_t but we need to use -1 */
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) */
91 struct Interface
*next
;
95 struct in6_addr Address
;
100 struct in6_addr Prefix
;
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 */
116 /* 6to4 etc. extensions */
117 char if6to4
[IFNAMSIZ
];
121 /* Select prefixes from this interface. */
124 struct AdvPrefix
*next
;
127 /* More-Specific Routes extensions */
130 struct in6_addr Prefix
;
133 int AdvRoutePreference
;
134 uint32_t AdvRouteLifetime
;
137 struct AdvRoute
*next
;
140 /* Options for DNS configuration */
144 uint32_t AdvRDNSSLifetime
;
146 struct in6_addr AdvRDNSSAddr1
;
147 struct in6_addr AdvRDNSSAddr2
;
148 struct in6_addr AdvRDNSSAddr3
;
150 struct AdvRDNSS
*next
;
154 uint32_t AdvDNSSLLifetime
;
158 char **AdvDNSSLSuffixes
;
160 struct AdvDNSSL
*next
;
163 /* Mobile IPv6 extensions */
172 struct HomeAgentInfo
{
175 uint16_t flags_reserved
;
188 int check_ip6_forwarding(void);
189 void reload_config(void);
190 void reset_prefix_lifetimes(void);
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
);
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);
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
*);
220 int open_icmpv6_socket(void);
223 int send_ra(struct Interface
*iface
, struct in6_addr
*dest
);
224 int send_ra_forall(struct Interface
*iface
, struct in6_addr
*dest
);
227 void process(struct Interface
*, unsigned char *, int,
228 struct sockaddr_in6
*, struct in6_pktinfo
*, int);
231 int recv_rs_ra(unsigned char *, struct sockaddr_in6
*, struct in6_pktinfo
**, int *);
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
);
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
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
270 # if defined IPV6_RECVPKTINFO && defined IPV6_2292PKTINFO
271 # undef IPV6_RECVPKTINFO
273 # define IPV6_RECVPKTINFO IPV6_2292PKTINFO
274 # define IPV6_PKTINFO IPV6_2292PKTINFO