rtadvd.h revision 1.10 1 1.10 rpaulo /* $NetBSD: rtadvd.h,v 1.10 2006/03/05 23:47:08 rpaulo 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.1 itojun #define ANY "::"
37 1.1 itojun #define RTSOLLEN 8
38 1.1 itojun
39 1.1 itojun /* protocol constants and default values */
40 1.1 itojun #define DEF_MAXRTRADVINTERVAL 600
41 1.1 itojun #define DEF_ADVLINKMTU 0
42 1.1 itojun #define DEF_ADVREACHABLETIME 0
43 1.1 itojun #define DEF_ADVRETRANSTIMER 0
44 1.1 itojun #define DEF_ADVCURHOPLIMIT 64
45 1.1 itojun #define DEF_ADVVALIDLIFETIME 2592000
46 1.1 itojun #define DEF_ADVPREFERREDLIFETIME 604800
47 1.1 itojun
48 1.1 itojun #define MAXROUTERLIFETIME 9000
49 1.10 rpaulo #define MIN_MAXINTERVAL 4
50 1.1 itojun #define MAX_MAXINTERVAL 1800
51 1.10 rpaulo #define MIN_MININTERVAL 3
52 1.1 itojun #define MAXREACHABLETIME 3600000
53 1.1 itojun
54 1.1 itojun #define MAX_INITIAL_RTR_ADVERT_INTERVAL 16
55 1.1 itojun #define MAX_INITIAL_RTR_ADVERTISEMENTS 3
56 1.1 itojun #define MAX_FINAL_RTR_ADVERTISEMENTS 3
57 1.1 itojun #define MIN_DELAY_BETWEEN_RAS 3
58 1.1 itojun #define MAX_RA_DELAY_TIME 500000 /* usec */
59 1.1 itojun
60 1.4 itojun #define PREFIX_FROM_KERNEL 1
61 1.4 itojun #define PREFIX_FROM_CONFIG 2
62 1.4 itojun #define PREFIX_FROM_DYNAMIC 3
63 1.4 itojun
64 1.1 itojun struct prefix {
65 1.1 itojun struct prefix *next; /* forward link */
66 1.1 itojun struct prefix *prev; /* previous link */
67 1.1 itojun
68 1.10 rpaulo struct rainfo *rainfo; /* back pointer to the interface */
69 1.10 rpaulo
70 1.10 rpaulo struct rtadvd_timer *timer; /* expiration timer. used when a prefix
71 1.10 rpaulo * derived from the kernel is deleted.
72 1.10 rpaulo */
73 1.10 rpaulo
74 1.1 itojun u_int32_t validlifetime; /* AdvValidLifetime */
75 1.6 itojun long vltimeexpire; /* expiration of vltime; decrement case only */
76 1.1 itojun u_int32_t preflifetime; /* AdvPreferredLifetime */
77 1.6 itojun long pltimeexpire; /* expiration of pltime; decrement case only */
78 1.1 itojun u_int onlinkflg; /* bool: AdvOnLinkFlag */
79 1.1 itojun u_int autoconfflg; /* bool: AdvAutonomousFlag */
80 1.4 itojun int prefixlen;
81 1.10 rpaulo int origin; /* from kernel or config */
82 1.1 itojun struct in6_addr prefix;
83 1.1 itojun };
84 1.1 itojun
85 1.10 rpaulo #ifdef ROUTEINFO
86 1.10 rpaulo struct rtinfo {
87 1.10 rpaulo struct rtinfo *prev; /* previous link */
88 1.10 rpaulo struct rtinfo *next; /* forward link */
89 1.10 rpaulo
90 1.10 rpaulo u_int32_t ltime; /* route lifetime */
91 1.10 rpaulo u_int rtpref; /* route preference */
92 1.10 rpaulo int prefixlen;
93 1.10 rpaulo struct in6_addr prefix;
94 1.10 rpaulo };
95 1.10 rpaulo #endif
96 1.9 itojun
97 1.5 itojun struct soliciter {
98 1.5 itojun struct soliciter *next;
99 1.5 itojun struct sockaddr_in6 addr;
100 1.5 itojun };
101 1.5 itojun
102 1.1 itojun struct rainfo {
103 1.1 itojun /* pointer for list */
104 1.1 itojun struct rainfo *next;
105 1.1 itojun
106 1.1 itojun /* timer related parameters */
107 1.1 itojun struct rtadvd_timer *timer;
108 1.1 itojun int initcounter; /* counter for the first few advertisements */
109 1.4 itojun struct timeval lastsent; /* timestamp when the latest RA was sent */
110 1.1 itojun int waiting; /* number of RS waiting for RA */
111 1.1 itojun
112 1.1 itojun /* interface information */
113 1.1 itojun int ifindex;
114 1.1 itojun int advlinkopt; /* bool: whether include link-layer addr opt */
115 1.1 itojun struct sockaddr_dl *sdl;
116 1.1 itojun char ifname[16];
117 1.1 itojun int phymtu; /* mtu of the physical interface */
118 1.1 itojun
119 1.1 itojun /* Router configuration variables */
120 1.1 itojun u_short lifetime; /* AdvDefaultLifetime */
121 1.1 itojun u_int maxinterval; /* MaxRtrAdvInterval */
122 1.1 itojun u_int mininterval; /* MinRtrAdvInterval */
123 1.1 itojun int managedflg; /* AdvManagedFlag */
124 1.1 itojun int otherflg; /* AdvOtherConfigFlag */
125 1.10 rpaulo
126 1.9 itojun int rtpref; /* router preference */
127 1.1 itojun u_int32_t linkmtu; /* AdvLinkMTU */
128 1.1 itojun u_int32_t reachabletime; /* AdvReachableTime */
129 1.1 itojun u_int32_t retranstimer; /* AdvRetransTimer */
130 1.1 itojun u_int hoplimit; /* AdvCurHopLimit */
131 1.1 itojun struct prefix prefix; /* AdvPrefixList(link head) */
132 1.1 itojun int pfxs; /* number of prefixes */
133 1.6 itojun long clockskew; /* used for consisitency check of lifetimes */
134 1.1 itojun
135 1.10 rpaulo #ifdef ROUTEINFO
136 1.10 rpaulo struct rtinfo route; /* route information option (link head) */
137 1.10 rpaulo int routes; /* number of route information options */
138 1.10 rpaulo #endif
139 1.3 itojun
140 1.1 itojun /* actual RA packet data and its length */
141 1.1 itojun size_t ra_datalen;
142 1.1 itojun u_char *ra_data;
143 1.4 itojun
144 1.4 itojun /* statistics */
145 1.4 itojun u_quad_t raoutput; /* number of RAs sent */
146 1.4 itojun u_quad_t rainput; /* number of RAs received */
147 1.4 itojun u_quad_t rainconsistent; /* number of RAs inconsistent with ours */
148 1.4 itojun u_quad_t rsinput; /* number of RSs received */
149 1.5 itojun
150 1.5 itojun /* info about soliciter */
151 1.5 itojun struct soliciter *soliciter; /* recent solication source */
152 1.1 itojun };
153 1.1 itojun
154 1.10 rpaulo struct rtadvd_timer *ra_timeout __P((void *));
155 1.1 itojun void ra_timer_update __P((void *, struct timeval *));
156 1.3 itojun
157 1.6 itojun int prefix_match __P((struct in6_addr *, int, struct in6_addr *, int));
158 1.6 itojun struct rainfo *if_indextorainfo __P((int));
159 1.8 itojun struct prefix *find_prefix __P((struct rainfo *, struct in6_addr *, int));
160 1.6 itojun
161 1.6 itojun extern struct in6_addr in6a_site_allrouters;
162