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