1 /* Copyright (C) 1991-2022 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
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.
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.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
18 #ifndef _NETINET_ICMP6_H
19 #define _NETINET_ICMP6_H 1
23 #include <sys/types.h>
24 #include <netinet/in.h>
26 #define ICMP6_FILTER 1
28 #define ICMP6_FILTER_BLOCK 1
29 #define ICMP6_FILTER_PASS 2
30 #define ICMP6_FILTER_BLOCKOTHERS 3
31 #define ICMP6_FILTER_PASSONLY 4
35 uint32_t icmp6_filt
[8];
40 uint8_t icmp6_type
; /* type field */
41 uint8_t icmp6_code
; /* code field */
42 uint16_t icmp6_cksum
; /* checksum field */
45 uint32_t icmp6_un_data32
[1]; /* type-specific field */
46 uint16_t icmp6_un_data16
[2]; /* type-specific field */
47 uint8_t icmp6_un_data8
[4]; /* type-specific field */
51 #define icmp6_data32 icmp6_dataun.icmp6_un_data32
52 #define icmp6_data16 icmp6_dataun.icmp6_un_data16
53 #define icmp6_data8 icmp6_dataun.icmp6_un_data8
54 #define icmp6_pptr icmp6_data32[0] /* parameter prob */
55 #define icmp6_mtu icmp6_data32[0] /* packet too big */
56 #define icmp6_id icmp6_data16[0] /* echo request/reply */
57 #define icmp6_seq icmp6_data16[1] /* echo request/reply */
58 #define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
60 #define ICMP6_DST_UNREACH 1
61 #define ICMP6_PACKET_TOO_BIG 2
62 #define ICMP6_TIME_EXCEEDED 3
63 #define ICMP6_PARAM_PROB 4
65 #define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
67 #define ICMP6_ECHO_REQUEST 128
68 #define ICMP6_ECHO_REPLY 129
69 #define MLD_LISTENER_QUERY 130
70 #define MLD_LISTENER_REPORT 131
71 #define MLD_LISTENER_REDUCTION 132
72 #define ICMPV6_EXT_ECHO_REQUEST 160
73 #define ICMPV6_EXT_ECHO_REPLY 161
75 #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
76 #define ICMP6_DST_UNREACH_ADMIN 1 /* communication with destination */
77 /* administratively prohibited */
78 #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
79 #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
80 #define ICMP6_DST_UNREACH_NOPORT 4 /* bad port */
82 #define ICMP6_TIME_EXCEED_TRANSIT 0 /* Hop Limit == 0 in transit */
83 #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* Reassembly time out */
85 #define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
86 #define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized Next Header */
87 #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized IPv6 option */
89 #define ICMP6_FILTER_WILLPASS(type, filterp) \
90 ((((filterp)->icmp6_filt[(type) >> 5]) & (1U << ((type) & 31))) == 0)
92 #define ICMP6_FILTER_WILLBLOCK(type, filterp) \
93 ((((filterp)->icmp6_filt[(type) >> 5]) & (1U << ((type) & 31))) != 0)
95 #define ICMP6_FILTER_SETPASS(type, filterp) \
96 ((((filterp)->icmp6_filt[(type) >> 5]) &= ~(1U << ((type) & 31))))
98 #define ICMP6_FILTER_SETBLOCK(type, filterp) \
99 ((((filterp)->icmp6_filt[(type) >> 5]) |= (1U << ((type) & 31))))
101 #define ICMP6_FILTER_SETPASSALL(filterp) \
102 memset (filterp, 0, sizeof (struct icmp6_filter));
104 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
105 memset (filterp, 0xFF, sizeof (struct icmp6_filter));
107 #define ND_ROUTER_SOLICIT 133
108 #define ND_ROUTER_ADVERT 134
109 #define ND_NEIGHBOR_SOLICIT 135
110 #define ND_NEIGHBOR_ADVERT 136
111 #define ND_REDIRECT 137
113 struct nd_router_solicit
/* router solicitation */
115 struct icmp6_hdr nd_rs_hdr
;
116 /* could be followed by options */
119 #define nd_rs_type nd_rs_hdr.icmp6_type
120 #define nd_rs_code nd_rs_hdr.icmp6_code
121 #define nd_rs_cksum nd_rs_hdr.icmp6_cksum
122 #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
124 struct nd_router_advert
/* router advertisement */
126 struct icmp6_hdr nd_ra_hdr
;
127 uint32_t nd_ra_reachable
; /* reachable time */
128 uint32_t nd_ra_retransmit
; /* retransmit timer */
129 /* could be followed by options */
132 #define nd_ra_type nd_ra_hdr.icmp6_type
133 #define nd_ra_code nd_ra_hdr.icmp6_code
134 #define nd_ra_cksum nd_ra_hdr.icmp6_cksum
135 #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
136 #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
137 #define ND_RA_FLAG_MANAGED 0x80
138 #define ND_RA_FLAG_OTHER 0x40
139 #define ND_RA_FLAG_HOME_AGENT 0x20
140 #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
142 struct nd_neighbor_solicit
/* neighbor solicitation */
144 struct icmp6_hdr nd_ns_hdr
;
145 struct in6_addr nd_ns_target
; /* target address */
146 /* could be followed by options */
149 #define nd_ns_type nd_ns_hdr.icmp6_type
150 #define nd_ns_code nd_ns_hdr.icmp6_code
151 #define nd_ns_cksum nd_ns_hdr.icmp6_cksum
152 #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
154 struct nd_neighbor_advert
/* neighbor advertisement */
156 struct icmp6_hdr nd_na_hdr
;
157 struct in6_addr nd_na_target
; /* target address */
158 /* could be followed by options */
161 #define nd_na_type nd_na_hdr.icmp6_type
162 #define nd_na_code nd_na_hdr.icmp6_code
163 #define nd_na_cksum nd_na_hdr.icmp6_cksum
164 #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
165 #if __BYTE_ORDER == __BIG_ENDIAN
166 #define ND_NA_FLAG_ROUTER 0x80000000
167 #define ND_NA_FLAG_SOLICITED 0x40000000
168 #define ND_NA_FLAG_OVERRIDE 0x20000000
169 #else /* __BYTE_ORDER == __LITTLE_ENDIAN */
170 #define ND_NA_FLAG_ROUTER 0x00000080
171 #define ND_NA_FLAG_SOLICITED 0x00000040
172 #define ND_NA_FLAG_OVERRIDE 0x00000020
175 struct nd_redirect
/* redirect */
177 struct icmp6_hdr nd_rd_hdr
;
178 struct in6_addr nd_rd_target
; /* target address */
179 struct in6_addr nd_rd_dst
; /* destination address */
180 /* could be followed by options */
183 #define nd_rd_type nd_rd_hdr.icmp6_type
184 #define nd_rd_code nd_rd_hdr.icmp6_code
185 #define nd_rd_cksum nd_rd_hdr.icmp6_cksum
186 #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
188 struct nd_opt_hdr
/* Neighbor discovery option header */
191 uint8_t nd_opt_len
; /* in units of 8 octets */
192 /* followed by option specific data */
195 #define ND_OPT_SOURCE_LINKADDR 1
196 #define ND_OPT_TARGET_LINKADDR 2
197 #define ND_OPT_PREFIX_INFORMATION 3
198 #define ND_OPT_REDIRECTED_HEADER 4
200 #define ND_OPT_RTR_ADV_INTERVAL 7
201 #define ND_OPT_HOME_AGENT_INFO 8
203 struct nd_opt_prefix_info
/* prefix information */
205 uint8_t nd_opt_pi_type
;
206 uint8_t nd_opt_pi_len
;
207 uint8_t nd_opt_pi_prefix_len
;
208 uint8_t nd_opt_pi_flags_reserved
;
209 uint32_t nd_opt_pi_valid_time
;
210 uint32_t nd_opt_pi_preferred_time
;
211 uint32_t nd_opt_pi_reserved2
;
212 struct in6_addr nd_opt_pi_prefix
;
215 #define ND_OPT_PI_FLAG_ONLINK 0x80
216 #define ND_OPT_PI_FLAG_AUTO 0x40
217 #define ND_OPT_PI_FLAG_RADDR 0x20
219 struct nd_opt_rd_hdr
/* redirected header */
221 uint8_t nd_opt_rh_type
;
222 uint8_t nd_opt_rh_len
;
223 uint16_t nd_opt_rh_reserved1
;
224 uint32_t nd_opt_rh_reserved2
;
225 /* followed by IP header and data */
228 struct nd_opt_mtu
/* MTU option */
230 uint8_t nd_opt_mtu_type
;
231 uint8_t nd_opt_mtu_len
;
232 uint16_t nd_opt_mtu_reserved
;
233 uint32_t nd_opt_mtu_mtu
;
238 struct icmp6_hdr mld_icmp6_hdr
;
239 struct in6_addr mld_addr
; /* multicast address */
242 #define mld_type mld_icmp6_hdr.icmp6_type
243 #define mld_code mld_icmp6_hdr.icmp6_code
244 #define mld_cksum mld_icmp6_hdr.icmp6_cksum
245 #define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0]
246 #define mld_reserved mld_icmp6_hdr.icmp6_data16[1]
248 #define ICMP6_ROUTER_RENUMBERING 138
250 struct icmp6_router_renum
/* router renumbering header */
252 struct icmp6_hdr rr_hdr
;
255 uint16_t rr_maxdelay
;
256 uint32_t rr_reserved
;
259 #define rr_type rr_hdr.icmp6_type
260 #define rr_code rr_hdr.icmp6_code
261 #define rr_cksum rr_hdr.icmp6_cksum
262 #define rr_seqnum rr_hdr.icmp6_data32[0]
264 /* Router renumbering flags */
265 #define ICMP6_RR_FLAGS_TEST 0x80
266 #define ICMP6_RR_FLAGS_REQRESULT 0x40
267 #define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
268 #define ICMP6_RR_FLAGS_SPECSITE 0x10
269 #define ICMP6_RR_FLAGS_PREVDONE 0x08
271 struct rr_pco_match
/* match prefix part */
276 uint8_t rpm_matchlen
;
279 uint16_t rpm_reserved
;
280 struct in6_addr rpm_prefix
;
283 /* PCO code values */
284 #define RPM_PCO_ADD 1
285 #define RPM_PCO_CHANGE 2
286 #define RPM_PCO_SETGLOBAL 3
288 struct rr_pco_use
/* use prefix part */
297 struct in6_addr rpu_prefix
;
300 #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x20
301 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x10
303 #if __BYTE_ORDER == __BIG_ENDIAN
304 # define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
305 # define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
306 #elif __BYTE_ORDER == __LITTLE_ENDIAN
307 # define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
308 # define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
311 struct rr_result
/* router renumbering result message */
315 uint8_t rrr_matchedlen
;
317 struct in6_addr rrr_prefix
;
320 #if __BYTE_ORDER == __BIG_ENDIAN
321 # define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
322 # define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
323 #elif __BYTE_ORDER == __LITTLE_ENDIAN
324 # define ICMP6_RR_RESULT_FLAGS_OOB 0x0200
325 # define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
328 /* Mobile IPv6 extension: Advertisement Interval. */
329 struct nd_opt_adv_interval
331 uint8_t nd_opt_adv_interval_type
;
332 uint8_t nd_opt_adv_interval_len
;
333 uint16_t nd_opt_adv_interval_reserved
;
334 uint32_t nd_opt_adv_interval_ival
;
337 /* Mobile IPv6 extension: Home Agent Info. */
338 struct nd_opt_home_agent_info
340 uint8_t nd_opt_home_agent_info_type
;
341 uint8_t nd_opt_home_agent_info_len
;
342 uint16_t nd_opt_home_agent_info_reserved
;
343 uint16_t nd_opt_home_agent_info_preference
;
344 uint16_t nd_opt_home_agent_info_lifetime
;
347 #endif /* netinet/icmpv6.h */