ip6_var.h revision 166938
16751Swpaul/* $FreeBSD: head/sys/netinet6/ip6_var.h 166938 2007-02-24 11:38:47Z bms $ */ 26751Swpaul/* $KAME: ip6_var.h,v 1.62 2001/05/03 14:51:48 itojun Exp $ */ 38857Srgrimes 46751Swpaul/*- 56751Swpaul * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 66751Swpaul * All rights reserved. 76751Swpaul * 829102Scharnier * Redistribution and use in source and binary forms, with or without 96751Swpaul * modification, are permitted provided that the following conditions 1029102Scharnier * are met: 1129102Scharnier * 1. Redistributions of source code must retain the above copyright 1229102Scharnier * notice, this list of conditions and the following disclaimer. 1329102Scharnier * 2. Redistributions in binary form must reproduce the above copyright 146751Swpaul * notice, this list of conditions and the following disclaimer in the 1529102Scharnier * documentation and/or other materials provided with the distribution. 1629102Scharnier * 3. Neither the name of the project nor the names of its contributors 1729102Scharnier * may be used to endorse or promote products derived from this software 189718Swpaul * without specific prior written permission. 1929102Scharnier * 209718Swpaul * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 216751Swpaul * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2229102Scharnier * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2329102Scharnier * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 2429102Scharnier * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 256751Swpaul * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2629102Scharnier * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2729102Scharnier * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2829102Scharnier * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 296751Swpaul * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 306751Swpaul * SUCH DAMAGE. 316751Swpaul */ 326751Swpaul 336751Swpaul/*- 346751Swpaul * Copyright (c) 1982, 1986, 1993 356751Swpaul * The Regents of the University of California. All rights reserved. 366751Swpaul * 376751Swpaul * Redistribution and use in source and binary forms, with or without 3829102Scharnier * modification, are permitted provided that the following conditions 396751Swpaul * are met: 4029102Scharnier * 1. Redistributions of source code must retain the above copyright 416751Swpaul * notice, this list of conditions and the following disclaimer. 426751Swpaul * 2. Redistributions in binary form must reproduce the above copyright 436751Swpaul * notice, this list of conditions and the following disclaimer in the 446751Swpaul * documentation and/or other materials provided with the distribution. 456751Swpaul * 4. Neither the name of the University nor the names of its contributors 469718Swpaul * may be used to endorse or promote products derived from this software 476751Swpaul * without specific prior written permission. 486751Swpaul * 496751Swpaul * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 506751Swpaul * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 5124428Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 526751Swpaul * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 536751Swpaul * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 546751Swpaul * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 556751Swpaul * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 566751Swpaul * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 576751Swpaul * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 586751Swpaul * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 596751Swpaul * SUCH DAMAGE. 606751Swpaul * 616751Swpaul * @(#)ip_var.h 8.1 (Berkeley) 6/10/93 626751Swpaul */ 636751Swpaul 646751Swpaul#ifndef _NETINET6_IP6_VAR_H_ 6529102Scharnier#define _NETINET6_IP6_VAR_H_ 6629102Scharnier 6729102Scharnier/* 686751Swpaul * IP6 reassembly queue structure. Each fragment 696751Swpaul * being reassembled is attached to one of these structures. 706751Swpaul */ 716751Swpaulstruct ip6q { 726751Swpaul u_int32_t ip6q_head; 736751Swpaul u_int16_t ip6q_len; 748857Srgrimes u_int8_t ip6q_nxt; /* ip6f_nxt in first fragment */ 7529102Scharnier u_int8_t ip6q_hlim; 766751Swpaul struct ip6asfrag *ip6q_down; 7729102Scharnier struct ip6asfrag *ip6q_up; 786751Swpaul u_int32_t ip6q_ident; 796751Swpaul u_int8_t ip6q_arrive; 806751Swpaul u_int8_t ip6q_ttl; 816751Swpaul struct in6_addr ip6q_src, ip6q_dst; 8229102Scharnier struct ip6q *ip6q_next; 836751Swpaul struct ip6q *ip6q_prev; 846751Swpaul int ip6q_unfrglen; /* len of unfragmentable part */ 8529102Scharnier#ifdef notyet 8629102Scharnier u_char *ip6q_nxtp; 876751Swpaul#endif 886751Swpaul int ip6q_nfrag; /* # of fragments */ 896751Swpaul}; 906751Swpaul 916751Swpaulstruct ip6asfrag { 926751Swpaul u_int32_t ip6af_head; 936751Swpaul u_int16_t ip6af_len; 9429102Scharnier u_int8_t ip6af_nxt; 9529102Scharnier u_int8_t ip6af_hlim; 966751Swpaul /* must not override the above members during reassembling */ 976751Swpaul struct ip6asfrag *ip6af_down; 988857Srgrimes struct ip6asfrag *ip6af_up; 996751Swpaul struct mbuf *ip6af_m; 1006751Swpaul int ip6af_offset; /* offset in ip6af_m to next header */ 1016751Swpaul int ip6af_frglen; /* fragmentable part length */ 10229102Scharnier int ip6af_off; /* fragment offset */ 10329102Scharnier u_int16_t ip6af_mff; /* more fragment bit in frag off */ 10429102Scharnier}; 10529102Scharnier 1066751Swpaul#define IP6_REASS_MBUF(ip6af) (*(struct mbuf **)&((ip6af)->ip6af_m)) 1076751Swpaul 10829102Scharnierstruct ip6_moptions { 10929102Scharnier struct ifnet *im6o_multicast_ifp; /* ifp for outgoing multicasts */ 11029102Scharnier u_char im6o_multicast_hlim; /* hoplimit for outgoing multicasts */ 11129102Scharnier u_char im6o_multicast_loop; /* 1 >= hear sends if a member */ 11229102Scharnier LIST_HEAD(, in6_multi_mship) im6o_memberships; 11329102Scharnier}; 11429102Scharnier 11529102Scharnier/* 1166751Swpaul * Control options for outgoing packets 1176751Swpaul */ 118 119/* Routing header related info */ 120struct ip6po_rhinfo { 121 struct ip6_rthdr *ip6po_rhi_rthdr; /* Routing header */ 122 struct route_in6 ip6po_rhi_route; /* Route to the 1st hop */ 123}; 124#define ip6po_rthdr ip6po_rhinfo.ip6po_rhi_rthdr 125#define ip6po_route ip6po_rhinfo.ip6po_rhi_route 126 127/* Nexthop related info */ 128struct ip6po_nhinfo { 129 struct sockaddr *ip6po_nhi_nexthop; 130 struct route_in6 ip6po_nhi_route; /* Route to the nexthop */ 131}; 132#define ip6po_nexthop ip6po_nhinfo.ip6po_nhi_nexthop 133#define ip6po_nextroute ip6po_nhinfo.ip6po_nhi_route 134 135struct ip6_pktopts { 136 struct mbuf *ip6po_m; /* Pointer to mbuf storing the data */ 137 int ip6po_hlim; /* Hoplimit for outgoing packets */ 138 139 /* Outgoing IF/address information */ 140 struct in6_pktinfo *ip6po_pktinfo; 141 142 /* Next-hop address information */ 143 struct ip6po_nhinfo ip6po_nhinfo; 144 145 struct ip6_hbh *ip6po_hbh; /* Hop-by-Hop options header */ 146 147 /* Destination options header (before a routing header) */ 148 struct ip6_dest *ip6po_dest1; 149 150 /* Routing header related info. */ 151 struct ip6po_rhinfo ip6po_rhinfo; 152 153 /* Destination options header (after a routing header) */ 154 struct ip6_dest *ip6po_dest2; 155 156 int ip6po_tclass; /* traffic class */ 157 158 int ip6po_minmtu; /* fragment vs PMTU discovery policy */ 159#define IP6PO_MINMTU_MCASTONLY -1 /* default; send at min MTU for multicast*/ 160#define IP6PO_MINMTU_DISABLE 0 /* always perform pmtu disc */ 161#define IP6PO_MINMTU_ALL 1 /* always send at min MTU */ 162 163 int ip6po_prefer_tempaddr; /* whether temporary addresses are 164 preferred as source address */ 165#define IP6PO_TEMPADDR_SYSTEM -1 /* follow the system default */ 166#define IP6PO_TEMPADDR_NOTPREFER 0 /* not prefer temporary address */ 167#define IP6PO_TEMPADDR_PREFER 1 /* prefer temporary address */ 168 169 int ip6po_flags; 170#if 0 /* parameters in this block is obsolete. do not reuse the values. */ 171#define IP6PO_REACHCONF 0x01 /* upper-layer reachability confirmation. */ 172#define IP6PO_MINMTU 0x02 /* use minimum MTU (IPV6_USE_MIN_MTU) */ 173#endif 174#define IP6PO_DONTFRAG 0x04 /* disable fragmentation (IPV6_DONTFRAG) */ 175#define IP6PO_USECOA 0x08 /* use care of address */ 176}; 177 178/* 179 * Control options for incoming packets 180 */ 181 182struct ip6stat { 183 u_quad_t ip6s_total; /* total packets received */ 184 u_quad_t ip6s_tooshort; /* packet too short */ 185 u_quad_t ip6s_toosmall; /* not enough data */ 186 u_quad_t ip6s_fragments; /* fragments received */ 187 u_quad_t ip6s_fragdropped; /* frags dropped(dups, out of space) */ 188 u_quad_t ip6s_fragtimeout; /* fragments timed out */ 189 u_quad_t ip6s_fragoverflow; /* fragments that exceeded limit */ 190 u_quad_t ip6s_forward; /* packets forwarded */ 191 u_quad_t ip6s_cantforward; /* packets rcvd for unreachable dest */ 192 u_quad_t ip6s_redirectsent; /* packets forwarded on same net */ 193 u_quad_t ip6s_delivered; /* datagrams delivered to upper level*/ 194 u_quad_t ip6s_localout; /* total ip packets generated here */ 195 u_quad_t ip6s_odropped; /* lost packets due to nobufs, etc. */ 196 u_quad_t ip6s_reassembled; /* total packets reassembled ok */ 197 u_quad_t ip6s_fragmented; /* datagrams successfully fragmented */ 198 u_quad_t ip6s_ofragments; /* output fragments created */ 199 u_quad_t ip6s_cantfrag; /* don't fragment flag was set, etc. */ 200 u_quad_t ip6s_badoptions; /* error in option processing */ 201 u_quad_t ip6s_noroute; /* packets discarded due to no route */ 202 u_quad_t ip6s_badvers; /* ip6 version != 6 */ 203 u_quad_t ip6s_rawout; /* total raw ip packets generated */ 204 u_quad_t ip6s_badscope; /* scope error */ 205 u_quad_t ip6s_notmember; /* don't join this multicast group */ 206 u_quad_t ip6s_nxthist[256]; /* next header history */ 207 u_quad_t ip6s_m1; /* one mbuf */ 208 u_quad_t ip6s_m2m[32]; /* two or more mbuf */ 209 u_quad_t ip6s_mext1; /* one ext mbuf */ 210 u_quad_t ip6s_mext2m; /* two or more ext mbuf */ 211 u_quad_t ip6s_exthdrtoolong; /* ext hdr are not continuous */ 212 u_quad_t ip6s_nogif; /* no match gif found */ 213 u_quad_t ip6s_toomanyhdr; /* discarded due to too many headers */ 214 215 /* 216 * statistics for improvement of the source address selection 217 * algorithm: 218 * XXX: hardcoded 16 = # of ip6 multicast scope types + 1 219 */ 220 /* number of times that address selection fails */ 221 u_quad_t ip6s_sources_none; 222 /* number of times that an address on the outgoing I/F is chosen */ 223 u_quad_t ip6s_sources_sameif[16]; 224 /* number of times that an address on a non-outgoing I/F is chosen */ 225 u_quad_t ip6s_sources_otherif[16]; 226 /* 227 * number of times that an address that has the same scope 228 * from the destination is chosen. 229 */ 230 u_quad_t ip6s_sources_samescope[16]; 231 /* 232 * number of times that an address that has a different scope 233 * from the destination is chosen. 234 */ 235 u_quad_t ip6s_sources_otherscope[16]; 236 /* number of times that a deprecated address is chosen */ 237 u_quad_t ip6s_sources_deprecated[16]; 238 239 u_quad_t ip6s_forward_cachehit; 240 u_quad_t ip6s_forward_cachemiss; 241 242 /* number of times that each rule of source selection is applied. */ 243 u_quad_t ip6s_sources_rule[16]; 244}; 245 246#ifdef _KERNEL 247/* 248 * IPv6 onion peeling state. 249 * it will be initialized when we come into ip6_input(). 250 * XXX do not make it a kitchen sink! 251 */ 252struct ip6aux { 253 u_int32_t ip6a_flags; 254#define IP6A_SWAP 0x01 /* swapped home/care-of on packet */ 255#define IP6A_HASEEN 0x02 /* HA was present */ 256#define IP6A_BRUID 0x04 /* BR Unique Identifier was present */ 257#define IP6A_RTALERTSEEN 0x08 /* rtalert present */ 258 259 /* ip6.ip6_src */ 260 struct in6_addr ip6a_careof; /* care-of address of the peer */ 261 struct in6_addr ip6a_home; /* home address of the peer */ 262 u_int16_t ip6a_bruid; /* BR unique identifier */ 263 264 /* ip6.ip6_dst */ 265 struct in6_ifaddr *ip6a_dstia6; /* my ifaddr that matches ip6_dst */ 266 267 /* rtalert */ 268 u_int16_t ip6a_rtalert; /* rtalert option value */ 269 270 /* 271 * decapsulation history will be here. 272 * with IPsec it may not be accurate. 273 */ 274}; 275#endif 276 277#ifdef _KERNEL 278/* flags passed to ip6_output as last parameter */ 279#define IPV6_UNSPECSRC 0x01 /* allow :: as the source address */ 280#define IPV6_FORWARDING 0x02 /* most of IPv6 header exists */ 281#define IPV6_MINMTU 0x04 /* use minimum MTU (IPV6_USE_MIN_MTU) */ 282 283#ifdef __NO_STRICT_ALIGNMENT 284#define IP6_HDR_ALIGNED_P(ip) 1 285#else 286#define IP6_HDR_ALIGNED_P(ip) ((((intptr_t) (ip)) & 3) == 0) 287#endif 288 289extern struct ip6stat ip6stat; /* statistics */ 290extern int ip6_defhlim; /* default hop limit */ 291extern int ip6_defmcasthlim; /* default multicast hop limit */ 292extern int ip6_forwarding; /* act as router? */ 293extern int ip6_forward_srcrt; /* forward src-routed? */ 294extern int ip6_gif_hlim; /* Hop limit for gif encap packet */ 295extern int ip6_use_deprecated; /* allow deprecated addr as source */ 296extern int ip6_rr_prune; /* router renumbering prefix 297 * walk list every 5 sec. */ 298extern int ip6_mcast_pmtu; /* enable pMTU discovery for multicast? */ 299extern int ip6_v6only; 300 301extern struct socket *ip6_mrouter; /* multicast routing daemon */ 302extern int ip6_sendredirects; /* send IP redirects when forwarding? */ 303extern int ip6_maxfragpackets; /* Maximum packets in reassembly queue */ 304extern int ip6_maxfrags; /* Maximum fragments in reassembly queue */ 305extern int ip6_sourcecheck; /* Verify source interface */ 306extern int ip6_sourcecheck_interval; /* Interval between log messages */ 307extern int ip6_accept_rtadv; /* Acts as a host not a router */ 308extern int ip6_keepfaith; /* Firewall Aided Internet Translator */ 309extern int ip6_log_interval; 310extern time_t ip6_log_time; 311extern int ip6_hdrnestlimit; /* upper limit of # of extension headers */ 312extern int ip6_dad_count; /* DupAddrDetectionTransmits */ 313 314extern int ip6_auto_flowlabel; 315extern int ip6_auto_linklocal; 316 317extern int ip6_anonportmin; /* minimum ephemeral port */ 318extern int ip6_anonportmax; /* maximum ephemeral port */ 319extern int ip6_lowportmin; /* minimum reserved port */ 320extern int ip6_lowportmax; /* maximum reserved port */ 321 322extern int ip6_use_tempaddr; /* whether to use temporary addresses. */ 323extern int ip6_prefer_tempaddr; /* whether to prefer temporary addresses 324 in the source address selection */ 325 326extern int ip6_use_defzone; /* whether to use the default scope zone 327 when unspecified */ 328 329extern struct pfil_head inet6_pfil_hook; /* packet filter hooks */ 330#ifdef IPSTEALTH 331extern int ip6stealth; 332#endif 333 334extern struct pr_usrreqs rip6_usrreqs; 335struct sockopt; 336 337struct inpcb; 338 339int icmp6_ctloutput __P((struct socket *, struct sockopt *sopt)); 340 341struct in6_ifaddr; 342void ip6_init __P((void)); 343void ip6_input __P((struct mbuf *)); 344struct in6_ifaddr *ip6_getdstifaddr __P((struct mbuf *)); 345void ip6_freepcbopts __P((struct ip6_pktopts *)); 346void ip6_freemoptions __P((struct ip6_moptions *)); 347int ip6_unknown_opt __P((u_int8_t *, struct mbuf *, int)); 348char * ip6_get_prevhdr __P((struct mbuf *, int)); 349int ip6_nexthdr __P((struct mbuf *, int, int, int *)); 350int ip6_lasthdr __P((struct mbuf *, int, int, int *)); 351 352struct ip6aux *ip6_addaux __P((struct mbuf *)); 353struct ip6aux *ip6_findaux __P((struct mbuf *)); 354void ip6_delaux __P((struct mbuf *)); 355 356extern int (*ip6_mforward)(struct ip6_hdr *, struct ifnet *, 357 struct mbuf *); 358 359int ip6_process_hopopts __P((struct mbuf *, u_int8_t *, int, u_int32_t *, 360 u_int32_t *)); 361void ip6_savecontrol __P((struct inpcb *, struct mbuf *, struct mbuf **)); 362void ip6_notify_pmtu __P((struct inpcb *, struct sockaddr_in6 *, 363 u_int32_t *)); 364int ip6_sysctl __P((int *, u_int, void *, size_t *, void *, size_t)); 365 366void ip6_forward __P((struct mbuf *, int)); 367 368void ip6_mloopback __P((struct ifnet *, struct mbuf *, struct sockaddr_in6 *)); 369int ip6_output __P((struct mbuf *, struct ip6_pktopts *, 370 struct route_in6 *, 371 int, 372 struct ip6_moptions *, struct ifnet **, 373 struct inpcb *)); 374int ip6_ctloutput __P((struct socket *, struct sockopt *)); 375int ip6_raw_ctloutput __P((struct socket *, struct sockopt *)); 376void ip6_initpktopts __P((struct ip6_pktopts *)); 377int ip6_setpktopts __P((struct mbuf *, struct ip6_pktopts *, 378 struct ip6_pktopts *, int, int)); 379void ip6_clearpktopts __P((struct ip6_pktopts *, int)); 380struct ip6_pktopts *ip6_copypktopts __P((struct ip6_pktopts *, int)); 381int ip6_optlen __P((struct inpcb *)); 382 383int route6_input __P((struct mbuf **, int *, int)); 384 385void frag6_init __P((void)); 386int frag6_input __P((struct mbuf **, int *, int)); 387void frag6_slowtimo __P((void)); 388void frag6_drain __P((void)); 389 390void rip6_init __P((void)); 391int rip6_input __P((struct mbuf **, int *, int)); 392void rip6_ctlinput __P((int, struct sockaddr *, void *)); 393int rip6_ctloutput __P((struct socket *, struct sockopt *)); 394int rip6_output __P((struct mbuf *, ...)); 395int rip6_usrreq __P((struct socket *, 396 int, struct mbuf *, struct mbuf *, struct mbuf *, struct thread *)); 397 398int dest6_input __P((struct mbuf **, int *, int)); 399int none_input __P((struct mbuf **, int *, int)); 400 401struct in6_addr *in6_selectsrc __P((struct sockaddr_in6 *, 402 struct ip6_pktopts *, struct ip6_moptions *, struct route_in6 *, 403 struct in6_addr *, struct ifnet **, int *)); 404int in6_selectroute __P((struct sockaddr_in6 *, struct ip6_pktopts *, 405 struct ip6_moptions *, struct route_in6 *, struct ifnet **, 406 struct rtentry **, int)); 407u_int32_t ip6_randomid __P((void)); 408u_int32_t ip6_randomflowlabel __P((void)); 409#endif /* _KERNEL */ 410 411#endif /* !_NETINET6_IP6_VAR_H_ */ 412