1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _NETINET_ICMP6_H 28*7c478bd9Sstevel@tonic-gate #define _NETINET_ICMP6_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 33*7c478bd9Sstevel@tonic-gate extern "C" { 34*7c478bd9Sstevel@tonic-gate #endif 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate /* 39*7c478bd9Sstevel@tonic-gate * Type and code definitions for ICMPv6. 40*7c478bd9Sstevel@tonic-gate * Based on RFC2292. 41*7c478bd9Sstevel@tonic-gate */ 42*7c478bd9Sstevel@tonic-gate 43*7c478bd9Sstevel@tonic-gate #define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */ 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate /* Minimum ICMPv6 header length. */ 46*7c478bd9Sstevel@tonic-gate #define ICMP6_MINLEN 8 47*7c478bd9Sstevel@tonic-gate 48*7c478bd9Sstevel@tonic-gate typedef struct icmp6_hdr { 49*7c478bd9Sstevel@tonic-gate uint8_t icmp6_type; /* type field */ 50*7c478bd9Sstevel@tonic-gate uint8_t icmp6_code; /* code field */ 51*7c478bd9Sstevel@tonic-gate uint16_t icmp6_cksum; /* checksum field */ 52*7c478bd9Sstevel@tonic-gate union { 53*7c478bd9Sstevel@tonic-gate uint32_t icmp6_un_data32[1]; /* type-specific field */ 54*7c478bd9Sstevel@tonic-gate uint16_t icmp6_un_data16[2]; /* type-specific field */ 55*7c478bd9Sstevel@tonic-gate uint8_t icmp6_un_data8[4]; /* type-specific field */ 56*7c478bd9Sstevel@tonic-gate } icmp6_dataun; 57*7c478bd9Sstevel@tonic-gate } icmp6_t; 58*7c478bd9Sstevel@tonic-gate 59*7c478bd9Sstevel@tonic-gate #define icmp6_data32 icmp6_dataun.icmp6_un_data32 60*7c478bd9Sstevel@tonic-gate #define icmp6_data16 icmp6_dataun.icmp6_un_data16 61*7c478bd9Sstevel@tonic-gate #define icmp6_data8 icmp6_dataun.icmp6_un_data8 62*7c478bd9Sstevel@tonic-gate #define icmp6_pptr icmp6_data32[0] /* parameter prob */ 63*7c478bd9Sstevel@tonic-gate #define icmp6_mtu icmp6_data32[0] /* packet too big */ 64*7c478bd9Sstevel@tonic-gate #define icmp6_id icmp6_data16[0] /* echo request/reply */ 65*7c478bd9Sstevel@tonic-gate #define icmp6_seq icmp6_data16[1] /* echo request/reply */ 66*7c478bd9Sstevel@tonic-gate #define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */ 67*7c478bd9Sstevel@tonic-gate 68*7c478bd9Sstevel@tonic-gate /* Multicast Listener Discovery messages (RFC 3542 (v1), RFC 3810 (v2)). */ 69*7c478bd9Sstevel@tonic-gate 70*7c478bd9Sstevel@tonic-gate #define MLD_MINLEN 24 71*7c478bd9Sstevel@tonic-gate #define MLD_V2_QUERY_MINLEN 28 72*7c478bd9Sstevel@tonic-gate 73*7c478bd9Sstevel@tonic-gate /* Query Header, common to v1 and v2 */ 74*7c478bd9Sstevel@tonic-gate typedef struct mld_hdr { 75*7c478bd9Sstevel@tonic-gate struct icmp6_hdr mld_icmp6_hdr; 76*7c478bd9Sstevel@tonic-gate struct in6_addr mld_addr; /* multicast address */ 77*7c478bd9Sstevel@tonic-gate } mld_hdr_t; 78*7c478bd9Sstevel@tonic-gate 79*7c478bd9Sstevel@tonic-gate #define mld_type mld_icmp6_hdr.icmp6_type 80*7c478bd9Sstevel@tonic-gate #define mld_code mld_icmp6_hdr.icmp6_code 81*7c478bd9Sstevel@tonic-gate #define mld_cksum mld_icmp6_hdr.icmp6_cksum 82*7c478bd9Sstevel@tonic-gate #define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0] 83*7c478bd9Sstevel@tonic-gate #define mld_reserved mld_icmp6_hdr.icmp6_data16[1] 84*7c478bd9Sstevel@tonic-gate 85*7c478bd9Sstevel@tonic-gate /* MLDv2 query */ 86*7c478bd9Sstevel@tonic-gate typedef struct mld2q { 87*7c478bd9Sstevel@tonic-gate mld_hdr_t mld2q_hdr; 88*7c478bd9Sstevel@tonic-gate uint8_t mld2q_sqrv; /* S Flag, Q's Robustness Variable */ 89*7c478bd9Sstevel@tonic-gate uint8_t mld2q_qqic; /* Querier's Query Interval Code */ 90*7c478bd9Sstevel@tonic-gate uint16_t mld2q_numsrc; /* number of sources */ 91*7c478bd9Sstevel@tonic-gate } mld2q_t; 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate #define mld2q_type mld2q_hdr.mld_icmp6_hdr.icmp6_type 94*7c478bd9Sstevel@tonic-gate #define mld2q_code mld2q_hdr.mld_icmp6_hdr.icmp6_code 95*7c478bd9Sstevel@tonic-gate #define mld2q_cksum mld2q_hdr.mld_icmp6_hdr.icmp6_cksum 96*7c478bd9Sstevel@tonic-gate #define mld2q_mxrc mld2q_hdr.mld_icmp6_hdr.icmp6_data16[0] 97*7c478bd9Sstevel@tonic-gate #define mld2q_addr mld2q_hdr.mld_addr 98*7c478bd9Sstevel@tonic-gate 99*7c478bd9Sstevel@tonic-gate #define MLD_V2_SFLAG_MASK 0x8 /* mask off s part of sqrv */ 100*7c478bd9Sstevel@tonic-gate #define MLD_V2_RV_MASK 0x7 /* mask off qrv part of sqrv */ 101*7c478bd9Sstevel@tonic-gate 102*7c478bd9Sstevel@tonic-gate /* definitions used to extract max response delay from mrc field */ 103*7c478bd9Sstevel@tonic-gate #define MLD_V2_MAXRT_FPMIN 0x8000 104*7c478bd9Sstevel@tonic-gate #define MLD_V2_MAXRT_MANT_MASK 0x0fff 105*7c478bd9Sstevel@tonic-gate #define MLD_V2_MAXRT_EXP_MASK 0x7000 106*7c478bd9Sstevel@tonic-gate 107*7c478bd9Sstevel@tonic-gate /* definitions used to extract querier's query interval from qqic field */ 108*7c478bd9Sstevel@tonic-gate #define MLD_V2_QQI_FPMIN 0x80 109*7c478bd9Sstevel@tonic-gate #define MLD_V2_QQI_MANT_MASK 0x0f 110*7c478bd9Sstevel@tonic-gate #define MLD_V2_QQI_EXP_MASK 0x70 111*7c478bd9Sstevel@tonic-gate 112*7c478bd9Sstevel@tonic-gate /* MLDv2 response */ 113*7c478bd9Sstevel@tonic-gate typedef icmp6_t mld2r_t; 114*7c478bd9Sstevel@tonic-gate 115*7c478bd9Sstevel@tonic-gate #define mld2r_type icmp6_type 116*7c478bd9Sstevel@tonic-gate #define mld2r_res icmp6_code 117*7c478bd9Sstevel@tonic-gate #define mld2r_cksum icmp6_cksum 118*7c478bd9Sstevel@tonic-gate #define mld2r_res1 icmp6_data16[0] 119*7c478bd9Sstevel@tonic-gate #define mld2r_nummar icmp6_data16[1] 120*7c478bd9Sstevel@tonic-gate 121*7c478bd9Sstevel@tonic-gate /* MLDv2 multicast address record */ 122*7c478bd9Sstevel@tonic-gate typedef struct mld2mar { 123*7c478bd9Sstevel@tonic-gate uint8_t mld2mar_type; /* type of record */ 124*7c478bd9Sstevel@tonic-gate uint8_t mld2mar_auxlen; /* auxiliary data length */ 125*7c478bd9Sstevel@tonic-gate uint16_t mld2mar_numsrc; /* number of sources */ 126*7c478bd9Sstevel@tonic-gate struct in6_addr mld2mar_group; /* group address being reported */ 127*7c478bd9Sstevel@tonic-gate } mld2mar_t; 128*7c478bd9Sstevel@tonic-gate 129*7c478bd9Sstevel@tonic-gate 130*7c478bd9Sstevel@tonic-gate /* For router renumbering. */ 131*7c478bd9Sstevel@tonic-gate struct icmp6_router_renum { /* router renumbering header */ 132*7c478bd9Sstevel@tonic-gate struct icmp6_hdr rr_hdr; 133*7c478bd9Sstevel@tonic-gate uint8_t rr_segnum; 134*7c478bd9Sstevel@tonic-gate uint8_t rr_flags; 135*7c478bd9Sstevel@tonic-gate uint16_t rr_maxdelay; 136*7c478bd9Sstevel@tonic-gate uint32_t rr_reserved; 137*7c478bd9Sstevel@tonic-gate }; 138*7c478bd9Sstevel@tonic-gate 139*7c478bd9Sstevel@tonic-gate #define rr_type rr_hdr.icmp6_type 140*7c478bd9Sstevel@tonic-gate #define rr_code rr_hdr.icmp6_code 141*7c478bd9Sstevel@tonic-gate #define rr_cksum rr_hdr.icmp6_cksum 142*7c478bd9Sstevel@tonic-gate #define rr_seqnum rr_hdr.icmp6_data32[0] 143*7c478bd9Sstevel@tonic-gate 144*7c478bd9Sstevel@tonic-gate /* Router renumbering flags */ 145*7c478bd9Sstevel@tonic-gate #define ICMP6_RR_FLAGS_TEST 0x80 146*7c478bd9Sstevel@tonic-gate #define ICMP6_RR_FLAGS_REQRESULT 0x40 147*7c478bd9Sstevel@tonic-gate #define ICMP6_RR_FLAGS_FORCEAPPLY 0x20 148*7c478bd9Sstevel@tonic-gate #define ICMP6_RR_FLAGS_SPECSITE 0x10 149*7c478bd9Sstevel@tonic-gate #define ICMP6_RR_FLAGS_PREVDONE 0x08 150*7c478bd9Sstevel@tonic-gate 151*7c478bd9Sstevel@tonic-gate struct rr_pco_match { /* match prefix part */ 152*7c478bd9Sstevel@tonic-gate uint8_t rpm_code; 153*7c478bd9Sstevel@tonic-gate uint8_t rpm_len; 154*7c478bd9Sstevel@tonic-gate uint8_t rpm_ordinal; 155*7c478bd9Sstevel@tonic-gate uint8_t rpm_matchlen; 156*7c478bd9Sstevel@tonic-gate uint8_t rpm_minlen; 157*7c478bd9Sstevel@tonic-gate uint8_t rpm_maxlen; 158*7c478bd9Sstevel@tonic-gate uint16_t rpm_reserved; 159*7c478bd9Sstevel@tonic-gate struct in6_addr rpm_prefix; 160*7c478bd9Sstevel@tonic-gate }; 161*7c478bd9Sstevel@tonic-gate 162*7c478bd9Sstevel@tonic-gate /* PCO code values */ 163*7c478bd9Sstevel@tonic-gate #define RPM_PCO_ADD 1 164*7c478bd9Sstevel@tonic-gate #define RPM_PCO_CHANGE 2 165*7c478bd9Sstevel@tonic-gate #define RPM_PCO_SETGLOBAL 3 166*7c478bd9Sstevel@tonic-gate 167*7c478bd9Sstevel@tonic-gate struct rr_pco_use { /* use prefix part */ 168*7c478bd9Sstevel@tonic-gate uint8_t rpu_uselen; 169*7c478bd9Sstevel@tonic-gate uint8_t rpu_keeplen; 170*7c478bd9Sstevel@tonic-gate uint8_t rpu_ramask; 171*7c478bd9Sstevel@tonic-gate uint8_t rpu_raflags; 172*7c478bd9Sstevel@tonic-gate uint32_t rpu_vltime; 173*7c478bd9Sstevel@tonic-gate uint32_t rpu_pltime; 174*7c478bd9Sstevel@tonic-gate uint32_t rpu_flags; 175*7c478bd9Sstevel@tonic-gate struct in6_addr rpu_prefix; 176*7c478bd9Sstevel@tonic-gate }; 177*7c478bd9Sstevel@tonic-gate 178*7c478bd9Sstevel@tonic-gate #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x20 179*7c478bd9Sstevel@tonic-gate #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x10 180*7c478bd9Sstevel@tonic-gate 181*7c478bd9Sstevel@tonic-gate #ifdef _BIG_ENDIAN 182*7c478bd9Sstevel@tonic-gate #define ICMP_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000 183*7c478bd9Sstevel@tonic-gate #define ICMP_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000 184*7c478bd9Sstevel@tonic-gate #else /* _BIG_ENDIAN */ 185*7c478bd9Sstevel@tonic-gate #define ICMP_RR_PCOUSE_FLAGS_DECRVLTIME 0x80 186*7c478bd9Sstevel@tonic-gate #define ICMP_RR_PCOUSE_FLAGS_DECRPLTIME 0x40 187*7c478bd9Sstevel@tonic-gate #endif /* _BIG_ENDIAN */ 188*7c478bd9Sstevel@tonic-gate 189*7c478bd9Sstevel@tonic-gate struct rr_result { /* router renumbering result message */ 190*7c478bd9Sstevel@tonic-gate uint16_t rrr_flags; 191*7c478bd9Sstevel@tonic-gate uint8_t rrr_ordinal; 192*7c478bd9Sstevel@tonic-gate uint8_t rrr_matchedlen; 193*7c478bd9Sstevel@tonic-gate uint32_t rrr_ifid; 194*7c478bd9Sstevel@tonic-gate struct in6_addr rrr_prefix; 195*7c478bd9Sstevel@tonic-gate }; 196*7c478bd9Sstevel@tonic-gate 197*7c478bd9Sstevel@tonic-gate #ifdef _BIG_ENDIAN 198*7c478bd9Sstevel@tonic-gate #define ICMP6_RR_RESULT_FLAGS_OOB 0x0002 199*7c478bd9Sstevel@tonic-gate #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001 200*7c478bd9Sstevel@tonic-gate #else /* _BIG_ENDIAN */ 201*7c478bd9Sstevel@tonic-gate #define ICMP6_RR_RESULT_FLAGS_OOB 0x0200 202*7c478bd9Sstevel@tonic-gate #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100 203*7c478bd9Sstevel@tonic-gate #endif /* _BIG_ENDIAN */ 204*7c478bd9Sstevel@tonic-gate 205*7c478bd9Sstevel@tonic-gate /* ICMPv6 error types */ 206*7c478bd9Sstevel@tonic-gate #define ICMP6_DST_UNREACH 1 207*7c478bd9Sstevel@tonic-gate #define ICMP6_PACKET_TOO_BIG 2 208*7c478bd9Sstevel@tonic-gate #define ICMP6_TIME_EXCEEDED 3 209*7c478bd9Sstevel@tonic-gate #define ICMP6_PARAM_PROB 4 210*7c478bd9Sstevel@tonic-gate 211*7c478bd9Sstevel@tonic-gate #define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */ 212*7c478bd9Sstevel@tonic-gate 213*7c478bd9Sstevel@tonic-gate /* ICMPv6 query types */ 214*7c478bd9Sstevel@tonic-gate #define ICMP6_ECHO_REQUEST 128 215*7c478bd9Sstevel@tonic-gate #define ICMP6_ECHO_REPLY 129 216*7c478bd9Sstevel@tonic-gate 217*7c478bd9Sstevel@tonic-gate /* 218*7c478bd9Sstevel@tonic-gate * ICMPv6 group membership types 219*7c478bd9Sstevel@tonic-gate * ICMP6_MEMBERSHIP* types are the older names for these constants and should 220*7c478bd9Sstevel@tonic-gate * not be used in new code. 221*7c478bd9Sstevel@tonic-gate */ 222*7c478bd9Sstevel@tonic-gate #define MLD_LISTENER_QUERY 130 223*7c478bd9Sstevel@tonic-gate #define ICMP6_MEMBERSHIP_QUERY 130 224*7c478bd9Sstevel@tonic-gate #define MLD_LISTENER_REPORT 131 225*7c478bd9Sstevel@tonic-gate #define ICMP6_MEMBERSHIP_REPORT 131 226*7c478bd9Sstevel@tonic-gate #define MLD_LISTENER_REDUCTION 132 227*7c478bd9Sstevel@tonic-gate #define ICMP6_MEMBERSHIP_REDUCTION 132 228*7c478bd9Sstevel@tonic-gate #define MLD_V2_LISTENER_REPORT 143 229*7c478bd9Sstevel@tonic-gate 230*7c478bd9Sstevel@tonic-gate /* types for neighbor discovery */ 231*7c478bd9Sstevel@tonic-gate #define ND_ROUTER_SOLICIT 133 232*7c478bd9Sstevel@tonic-gate #define ND_ROUTER_ADVERT 134 233*7c478bd9Sstevel@tonic-gate #define ND_NEIGHBOR_SOLICIT 135 234*7c478bd9Sstevel@tonic-gate #define ND_NEIGHBOR_ADVERT 136 235*7c478bd9Sstevel@tonic-gate #define ND_REDIRECT 137 236*7c478bd9Sstevel@tonic-gate 237*7c478bd9Sstevel@tonic-gate /* router renumbering */ 238*7c478bd9Sstevel@tonic-gate #define ICMP6_ROUTER_RENUMBERING 138 239*7c478bd9Sstevel@tonic-gate 240*7c478bd9Sstevel@tonic-gate #define ICMP6_MAX_INFO_TYPE 138 241*7c478bd9Sstevel@tonic-gate 242*7c478bd9Sstevel@tonic-gate #define ICMP6_IS_ERROR(x) ((x) < 128) 243*7c478bd9Sstevel@tonic-gate 244*7c478bd9Sstevel@tonic-gate /* codes for ICMP6_DST_UNREACH */ 245*7c478bd9Sstevel@tonic-gate #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */ 246*7c478bd9Sstevel@tonic-gate #define ICMP6_DST_UNREACH_ADMIN 1 /* communication with destination */ 247*7c478bd9Sstevel@tonic-gate /* administratively prohibited */ 248*7c478bd9Sstevel@tonic-gate #define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor */ 249*7c478bd9Sstevel@tonic-gate #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source */ 250*7c478bd9Sstevel@tonic-gate #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */ 251*7c478bd9Sstevel@tonic-gate #define ICMP6_DST_UNREACH_NOPORT 4 /* bad port */ 252*7c478bd9Sstevel@tonic-gate 253*7c478bd9Sstevel@tonic-gate /* codes for ICMP6_TIME_EXCEEDED */ 254*7c478bd9Sstevel@tonic-gate #define ICMP6_TIME_EXCEED_TRANSIT 0 /* Hop Limit == 0 in transit */ 255*7c478bd9Sstevel@tonic-gate #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* Reassembly time out */ 256*7c478bd9Sstevel@tonic-gate 257*7c478bd9Sstevel@tonic-gate /* codes for ICMP6_PARAM_PROB */ 258*7c478bd9Sstevel@tonic-gate #define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */ 259*7c478bd9Sstevel@tonic-gate #define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized Next Header */ 260*7c478bd9Sstevel@tonic-gate #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized IPv6 option */ 261*7c478bd9Sstevel@tonic-gate 262*7c478bd9Sstevel@tonic-gate /* Default MLD max report delay value */ 263*7c478bd9Sstevel@tonic-gate #define ICMP6_MAX_HOST_REPORT_DELAY 10 /* max delay for response to */ 264*7c478bd9Sstevel@tonic-gate /* query (in seconds) */ 265*7c478bd9Sstevel@tonic-gate 266*7c478bd9Sstevel@tonic-gate typedef struct nd_router_solicit { /* router solicitation */ 267*7c478bd9Sstevel@tonic-gate icmp6_t nd_rs_hdr; 268*7c478bd9Sstevel@tonic-gate /* could be followed by options */ 269*7c478bd9Sstevel@tonic-gate } nd_router_solicit_t; 270*7c478bd9Sstevel@tonic-gate 271*7c478bd9Sstevel@tonic-gate #define nd_rs_type nd_rs_hdr.icmp6_type 272*7c478bd9Sstevel@tonic-gate #define nd_rs_code nd_rs_hdr.icmp6_code 273*7c478bd9Sstevel@tonic-gate #define nd_rs_cksum nd_rs_hdr.icmp6_cksum 274*7c478bd9Sstevel@tonic-gate #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0] 275*7c478bd9Sstevel@tonic-gate 276*7c478bd9Sstevel@tonic-gate typedef struct nd_router_advert { /* router advertisement */ 277*7c478bd9Sstevel@tonic-gate icmp6_t nd_ra_hdr; 278*7c478bd9Sstevel@tonic-gate uint32_t nd_ra_reachable; /* reachable time */ 279*7c478bd9Sstevel@tonic-gate uint32_t nd_ra_retransmit; /* retransmit timer */ 280*7c478bd9Sstevel@tonic-gate /* could be followed by options */ 281*7c478bd9Sstevel@tonic-gate } nd_router_advert_t; 282*7c478bd9Sstevel@tonic-gate 283*7c478bd9Sstevel@tonic-gate #define nd_ra_type nd_ra_hdr.icmp6_type 284*7c478bd9Sstevel@tonic-gate #define nd_ra_code nd_ra_hdr.icmp6_code 285*7c478bd9Sstevel@tonic-gate #define nd_ra_cksum nd_ra_hdr.icmp6_cksum 286*7c478bd9Sstevel@tonic-gate #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0] 287*7c478bd9Sstevel@tonic-gate #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1] 288*7c478bd9Sstevel@tonic-gate 289*7c478bd9Sstevel@tonic-gate #define ND_RA_FLAG_OTHER 0x40 290*7c478bd9Sstevel@tonic-gate #define ND_RA_FLAG_MANAGED 0x80 291*7c478bd9Sstevel@tonic-gate 292*7c478bd9Sstevel@tonic-gate #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1] 293*7c478bd9Sstevel@tonic-gate 294*7c478bd9Sstevel@tonic-gate typedef struct nd_neighbor_solicit { /* neighbor solicitation */ 295*7c478bd9Sstevel@tonic-gate icmp6_t nd_ns_hdr; 296*7c478bd9Sstevel@tonic-gate struct in6_addr nd_ns_target; /* target address */ 297*7c478bd9Sstevel@tonic-gate /* could be followed by options */ 298*7c478bd9Sstevel@tonic-gate } nd_neighbor_solicit_t; 299*7c478bd9Sstevel@tonic-gate 300*7c478bd9Sstevel@tonic-gate #define nd_ns_type nd_ns_hdr.icmp6_type 301*7c478bd9Sstevel@tonic-gate #define nd_ns_code nd_ns_hdr.icmp6_code 302*7c478bd9Sstevel@tonic-gate #define nd_ns_cksum nd_ns_hdr.icmp6_cksum 303*7c478bd9Sstevel@tonic-gate #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0] 304*7c478bd9Sstevel@tonic-gate 305*7c478bd9Sstevel@tonic-gate typedef struct nd_neighbor_advert { /* neighbor advertisement */ 306*7c478bd9Sstevel@tonic-gate icmp6_t nd_na_hdr; 307*7c478bd9Sstevel@tonic-gate struct in6_addr nd_na_target; /* target address */ 308*7c478bd9Sstevel@tonic-gate /* could be followed by options */ 309*7c478bd9Sstevel@tonic-gate } nd_neighbor_advert_t; 310*7c478bd9Sstevel@tonic-gate 311*7c478bd9Sstevel@tonic-gate #define nd_na_type nd_na_hdr.icmp6_type 312*7c478bd9Sstevel@tonic-gate #define nd_na_code nd_na_hdr.icmp6_code 313*7c478bd9Sstevel@tonic-gate #define nd_na_cksum nd_na_hdr.icmp6_cksum 314*7c478bd9Sstevel@tonic-gate 315*7c478bd9Sstevel@tonic-gate #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0] 316*7c478bd9Sstevel@tonic-gate 317*7c478bd9Sstevel@tonic-gate /* 318*7c478bd9Sstevel@tonic-gate * The first three bits of the flgs_reserved field of the ND structure are 319*7c478bd9Sstevel@tonic-gate * defined in this order: 320*7c478bd9Sstevel@tonic-gate * Router flag 321*7c478bd9Sstevel@tonic-gate * Solicited flag 322*7c478bd9Sstevel@tonic-gate * Override flag 323*7c478bd9Sstevel@tonic-gate */ 324*7c478bd9Sstevel@tonic-gate 325*7c478bd9Sstevel@tonic-gate /* Save valuable htonl() cycles on little-endian boxen. */ 326*7c478bd9Sstevel@tonic-gate 327*7c478bd9Sstevel@tonic-gate #ifdef _BIG_ENDIAN 328*7c478bd9Sstevel@tonic-gate 329*7c478bd9Sstevel@tonic-gate #define ND_NA_FLAG_ROUTER 0x80000000 330*7c478bd9Sstevel@tonic-gate #define ND_NA_FLAG_SOLICITED 0x40000000 331*7c478bd9Sstevel@tonic-gate #define ND_NA_FLAG_OVERRIDE 0x20000000 332*7c478bd9Sstevel@tonic-gate 333*7c478bd9Sstevel@tonic-gate #else /* _BIG_ENDIAN */ 334*7c478bd9Sstevel@tonic-gate 335*7c478bd9Sstevel@tonic-gate #define ND_NA_FLAG_ROUTER 0x80 336*7c478bd9Sstevel@tonic-gate #define ND_NA_FLAG_SOLICITED 0x40 337*7c478bd9Sstevel@tonic-gate #define ND_NA_FLAG_OVERRIDE 0x20 338*7c478bd9Sstevel@tonic-gate 339*7c478bd9Sstevel@tonic-gate #endif /* _BIG_ENDIAN */ 340*7c478bd9Sstevel@tonic-gate 341*7c478bd9Sstevel@tonic-gate typedef struct nd_redirect { /* redirect */ 342*7c478bd9Sstevel@tonic-gate icmp6_t nd_rd_hdr; 343*7c478bd9Sstevel@tonic-gate struct in6_addr nd_rd_target; /* target address */ 344*7c478bd9Sstevel@tonic-gate struct in6_addr nd_rd_dst; /* destination address */ 345*7c478bd9Sstevel@tonic-gate /* could be followed by options */ 346*7c478bd9Sstevel@tonic-gate } nd_redirect_t; 347*7c478bd9Sstevel@tonic-gate 348*7c478bd9Sstevel@tonic-gate #define nd_rd_type nd_rd_hdr.icmp6_type 349*7c478bd9Sstevel@tonic-gate #define nd_rd_code nd_rd_hdr.icmp6_code 350*7c478bd9Sstevel@tonic-gate #define nd_rd_cksum nd_rd_hdr.icmp6_cksum 351*7c478bd9Sstevel@tonic-gate #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0] 352*7c478bd9Sstevel@tonic-gate 353*7c478bd9Sstevel@tonic-gate typedef struct nd_opt_hdr { /* Neighbor discovery option header */ 354*7c478bd9Sstevel@tonic-gate uint8_t nd_opt_type; 355*7c478bd9Sstevel@tonic-gate uint8_t nd_opt_len; /* in units of 8 octets */ 356*7c478bd9Sstevel@tonic-gate /* followed by option specific data */ 357*7c478bd9Sstevel@tonic-gate } nd_opt_hdr_t; 358*7c478bd9Sstevel@tonic-gate 359*7c478bd9Sstevel@tonic-gate /* Neighbor discovery option types */ 360*7c478bd9Sstevel@tonic-gate #define ND_OPT_SOURCE_LINKADDR 1 361*7c478bd9Sstevel@tonic-gate #define ND_OPT_TARGET_LINKADDR 2 362*7c478bd9Sstevel@tonic-gate #define ND_OPT_PREFIX_INFORMATION 3 363*7c478bd9Sstevel@tonic-gate #define ND_OPT_REDIRECTED_HEADER 4 364*7c478bd9Sstevel@tonic-gate #define ND_OPT_MTU 5 365*7c478bd9Sstevel@tonic-gate 366*7c478bd9Sstevel@tonic-gate typedef struct nd_opt_prefix_info { /* prefix information */ 367*7c478bd9Sstevel@tonic-gate uint8_t nd_opt_pi_type; 368*7c478bd9Sstevel@tonic-gate uint8_t nd_opt_pi_len; 369*7c478bd9Sstevel@tonic-gate uint8_t nd_opt_pi_prefix_len; 370*7c478bd9Sstevel@tonic-gate uint8_t nd_opt_pi_flags_reserved; 371*7c478bd9Sstevel@tonic-gate uint32_t nd_opt_pi_valid_time; 372*7c478bd9Sstevel@tonic-gate uint32_t nd_opt_pi_preferred_time; 373*7c478bd9Sstevel@tonic-gate uint32_t nd_opt_pi_reserved2; 374*7c478bd9Sstevel@tonic-gate struct in6_addr nd_opt_pi_prefix; 375*7c478bd9Sstevel@tonic-gate } nd_opt_prefix_info_t; 376*7c478bd9Sstevel@tonic-gate 377*7c478bd9Sstevel@tonic-gate #define ND_OPT_PI_FLAG_AUTO 0x40 378*7c478bd9Sstevel@tonic-gate #define ND_OPT_PI_FLAG_ONLINK 0x80 379*7c478bd9Sstevel@tonic-gate 380*7c478bd9Sstevel@tonic-gate typedef struct nd_opt_rd_hdr { /* redirected header */ 381*7c478bd9Sstevel@tonic-gate uint8_t nd_opt_rh_type; 382*7c478bd9Sstevel@tonic-gate uint8_t nd_opt_rh_len; 383*7c478bd9Sstevel@tonic-gate uint16_t nd_opt_rh_reserved1; 384*7c478bd9Sstevel@tonic-gate uint32_t nd_opt_rh_reserved2; 385*7c478bd9Sstevel@tonic-gate /* followed by IP header and data */ 386*7c478bd9Sstevel@tonic-gate } nd_opt_rd_hdr_t; 387*7c478bd9Sstevel@tonic-gate 388*7c478bd9Sstevel@tonic-gate typedef struct nd_opt_mtu { /* MTU option */ 389*7c478bd9Sstevel@tonic-gate uint8_t nd_opt_mtu_type; 390*7c478bd9Sstevel@tonic-gate uint8_t nd_opt_mtu_len; 391*7c478bd9Sstevel@tonic-gate uint16_t nd_opt_mtu_reserved; 392*7c478bd9Sstevel@tonic-gate uint32_t nd_opt_mtu_mtu; 393*7c478bd9Sstevel@tonic-gate } nd_opt_mtu_t; 394*7c478bd9Sstevel@tonic-gate 395*7c478bd9Sstevel@tonic-gate /* Note: the option is variable length (at least 8 bytes long) */ 396*7c478bd9Sstevel@tonic-gate #ifndef ND_MAX_HDW_LEN 397*7c478bd9Sstevel@tonic-gate #define ND_MAX_HDW_LEN 64 398*7c478bd9Sstevel@tonic-gate #endif 399*7c478bd9Sstevel@tonic-gate struct nd_opt_lla { 400*7c478bd9Sstevel@tonic-gate uint8_t nd_opt_lla_type; 401*7c478bd9Sstevel@tonic-gate uint8_t nd_opt_lla_len; /* in units of 8 octets */ 402*7c478bd9Sstevel@tonic-gate uint8_t nd_opt_lla_hdw_addr[ND_MAX_HDW_LEN]; 403*7c478bd9Sstevel@tonic-gate }; 404*7c478bd9Sstevel@tonic-gate 405*7c478bd9Sstevel@tonic-gate 406*7c478bd9Sstevel@tonic-gate /* Neighbor discovery protocol constants */ 407*7c478bd9Sstevel@tonic-gate 408*7c478bd9Sstevel@tonic-gate /* Router constants */ 409*7c478bd9Sstevel@tonic-gate #define ND_MAX_INITIAL_RTR_ADVERT_INTERVAL 16000 /* milliseconds */ 410*7c478bd9Sstevel@tonic-gate #define ND_MAX_INITIAL_RTR_ADVERTISEMENTS 3 /* transmissions */ 411*7c478bd9Sstevel@tonic-gate #define ND_MAX_FINAL_RTR_ADVERTISEMENTS 3 /* transmissions */ 412*7c478bd9Sstevel@tonic-gate #define ND_MIN_DELAY_BETWEEN_RAS 3000 /* milliseconds */ 413*7c478bd9Sstevel@tonic-gate #define ND_MAX_RA_DELAY_TIME 500 /* milliseconds */ 414*7c478bd9Sstevel@tonic-gate 415*7c478bd9Sstevel@tonic-gate /* Host constants */ 416*7c478bd9Sstevel@tonic-gate #define ND_MAX_RTR_SOLICITATION_DELAY 1000 /* milliseconds */ 417*7c478bd9Sstevel@tonic-gate #define ND_RTR_SOLICITATION_INTERVAL 4000 /* milliseconds */ 418*7c478bd9Sstevel@tonic-gate #define ND_MAX_RTR_SOLICITATIONS 3 /* transmissions */ 419*7c478bd9Sstevel@tonic-gate 420*7c478bd9Sstevel@tonic-gate /* Node constants */ 421*7c478bd9Sstevel@tonic-gate #define ND_MAX_MULTICAST_SOLICIT 3 /* transmissions */ 422*7c478bd9Sstevel@tonic-gate #define ND_MAX_UNICAST_SOLICIT 3 /* transmissions */ 423*7c478bd9Sstevel@tonic-gate #define ND_MAX_ANYCAST_DELAY_TIME 1000 /* milliseconds */ 424*7c478bd9Sstevel@tonic-gate #define ND_MAX_NEIGHBOR_ADVERTISEMENT 3 /* transmissions */ 425*7c478bd9Sstevel@tonic-gate #define ND_REACHABLE_TIME 30000 /* milliseconds */ 426*7c478bd9Sstevel@tonic-gate #define ND_RETRANS_TIMER 1000 /* milliseconds */ 427*7c478bd9Sstevel@tonic-gate #define ND_DELAY_FIRST_PROBE_TIME 5000 /* milliseconds */ 428*7c478bd9Sstevel@tonic-gate #define ND_MIN_RANDOM_FACTOR .5 429*7c478bd9Sstevel@tonic-gate #define ND_MAX_RANDOM_FACTOR 1.5 430*7c478bd9Sstevel@tonic-gate 431*7c478bd9Sstevel@tonic-gate #define ND_MAX_REACHTIME 3600000 /* milliseconds */ 432*7c478bd9Sstevel@tonic-gate #define ND_MAX_REACHRETRANSTIME 100000 /* milliseconds */ 433*7c478bd9Sstevel@tonic-gate 434*7c478bd9Sstevel@tonic-gate /* 435*7c478bd9Sstevel@tonic-gate * ICMPv6 type filtering for IPPROTO_ICMPV6 ICMP6_FILTER socket option 436*7c478bd9Sstevel@tonic-gate */ 437*7c478bd9Sstevel@tonic-gate #define ICMP6_FILTER 0x01 /* Set filter */ 438*7c478bd9Sstevel@tonic-gate 439*7c478bd9Sstevel@tonic-gate typedef struct icmp6_filter { 440*7c478bd9Sstevel@tonic-gate uint32_t __icmp6_filt[8]; 441*7c478bd9Sstevel@tonic-gate } icmp6_filter_t; 442*7c478bd9Sstevel@tonic-gate 443*7c478bd9Sstevel@tonic-gate /* Pass all ICMPv6 messages to the application */ 444*7c478bd9Sstevel@tonic-gate #define ICMP6_FILTER_SETPASSALL(filterp) ( \ 445*7c478bd9Sstevel@tonic-gate ((filterp)->__icmp6_filt[0] = 0xFFFFFFFFU), \ 446*7c478bd9Sstevel@tonic-gate ((filterp)->__icmp6_filt[1] = 0xFFFFFFFFU), \ 447*7c478bd9Sstevel@tonic-gate ((filterp)->__icmp6_filt[2] = 0xFFFFFFFFU), \ 448*7c478bd9Sstevel@tonic-gate ((filterp)->__icmp6_filt[3] = 0xFFFFFFFFU), \ 449*7c478bd9Sstevel@tonic-gate ((filterp)->__icmp6_filt[4] = 0xFFFFFFFFU), \ 450*7c478bd9Sstevel@tonic-gate ((filterp)->__icmp6_filt[5] = 0xFFFFFFFFU), \ 451*7c478bd9Sstevel@tonic-gate ((filterp)->__icmp6_filt[6] = 0xFFFFFFFFU), \ 452*7c478bd9Sstevel@tonic-gate ((filterp)->__icmp6_filt[7] = 0xFFFFFFFFU)) 453*7c478bd9Sstevel@tonic-gate 454*7c478bd9Sstevel@tonic-gate /* ICMPv6 messages are blocked from being passed to the application */ 455*7c478bd9Sstevel@tonic-gate #define ICMP6_FILTER_SETBLOCKALL(filterp) ( \ 456*7c478bd9Sstevel@tonic-gate ((filterp)->__icmp6_filt[0] = 0x0), \ 457*7c478bd9Sstevel@tonic-gate ((filterp)->__icmp6_filt[1] = 0x0), \ 458*7c478bd9Sstevel@tonic-gate ((filterp)->__icmp6_filt[2] = 0x0), \ 459*7c478bd9Sstevel@tonic-gate ((filterp)->__icmp6_filt[3] = 0x0), \ 460*7c478bd9Sstevel@tonic-gate ((filterp)->__icmp6_filt[4] = 0x0), \ 461*7c478bd9Sstevel@tonic-gate ((filterp)->__icmp6_filt[5] = 0x0), \ 462*7c478bd9Sstevel@tonic-gate ((filterp)->__icmp6_filt[6] = 0x0), \ 463*7c478bd9Sstevel@tonic-gate ((filterp)->__icmp6_filt[7] = 0x0)) 464*7c478bd9Sstevel@tonic-gate 465*7c478bd9Sstevel@tonic-gate /* Pass messages of a given type to the application */ 466*7c478bd9Sstevel@tonic-gate #define ICMP6_FILTER_SETPASS(type, filterp) \ 467*7c478bd9Sstevel@tonic-gate ((((filterp)->__icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))) 468*7c478bd9Sstevel@tonic-gate 469*7c478bd9Sstevel@tonic-gate /* Block messages of a given type from being passed to the application */ 470*7c478bd9Sstevel@tonic-gate #define ICMP6_FILTER_SETBLOCK(type, filterp) \ 471*7c478bd9Sstevel@tonic-gate ((((filterp)->__icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))) 472*7c478bd9Sstevel@tonic-gate 473*7c478bd9Sstevel@tonic-gate /* Test if message of a given type will be passed to an application */ 474*7c478bd9Sstevel@tonic-gate #define ICMP6_FILTER_WILLPASS(type, filterp) \ 475*7c478bd9Sstevel@tonic-gate ((((filterp)->__icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0) 476*7c478bd9Sstevel@tonic-gate 477*7c478bd9Sstevel@tonic-gate /* 478*7c478bd9Sstevel@tonic-gate * Test if message of a given type will blocked from 479*7c478bd9Sstevel@tonic-gate * being passed to an application 480*7c478bd9Sstevel@tonic-gate */ 481*7c478bd9Sstevel@tonic-gate #define ICMP6_FILTER_WILLBLOCK(type, filterp) \ 482*7c478bd9Sstevel@tonic-gate ((((filterp)->__icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0) 483*7c478bd9Sstevel@tonic-gate 484*7c478bd9Sstevel@tonic-gate 485*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 486*7c478bd9Sstevel@tonic-gate } 487*7c478bd9Sstevel@tonic-gate #endif 488*7c478bd9Sstevel@tonic-gate 489*7c478bd9Sstevel@tonic-gate #endif /* _NETINET_ICMP6_H */ 490