| 1 | /* Copyright (C) 1991,92,93,94,95,96,97,2000 Free Software Foundation, Inc. |
|---|
| 2 | This file is part of the GNU C Library. |
|---|
| 3 | |
|---|
| 4 | The GNU C Library is free software; you can redistribute it and/or |
|---|
| 5 | modify it under the terms of the GNU Lesser General Public |
|---|
| 6 | License as published by the Free Software Foundation; either |
|---|
| 7 | version 2.1 of the License, or (at your option) any later version. |
|---|
| 8 | |
|---|
| 9 | The GNU C Library is distributed in the hope that it will be useful, |
|---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 12 | Lesser General Public License for more details. |
|---|
| 13 | |
|---|
| 14 | You should have received a copy of the GNU Lesser General Public |
|---|
| 15 | License along with the GNU C Library; if not, write to the Free |
|---|
| 16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|---|
| 17 | 02111-1307 USA. */ |
|---|
| 18 | |
|---|
| 19 | #ifndef _NETINET_ICMP6_H |
|---|
| 20 | #define _NETINET_ICMP6_H 1 |
|---|
| 21 | |
|---|
| 22 | #include <inttypes.h> |
|---|
| 23 | #include <string.h> |
|---|
| 24 | #include <sys/types.h> |
|---|
| 25 | #include <netinet/in.h> |
|---|
| 26 | |
|---|
| 27 | #define ICMP6_FILTER 1 |
|---|
| 28 | |
|---|
| 29 | #define ICMP6_FILTER_BLOCK 1 |
|---|
| 30 | #define ICMP6_FILTER_PASS 2 |
|---|
| 31 | #define ICMP6_FILTER_BLOCKOTHERS 3 |
|---|
| 32 | #define ICMP6_FILTER_PASSONLY 4 |
|---|
| 33 | |
|---|
| 34 | struct icmp6_filter |
|---|
| 35 | { |
|---|
| 36 | uint32_t data[8]; |
|---|
| 37 | }; |
|---|
| 38 | |
|---|
| 39 | struct icmp6_hdr |
|---|
| 40 | { |
|---|
| 41 | uint8_t icmp6_type; /* type field */ |
|---|
| 42 | uint8_t icmp6_code; /* code field */ |
|---|
| 43 | uint16_t icmp6_cksum; /* checksum field */ |
|---|
| 44 | union |
|---|
| 45 | { |
|---|
| 46 | uint32_t icmp6_un_data32[1]; /* type-specific field */ |
|---|
| 47 | uint16_t icmp6_un_data16[2]; /* type-specific field */ |
|---|
| 48 | uint8_t icmp6_un_data8[4]; /* type-specific field */ |
|---|
| 49 | } icmp6_dataun; |
|---|
| 50 | }; |
|---|
| 51 | |
|---|
| 52 | #define icmp6_data32 icmp6_dataun.icmp6_un_data32 |
|---|
| 53 | #define icmp6_data16 icmp6_dataun.icmp6_un_data16 |
|---|
| 54 | #define icmp6_data8 icmp6_dataun.icmp6_un_data8 |
|---|
| 55 | #define icmp6_pptr icmp6_data32[0] /* parameter prob */ |
|---|
| 56 | #define icmp6_mtu icmp6_data32[0] /* packet too big */ |
|---|
| 57 | #define icmp6_id icmp6_data16[0] /* echo request/reply */ |
|---|
| 58 | #define icmp6_seq icmp6_data16[1] /* echo request/reply */ |
|---|
| 59 | #define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */ |
|---|
| 60 | |
|---|
| 61 | #define ICMP6_DST_UNREACH 1 |
|---|
| 62 | #define ICMP6_PACKET_TOO_BIG 2 |
|---|
| 63 | #define ICMP6_TIME_EXCEEDED 3 |
|---|
| 64 | #define ICMP6_PARAM_PROB 4 |
|---|
| 65 | |
|---|
| 66 | #define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */ |
|---|
| 67 | |
|---|
| 68 | #define ICMP6_ECHO_REQUEST 128 |
|---|
| 69 | #define ICMP6_ECHO_REPLY 129 |
|---|
| 70 | #define ICMP6_MEMBERSHIP_QUERY 130 |
|---|
| 71 | #define ICMP6_MEMBERSHIP_REPORT 131 |
|---|
| 72 | #define ICMP6_MEMBERSHIP_REDUCTION 132 |
|---|
| 73 | |
|---|
| 74 | #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */ |
|---|
| 75 | #define ICMP6_DST_UNREACH_ADMIN 1 /* communication with destination */ |
|---|
| 76 | /* administratively prohibited */ |
|---|
| 77 | #define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor */ |
|---|
| 78 | #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */ |
|---|
| 79 | #define ICMP6_DST_UNREACH_NOPORT 4 /* bad port */ |
|---|
| 80 | |
|---|
| 81 | #define ICMP6_TIME_EXCEED_TRANSIT 0 /* Hop Limit == 0 in transit */ |
|---|
| 82 | #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* Reassembly time out */ |
|---|
| 83 | |
|---|
| 84 | #define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */ |
|---|
| 85 | #define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized Next Header */ |
|---|
| 86 | #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized IPv6 option */ |
|---|
| 87 | |
|---|
| 88 | #define ICMP6_FILTER_WILLPASS(type, filterp) \ |
|---|
| 89 | ((((filterp)->data[(type) >> 5]) & (1 << ((type) & 31))) == 0) |
|---|
| 90 | |
|---|
| 91 | #define ICMP6_FILTER_WILLBLOCK(type, filterp) \ |
|---|
| 92 | ((((filterp)->data[(type) >> 5]) & (1 << ((type) & 31))) != 0) |
|---|
| 93 | |
|---|
| 94 | #define ICMP6_FILTER_SETPASS(type, filterp) \ |
|---|
| 95 | ((((filterp)->data[(type) >> 5]) &= ~(1 << ((type) & 31)))) |
|---|
| 96 | |
|---|
| 97 | #define ICMP6_FILTER_SETBLOCK(type, filterp) \ |
|---|
| 98 | ((((filterp)->data[(type) >> 5]) |= (1 << ((type) & 31)))) |
|---|
| 99 | |
|---|
| 100 | #define ICMP6_FILTER_SETPASSALL(filterp) \ |
|---|
| 101 | memset (filterp, 0, sizeof (struct icmp6_filter)); |
|---|
| 102 | |
|---|
| 103 | #define ICMP6_FILTER_SETBLOCKALL(filterp) \ |
|---|
| 104 | memset (filterp, 0xFF, sizeof (struct icmp6_filter)); |
|---|
| 105 | |
|---|
| 106 | #define ND_ROUTER_SOLICIT 133 |
|---|
| 107 | #define ND_ROUTER_ADVERT 134 |
|---|
| 108 | #define ND_NEIGHBOR_SOLICIT 135 |
|---|
| 109 | #define ND_NEIGHBOR_ADVERT 136 |
|---|
| 110 | #define ND_REDIRECT 137 |
|---|
| 111 | |
|---|
| 112 | struct nd_router_solicit /* router solicitation */ |
|---|
| 113 | { |
|---|
| 114 | struct icmp6_hdr nd_rs_hdr; |
|---|
| 115 | /* could be followed by options */ |
|---|
| 116 | }; |
|---|
| 117 | |
|---|
| 118 | #define nd_rs_type nd_rs_hdr.icmp6_type |
|---|
| 119 | #define nd_rs_code nd_rs_hdr.icmp6_code |
|---|
| 120 | #define nd_rs_cksum nd_rs_hdr.icmp6_cksum |
|---|
| 121 | #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0] |
|---|
| 122 | |
|---|
| 123 | struct nd_router_advert /* router advertisement */ |
|---|
| 124 | { |
|---|
| 125 | struct icmp6_hdr nd_ra_hdr; |
|---|
| 126 | uint32_t nd_ra_reachable; /* reachable time */ |
|---|
| 127 | uint32_t nd_ra_retransmit; /* retransmit timer */ |
|---|
| 128 | /* could be followed by options */ |
|---|
| 129 | }; |
|---|
| 130 | |
|---|
| 131 | #define nd_ra_type nd_ra_hdr.icmp6_type |
|---|
| 132 | #define nd_ra_code nd_ra_hdr.icmp6_code |
|---|
| 133 | #define nd_ra_cksum nd_ra_hdr.icmp6_cksum |
|---|
| 134 | #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0] |
|---|
| 135 | #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1] |
|---|
| 136 | #define ND_RA_FLAG_MANAGED 0x80 |
|---|
| 137 | #define ND_RA_FLAG_OTHER 0x40 |
|---|
| 138 | #define ND_RA_FLAG_HOME_AGENT 0x20 |
|---|
| 139 | #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1] |
|---|
| 140 | |
|---|
| 141 | struct nd_neighbor_solicit /* neighbor solicitation */ |
|---|
| 142 | { |
|---|
| 143 | struct icmp6_hdr nd_ns_hdr; |
|---|
| 144 | struct in6_addr nd_ns_target; /* target address */ |
|---|
| 145 | /* could be followed by options */ |
|---|
| 146 | }; |
|---|
| 147 | |
|---|
| 148 | #define nd_ns_type nd_ns_hdr.icmp6_type |
|---|
| 149 | #define nd_ns_code nd_ns_hdr.icmp6_code |
|---|
| 150 | #define nd_ns_cksum nd_ns_hdr.icmp6_cksum |
|---|
| 151 | #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0] |
|---|
| 152 | |
|---|
| 153 | struct nd_neighbor_advert /* neighbor advertisement */ |
|---|
| 154 | { |
|---|
| 155 | struct icmp6_hdr nd_na_hdr; |
|---|
| 156 | struct in6_addr nd_na_target; /* target address */ |
|---|
| 157 | /* could be followed by options */ |
|---|
| 158 | }; |
|---|
| 159 | |
|---|
| 160 | #define nd_na_type nd_na_hdr.icmp6_type |
|---|
| 161 | #define nd_na_code nd_na_hdr.icmp6_code |
|---|
| 162 | #define nd_na_cksum nd_na_hdr.icmp6_cksum |
|---|
| 163 | #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0] |
|---|
| 164 | #if BYTE_ORDER == BIG_ENDIAN |
|---|
| 165 | #define ND_NA_FLAG_ROUTER 0x80000000 |
|---|
| 166 | #define ND_NA_FLAG_SOLICITED 0x40000000 |
|---|
| 167 | #define ND_NA_FLAG_OVERRIDE 0x20000000 |
|---|
| 168 | #else /* BYTE_ORDER == LITTLE_ENDIAN */ |
|---|
| 169 | #define ND_NA_FLAG_ROUTER 0x00000080 |
|---|
| 170 | #define ND_NA_FLAG_SOLICITED 0x00000040 |
|---|
| 171 | #define ND_NA_FLAG_OVERRIDE 0x00000020 |
|---|
| 172 | #endif |
|---|
| 173 | |
|---|
| 174 | struct nd_redirect /* redirect */ |
|---|
| 175 | { |
|---|
| 176 | struct icmp6_hdr nd_rd_hdr; |
|---|
| 177 | struct in6_addr nd_rd_target; /* target address */ |
|---|
| 178 | struct in6_addr nd_rd_dst; /* destination address */ |
|---|
| 179 | /* could be followed by options */ |
|---|
| 180 | }; |
|---|
| 181 | |
|---|
| 182 | #define nd_rd_type nd_rd_hdr.icmp6_type |
|---|
| 183 | #define nd_rd_code nd_rd_hdr.icmp6_code |
|---|
| 184 | #define nd_rd_cksum nd_rd_hdr.icmp6_cksum |
|---|
| 185 | #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0] |
|---|
| 186 | |
|---|
| 187 | struct nd_opt_hdr /* Neighbor discovery option header */ |
|---|
| 188 | { |
|---|
| 189 | uint8_t nd_opt_type; |
|---|
| 190 | uint8_t nd_opt_len; /* in units of 8 octets */ |
|---|
| 191 | /* followed by option specific data */ |
|---|
| 192 | }; |
|---|
| 193 | |
|---|
| 194 | #define ND_OPT_SOURCE_LINKADDR 1 |
|---|
| 195 | #define ND_OPT_TARGET_LINKADDR 2 |
|---|
| 196 | #define ND_OPT_PREFIX_INFORMATION 3 |
|---|
| 197 | #define ND_OPT_REDIRECTED_HEADER 4 |
|---|
| 198 | #define ND_OPT_MTU 5 |
|---|
| 199 | #define ND_OPT_RTR_ADV_INTERVAL 7 |
|---|
| 200 | #define ND_OPT_HOME_AGENT_INFO 8 |
|---|
| 201 | |
|---|
| 202 | struct nd_opt_prefix_info /* prefix information */ |
|---|
| 203 | { |
|---|
| 204 | uint8_t nd_opt_pi_type; |
|---|
| 205 | uint8_t nd_opt_pi_len; |
|---|
| 206 | uint8_t nd_opt_pi_prefix_len; |
|---|
| 207 | uint8_t nd_opt_pi_flags_reserved; |
|---|
| 208 | uint32_t nd_opt_pi_valid_time; |
|---|
| 209 | uint32_t nd_opt_pi_preferred_time; |
|---|
| 210 | uint32_t nd_opt_pi_reserved2; |
|---|
| 211 | struct in6_addr nd_opt_pi_prefix; |
|---|
| 212 | }; |
|---|
| 213 | |
|---|
| 214 | #define ND_OPT_PI_FLAG_ONLINK 0x80 |
|---|
| 215 | #define ND_OPT_PI_FLAG_AUTO 0x40 |
|---|
| 216 | #define ND_OPT_PI_FLAG_RADDR 0x20 |
|---|
| 217 | |
|---|
| 218 | struct nd_opt_rd_hdr /* redirected header */ |
|---|
| 219 | { |
|---|
| 220 | uint8_t nd_opt_rh_type; |
|---|
| 221 | uint8_t nd_opt_rh_len; |
|---|
| 222 | uint16_t nd_opt_rh_reserved1; |
|---|
| 223 | uint32_t nd_opt_rh_reserved2; |
|---|
| 224 | /* followed by IP header and data */ |
|---|
| 225 | }; |
|---|
| 226 | |
|---|
| 227 | struct nd_opt_mtu /* MTU option */ |
|---|
| 228 | { |
|---|
| 229 | uint8_t nd_opt_mtu_type; |
|---|
| 230 | uint8_t nd_opt_mtu_len; |
|---|
| 231 | uint16_t nd_opt_mtu_reserved; |
|---|
| 232 | uint32_t nd_opt_mtu_mtu; |
|---|
| 233 | }; |
|---|
| 234 | |
|---|
| 235 | /* Mobile IPv6 extension: Advertisement Interval. */ |
|---|
| 236 | struct nd_opt_adv_interval |
|---|
| 237 | { |
|---|
| 238 | uint8_t nd_opt_adv_interval_type; |
|---|
| 239 | uint8_t nd_opt_adv_interval_len; |
|---|
| 240 | uint16_t nd_opt_adv_interval_reserved; |
|---|
| 241 | uint32_t nd_opt_adv_interval_ival; |
|---|
| 242 | }; |
|---|
| 243 | |
|---|
| 244 | /* Mobile IPv6 extension: Home Agent Info. */ |
|---|
| 245 | struct nd_opt_home_agent_info |
|---|
| 246 | { |
|---|
| 247 | uint8_t nd_opt_home_agent_info_type; |
|---|
| 248 | uint8_t nd_opt_home_agent_info_len; |
|---|
| 249 | uint16_t nd_opt_home_agent_info_reserved; |
|---|
| 250 | int16_t nd_opt_home_agent_info_preference; |
|---|
| 251 | uint16_t nd_opt_home_agent_info_lifetime; |
|---|
| 252 | }; |
|---|
| 253 | |
|---|
| 254 | #endif /* netinet/icmpv6.h */ |
|---|