kernel - Bring in dff23c692 from FreeBSD
[dragonfly.git] / usr.sbin / rtadvd / rtadvd.h
blob64c56b6a1e8d08a9f6d2d587cd4e31f6befc5f48
1 /* $KAME: rtadvd.h,v 1.16 2001/04/10 15:08:31 suz Exp $ */
3 /*
4 * Copyright (C) 1998 WIDE Project.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the project nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
31 * $FreeBSD: src/usr.sbin/rtadvd/rtadvd.h,v 1.1.2.3 2002/06/29 18:59:53 ume Exp $
32 * $DragonFly: src/usr.sbin/rtadvd/rtadvd.h,v 1.3 2003/11/03 19:31:42 eirikn Exp $
35 #define ALLNODES "ff02::1"
36 #define ALLROUTERS_LINK "ff02::2"
37 #define ALLROUTERS_SITE "ff05::2"
38 #define ANY "::"
39 #define RTSOLLEN 8
41 /* protocol constants and default values */
42 #define DEF_MAXRTRADVINTERVAL 600
43 #define DEF_ADVLINKMTU 0
44 #define DEF_ADVREACHABLETIME 0
45 #define DEF_ADVRETRANSTIMER 0
46 #define DEF_ADVCURHOPLIMIT 64
47 #define DEF_ADVVALIDLIFETIME 2592000
48 #define DEF_ADVPREFERREDLIFETIME 604800
50 /*XXX int-to-double comparison for INTERVAL items */
51 #ifndef MIP6
52 #define mobileip6 0
53 #endif
55 #define MAXROUTERLIFETIME 9000
56 #define MIN_MAXINTERVAL (mobileip6 ? 1.5 : 4.0)
57 #define MAX_MAXINTERVAL 1800
58 #define MIN_MININTERVAL (mobileip6 ? 0.5 : 3)
59 #define MAXREACHABLETIME 3600000
61 #ifndef MIP6
62 #undef miobileip6
63 #endif
65 #define MAX_INITIAL_RTR_ADVERT_INTERVAL 16
66 #define MAX_INITIAL_RTR_ADVERTISEMENTS 3
67 #define MAX_FINAL_RTR_ADVERTISEMENTS 3
68 #define MIN_DELAY_BETWEEN_RAS 3
69 #define MAX_RA_DELAY_TIME 500000 /* usec */
71 #define PREFIX_FROM_KERNEL 1
72 #define PREFIX_FROM_CONFIG 2
73 #define PREFIX_FROM_DYNAMIC 3
75 struct prefix {
76 struct prefix *next; /* forward link */
77 struct prefix *prev; /* previous link */
79 struct rainfo *rainfo; /* back pointer to the interface */
81 struct rtadvd_timer *timer; /* expiration timer. used when a prefix
82 * derived from the kernel is deleted.
85 u_int32_t validlifetime; /* AdvValidLifetime */
86 long vltimeexpire; /* expiration of vltime; decrement case only */
87 u_int32_t preflifetime; /* AdvPreferredLifetime */
88 long pltimeexpire; /* expiration of pltime; decrement case only */
89 u_int onlinkflg; /* bool: AdvOnLinkFlag */
90 u_int autoconfflg; /* bool: AdvAutonomousFlag */
91 #ifdef MIP6
92 u_int routeraddr; /* bool: RouterAddress */
93 #endif
94 int prefixlen;
95 int origin; /* from kernel or cofig */
96 struct in6_addr prefix;
99 struct rtinfo {
100 struct rtinfo *prev; /* previous link */
101 struct rtinfo *next; /* forward link */
103 u_int32_t ltime; /* route lifetime */
104 u_int rtpref; /* router preference */
105 int prefixlen;
106 struct in6_addr prefix;
109 struct soliciter {
110 struct soliciter *next;
111 struct sockaddr_in6 addr;
114 struct rainfo {
115 /* pointer for list */
116 struct rainfo *next;
118 /* timer related parameters */
119 struct rtadvd_timer *timer;
120 int initcounter; /* counter for the first few advertisements */
121 struct timeval lastsent; /* timestamp when the latest RA was sent */
122 int waiting; /* number of RS waiting for RA */
124 /* interface information */
125 int ifindex;
126 int advlinkopt; /* bool: whether include link-layer addr opt */
127 struct sockaddr_dl *sdl;
128 char ifname[16];
129 int phymtu; /* mtu of the physical interface */
131 /* Router configuration variables */
132 u_short lifetime; /* AdvDefaultLifetime */
133 u_int maxinterval; /* MaxRtrAdvInterval */
134 u_int mininterval; /* MinRtrAdvInterval */
135 int managedflg; /* AdvManagedFlag */
136 int otherflg; /* AdvOtherConfigFlag */
137 #ifdef MIP6
138 int haflg; /* HAFlag */
139 #endif
140 int rtpref; /* router preference */
141 u_int32_t linkmtu; /* AdvLinkMTU */
142 u_int32_t reachabletime; /* AdvReachableTime */
143 u_int32_t retranstimer; /* AdvRetransTimer */
144 u_int hoplimit; /* AdvCurHopLimit */
145 struct prefix prefix; /* AdvPrefixList(link head) */
146 int pfxs; /* number of prefixes */
147 long clockskew; /* used for consisitency check of lifetimes */
149 #ifdef MIP6
150 u_short hapref; /* Home Agent Preference */
151 u_short hatime; /* Home Agent Lifetime */
152 #endif
153 struct rtinfo route; /* route information option (link head) */
154 int routes; /* number of route information options */
156 /* actual RA packet data and its length */
157 size_t ra_datalen;
158 u_char *ra_data;
160 /* statistics */
161 u_quad_t raoutput; /* number of RAs sent */
162 u_quad_t rainput; /* number of RAs received */
163 u_quad_t rainconsistent; /* number of RAs inconsistent with ours */
164 u_quad_t rsinput; /* number of RSs received */
166 /* info about soliciter */
167 struct soliciter *soliciter; /* recent solication source */
170 struct rtadvd_timer *ra_timeout(void *);
171 void ra_timer_update(void *, struct timeval *);
173 int prefix_match(struct in6_addr *, int, struct in6_addr *, int);
174 struct rainfo *if_indextorainfo(int);
175 struct prefix *find_prefix(struct rainfo *, struct in6_addr *, int);
177 extern struct in6_addr in6a_site_allrouters;
178 #ifdef MIP6
179 extern int mobileip6;
180 #endif