rtadvd.h revision 1.11 1 1.11 roy /* $NetBSD: rtadvd.h,v 1.11 2011/12/10 19:14:29 roy Exp $ */
2 1.10 rpaulo /* $KAME: rtadvd.h,v 1.30 2005/10/17 14:40:02 suz Exp $ */
3 1.2 itojun
4 1.1 itojun /*
5 1.1 itojun * Copyright (C) 1998 WIDE Project.
6 1.1 itojun * All rights reserved.
7 1.1 itojun *
8 1.1 itojun * Redistribution and use in source and binary forms, with or without
9 1.1 itojun * modification, are permitted provided that the following conditions
10 1.1 itojun * are met:
11 1.1 itojun * 1. Redistributions of source code must retain the above copyright
12 1.1 itojun * notice, this list of conditions and the following disclaimer.
13 1.1 itojun * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 itojun * notice, this list of conditions and the following disclaimer in the
15 1.1 itojun * documentation and/or other materials provided with the distribution.
16 1.1 itojun * 3. Neither the name of the project nor the names of its contributors
17 1.1 itojun * may be used to endorse or promote products derived from this software
18 1.1 itojun * without specific prior written permission.
19 1.1 itojun *
20 1.1 itojun * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21 1.1 itojun * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 1.1 itojun * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 1.1 itojun * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24 1.1 itojun * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 1.1 itojun * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 1.1 itojun * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 1.1 itojun * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 1.1 itojun * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 1.1 itojun * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 1.1 itojun * SUCH DAMAGE.
31 1.1 itojun */
32 1.1 itojun
33 1.1 itojun #define ALLNODES "ff02::1"
34 1.6 itojun #define ALLROUTERS_LINK "ff02::2"
35 1.6 itojun #define ALLROUTERS_SITE "ff05::2"
36 1.11 roy
37 1.11 roy #define IN6ADDR_SITELOCAL_ALLROUTERS_INIT \
38 1.11 roy {{{ 0xff, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
39 1.11 roy 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}}
40 1.11 roy
41 1.11 roy //extern struct sockaddr_in6 sin6_linklocal_allnodes;
42 1.11 roy //extern struct sockaddr_in6 sin6_linklocal_allrouters;
43 1.11 roy extern struct sockaddr_in6 sin6_sitelocal_allrouters;
44 1.1 itojun
45 1.1 itojun /* protocol constants and default values */
46 1.1 itojun #define DEF_MAXRTRADVINTERVAL 600
47 1.1 itojun #define DEF_ADVLINKMTU 0
48 1.1 itojun #define DEF_ADVREACHABLETIME 0
49 1.1 itojun #define DEF_ADVRETRANSTIMER 0
50 1.1 itojun #define DEF_ADVCURHOPLIMIT 64
51 1.1 itojun #define DEF_ADVVALIDLIFETIME 2592000
52 1.1 itojun #define DEF_ADVPREFERREDLIFETIME 604800
53 1.1 itojun
54 1.1 itojun #define MAXROUTERLIFETIME 9000
55 1.10 rpaulo #define MIN_MAXINTERVAL 4
56 1.1 itojun #define MAX_MAXINTERVAL 1800
57 1.10 rpaulo #define MIN_MININTERVAL 3
58 1.1 itojun #define MAXREACHABLETIME 3600000
59 1.1 itojun
60 1.1 itojun #define MAX_INITIAL_RTR_ADVERT_INTERVAL 16
61 1.1 itojun #define MAX_INITIAL_RTR_ADVERTISEMENTS 3
62 1.1 itojun #define MAX_FINAL_RTR_ADVERTISEMENTS 3
63 1.1 itojun #define MIN_DELAY_BETWEEN_RAS 3
64 1.1 itojun #define MAX_RA_DELAY_TIME 500000 /* usec */
65 1.1 itojun
66 1.4 itojun #define PREFIX_FROM_KERNEL 1
67 1.4 itojun #define PREFIX_FROM_CONFIG 2
68 1.4 itojun #define PREFIX_FROM_DYNAMIC 3
69 1.4 itojun
70 1.1 itojun struct prefix {
71 1.11 roy TAILQ_ENTRY(prefix) next;
72 1.1 itojun
73 1.10 rpaulo struct rainfo *rainfo; /* back pointer to the interface */
74 1.10 rpaulo
75 1.10 rpaulo struct rtadvd_timer *timer; /* expiration timer. used when a prefix
76 1.10 rpaulo * derived from the kernel is deleted.
77 1.10 rpaulo */
78 1.10 rpaulo
79 1.11 roy uint32_t validlifetime; /* AdvValidLifetime */
80 1.6 itojun long vltimeexpire; /* expiration of vltime; decrement case only */
81 1.11 roy uint32_t preflifetime; /* AdvPreferredLifetime */
82 1.6 itojun long pltimeexpire; /* expiration of pltime; decrement case only */
83 1.11 roy uint16_t onlinkflg; /* bool: AdvOnLinkFlag */
84 1.11 roy uint16_t autoconfflg; /* bool: AdvAutonomousFlag */
85 1.4 itojun int prefixlen;
86 1.10 rpaulo int origin; /* from kernel or config */
87 1.1 itojun struct in6_addr prefix;
88 1.1 itojun };
89 1.1 itojun
90 1.10 rpaulo struct rtinfo {
91 1.11 roy TAILQ_ENTRY(rtinfo) next;
92 1.10 rpaulo
93 1.11 roy uint32_t ltime; /* route lifetime */
94 1.11 roy uint16_t rtpref; /* route preference */
95 1.10 rpaulo int prefixlen;
96 1.10 rpaulo struct in6_addr prefix;
97 1.10 rpaulo };
98 1.11 roy
99 1.11 roy struct rdnss_addr {
100 1.11 roy TAILQ_ENTRY(rdnss_addr) next;
101 1.11 roy
102 1.11 roy struct in6_addr addr;
103 1.11 roy };
104 1.11 roy
105 1.11 roy struct rdnss {
106 1.11 roy TAILQ_ENTRY(rdnss) next;
107 1.11 roy
108 1.11 roy TAILQ_HEAD(, rdnss_addr) list;
109 1.11 roy uint32_t lifetime;
110 1.11 roy };
111 1.11 roy
112 1.11 roy struct dnssl_domain {
113 1.11 roy TAILQ_ENTRY(dnssl_domain) next;
114 1.11 roy
115 1.11 roy int len;
116 1.11 roy char domain[256];
117 1.11 roy };
118 1.11 roy
119 1.11 roy struct dnssl {
120 1.11 roy TAILQ_ENTRY(dnssl) next;
121 1.11 roy
122 1.11 roy TAILQ_HEAD(, dnssl_domain) list;
123 1.11 roy uint32_t lifetime;
124 1.11 roy };
125 1.9 itojun
126 1.5 itojun struct soliciter {
127 1.11 roy TAILQ_ENTRY(soliciter) next;
128 1.11 roy
129 1.5 itojun struct sockaddr_in6 addr;
130 1.5 itojun };
131 1.5 itojun
132 1.1 itojun struct rainfo {
133 1.11 roy TAILQ_ENTRY(rainfo) next;
134 1.1 itojun
135 1.1 itojun /* timer related parameters */
136 1.1 itojun struct rtadvd_timer *timer;
137 1.1 itojun int initcounter; /* counter for the first few advertisements */
138 1.4 itojun struct timeval lastsent; /* timestamp when the latest RA was sent */
139 1.1 itojun int waiting; /* number of RS waiting for RA */
140 1.1 itojun
141 1.1 itojun /* interface information */
142 1.11 roy uint16_t ifindex;
143 1.1 itojun int advlinkopt; /* bool: whether include link-layer addr opt */
144 1.1 itojun struct sockaddr_dl *sdl;
145 1.1 itojun char ifname[16];
146 1.11 roy uint32_t phymtu; /* mtu of the physical interface */
147 1.1 itojun
148 1.1 itojun /* Router configuration variables */
149 1.11 roy uint16_t lifetime; /* AdvDefaultLifetime */
150 1.11 roy uint16_t maxinterval; /* MaxRtrAdvInterval */
151 1.11 roy uint16_t mininterval; /* MinRtrAdvInterval */
152 1.1 itojun int managedflg; /* AdvManagedFlag */
153 1.1 itojun int otherflg; /* AdvOtherConfigFlag */
154 1.10 rpaulo
155 1.9 itojun int rtpref; /* router preference */
156 1.11 roy uint32_t linkmtu; /* AdvLinkMTU */
157 1.11 roy uint32_t reachabletime; /* AdvReachableTime */
158 1.11 roy uint32_t retranstimer; /* AdvRetransTimer */
159 1.11 roy uint16_t hoplimit; /* AdvCurHopLimit */
160 1.11 roy TAILQ_HEAD(, prefix) prefix; /* AdvPrefixList(link head) */
161 1.11 roy int pfxs;
162 1.11 roy uint16_t clockskew;/* used for consisitency check of lifetimes */
163 1.11 roy
164 1.11 roy TAILQ_HEAD(, rtinfo) route;
165 1.11 roy TAILQ_HEAD(, rdnss) rdnss; /* RDNSS list */
166 1.11 roy TAILQ_HEAD(, dnssl) dnssl; /* DNS Search List */
167 1.3 itojun
168 1.1 itojun /* actual RA packet data and its length */
169 1.1 itojun size_t ra_datalen;
170 1.11 roy char *ra_data;
171 1.4 itojun
172 1.4 itojun /* statistics */
173 1.11 roy uint64_t raoutput; /* number of RAs sent */
174 1.11 roy uint64_t rainput; /* number of RAs received */
175 1.11 roy uint64_t rainconsistent; /* number of RAs inconsistent with ours */
176 1.11 roy uint64_t rsinput; /* number of RSs received */
177 1.5 itojun
178 1.5 itojun /* info about soliciter */
179 1.11 roy TAILQ_HEAD(, soliciter) soliciter; /* recent solication source */
180 1.1 itojun };
181 1.1 itojun
182 1.11 roy extern TAILQ_HEAD(ralist_head_t, rainfo) ralist;
183 1.3 itojun
184 1.11 roy struct rtadvd_timer *ra_timeout(void *);
185 1.11 roy void ra_timer_update(void *, struct timeval *);
186 1.6 itojun
187 1.11 roy int prefix_match(struct in6_addr *, int, struct in6_addr *, int);
188 1.11 roy struct rainfo *if_indextorainfo(unsigned int);
189 1.11 roy struct prefix *find_prefix(struct rainfo *, struct in6_addr *, int);
190