17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 545916cd2Sjpk * Common Development and Distribution License (the "License"). 645916cd2Sjpk * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*e11c3f44Smeem * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _INET_IP6_H 277c478bd9Sstevel@tonic-gate #define _INET_IP6_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifdef __cplusplus 307c478bd9Sstevel@tonic-gate extern "C" { 317c478bd9Sstevel@tonic-gate #endif 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h> 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #ifdef _KERNEL 367c478bd9Sstevel@tonic-gate /* icmp6_t is used in the prototype of icmp_inbound_error_fanout_v6() */ 377c478bd9Sstevel@tonic-gate #include <netinet/icmp6.h> 387c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate /* version number for IPv6 - hard to get this one wrong! */ 417c478bd9Sstevel@tonic-gate #define IPV6_VERSION 6 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #define IPV6_HDR_LEN 40 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate #define IPV6_ADDR_LEN 16 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate /* 487c478bd9Sstevel@tonic-gate * IPv6 address scopes. The values of these enums also match the scope 497c478bd9Sstevel@tonic-gate * field of multicast addresses. 507c478bd9Sstevel@tonic-gate */ 517c478bd9Sstevel@tonic-gate typedef enum { 527c478bd9Sstevel@tonic-gate IP6_SCOPE_INTFLOCAL = 1, /* Multicast addresses only */ 537c478bd9Sstevel@tonic-gate IP6_SCOPE_LINKLOCAL, 547c478bd9Sstevel@tonic-gate IP6_SCOPE_SUBNETLOCAL, /* Multicast addresses only */ 557c478bd9Sstevel@tonic-gate IP6_SCOPE_ADMINLOCAL, /* Multicast addresses only */ 567c478bd9Sstevel@tonic-gate IP6_SCOPE_SITELOCAL, 577c478bd9Sstevel@tonic-gate IP6_SCOPE_GLOBAL 587c478bd9Sstevel@tonic-gate } in6addr_scope_t; 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate #ifdef _KERNEL 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate /* 637c478bd9Sstevel@tonic-gate * Private header used between the transports and IP to carry the content 647c478bd9Sstevel@tonic-gate * of the options IPV6_PKTINFO/IPV6_RECVPKTINFO (the interface index only) 657c478bd9Sstevel@tonic-gate * and IPV6_NEXTHOP. 667c478bd9Sstevel@tonic-gate * Also used to specify that raw sockets do not want the UDP/TCP transport 677c478bd9Sstevel@tonic-gate * checksums calculated in IP (akin to IP_HDR_INCLUDED) and provide for 687c478bd9Sstevel@tonic-gate * IPV6_CHECKSUM on the transmit side (using ip6i_checksum_off). 697c478bd9Sstevel@tonic-gate * 707c478bd9Sstevel@tonic-gate * When this header is used it must be the first header in the packet i.e. 717c478bd9Sstevel@tonic-gate * before the real ip6 header. The use of a next header value of 255 727c478bd9Sstevel@tonic-gate * (IPPROTO_RAW) in this header indicates its presence. Note that 737c478bd9Sstevel@tonic-gate * ip6_nxt = IPPROTO_RAW indicates that "this" header is ip6_info - the 747c478bd9Sstevel@tonic-gate * next header is always IPv6. 757c478bd9Sstevel@tonic-gate * 767c478bd9Sstevel@tonic-gate * Note that ip6i_nexthop is at the same offset as ip6_dst so that 777c478bd9Sstevel@tonic-gate * this header can be kept in the packet while the it passes through 787c478bd9Sstevel@tonic-gate * ip_newroute* and the ndp code. Those routines will use ip6_dst for 797c478bd9Sstevel@tonic-gate * resolution. 807c478bd9Sstevel@tonic-gate * 817c478bd9Sstevel@tonic-gate * Implementation offset assumptions about ip6_info_t and ip6_t fields 827c478bd9Sstevel@tonic-gate * and their alignments shown in figure below 837c478bd9Sstevel@tonic-gate * 847c478bd9Sstevel@tonic-gate * ip6_info (Private headers from transports to IP) header below 857c478bd9Sstevel@tonic-gate * _______________________________________________________________ _ _ _ _ _ 867c478bd9Sstevel@tonic-gate * | .... | ip6i_nxt (255)| ......................|ip6i_nexthop| ...ip6_t. 877c478bd9Sstevel@tonic-gate * --------------------------------------------------------------- - - - - - 887c478bd9Sstevel@tonic-gate * ^ ^ 897c478bd9Sstevel@tonic-gate * <---- >| same offset for {ip6i_nxt,ip6_nxt} ^ 907c478bd9Sstevel@tonic-gate * ^ ^ 917c478bd9Sstevel@tonic-gate * <------^-------------------------------------->| same offset for 927c478bd9Sstevel@tonic-gate * ^ ^ {ip6i_nxthop,ip6_dst} 937c478bd9Sstevel@tonic-gate * _______________________________________________________________ _ _ _ 947c478bd9Sstevel@tonic-gate * | .... | ip6_nxt | ......................|ip6_dst | .other hdrs... 957c478bd9Sstevel@tonic-gate * --------------------------------------------------------------- - - - 967c478bd9Sstevel@tonic-gate * ip6_t (IPv6 protocol) header above 977c478bd9Sstevel@tonic-gate */ 987c478bd9Sstevel@tonic-gate struct ip6_info { 997c478bd9Sstevel@tonic-gate union { 1007c478bd9Sstevel@tonic-gate struct ip6_info_ctl { 1017c478bd9Sstevel@tonic-gate uint32_t ip6i_un1_flow; 1027c478bd9Sstevel@tonic-gate uint16_t ip6i_un1_plen; /* payload length */ 1037c478bd9Sstevel@tonic-gate uint8_t ip6i_un1_nxt; /* next header */ 1047c478bd9Sstevel@tonic-gate uint8_t ip6i_un1_hlim; /* hop limit */ 1057c478bd9Sstevel@tonic-gate } ip6i_un1; 1067c478bd9Sstevel@tonic-gate } ip6i_ctlun; 1077c478bd9Sstevel@tonic-gate int ip6i_flags; /* See below */ 1087c478bd9Sstevel@tonic-gate int ip6i_ifindex; 1097c478bd9Sstevel@tonic-gate int ip6i_checksum_off; 1107c478bd9Sstevel@tonic-gate int ip6i_pad; 1117c478bd9Sstevel@tonic-gate in6_addr_t ip6i_nexthop; /* Same offset as ip6_dst */ 1127c478bd9Sstevel@tonic-gate }; 1137c478bd9Sstevel@tonic-gate typedef struct ip6_info ip6i_t; 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate #define ip6i_flow ip6i_ctlun.ip6i_un1.ip6i_un1_flow 1167c478bd9Sstevel@tonic-gate #define ip6i_vcf ip6i_flow /* Version, class, flow */ 1177c478bd9Sstevel@tonic-gate #define ip6i_nxt ip6i_ctlun.ip6i_un1.ip6i_un1_nxt 1187c478bd9Sstevel@tonic-gate #define ip6i_hops ip6i_ctlun.ip6i_un1.ip6i_un1_hlim 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate /* ip6_info flags */ 1217c478bd9Sstevel@tonic-gate #define IP6I_IFINDEX 0x1 /* ip6i_ifindex is set (to nonzero value) */ 1227c478bd9Sstevel@tonic-gate #define IP6I_NEXTHOP 0x2 /* ip6i_nexthop is different than ip6_dst */ 1237c478bd9Sstevel@tonic-gate #define IP6I_NO_ULP_CKSUM 0x4 1247c478bd9Sstevel@tonic-gate /* 1257c478bd9Sstevel@tonic-gate * Do not generate TCP/UDP/SCTP transport checksum. 1267c478bd9Sstevel@tonic-gate * Used by raw sockets. Does not affect the 1277c478bd9Sstevel@tonic-gate * generation of transport checksums for ICMPv6 1287c478bd9Sstevel@tonic-gate * since such packets always arrive through 1297c478bd9Sstevel@tonic-gate * a raw socket. 1307c478bd9Sstevel@tonic-gate */ 1317c478bd9Sstevel@tonic-gate #define IP6I_UNSPEC_SRC 0x8 1327c478bd9Sstevel@tonic-gate /* Used to carry conn_unspec_src through ip_newroute* */ 1337c478bd9Sstevel@tonic-gate #define IP6I_RAW_CHECKSUM 0x10 1347c478bd9Sstevel@tonic-gate /* Compute checksum and stuff in ip6i_checksum_off */ 1357c478bd9Sstevel@tonic-gate #define IP6I_VERIFY_SRC 0x20 /* Verify ip6_src. Used when IPV6_PKTINFO */ 136*e11c3f44Smeem #define IP6I_IPMP_PROBE 0x40 /* IPMP (in.mpathd) probe packet */ 137*e11c3f44Smeem /* 0x80 - 0x100 available */ 1387c478bd9Sstevel@tonic-gate #define IP6I_DONTFRAG 0x200 /* Don't fragment this packet */ 1397c478bd9Sstevel@tonic-gate #define IP6I_HOPLIMIT 0x400 /* hoplimit has been set by the sender */ 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate /* 1427c478bd9Sstevel@tonic-gate * These constants refer to the IPV6_USE_MIN_MTU API. The 1437c478bd9Sstevel@tonic-gate * actually values used in the API are these values shifted down 1447c478bd9Sstevel@tonic-gate * 10 bits minus 2 [-1, 1]. 0 (-2 after conversion) is considered 1457c478bd9Sstevel@tonic-gate * the same as the default (-1). IP6I_API_USE_MIN_MTU(f, x) returns 1467c478bd9Sstevel@tonic-gate * the flags field updated with min mtu. IP6I_USE_MIN_MTU_API takes the 1477c478bd9Sstevel@tonic-gate * field and returns the API value (+ the -2 value). 1487c478bd9Sstevel@tonic-gate */ 1497c478bd9Sstevel@tonic-gate #define IP6I_USE_MIN_MTU_UNICAST 0x400 1507c478bd9Sstevel@tonic-gate #define IP6I_USE_MIN_MTU_ALWAYS 0x800 1517c478bd9Sstevel@tonic-gate #define IP6I_USE_MIN_MTU_NEVER 0xC00 1527c478bd9Sstevel@tonic-gate #define IP6I_USE_MIN_MTU_API(x) ((((x) & 0xC00) >> 10) - 2) 1537c478bd9Sstevel@tonic-gate #define IP6I_API_USE_MIN_MTU(f, x) (((f) & ~0xC00) &\ 1547c478bd9Sstevel@tonic-gate ((((x) + 2) & 0x3) << 11)) 1557c478bd9Sstevel@tonic-gate #define IPV6_USE_MIN_MTU_DEFAULT -2 1567c478bd9Sstevel@tonic-gate #define IPV6_USE_MIN_MTU_UNICAST -1 1577c478bd9Sstevel@tonic-gate #define IPV6_USE_MIN_MTU_ALWAYS 0 1587c478bd9Sstevel@tonic-gate #define IPV6_USE_MIN_MTU_NEVER 1 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate /* Extract the scope from a multicast address */ 1617c478bd9Sstevel@tonic-gate #ifdef _BIG_ENDIAN 1627c478bd9Sstevel@tonic-gate #define IN6_ADDR_MC_SCOPE(addr) \ 1637c478bd9Sstevel@tonic-gate (((addr)->s6_addr32[0] & 0x000f0000) >> 16) 1647c478bd9Sstevel@tonic-gate #else 1657c478bd9Sstevel@tonic-gate #define IN6_ADDR_MC_SCOPE(addr) \ 1667c478bd9Sstevel@tonic-gate (((addr)->s6_addr32[0] & 0x00000f00) >> 8) 1677c478bd9Sstevel@tonic-gate #endif 1687c478bd9Sstevel@tonic-gate 1697c478bd9Sstevel@tonic-gate /* Default IPv4 TTL for IPv6-in-IPv4 encapsulated packets */ 1707c478bd9Sstevel@tonic-gate #define IPV6_DEFAULT_HOPS 60 /* XXX What should it be? */ 1717c478bd9Sstevel@tonic-gate 1727c478bd9Sstevel@tonic-gate /* Max IPv6 TTL */ 1737c478bd9Sstevel@tonic-gate #define IPV6_MAX_HOPS 255 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gate /* Minimum IPv6 MTU from rfc2460 */ 1767c478bd9Sstevel@tonic-gate #define IPV6_MIN_MTU 1280 1777c478bd9Sstevel@tonic-gate 1787c478bd9Sstevel@tonic-gate /* EUI-64 based token length */ 1797c478bd9Sstevel@tonic-gate #define IPV6_TOKEN_LEN 64 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate /* Length of an advertised IPv6 prefix */ 1827c478bd9Sstevel@tonic-gate #define IPV6_PREFIX_LEN 64 1837c478bd9Sstevel@tonic-gate 1847c478bd9Sstevel@tonic-gate /* Default and maximum tunnel encapsulation limits. See RFC 2473. */ 1857c478bd9Sstevel@tonic-gate #define IPV6_DEFAULT_ENCAPLIMIT 4 1867c478bd9Sstevel@tonic-gate #define IPV6_MAX_ENCAPLIMIT 255 1877c478bd9Sstevel@tonic-gate 1887c478bd9Sstevel@tonic-gate /* 1897c478bd9Sstevel@tonic-gate * Minimum and maximum extension header lengths for IPv6. The 8-bit 1907c478bd9Sstevel@tonic-gate * length field of each extension header (see rfc2460) specifies the 1917c478bd9Sstevel@tonic-gate * number of 8 octet units of data in the header not including the 1927c478bd9Sstevel@tonic-gate * first 8 octets. A value of 0 would indicate 8 bytes (0 * 8 + 8), 1937c478bd9Sstevel@tonic-gate * and 255 would indicate 2048 bytes (255 * 8 + 8). 1947c478bd9Sstevel@tonic-gate */ 1957c478bd9Sstevel@tonic-gate #define MIN_EHDR_LEN 8 1967c478bd9Sstevel@tonic-gate #define MAX_EHDR_LEN 2048 1977c478bd9Sstevel@tonic-gate 1987c478bd9Sstevel@tonic-gate /* 1997c478bd9Sstevel@tonic-gate * The high-order bit of the version field is used by the transports to 2001934b508Skp158701 * indicate a reachability confirmation to IP. 2017c478bd9Sstevel@tonic-gate */ 2021934b508Skp158701 #define IP_FORWARD_PROG_BIT 0x8 2031934b508Skp158701 2047c478bd9Sstevel@tonic-gate #ifdef _BIG_ENDIAN 2057c478bd9Sstevel@tonic-gate #define IPV6_DEFAULT_VERS_AND_FLOW 0x60000000 2067c478bd9Sstevel@tonic-gate #define IPV6_VERS_AND_FLOW_MASK 0xF0000000 2071934b508Skp158701 #define IP_FORWARD_PROG ((uint32_t)IP_FORWARD_PROG_BIT << 28) 2087c478bd9Sstevel@tonic-gate #define V6_MCAST 0xFF000000 2097c478bd9Sstevel@tonic-gate #define V6_LINKLOCAL 0xFE800000 2107c478bd9Sstevel@tonic-gate 2117c478bd9Sstevel@tonic-gate #define IPV6_FLOW_TCLASS(x) (((x) & IPV6_FLOWINFO_TCLASS) >> 20) 2127c478bd9Sstevel@tonic-gate #define IPV6_TCLASS_FLOW(f, c) (((f) & ~IPV6_FLOWINFO_TCLASS) |\ 2137c478bd9Sstevel@tonic-gate ((c) << 20)) 2147c478bd9Sstevel@tonic-gate 2157c478bd9Sstevel@tonic-gate #else 2167c478bd9Sstevel@tonic-gate #define IPV6_DEFAULT_VERS_AND_FLOW 0x00000060 2177c478bd9Sstevel@tonic-gate #define IPV6_VERS_AND_FLOW_MASK 0x000000F0 2181934b508Skp158701 #define IP_FORWARD_PROG ((uint32_t)IP_FORWARD_PROG_BIT << 4) 2197c478bd9Sstevel@tonic-gate 2207c478bd9Sstevel@tonic-gate #define V6_MCAST 0x000000FF 2217c478bd9Sstevel@tonic-gate #define V6_LINKLOCAL 0x000080FE 2227c478bd9Sstevel@tonic-gate 2237c478bd9Sstevel@tonic-gate #define IPV6_FLOW_TCLASS(x) ((((x) & 0xf000U) >> 12) |\ 2247c478bd9Sstevel@tonic-gate (((x) & 0xf) << 4)) 2257c478bd9Sstevel@tonic-gate #define IPV6_TCLASS_FLOW(f, c) (((f) & ~IPV6_FLOWINFO_TCLASS) |\ 2267c478bd9Sstevel@tonic-gate ((((c) & 0xf) << 12) |\ 2277c478bd9Sstevel@tonic-gate (((c) & 0xf0) >> 4))) 2287c478bd9Sstevel@tonic-gate #endif 2297c478bd9Sstevel@tonic-gate 2307c478bd9Sstevel@tonic-gate /* 2317c478bd9Sstevel@tonic-gate * UTILITY MACROS FOR ADDRESSES. 2327c478bd9Sstevel@tonic-gate */ 2337c478bd9Sstevel@tonic-gate 2347c478bd9Sstevel@tonic-gate /* 2357c478bd9Sstevel@tonic-gate * Convert an IPv4 address mask to an IPv6 mask. Pad with 1-bits. 2367c478bd9Sstevel@tonic-gate */ 2377c478bd9Sstevel@tonic-gate #define V4MASK_TO_V6(v4, v6) ((v6).s6_addr32[0] = 0xffffffffUL, \ 2387c478bd9Sstevel@tonic-gate (v6).s6_addr32[1] = 0xffffffffUL, \ 2397c478bd9Sstevel@tonic-gate (v6).s6_addr32[2] = 0xffffffffUL, \ 2407c478bd9Sstevel@tonic-gate (v6).s6_addr32[3] = (v4)) 2417c478bd9Sstevel@tonic-gate 2427c478bd9Sstevel@tonic-gate /* 2437c478bd9Sstevel@tonic-gate * Convert aligned IPv4-mapped IPv6 address into an IPv4 address. 2447c478bd9Sstevel@tonic-gate * Note: We use "v6" here in definition of macro instead of "(v6)" 2457c478bd9Sstevel@tonic-gate * Not possible to use "(v6)" here since macro is used with struct 2467c478bd9Sstevel@tonic-gate * field names as arguments. 2477c478bd9Sstevel@tonic-gate */ 2487c478bd9Sstevel@tonic-gate #define V4_PART_OF_V6(v6) v6.s6_addr32[3] 2497c478bd9Sstevel@tonic-gate 2507c478bd9Sstevel@tonic-gate #ifdef _BIG_ENDIAN 2517c478bd9Sstevel@tonic-gate #define V6_OR_V4_INADDR_ANY(a) ((a).s6_addr32[3] == 0 && \ 2527c478bd9Sstevel@tonic-gate ((a).s6_addr32[2] == 0xffffU || \ 2537c478bd9Sstevel@tonic-gate (a).s6_addr32[2] == 0) && \ 2547c478bd9Sstevel@tonic-gate (a).s6_addr32[1] == 0 && \ 2557c478bd9Sstevel@tonic-gate (a).s6_addr32[0] == 0) 2567c478bd9Sstevel@tonic-gate 2577c478bd9Sstevel@tonic-gate #else 2587c478bd9Sstevel@tonic-gate #define V6_OR_V4_INADDR_ANY(a) ((a).s6_addr32[3] == 0 && \ 2597c478bd9Sstevel@tonic-gate ((a).s6_addr32[2] == 0xffff0000U || \ 2607c478bd9Sstevel@tonic-gate (a).s6_addr32[2] == 0) && \ 2617c478bd9Sstevel@tonic-gate (a).s6_addr32[1] == 0 && \ 2627c478bd9Sstevel@tonic-gate (a).s6_addr32[0] == 0) 2637c478bd9Sstevel@tonic-gate #endif /* _BIG_ENDIAN */ 2647c478bd9Sstevel@tonic-gate 2657c478bd9Sstevel@tonic-gate /* IPv4-mapped CLASSD addresses */ 2667c478bd9Sstevel@tonic-gate #ifdef _BIG_ENDIAN 2677c478bd9Sstevel@tonic-gate #define IN6_IS_ADDR_V4MAPPED_CLASSD(addr) \ 2687c478bd9Sstevel@tonic-gate (((addr)->_S6_un._S6_u32[2] == 0x0000ffff) && \ 2697c478bd9Sstevel@tonic-gate (CLASSD((addr)->_S6_un._S6_u32[3])) && \ 2707c478bd9Sstevel@tonic-gate ((addr)->_S6_un._S6_u32[1] == 0) && \ 2717c478bd9Sstevel@tonic-gate ((addr)->_S6_un._S6_u32[0] == 0)) 2727c478bd9Sstevel@tonic-gate #else /* _BIG_ENDIAN */ 2737c478bd9Sstevel@tonic-gate #define IN6_IS_ADDR_V4MAPPED_CLASSD(addr) \ 2747c478bd9Sstevel@tonic-gate (((addr)->_S6_un._S6_u32[2] == 0xffff0000U) && \ 2757c478bd9Sstevel@tonic-gate (CLASSD((addr)->_S6_un._S6_u32[3])) && \ 2767c478bd9Sstevel@tonic-gate ((addr)->_S6_un._S6_u32[1] == 0) && \ 2777c478bd9Sstevel@tonic-gate ((addr)->_S6_un._S6_u32[0] == 0)) 2787c478bd9Sstevel@tonic-gate #endif /* _BIG_ENDIAN */ 2797c478bd9Sstevel@tonic-gate 2807c478bd9Sstevel@tonic-gate /* Clear an IPv6 addr */ 2817c478bd9Sstevel@tonic-gate #define V6_SET_ZERO(a) ((a).s6_addr32[0] = 0, \ 2827c478bd9Sstevel@tonic-gate (a).s6_addr32[1] = 0, \ 2837c478bd9Sstevel@tonic-gate (a).s6_addr32[2] = 0, \ 2847c478bd9Sstevel@tonic-gate (a).s6_addr32[3] = 0) 2857c478bd9Sstevel@tonic-gate 2867c478bd9Sstevel@tonic-gate /* Mask comparison: is IPv6 addr a, and'ed with mask m, equal to addr b? */ 2877c478bd9Sstevel@tonic-gate #define V6_MASK_EQ(a, m, b) \ 2887c478bd9Sstevel@tonic-gate ((((a).s6_addr32[0] & (m).s6_addr32[0]) == (b).s6_addr32[0]) && \ 2897c478bd9Sstevel@tonic-gate (((a).s6_addr32[1] & (m).s6_addr32[1]) == (b).s6_addr32[1]) && \ 2907c478bd9Sstevel@tonic-gate (((a).s6_addr32[2] & (m).s6_addr32[2]) == (b).s6_addr32[2]) && \ 2917c478bd9Sstevel@tonic-gate (((a).s6_addr32[3] & (m).s6_addr32[3]) == (b).s6_addr32[3])) 2927c478bd9Sstevel@tonic-gate 2937c478bd9Sstevel@tonic-gate #define V6_MASK_EQ_2(a, m, b) \ 2947c478bd9Sstevel@tonic-gate ((((a).s6_addr32[0] & (m).s6_addr32[0]) == \ 2957c478bd9Sstevel@tonic-gate ((b).s6_addr32[0] & (m).s6_addr32[0])) && \ 2967c478bd9Sstevel@tonic-gate (((a).s6_addr32[1] & (m).s6_addr32[1]) == \ 2977c478bd9Sstevel@tonic-gate ((b).s6_addr32[1] & (m).s6_addr32[1])) && \ 2987c478bd9Sstevel@tonic-gate (((a).s6_addr32[2] & (m).s6_addr32[2]) == \ 2997c478bd9Sstevel@tonic-gate ((b).s6_addr32[2] & (m).s6_addr32[2])) && \ 3007c478bd9Sstevel@tonic-gate (((a).s6_addr32[3] & (m).s6_addr32[3]) == \ 3017c478bd9Sstevel@tonic-gate ((b).s6_addr32[3] & (m).s6_addr32[3]))) 3027c478bd9Sstevel@tonic-gate 3037c478bd9Sstevel@tonic-gate /* Copy IPv6 address (s), logically and'ed with mask (m), into (d) */ 3047c478bd9Sstevel@tonic-gate #define V6_MASK_COPY(s, m, d) \ 3057c478bd9Sstevel@tonic-gate ((d).s6_addr32[0] = (s).s6_addr32[0] & (m).s6_addr32[0], \ 3067c478bd9Sstevel@tonic-gate (d).s6_addr32[1] = (s).s6_addr32[1] & (m).s6_addr32[1], \ 3077c478bd9Sstevel@tonic-gate (d).s6_addr32[2] = (s).s6_addr32[2] & (m).s6_addr32[2], \ 3087c478bd9Sstevel@tonic-gate (d).s6_addr32[3] = (s).s6_addr32[3] & (m).s6_addr32[3]) 3097c478bd9Sstevel@tonic-gate 3107c478bd9Sstevel@tonic-gate #define ILL_FRAG_HASH_V6(v6addr, i) \ 3117c478bd9Sstevel@tonic-gate ((ntohl((v6addr).s6_addr32[3]) ^ (i ^ (i >> 8))) % \ 3127c478bd9Sstevel@tonic-gate ILL_FRAG_HASH_TBL_COUNT) 3137c478bd9Sstevel@tonic-gate 314f4b3ec61Sdh155122 3157c478bd9Sstevel@tonic-gate /* 3167c478bd9Sstevel@tonic-gate * GLOBAL EXTERNALS 3177c478bd9Sstevel@tonic-gate */ 3187c478bd9Sstevel@tonic-gate extern const in6_addr_t ipv6_all_ones; 3197c478bd9Sstevel@tonic-gate extern const in6_addr_t ipv6_all_zeros; 3207c478bd9Sstevel@tonic-gate extern const in6_addr_t ipv6_loopback; 3217c478bd9Sstevel@tonic-gate extern const in6_addr_t ipv6_all_hosts_mcast; 3227c478bd9Sstevel@tonic-gate extern const in6_addr_t ipv6_all_rtrs_mcast; 3237c478bd9Sstevel@tonic-gate extern const in6_addr_t ipv6_all_v2rtrs_mcast; 3247c478bd9Sstevel@tonic-gate extern const in6_addr_t ipv6_solicited_node_mcast; 3257c478bd9Sstevel@tonic-gate extern const in6_addr_t ipv6_unspecified_group; 3267c478bd9Sstevel@tonic-gate 3277c478bd9Sstevel@tonic-gate /* 3287c478bd9Sstevel@tonic-gate * FUNCTION PROTOTYPES 3297c478bd9Sstevel@tonic-gate */ 3307c478bd9Sstevel@tonic-gate 3317c478bd9Sstevel@tonic-gate struct ipsec_out_s; 3327c478bd9Sstevel@tonic-gate 3337c478bd9Sstevel@tonic-gate extern void convert2ascii(char *buf, const in6_addr_t *addr); 3347c478bd9Sstevel@tonic-gate extern char *inet_ntop(int, const void *, char *, int); 3357c478bd9Sstevel@tonic-gate extern int inet_pton(int, char *, void *); 3367c478bd9Sstevel@tonic-gate extern void icmp_time_exceeded_v6(queue_t *, mblk_t *, uint8_t, 337f4b3ec61Sdh155122 boolean_t, boolean_t, zoneid_t, ip_stack_t *); 3387c478bd9Sstevel@tonic-gate extern void icmp_unreachable_v6(queue_t *, mblk_t *, uint8_t, 339f4b3ec61Sdh155122 boolean_t, boolean_t, zoneid_t, ip_stack_t *); 3407c478bd9Sstevel@tonic-gate extern void icmp_inbound_error_fanout_v6(queue_t *, mblk_t *, ip6_t *, 341*e11c3f44Smeem icmp6_t *, ill_t *, ill_t *, boolean_t, zoneid_t); 3427c478bd9Sstevel@tonic-gate extern boolean_t conn_wantpacket_v6(conn_t *, ill_t *, ip6_t *, int, zoneid_t); 3437c478bd9Sstevel@tonic-gate extern mblk_t *ip_add_info_v6(mblk_t *, ill_t *, const in6_addr_t *); 3447c478bd9Sstevel@tonic-gate extern in6addr_scope_t ip_addr_scope_v6(const in6_addr_t *); 3457c478bd9Sstevel@tonic-gate extern mblk_t *ip_bind_v6(queue_t *, mblk_t *, conn_t *, ip6_pkt_t *); 3467c478bd9Sstevel@tonic-gate extern void ip_build_hdrs_v6(uchar_t *, uint_t, ip6_pkt_t *, uint8_t); 3477c478bd9Sstevel@tonic-gate extern int ip_fanout_send_icmp_v6(queue_t *, mblk_t *, uint_t, 348f4b3ec61Sdh155122 uint_t, uint8_t, uint_t, boolean_t, zoneid_t, ip_stack_t *); 3497c478bd9Sstevel@tonic-gate extern int ip_find_hdr_v6(mblk_t *, ip6_t *, ip6_pkt_t *, uint8_t *); 3507c478bd9Sstevel@tonic-gate extern in6_addr_t ip_get_dst_v6(ip6_t *, boolean_t *); 3517c478bd9Sstevel@tonic-gate extern ip6_rthdr_t *ip_find_rthdr_v6(ip6_t *, uint8_t *); 352f4b3ec61Sdh155122 extern int ip_hdr_complete_v6(ip6_t *, zoneid_t, ip_stack_t *); 3537c478bd9Sstevel@tonic-gate extern boolean_t ip_hdr_length_nexthdr_v6(mblk_t *, ip6_t *, 3547c478bd9Sstevel@tonic-gate uint16_t *, uint8_t **); 3557c478bd9Sstevel@tonic-gate extern int ip_hdr_length_v6(mblk_t *, ip6_t *); 356381a2a9aSdr146992 extern int ip_check_v6_mblk(mblk_t *, ill_t *); 357f4b3ec61Sdh155122 extern uint32_t ip_massage_options_v6(ip6_t *, ip6_rthdr_t *, netstack_t *); 358ff550d0eSmasputra extern void ip_wput_frag_v6(mblk_t *, ire_t *, uint_t, conn_t *, int, int); 3597c478bd9Sstevel@tonic-gate extern void ip_wput_ipsec_out_v6(queue_t *, mblk_t *, ip6_t *, ill_t *, 3607c478bd9Sstevel@tonic-gate ire_t *); 3617c478bd9Sstevel@tonic-gate extern int ip_total_hdrs_len_v6(ip6_pkt_t *); 3627c478bd9Sstevel@tonic-gate extern int ipsec_ah_get_hdr_size_v6(mblk_t *, boolean_t); 363fc80c0dfSnordmark extern void ip_wput_v6(queue_t *, mblk_t *); 3647c478bd9Sstevel@tonic-gate extern void ip_wput_local_v6(queue_t *, ill_t *, ip6_t *, mblk_t *, 365b127ac41SPhilip Kirk ire_t *, int, zoneid_t); 3667c478bd9Sstevel@tonic-gate extern void ip_output_v6(void *, mblk_t *, void *, int); 3677c478bd9Sstevel@tonic-gate extern void ip_xmit_v6(mblk_t *, ire_t *, uint_t, conn_t *, int, 3687c478bd9Sstevel@tonic-gate struct ipsec_out_s *); 369381a2a9aSdr146992 extern void ip_rput_v6(queue_t *, mblk_t *); 3707c478bd9Sstevel@tonic-gate extern void ip_rput_data_v6(queue_t *, ill_t *, mblk_t *, ip6_t *, 37169bb4bb4Scarlsonj uint_t, mblk_t *, mblk_t *); 3727c478bd9Sstevel@tonic-gate extern void mld_input(queue_t *, mblk_t *, ill_t *); 3737c478bd9Sstevel@tonic-gate extern void mld_joingroup(ilm_t *); 3747c478bd9Sstevel@tonic-gate extern void mld_leavegroup(ilm_t *); 3757c478bd9Sstevel@tonic-gate extern void mld_timeout_handler(void *); 3767c478bd9Sstevel@tonic-gate 3777c478bd9Sstevel@tonic-gate extern void pr_addr_dbg(char *, int, const void *); 3787c478bd9Sstevel@tonic-gate extern int ip_multirt_apply_membership_v6(int (*fn)(conn_t *, boolean_t, 3790f1702c5SYu Xiangning const in6_addr_t *, int, mcast_record_t, const in6_addr_t *, mblk_t *), 3800f1702c5SYu Xiangning ire_t *, conn_t *, boolean_t, const in6_addr_t *, mcast_record_t, 3810f1702c5SYu Xiangning const in6_addr_t *, mblk_t *); 3827c478bd9Sstevel@tonic-gate extern void ip_newroute_ipif_v6(queue_t *, mblk_t *, ipif_t *, 383*e11c3f44Smeem const in6_addr_t *, const in6_addr_t *, int, zoneid_t); 3847c478bd9Sstevel@tonic-gate extern void ip_newroute_v6(queue_t *, mblk_t *, const in6_addr_t *, 385f4b3ec61Sdh155122 const in6_addr_t *, ill_t *, zoneid_t, ip_stack_t *); 386f4b3ec61Sdh155122 extern void *ip6_kstat_init(netstackid_t, ip6_stat_t *); 387f4b3ec61Sdh155122 extern void ip6_kstat_fini(netstackid_t, kstat_t *); 3887c478bd9Sstevel@tonic-gate extern size_t ip6_get_src_preferences(conn_t *, uint32_t *); 3897c478bd9Sstevel@tonic-gate extern int ip6_set_src_preferences(conn_t *, uint32_t); 3907c478bd9Sstevel@tonic-gate extern int ip6_set_pktinfo(cred_t *, conn_t *, struct in6_pktinfo *, 3917c478bd9Sstevel@tonic-gate mblk_t *); 3920f1702c5SYu Xiangning extern int ip_proto_bind_laddr_v6(conn_t *, mblk_t **, uint8_t, 3930f1702c5SYu Xiangning const in6_addr_t *, uint16_t, boolean_t); 3940f1702c5SYu Xiangning extern int ip_proto_bind_connected_v6(conn_t *, mblk_t **, 3950f1702c5SYu Xiangning uint8_t, in6_addr_t *, uint16_t, const in6_addr_t *, ip6_pkt_t *, 3960f1702c5SYu Xiangning uint16_t, boolean_t, boolean_t); 3977c478bd9Sstevel@tonic-gate 3987c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 3997c478bd9Sstevel@tonic-gate 4007c478bd9Sstevel@tonic-gate #ifdef __cplusplus 4017c478bd9Sstevel@tonic-gate } 4027c478bd9Sstevel@tonic-gate #endif 4037c478bd9Sstevel@tonic-gate 4047c478bd9Sstevel@tonic-gate #endif /* _INET_IP6_H */ 405