]> git.saurik.com Git - apple/network_cmds.git/blob - rtadvd.tproj/rtadvd.h
network_cmds-176.3.1.tar.gz
[apple/network_cmds.git] / rtadvd.tproj / rtadvd.h
1 /* $KAME: rtadvd.h,v 1.16 2001/04/10 15:08:31 suz Exp $ */
2
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.
18 *
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.
30 *
31 * $FreeBSD: src/usr.sbin/rtadvd/rtadvd.h,v 1.1.2.2 2001/07/03 11:02:14 ume Exp $
32 */
33
34 #define ALLNODES "ff02::1"
35 #define ALLROUTERS_LINK "ff02::2"
36 #define ALLROUTERS_SITE "ff05::2"
37 #define ANY "::"
38 #define RTSOLLEN 8
39
40 /* protocol constants and default values */
41 #define DEF_MAXRTRADVINTERVAL 600
42 #define DEF_ADVLINKMTU 0
43 #define DEF_ADVREACHABLETIME 0
44 #define DEF_ADVRETRANSTIMER 0
45 #define DEF_ADVCURHOPLIMIT 64
46 #define DEF_ADVVALIDLIFETIME 2592000
47 #define DEF_ADVPREFERREDLIFETIME 604800
48
49 /*XXX int-to-double comparison for INTERVAL items */
50 #ifndef MIP6
51 #define mobileip6 0
52 #endif
53
54 #define MAXROUTERLIFETIME 9000
55 #define MIN_MAXINTERVAL (mobileip6 ? 1.5 : 4.0)
56 #define MAX_MAXINTERVAL 1800
57 #define MIN_MININTERVAL (mobileip6 ? 0.5 : 3)
58 #define MAXREACHABLETIME 3600000
59
60 #ifndef MIP6
61 #undef miobileip6
62 #endif
63
64 #define MAX_INITIAL_RTR_ADVERT_INTERVAL 16
65 #define MAX_INITIAL_RTR_ADVERTISEMENTS 3
66 #define MAX_FINAL_RTR_ADVERTISEMENTS 3
67 #define MIN_DELAY_BETWEEN_RAS 3
68 #define MAX_RA_DELAY_TIME 500000 /* usec */
69
70 #define PREFIX_FROM_KERNEL 1
71 #define PREFIX_FROM_CONFIG 2
72 #define PREFIX_FROM_DYNAMIC 3
73
74 struct prefix {
75 struct prefix *next; /* forward link */
76 struct prefix *prev; /* previous link */
77
78 u_int32_t validlifetime; /* AdvValidLifetime */
79 long vltimeexpire; /* expiration of vltime; decrement case only */
80 u_int32_t preflifetime; /* AdvPreferredLifetime */
81 long pltimeexpire; /* expiration of pltime; decrement case only */
82 u_int onlinkflg; /* bool: AdvOnLinkFlag */
83 u_int autoconfflg; /* bool: AdvAutonomousFlag */
84 #ifdef MIP6
85 u_int routeraddr; /* bool: RouterAddress */
86 #endif
87 int prefixlen;
88 int origin; /* from kernel or cofig */
89 struct in6_addr prefix;
90 };
91
92 struct rtinfo {
93 struct rtinfo *prev; /* previous link */
94 struct rtinfo *next; /* forward link */
95
96 u_int32_t ltime; /* route lifetime */
97 u_int rtpref; /* router preference */
98 int prefixlen;
99 struct in6_addr prefix;
100 };
101
102 struct soliciter {
103 struct soliciter *next;
104 struct sockaddr_in6 addr;
105 };
106
107 struct rainfo {
108 /* pointer for list */
109 struct rainfo *next;
110
111 /* timer related parameters */
112 struct rtadvd_timer *timer;
113 int initcounter; /* counter for the first few advertisements */
114 struct timeval lastsent; /* timestamp when the latest RA was sent */
115 int waiting; /* number of RS waiting for RA */
116
117 /* interface information */
118 int ifindex;
119 int advlinkopt; /* bool: whether include link-layer addr opt */
120 struct sockaddr_dl *sdl;
121 char ifname[16];
122 int phymtu; /* mtu of the physical interface */
123
124 /* Router configuration variables */
125 u_short lifetime; /* AdvDefaultLifetime */
126 u_int maxinterval; /* MaxRtrAdvInterval */
127 u_int mininterval; /* MinRtrAdvInterval */
128 int managedflg; /* AdvManagedFlag */
129 int otherflg; /* AdvOtherConfigFlag */
130 #ifdef MIP6
131 int haflg; /* HAFlag */
132 #endif
133 int rtpref; /* router preference */
134 u_int32_t linkmtu; /* AdvLinkMTU */
135 u_int32_t reachabletime; /* AdvReachableTime */
136 u_int32_t retranstimer; /* AdvRetransTimer */
137 u_int hoplimit; /* AdvCurHopLimit */
138 struct prefix prefix; /* AdvPrefixList(link head) */
139 int pfxs; /* number of prefixes */
140 long clockskew; /* used for consisitency check of lifetimes */
141
142 #ifdef MIP6
143 u_short hapref; /* Home Agent Preference */
144 u_short hatime; /* Home Agent Lifetime */
145 #endif
146 struct rtinfo route; /* route information option (link head) */
147 int routes; /* number of route information options */
148
149 /* actual RA packet data and its length */
150 size_t ra_datalen;
151 u_char *ra_data;
152
153 /* statistics */
154 u_quad_t raoutput; /* number of RAs sent */
155 u_quad_t rainput; /* number of RAs received */
156 u_quad_t rainconsistent; /* number of RAs inconsistent with ours */
157 u_quad_t rsinput; /* number of RSs received */
158
159 /* info about soliciter */
160 struct soliciter *soliciter; /* recent solication source */
161 };
162
163 void ra_timeout __P((void *));
164 void ra_timer_update __P((void *, struct timeval *));
165
166 int prefix_match __P((struct in6_addr *, int, struct in6_addr *, int));
167 struct rainfo *if_indextorainfo __P((int));
168
169 extern struct in6_addr in6a_site_allrouters;
170 #ifdef MIP6
171 extern int mobileip6;
172 #endif