]> git.saurik.com Git - apple/network_cmds.git/blob - rtadvd.tproj/rtadvd.h
network_cmds-396.6.tar.gz
[apple/network_cmds.git] / rtadvd.tproj / rtadvd.h
1 /* $KAME: rtadvd.h,v 1.26 2003/08/05 12:34:23 itojun 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
32 #define ROUTEINFO 1
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 #define MAXROUTERLIFETIME 9000
50 #define MIN_MAXINTERVAL 4
51 #define MAX_MAXINTERVAL 1800
52 #define MIN_MININTERVAL 3
53 #define MAXREACHABLETIME 3600000
54
55 #define MAX_INITIAL_RTR_ADVERT_INTERVAL 16
56 #define MAX_INITIAL_RTR_ADVERTISEMENTS 3
57 #define MAX_FINAL_RTR_ADVERTISEMENTS 3
58 #define MIN_DELAY_BETWEEN_RAS 3
59 #define MAX_RA_DELAY_TIME 500000 /* usec */
60
61 #define PREFIX_FROM_KERNEL 1
62 #define PREFIX_FROM_CONFIG 2
63 #define PREFIX_FROM_DYNAMIC 3
64
65 struct prefix {
66 struct prefix *next; /* forward link */
67 struct prefix *prev; /* previous link */
68
69 struct rainfo *rainfo; /* back pointer to the interface */
70
71 struct rtadvd_timer *timer; /* expiration timer. used when a prefix
72 * derived from the kernel is deleted.
73 */
74
75 u_int32_t validlifetime; /* AdvValidLifetime */
76 long vltimeexpire; /* expiration of vltime; decrement case only */
77 u_int32_t preflifetime; /* AdvPreferredLifetime */
78 long pltimeexpire; /* expiration of pltime; decrement case only */
79 u_int onlinkflg; /* bool: AdvOnLinkFlag */
80 u_int autoconfflg; /* bool: AdvAutonomousFlag */
81 int prefixlen;
82 int origin; /* from kernel or config */
83 struct in6_addr prefix;
84 };
85
86 #ifdef ROUTEINFO
87 struct rtinfo {
88 struct rtinfo *prev; /* previous link */
89 struct rtinfo *next; /* forward link */
90
91 u_int32_t ltime; /* route lifetime */
92 u_int rtpref; /* route preference */
93 int prefixlen;
94 struct in6_addr prefix;
95 };
96 #endif
97
98 struct soliciter {
99 struct soliciter *next;
100 struct sockaddr_in6 addr;
101 };
102
103 struct rdnss {
104 struct rdnss *next; /* forward link */
105 struct rdnss *prev; /* previous link */
106
107 struct in6_addr addr;
108 };
109
110 struct dnssl {
111 struct dnssl *next;
112 struct dnssl *prev;
113
114 char domain[1];
115 };
116
117 struct rainfo {
118 /* pointer for list */
119 struct rainfo *next;
120
121 /* timer related parameters */
122 struct rtadvd_timer *timer;
123 int initcounter; /* counter for the first few advertisements */
124 struct timeval lastsent; /* timestamp when the latest RA was sent */
125 int waiting; /* number of RS waiting for RA */
126
127 /* interface information */
128 int ifindex;
129 int advlinkopt; /* bool: whether include link-layer addr opt */
130 struct sockaddr_dl *sdl;
131 char ifname[16];
132 int phymtu; /* mtu of the physical interface */
133
134 /* Router configuration variables */
135 u_short lifetime; /* AdvDefaultLifetime */
136 u_int maxinterval; /* MaxRtrAdvInterval */
137 u_int mininterval; /* MinRtrAdvInterval */
138 int managedflg; /* AdvManagedFlag */
139 int otherflg; /* AdvOtherConfigFlag */
140
141 int rtpref; /* router preference */
142 u_int32_t linkmtu; /* AdvLinkMTU */
143 u_int32_t reachabletime; /* AdvReachableTime */
144 u_int32_t retranstimer; /* AdvRetransTimer */
145 u_int hoplimit; /* AdvCurHopLimit */
146 struct prefix prefix; /* AdvPrefixList(link head) */
147 int pfxs; /* number of prefixes */
148 long clockskew; /* used for consisitency check of lifetimes */
149
150 #ifdef ROUTEINFO
151 struct rtinfo route; /* route information option (link head) */
152 int routes; /* number of route information options */
153 #endif
154
155 /* Recursive DNS Servers RFC5006 */
156 struct rdnss rdnss_list;
157 int rdnss_length;
158 u_int32_t rdnss_lifetime;
159
160 /* DNS Search List RFC6106 */
161 struct dnssl dnssl_list;
162 int dnssl_length;
163 u_int32_t dnssl_lifetime;
164 u_int32_t dnssl_option_length;
165
166 /* actual RA packet data and its length */
167 size_t ra_datalen;
168 u_char *ra_data;
169
170 /* statistics */
171 u_quad_t raoutput; /* number of RAs sent */
172 u_quad_t rainput; /* number of RAs received */
173 u_quad_t rainconsistent; /* number of RAs inconsistent with ours */
174 u_quad_t rsinput; /* number of RSs received */
175
176 /* info about soliciter */
177 struct soliciter *soliciter; /* recent solication source */
178 };
179
180 struct rtadvd_timer *ra_timeout(void *);
181 void ra_timer_update(void *, struct timeval *);
182
183 int prefix_match(struct in6_addr *, int, struct in6_addr *, int);
184 struct rainfo *if_indextorainfo(int);
185 struct prefix *find_prefix(struct rainfo *, struct in6_addr *, int);
186
187 extern struct in6_addr in6a_site_allrouters;