Mercurial > ecos-v2_0-branch
comparison packages/net/tcpip/current/include/netinet6/nd6.h @ 97:ced4577552cd ecos-sw-2000-06-06
Merge from eCos master repository on 2000-06-06-08:44:00-BST
| author | jlarmour |
|---|---|
| date | Tue, 06 Jun 2000 08:39:36 +0000 |
| parents | |
| children | e0c0827131d1 |
comparison
equal
deleted
inserted
replaced
| 96:b15c60e34c84 | 97:ced4577552cd |
|---|---|
| 1 //========================================================================== | |
| 2 // | |
| 3 // include/netinet6.nd6.h | |
| 4 // | |
| 5 // | |
| 6 // | |
| 7 //========================================================================== | |
| 8 //####COPYRIGHTBEGIN#### | |
| 9 // | |
| 10 // ------------------------------------------- | |
| 11 // The contents of this file are subject to the Red Hat eCos Public License | |
| 12 // Version 1.1 (the "License"); you may not use this file except in | |
| 13 // compliance with the License. You may obtain a copy of the License at | |
| 14 // http://www.redhat.com/ | |
| 15 // | |
| 16 // Software distributed under the License is distributed on an "AS IS" | |
| 17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | |
| 18 // License for the specific language governing rights and limitations under | |
| 19 // the License. | |
| 20 // | |
| 21 // The Original Code is eCos - Embedded Configurable Operating System, | |
| 22 // released September 30, 1998. | |
| 23 // | |
| 24 // The Initial Developer of the Original Code is Red Hat. | |
| 25 // Portions created by Red Hat are | |
| 26 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. | |
| 27 // All Rights Reserved. | |
| 28 // ------------------------------------------- | |
| 29 // | |
| 30 //####COPYRIGHTEND#### | |
| 31 //####BSDCOPYRIGHTBEGIN#### | |
| 32 // | |
| 33 // ------------------------------------------- | |
| 34 // | |
| 35 // Portions of this software may have been derived from OpenBSD or other sources, | |
| 36 // and are covered by the appropriate copyright disclaimers included herein. | |
| 37 // | |
| 38 // ------------------------------------------- | |
| 39 // | |
| 40 //####BSDCOPYRIGHTEND#### | |
| 41 //========================================================================== | |
| 42 //#####DESCRIPTIONBEGIN#### | |
| 43 // | |
| 44 // Author(s): gthomas | |
| 45 // Contributors: gthomas | |
| 46 // Date: 2000-01-10 | |
| 47 // Purpose: | |
| 48 // Description: | |
| 49 // | |
| 50 // | |
| 51 //####DESCRIPTIONEND#### | |
| 52 // | |
| 53 //========================================================================== | |
| 54 | |
| 55 /* $OpenBSD: nd6.h,v 1.1 1999/12/08 06:50:23 itojun Exp $ */ | |
| 56 | |
| 57 /* | |
| 58 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | |
| 59 * All rights reserved. | |
| 60 * | |
| 61 * Redistribution and use in source and binary forms, with or without | |
| 62 * modification, are permitted provided that the following conditions | |
| 63 * are met: | |
| 64 * 1. Redistributions of source code must retain the above copyright | |
| 65 * notice, this list of conditions and the following disclaimer. | |
| 66 * 2. Redistributions in binary form must reproduce the above copyright | |
| 67 * notice, this list of conditions and the following disclaimer in the | |
| 68 * documentation and/or other materials provided with the distribution. | |
| 69 * 3. Neither the name of the project nor the names of its contributors | |
| 70 * may be used to endorse or promote products derived from this software | |
| 71 * without specific prior written permission. | |
| 72 * | |
| 73 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND | |
| 74 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 75 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
| 76 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE | |
| 77 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
| 78 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
| 79 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
| 80 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
| 81 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
| 82 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
| 83 * SUCH DAMAGE. | |
| 84 */ | |
| 85 | |
| 86 #ifndef _NETINET6_ND6_H_ | |
| 87 #define _NETINET6_ND6_H_ | |
| 88 | |
| 89 #include <sys/queue.h> | |
| 90 | |
| 91 struct llinfo_nd6 { | |
| 92 struct llinfo_nd6 *ln_next; | |
| 93 struct llinfo_nd6 *ln_prev; | |
| 94 struct rtentry *ln_rt; | |
| 95 struct mbuf *ln_hold; /* last packet until resolved/timeout */ | |
| 96 long ln_asked; /* number of queries already sent for this addr */ | |
| 97 u_long ln_expire; /* lifetime for NDP state transition */ | |
| 98 short ln_state; /* reachability state */ | |
| 99 short ln_router; /* 2^0: ND6 router bit */ | |
| 100 }; | |
| 101 | |
| 102 #define ND6_LLINFO_NOSTATE -2 | |
| 103 #define ND6_LLINFO_WAITDELETE -1 | |
| 104 #define ND6_LLINFO_INCOMPLETE 0 | |
| 105 #define ND6_LLINFO_REACHABLE 1 | |
| 106 #define ND6_LLINFO_STALE 2 | |
| 107 #define ND6_LLINFO_DELAY 3 | |
| 108 #define ND6_LLINFO_PROBE 4 | |
| 109 | |
| 110 struct nd_ifinfo { | |
| 111 u_int32_t linkmtu; /* LinkMTU */ | |
| 112 u_int32_t maxmtu; /* Upper bound of LinkMTU */ | |
| 113 u_int32_t basereachable; /* BaseReachableTime */ | |
| 114 u_int32_t reachable; /* Reachable Time */ | |
| 115 u_int32_t retrans; /* Retrans Timer */ | |
| 116 int recalctm; /* BaseReacable re-calculation timer */ | |
| 117 u_int8_t chlim; /* CurHopLimit */ | |
| 118 u_int8_t receivedra; | |
| 119 }; | |
| 120 | |
| 121 struct in6_nbrinfo { | |
| 122 char ifname[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
| 123 struct in6_addr addr; /* IPv6 address of the neighbor */ | |
| 124 long asked; /* number of queries already sent for this addr */ | |
| 125 int isrouter; /* if it acts as a router */ | |
| 126 int state; /* reachability state */ | |
| 127 int expire; /* lifetime for NDP state transition */ | |
| 128 }; | |
| 129 | |
| 130 #define DRLSTSIZ 10 | |
| 131 #define PRLSTSIZ 10 | |
| 132 struct in6_drlist { | |
| 133 char ifname[IFNAMSIZ]; | |
| 134 struct { | |
| 135 struct in6_addr rtaddr; | |
| 136 u_char flags; | |
| 137 u_short rtlifetime; | |
| 138 u_long expire; | |
| 139 u_short if_index; | |
| 140 } defrouter[DRLSTSIZ]; | |
| 141 }; | |
| 142 | |
| 143 struct in6_prlist { | |
| 144 char ifname[IFNAMSIZ]; | |
| 145 struct { | |
| 146 struct in6_addr prefix; | |
| 147 struct prf_ra raflags; | |
| 148 u_char prefixlen; | |
| 149 u_long vltime; | |
| 150 u_long pltime; | |
| 151 u_long expire; | |
| 152 u_short if_index; | |
| 153 u_short advrtrs; /* number of advertisement routers */ | |
| 154 struct in6_addr advrtr[DRLSTSIZ]; /* XXX: explicit limit */ | |
| 155 } prefix[PRLSTSIZ]; | |
| 156 }; | |
| 157 | |
| 158 struct in6_ndireq { | |
| 159 char ifname[IFNAMSIZ]; | |
| 160 struct nd_ifinfo ndi; | |
| 161 }; | |
| 162 | |
| 163 /* protocol constants */ | |
| 164 #define MAX_RTR_SOLICITATION_DELAY 1 /*1sec*/ | |
| 165 #define RTR_SOLICITATION_INTERVAL 4 /*4sec*/ | |
| 166 #define MAX_RTR_SOLICITATIONS 3 | |
| 167 | |
| 168 #define ND6_INFINITE_LIFETIME 0xffffffff | |
| 169 | |
| 170 #ifdef _KERNEL | |
| 171 /* node constants */ | |
| 172 #define MAX_REACHABLE_TIME 3600000 /* msec */ | |
| 173 #define REACHABLE_TIME 30000 /* msec */ | |
| 174 #define RETRANS_TIMER 1000 /* msec */ | |
| 175 #define MIN_RANDOM_FACTOR 512 /* 1024 * 0.5 */ | |
| 176 #define MAX_RANDOM_FACTOR 1536 /* 1024 * 1.5 */ | |
| 177 #define ND_COMPUTE_RTIME(x) \ | |
| 178 (((MIN_RANDOM_FACTOR * (x >> 10)) + (random() & \ | |
| 179 ((MAX_RANDOM_FACTOR - MIN_RANDOM_FACTOR) * (x >> 10)))) /1000) | |
| 180 | |
| 181 struct nd_defrouter { | |
| 182 LIST_ENTRY(nd_defrouter) dr_entry; | |
| 183 #define dr_next dr_entry.le_next | |
| 184 struct in6_addr rtaddr; | |
| 185 u_char flags; | |
| 186 u_short rtlifetime; | |
| 187 u_long expire; | |
| 188 struct ifnet *ifp; | |
| 189 }; | |
| 190 | |
| 191 struct nd_prefix { | |
| 192 struct ifnet *ndpr_ifp; | |
| 193 LIST_ENTRY(nd_prefix) ndpr_entry; | |
| 194 struct sockaddr_in6 ndpr_prefix; /* prefix */ | |
| 195 struct in6_addr ndpr_mask; /* netmask derived from the prefix */ | |
| 196 struct in6_addr ndpr_addr; /* address that is derived from the prefix */ | |
| 197 u_int32_t ndpr_vltime; /* advertised valid lifetime */ | |
| 198 u_int32_t ndpr_pltime; /* advertised preferred lifetime */ | |
| 199 time_t ndpr_expire; /* expiration time of the prefix */ | |
| 200 time_t ndpr_preferred; /* preferred time of the prefix */ | |
| 201 struct prf_ra ndpr_flags; | |
| 202 /* list of routers that advertise the prefix: */ | |
| 203 LIST_HEAD(pr_rtrhead, nd_pfxrouter) ndpr_advrtrs; | |
| 204 u_char ndpr_plen; | |
| 205 struct ndpr_stateflags { | |
| 206 /* if this prefix can be regarded as on-link */ | |
| 207 u_char onlink : 1; | |
| 208 } ndpr_stateflags; | |
| 209 }; | |
| 210 | |
| 211 #define ndpr_next ndpr_entry.le_next | |
| 212 | |
| 213 #define ndpr_raf ndpr_flags | |
| 214 #define ndpr_raf_onlink ndpr_flags.onlink | |
| 215 #define ndpr_raf_auto ndpr_flags.autonomous | |
| 216 | |
| 217 #define ndpr_statef_onlink ndpr_stateflags.onlink | |
| 218 #define ndpr_statef_addmark ndpr_stateflags.addmark | |
| 219 | |
| 220 /* | |
| 221 * We keep expired prefix for certain amount of time, for validation purposes. | |
| 222 * 1800s = MaxRtrAdvInterval | |
| 223 */ | |
| 224 #define NDPR_KEEP_EXPIRED (1800 * 2) | |
| 225 | |
| 226 /* | |
| 227 * Message format for use in obtaining information about prefixes | |
| 228 * from inet6 sysctl function | |
| 229 */ | |
| 230 struct inet6_ndpr_msghdr { | |
| 231 u_short inpm_msglen; /* to skip over non-understood messages */ | |
| 232 u_char inpm_version; /* future binary compatability */ | |
| 233 u_char inpm_type; /* message type */ | |
| 234 struct in6_addr inpm_prefix; | |
| 235 u_long prm_vltim; | |
| 236 u_long prm_pltime; | |
| 237 u_long prm_expire; | |
| 238 u_long prm_preferred; | |
| 239 struct in6_prflags prm_flags; | |
| 240 u_short prm_index; /* index for associated ifp */ | |
| 241 u_char prm_plen; /* length of prefix in bits */ | |
| 242 }; | |
| 243 | |
| 244 #define prm_raf_onlink prm_flags.prf_ra.onlink | |
| 245 #define prm_raf_auto prm_flags.prf_ra.autonomous | |
| 246 | |
| 247 #define prm_statef_onlink prm_flags.prf_state.onlink | |
| 248 | |
| 249 #define prm_rrf_decrvalid prm_flags.prf_rr.decrvalid | |
| 250 #define prm_rrf_decrprefd prm_flags.prf_rr.decrprefd | |
| 251 | |
| 252 #define ifpr2ndpr(ifpr) ((struct nd_prefix *)(ifpr)) | |
| 253 #define ndpr2ifpr(ndpr) ((struct ifprefix *)(ndpr)) | |
| 254 | |
| 255 struct nd_pfxrouter { | |
| 256 LIST_ENTRY(nd_pfxrouter) pfr_entry; | |
| 257 #define pfr_next pfr_entry.le_next | |
| 258 struct nd_defrouter *router; | |
| 259 }; | |
| 260 | |
| 261 LIST_HEAD(nd_drhead, nd_defrouter); | |
| 262 LIST_HEAD(nd_prhead, nd_prefix); | |
| 263 | |
| 264 /* nd6.c */ | |
| 265 extern int nd6_prune; | |
| 266 extern int nd6_delay; | |
| 267 extern int nd6_umaxtries; | |
| 268 extern int nd6_mmaxtries; | |
| 269 extern int nd6_useloopback; | |
| 270 extern int nd6_proxyall; | |
| 271 extern struct llinfo_nd6 llinfo_nd6; | |
| 272 extern struct nd_ifinfo *nd_ifinfo; | |
| 273 extern struct nd_drhead nd_defrouter; | |
| 274 extern struct nd_prhead nd_prefix; | |
| 275 | |
| 276 union nd_opts { | |
| 277 struct nd_opt_hdr *nd_opt_array[9]; | |
| 278 struct { | |
| 279 struct nd_opt_hdr *zero; | |
| 280 struct nd_opt_hdr *src_lladdr; | |
| 281 struct nd_opt_hdr *tgt_lladdr; | |
| 282 struct nd_opt_prefix_info *pi_beg;/* multiple opts, start */ | |
| 283 struct nd_opt_rd_hdr *rh; | |
| 284 struct nd_opt_mtu *mtu; | |
| 285 struct nd_opt_hdr *search; /* multiple opts */ | |
| 286 struct nd_opt_hdr *last; /* multiple opts */ | |
| 287 int done; | |
| 288 struct nd_opt_prefix_info *pi_end;/* multiple opts, end */ | |
| 289 } nd_opt_each; | |
| 290 }; | |
| 291 #define nd_opts_src_lladdr nd_opt_each.src_lladdr | |
| 292 #define nd_opts_tgt_lladdr nd_opt_each.tgt_lladdr | |
| 293 #define nd_opts_pi nd_opt_each.pi_beg | |
| 294 #define nd_opts_pi_end nd_opt_each.pi_end | |
| 295 #define nd_opts_rh nd_opt_each.rh | |
| 296 #define nd_opts_mtu nd_opt_each.mtu | |
| 297 #define nd_opts_search nd_opt_each.search | |
| 298 #define nd_opts_last nd_opt_each.last | |
| 299 #define nd_opts_done nd_opt_each.done | |
| 300 | |
| 301 /* XXX: need nd6_var.h?? */ | |
| 302 /* nd6.c */ | |
| 303 void nd6_init __P((void)); | |
| 304 void nd6_ifattach __P((struct ifnet *)); | |
| 305 int nd6_is_addr_neighbor __P((struct in6_addr *, struct ifnet *)); | |
| 306 void nd6_option_init __P((void *, int, union nd_opts *)); | |
| 307 struct nd_opt_hdr *nd6_option __P((union nd_opts *)); | |
| 308 int nd6_options __P((union nd_opts *)); | |
| 309 struct rtentry *nd6_lookup __P((struct in6_addr *, int, struct ifnet *)); | |
| 310 void nd6_setmtu __P((struct ifnet *)); | |
| 311 void nd6_timer __P((void *)); | |
| 312 void nd6_free __P((struct rtentry *)); | |
| 313 void nd6_nud_hint __P((struct rtentry *, struct in6_addr *)); | |
| 314 int nd6_resolve __P((struct ifnet *, struct rtentry *, | |
| 315 struct mbuf *, struct sockaddr *, u_char *)); | |
| 316 #if defined(__bsdi__) && _BSDI_VERSION >= 199802 | |
| 317 void nd6_rtrequest __P((int, struct rtentry *, struct rt_addrinfo *)); | |
| 318 void nd6_p2p_rtrequest __P((int, struct rtentry *, struct rt_addrinfo *)); | |
| 319 #else | |
| 320 void nd6_rtrequest __P((int, struct rtentry *, struct sockaddr *)); | |
| 321 void nd6_p2p_rtrequest __P((int, struct rtentry *, struct sockaddr *)); | |
| 322 #endif | |
| 323 int nd6_ioctl __P((u_long, caddr_t, struct ifnet *)); | |
| 324 struct rtentry *nd6_cache_lladdr __P((struct ifnet *, struct in6_addr *, | |
| 325 char *, int, int, int)); | |
| 326 /* for test */ | |
| 327 int nd6_output __P((struct ifnet *, struct mbuf *, struct sockaddr_in6 *, | |
| 328 struct rtentry *)); | |
| 329 int nd6_storelladdr __P((struct ifnet *, struct rtentry *, struct mbuf *, | |
| 330 struct sockaddr *, u_char *)); | |
| 331 | |
| 332 /* nd6_nbr.c */ | |
| 333 void nd6_na_input __P((struct mbuf *, int, int)); | |
| 334 void nd6_na_output __P((struct ifnet *, struct in6_addr *, | |
| 335 struct in6_addr *, u_long, int)); | |
| 336 void nd6_ns_input __P((struct mbuf *, int, int)); | |
| 337 void nd6_ns_output __P((struct ifnet *, struct in6_addr *, | |
| 338 struct in6_addr *, struct llinfo_nd6 *, int)); | |
| 339 caddr_t nd6_ifptomac __P((struct ifnet *)); | |
| 340 void nd6_dad_start __P((struct ifaddr *, int *)); | |
| 341 void nd6_dad_duplicated __P((struct ifaddr *)); | |
| 342 | |
| 343 /* nd6_rtr.c */ | |
| 344 void nd6_rs_input __P((struct mbuf *, int, int)); | |
| 345 void nd6_ra_input __P((struct mbuf *, int, int)); | |
| 346 void prelist_del __P((struct nd_prefix *)); | |
| 347 void defrouter_addreq __P((struct nd_defrouter *)); | |
| 348 void defrouter_delreq __P((struct nd_defrouter *, int)); | |
| 349 void defrtrlist_del __P((struct nd_defrouter *)); | |
| 350 void prelist_remove __P((struct nd_prefix *)); | |
| 351 int prelist_update __P((struct nd_prefix *, struct nd_defrouter *, | |
| 352 struct mbuf *)); | |
| 353 struct nd_defrouter *defrouter_lookup __P((struct in6_addr *, | |
| 354 struct ifnet *)); | |
| 355 int in6_ifdel __P((struct ifnet *, struct in6_addr *)); | |
| 356 int in6_init_prefix_ltimes __P((struct nd_prefix *ndpr)); | |
| 357 void rt6_flush __P((struct in6_addr *, struct ifnet *)); | |
| 358 | |
| 359 #endif /* _KERNEL */ | |
| 360 | |
| 361 #endif /* _NETINET6_ND6_H_ */ |
