1 /*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (C) 1995, 1996, 1997, and 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 * $KAME: ip6_var.h,v 1.62 2001/05/03 14:51:48 itojun Exp $ 32 */ 33 34 /*- 35 * Copyright (c) 1982, 1986, 1993 36 * The Regents of the University of California. All rights reserved. 37 * 38 * Redistribution and use in source and binary forms, with or without 39 * modification, are permitted provided that the following conditions 40 * are met: 41 * 1. Redistributions of source code must retain the above copyright 42 * notice, this list of conditions and the following disclaimer. 43 * 2. Redistributions in binary form must reproduce the above copyright 44 * notice, this list of conditions and the following disclaimer in the 45 * documentation and/or other materials provided with the distribution. 46 * 3. Neither the name of the University nor the names of its contributors 47 * may be used to endorse or promote products derived from this software 48 * without specific prior written permission. 49 * 50 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 51 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 52 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 53 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 54 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 55 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 56 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 60 * SUCH DAMAGE. 61 */ 62 63 #ifndef _NETINET6_IP6_VAR_H_ 64 #define _NETINET6_IP6_VAR_H_ 65 66 #include <sys/epoch.h> 67 68 #ifdef _KERNEL 69 /* 70 * For IPv6 pseudo header checksum; to be used by TCP-MD5, 71 * and for OCF source level compatibility with OpenBSD. 72 */ 73 struct ip6_hdr_pseudo { 74 struct in6_addr ip6ph_src; 75 struct in6_addr ip6ph_dst; 76 uint32_t ip6ph_len; 77 uint8_t ip6ph_zero[3]; 78 uint8_t ip6ph_nxt; 79 } __aligned(4); 80 81 #ifdef INVARIANTS 82 /* Aligned size of pseudo-header must equal size of IPv6 header. */ 83 _Static_assert(sizeof(struct ip6_hdr_pseudo) == 40, 84 "IPv6 pseudo-header alignment failure"); 85 #endif 86 87 struct ip6asfrag; /* frag6.c */ 88 TAILQ_HEAD(ip6fraghead, ip6asfrag); 89 90 /* 91 * IP6 reassembly queue structure. Each fragment 92 * being reassembled is attached to one of these structures. 93 */ 94 struct ip6q { 95 struct ip6fraghead ip6q_frags; 96 u_int32_t ip6q_ident; 97 u_int8_t ip6q_nxt; 98 u_int8_t ip6q_ecn; 99 u_int16_t ip6q_ttl; 100 struct in6_addr ip6q_src, ip6q_dst; 101 TAILQ_ENTRY(ip6q) ip6q_tq; 102 int ip6q_unfrglen; /* len of unfragmentable part */ 103 int ip6q_nfrag; /* # of fragments */ 104 struct label *ip6q_label; 105 }; 106 #endif /* _KERNEL */ 107 108 /* 109 * IP6 reinjecting structure. 110 */ 111 struct ip6_direct_ctx { 112 uint32_t ip6dc_nxt; /* next header to process */ 113 uint32_t ip6dc_off; /* offset to next header */ 114 }; 115 116 /* 117 * Control options for outgoing packets 118 */ 119 120 /* Routing header related info */ 121 struct ip6po_rhinfo { 122 struct ip6_rthdr *ip6po_rhi_rthdr; /* Routing header */ 123 struct route_in6 ip6po_rhi_route; /* Route to the 1st hop */ 124 }; 125 #define ip6po_rthdr ip6po_rhinfo.ip6po_rhi_rthdr 126 #define ip6po_route ip6po_rhinfo.ip6po_rhi_route 127 128 /* Nexthop related info */ 129 struct ip6po_nhinfo { 130 struct sockaddr *ip6po_nhi_nexthop; 131 struct route_in6 ip6po_nhi_route; /* Route to the nexthop */ 132 }; 133 #define ip6po_nexthop ip6po_nhinfo.ip6po_nhi_nexthop 134 #define ip6po_nextroute ip6po_nhinfo.ip6po_nhi_route 135 136 /* 137 * Note that fields with valid data must be flagged in ip6po_valid. 138 * This is done to reduce cache misses in ip6_output(). Before 139 * ip6po_valid, ip6_output needed to check all the individual fields 140 * of ip6_pktopts needed to be checked themselves, and they are spread 141 * across 4 cachelines. ip6_output() is currently the only consumer of 142 * these flags, as it is in the critical path of every packet sent. 143 */ 144 struct ip6_pktopts { 145 uint32_t ip6po_valid; 146 #define IP6PO_VALID_HLIM 0x0001 147 #define IP6PO_VALID_PKTINFO 0x0002 148 #define IP6PO_VALID_NHINFO 0x0004 149 #define IP6PO_VALID_HBH 0x0008 150 #define IP6PO_VALID_DEST1 0x0010 151 #define IP6PO_VALID_RHINFO 0x0020 152 #define IP6PO_VALID_DEST2 0x0040 153 #define IP6PO_VALID_TC 0x0080 154 155 int ip6po_hlim; /* Hoplimit for outgoing packets */ 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 struct mbuf *ip6po_m; /* Pointer to mbuf storing the data */ 178 179 /* Outgoing IF/address information */ 180 struct in6_pktinfo *ip6po_pktinfo; 181 182 /* Next-hop address information */ 183 struct ip6po_nhinfo ip6po_nhinfo; 184 185 struct ip6_hbh *ip6po_hbh; /* Hop-by-Hop options header */ 186 187 /* Destination options header (before a routing header) */ 188 struct ip6_dest *ip6po_dest1; 189 190 /* Routing header related info. */ 191 struct ip6po_rhinfo ip6po_rhinfo; 192 193 /* Destination options header (after a routing header) */ 194 struct ip6_dest *ip6po_dest2; 195 }; 196 197 /* 198 * Control options for incoming packets 199 */ 200 201 struct ip6stat { 202 uint64_t ip6s_total; /* total packets received */ 203 uint64_t ip6s_tooshort; /* packet too short */ 204 uint64_t ip6s_toosmall; /* not enough data */ 205 uint64_t ip6s_fragments; /* fragments received */ 206 uint64_t ip6s_fragdropped; /* frags dropped(dups, out of space) */ 207 uint64_t ip6s_fragtimeout; /* fragments timed out */ 208 uint64_t ip6s_fragoverflow; /* fragments that exceeded limit */ 209 uint64_t ip6s_forward; /* packets forwarded */ 210 uint64_t ip6s_cantforward; /* packets rcvd for unreachable dest */ 211 uint64_t ip6s_redirectsent; /* packets forwarded on same net */ 212 uint64_t ip6s_delivered; /* datagrams delivered to upper level*/ 213 uint64_t ip6s_localout; /* total ip packets generated here */ 214 uint64_t ip6s_odropped; /* lost packets due to nobufs, etc. */ 215 uint64_t ip6s_reassembled; /* total packets reassembled ok */ 216 uint64_t ip6s_atomicfrags; /* atomic fragments */ 217 uint64_t ip6s_fragmented; /* datagrams successfully fragmented */ 218 uint64_t ip6s_ofragments; /* output fragments created */ 219 uint64_t ip6s_cantfrag; /* don't fragment flag was set, etc. */ 220 uint64_t ip6s_badoptions; /* error in option processing */ 221 uint64_t ip6s_noroute; /* packets discarded due to no route */ 222 uint64_t ip6s_badvers; /* ip6 version != 6 */ 223 uint64_t ip6s_rawout; /* total raw ip packets generated */ 224 uint64_t ip6s_badscope; /* scope error */ 225 uint64_t ip6s_notmember; /* don't join this multicast group */ 226 #define IP6S_HDRCNT 256 /* headers count */ 227 uint64_t ip6s_nxthist[IP6S_HDRCNT]; /* next header history */ 228 uint64_t ip6s_m1; /* one mbuf */ 229 #define IP6S_M2MMAX 32 230 uint64_t ip6s_m2m[IP6S_M2MMAX]; /* two or more mbuf */ 231 uint64_t ip6s_mext1; /* one ext mbuf */ 232 uint64_t ip6s_mext2m; /* two or more ext mbuf */ 233 uint64_t ip6s_exthdrtoolong; /* ext hdr are not contiguous */ 234 uint64_t ip6s_nogif; /* no match gif found */ 235 uint64_t ip6s_toomanyhdr; /* discarded due to too many headers */ 236 237 /* 238 * statistics for improvement of the source address selection 239 * algorithm: 240 * XXX: hardcoded 16 = # of ip6 multicast scope types + 1 241 */ 242 #define IP6S_RULESMAX 16 243 #define IP6S_SCOPECNT 16 244 /* number of times that address selection fails */ 245 uint64_t ip6s_sources_none; 246 /* number of times that an address on the outgoing I/F is chosen */ 247 uint64_t ip6s_sources_sameif[IP6S_SCOPECNT]; 248 /* number of times that an address on a non-outgoing I/F is chosen */ 249 uint64_t ip6s_sources_otherif[IP6S_SCOPECNT]; 250 /* 251 * number of times that an address that has the same scope 252 * from the destination is chosen. 253 */ 254 uint64_t ip6s_sources_samescope[IP6S_SCOPECNT]; 255 /* 256 * number of times that an address that has a different scope 257 * from the destination is chosen. 258 */ 259 uint64_t ip6s_sources_otherscope[IP6S_SCOPECNT]; 260 /* number of times that a deprecated address is chosen */ 261 uint64_t ip6s_sources_deprecated[IP6S_SCOPECNT]; 262 263 /* number of times that each rule of source selection is applied. */ 264 uint64_t ip6s_sources_rule[IP6S_RULESMAX]; 265 }; 266 267 #ifdef _KERNEL 268 #include <sys/counter.h> 269 #include <netinet/in_kdtrace.h> 270 271 VNET_PCPUSTAT_DECLARE(struct ip6stat, ip6stat); 272 #define IP6STAT_ADD(name, val) \ 273 do { \ 274 MIB_SDT_PROBE1(ip6, count, name, (val)); \ 275 VNET_PCPUSTAT_ADD(struct ip6stat, ip6stat, name, (val)); \ 276 } while (0) 277 #define IP6STAT_SUB(name, val) IP6STAT_ADD(name, -(val)) 278 #define IP6STAT_INC(name) IP6STAT_ADD(name, 1) 279 #define IP6STAT_INC2(name, type) \ 280 do { \ 281 MIB_SDT_PROBE2(ip6, count, name, 1, type); \ 282 VNET_PCPUSTAT_ADD(struct ip6stat, ip6stat, name, 1); \ 283 } while (0) 284 #define IP6STAT_DEC(name) IP6STAT_SUB(name, 1) 285 #endif 286 287 #ifdef _KERNEL 288 /* flags passed to ip6_output as last parameter */ 289 #define IPV6_UNSPECSRC 0x01 /* allow :: as the source address */ 290 #define IPV6_FORWARDING 0x02 /* most of IPv6 header exists */ 291 #define IPV6_MINMTU 0x04 /* use minimum MTU (IPV6_USE_MIN_MTU) */ 292 293 #ifdef __NO_STRICT_ALIGNMENT 294 #define IP6_HDR_ALIGNED_P(ip) 1 295 #else 296 #define IP6_HDR_ALIGNED_P(ip) ((((intptr_t) (ip)) & 3) == 0) 297 #endif 298 299 VNET_DECLARE(int, ip6_defhlim); /* default hop limit */ 300 VNET_DECLARE(int, ip6_defmcasthlim); /* default multicast hop limit */ 301 VNET_DECLARE(int, ip6_forwarding); /* act as router? */ 302 VNET_DECLARE(int, ip6_use_deprecated); /* allow deprecated addr as source */ 303 VNET_DECLARE(int, ip6_rr_prune); /* router renumbering prefix 304 * walk list every 5 sec. */ 305 VNET_DECLARE(int, ip6_mcast_pmtu); /* enable pMTU discovery for multicast? */ 306 VNET_DECLARE(int, ip6_v6only); 307 #define V_ip6_defhlim VNET(ip6_defhlim) 308 #define V_ip6_defmcasthlim VNET(ip6_defmcasthlim) 309 #define V_ip6_forwarding VNET(ip6_forwarding) 310 #define V_ip6_use_deprecated VNET(ip6_use_deprecated) 311 #define V_ip6_rr_prune VNET(ip6_rr_prune) 312 #define V_ip6_mcast_pmtu VNET(ip6_mcast_pmtu) 313 #define V_ip6_v6only VNET(ip6_v6only) 314 315 VNET_DECLARE(int, ip6_sendredirects); /* send IP redirects when forwarding? */ 316 VNET_DECLARE(int, ip6_accept_rtadv); /* Acts as a host not a router */ 317 VNET_DECLARE(int, ip6_no_radr); /* No defroute from RA */ 318 VNET_DECLARE(int, ip6_norbit_raif); /* Disable R-bit in NA on RA 319 * receiving IF. */ 320 VNET_DECLARE(int, ip6_rfc6204w3); /* Accept defroute from RA even when 321 forwarding enabled */ 322 VNET_DECLARE(int, ip6_hdrnestlimit); /* upper limit of # of extension 323 * headers */ 324 VNET_DECLARE(int, ip6_dad_count); /* DupAddrDetectionTransmits */ 325 VNET_DECLARE(int, ip6_grand_count); /* Gratuitous ND Transmits */ 326 #define V_ip6_sendredirects VNET(ip6_sendredirects) 327 #define V_ip6_accept_rtadv VNET(ip6_accept_rtadv) 328 #define V_ip6_no_radr VNET(ip6_no_radr) 329 #define V_ip6_norbit_raif VNET(ip6_norbit_raif) 330 #define V_ip6_rfc6204w3 VNET(ip6_rfc6204w3) 331 #define V_ip6_hdrnestlimit VNET(ip6_hdrnestlimit) 332 #define V_ip6_dad_count VNET(ip6_dad_count) 333 #define V_ip6_grand_count VNET(ip6_grand_count) 334 335 VNET_DECLARE(int, ip6_auto_flowlabel); 336 VNET_DECLARE(int, ip6_auto_linklocal); 337 #define V_ip6_auto_flowlabel VNET(ip6_auto_flowlabel) 338 #define V_ip6_auto_linklocal VNET(ip6_auto_linklocal) 339 340 VNET_DECLARE(int, ip6_use_tempaddr); /* Whether to use temporary addresses */ 341 VNET_DECLARE(int, ip6_prefer_tempaddr); /* Whether to prefer temporary 342 * addresses in the source address 343 * selection */ 344 VNET_DECLARE(bool, ip6_use_stableaddr); /* Whether to use stable address generation (RFC 7217) */ 345 #define V_ip6_use_tempaddr VNET(ip6_use_tempaddr) 346 #define V_ip6_prefer_tempaddr VNET(ip6_prefer_tempaddr) 347 #define V_ip6_use_stableaddr VNET(ip6_use_stableaddr) 348 349 #define IP6_IDGEN_RETRIES 3 /* RFC 7217 section 7 default max retries */ 350 VNET_DECLARE(u_int, ip6_stableaddr_maxretries); 351 #define V_ip6_stableaddr_maxretries VNET(ip6_stableaddr_maxretries) 352 353 #define IP6_STABLEADDR_NETIFSRC_NAME 0 354 #define IP6_STABLEADDR_NETIFSRC_ID 1 355 #define IP6_STABLEADDR_NETIFSRC_MAC 2 356 VNET_DECLARE(int, ip6_stableaddr_netifsource); 357 #define V_ip6_stableaddr_netifsource VNET(ip6_stableaddr_netifsource) 358 359 VNET_DECLARE(int, ip6_use_defzone); /* Whether to use the default scope 360 * zone when unspecified */ 361 #define V_ip6_use_defzone VNET(ip6_use_defzone) 362 363 VNET_DECLARE(struct pfil_head *, inet6_pfil_head); 364 #define V_inet6_pfil_head VNET(inet6_pfil_head) 365 #define PFIL_INET6_NAME "inet6" 366 367 VNET_DECLARE(struct pfil_head *, inet6_local_pfil_head); 368 #define V_inet6_local_pfil_head VNET(inet6_local_pfil_head) 369 #define PFIL_INET6_LOCAL_NAME "inet6-local" 370 371 #ifdef IPSTEALTH 372 VNET_DECLARE(int, ip6stealth); 373 #define V_ip6stealth VNET(ip6stealth) 374 #endif 375 376 VNET_DECLARE(bool, ip6_log_cannot_forward); 377 #define V_ip6_log_cannot_forward VNET(ip6_log_cannot_forward) 378 379 struct inpcb; 380 struct socket; 381 struct sockopt; 382 struct ucred; 383 struct ip6_moptions; 384 385 int icmp6_ctloutput(struct socket *, struct sockopt *sopt); 386 387 void ip6_input(struct mbuf *); 388 void ip6_direct_input(struct mbuf *); 389 void ip6_freepcbopts(struct ip6_pktopts *); 390 391 int ip6_unknown_opt(u_int8_t *, struct mbuf *, int); 392 int ip6_get_prevhdr(const struct mbuf *, int); 393 int ip6_nexthdr(const struct mbuf *, int, int, int *); 394 int ip6_lasthdr(const struct mbuf *, int, int, int *); 395 396 extern int (*ip6_mforward)(struct ip6_hdr *, struct ifnet *, 397 struct mbuf *); 398 399 int ip6_process_hopopts(struct mbuf *, u_int8_t *, int, u_int32_t *); 400 struct mbuf **ip6_savecontrol_v4(struct inpcb *, struct mbuf *, 401 struct mbuf **, int *); 402 void ip6_savecontrol(struct inpcb *, struct mbuf *, struct mbuf **); 403 void ip6_notify_pmtu(struct inpcb *, struct sockaddr_in6 *, u_int32_t); 404 int ip6_sysctl(int *, u_int, void *, size_t *, void *, size_t); 405 406 void ip6_forward(struct mbuf *, int); 407 408 void ip6_mloopback(struct ifnet *, struct mbuf *); 409 int ip6_output(struct mbuf *, struct ip6_pktopts *, 410 struct route_in6 *, 411 int, 412 struct ip6_moptions *, struct ifnet **, 413 struct inpcb *); 414 int ip6_ctloutput(struct socket *, struct sockopt *); 415 int ip6_raw_ctloutput(struct socket *, struct sockopt *); 416 void ip6_initpktopts(struct ip6_pktopts *); 417 int ip6_setpktopts(struct mbuf *, struct ip6_pktopts *, 418 struct ip6_pktopts *, struct ucred *, int); 419 void ip6_clearpktopts(struct ip6_pktopts *, int); 420 struct ip6_pktopts *ip6_copypktopts(struct ip6_pktopts *, int); 421 int ip6_optlen(struct inpcb *); 422 int ip6_deletefraghdr(struct mbuf *, int, int); 423 int ip6_fragment(struct ifnet *, struct mbuf *, int, u_char, int, 424 uint32_t); 425 426 int route6_input(struct mbuf **, int *, int); 427 428 void frag6_init(void); 429 void frag6_destroy(void); 430 int frag6_input(struct mbuf **, int *, int); 431 void frag6_drain(void *, int); 432 433 void rip6_init(void); 434 int rip6_ctloutput(struct socket *, struct sockopt *); 435 int rip6_usrreq(struct socket *, 436 int, struct mbuf *, struct mbuf *, struct mbuf *, struct thread *); 437 438 int dest6_input(struct mbuf **, int *, int); 439 int none_input(struct mbuf **, int *, int); 440 441 int in6_selectsrc_socket(struct sockaddr_in6 *, struct ip6_pktopts *, 442 struct inpcb *, struct ucred *, int, struct in6_addr *, int *); 443 int in6_selectsrc_addr(uint32_t, const struct in6_addr *, 444 uint32_t, struct ifnet *, struct in6_addr *, int *); 445 int in6_selectsrc_nbr(uint32_t, const struct in6_addr *, 446 struct ip6_moptions *, struct ifnet *, struct in6_addr *); 447 int in6_selectroute(struct sockaddr_in6 *, struct ip6_pktopts *, 448 struct ip6_moptions *, struct route_in6 *, struct ifnet **, 449 struct nhop_object **, u_int, uint32_t); 450 u_int32_t ip6_randomid(void); 451 u_int32_t ip6_randomflowlabel(void); 452 void in6_delayed_cksum(struct mbuf *m, uint32_t plen, u_short offset); 453 454 int ip6_log_ratelimit(void); 455 456 /* 457 * Argument type for the last arg of ip6proto_ctlinput_t(). 458 * 459 * IPv6 ICMP IPv6 [exthdrs] finalhdr payload 460 * ^ ^ ^ ^ 461 * | | ip6c_ip6 ip6c_off 462 * | ip6c_icmp6 463 * ip6c_m 464 * 465 * ip6c_finaldst's sin6_addr usually points to ip6c_ip6->ip6_dst. If the 466 * original * (internal) packet carries a routing header, it may point the 467 * final * destination address in the routing header. 468 * 469 * ip6c_src: ip6c_ip6->ip6_src + scope info + flowlabel in ip6c_ip6 470 * (beware of flowlabel, if you try to compare it against others) 471 * ip6c_dst: ip6c_finaldst + scope info 472 */ 473 struct ip6ctlparam { 474 struct mbuf *ip6c_m; /* start of mbuf chain */ 475 struct icmp6_hdr *ip6c_icmp6; /* icmp6 header of target packet */ 476 struct ip6_hdr *ip6c_ip6; /* ip6 header of target packet */ 477 int ip6c_off; /* offset of the target proto header */ 478 struct sockaddr_in6 *ip6c_src; /* srcaddr w/ additional info */ 479 struct sockaddr_in6 *ip6c_dst; /* (final) dstaddr w/ additional info */ 480 struct sockaddr_in6 *ip6c_finaldst; /* final destination address */ 481 void *ip6c_cmdarg; /* control command dependent data */ 482 u_int8_t ip6c_nxt; /* final next header field */ 483 }; 484 485 typedef int ip6proto_input_t(struct mbuf **, int *, int); 486 typedef void ip6proto_ctlinput_t(struct ip6ctlparam *); 487 int ip6proto_register(uint8_t, ip6proto_input_t, ip6proto_ctlinput_t); 488 int ip6proto_unregister(uint8_t); 489 #define IP6PROTO_REGISTER(prot, input, ctl) do { \ 490 int error __diagused; \ 491 error = ip6proto_register(prot, input, ctl); \ 492 MPASS(error == 0); \ 493 } while (0) 494 495 ip6proto_input_t rip6_input; 496 ip6proto_ctlinput_t rip6_ctlinput; 497 498 #endif /* _KERNEL */ 499 500 #endif /* !_NETINET6_IP6_VAR_H_ */ 501