1 /* Copyright (C) 1991-2014 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 <http://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
73 #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
74 #define ICMP6_DST_UNREACH_ADMIN 1 /* communication with destination */
75 /* administratively prohibited */
76 #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
77 #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
78 #define ICMP6_DST_UNREACH_NOPORT 4 /* bad port */
80 #define ICMP6_TIME_EXCEED_TRANSIT 0 /* Hop Limit == 0 in transit */
81 #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* Reassembly time out */
83 #define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
84 #define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized Next Header */
85 #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized IPv6 option */
87 #define ICMP6_FILTER_WILLPASS(type, filterp) \
88 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
90 #define ICMP6_FILTER_WILLBLOCK(type, filterp) \
91 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
93 #define ICMP6_FILTER_SETPASS(type, filterp) \
94 ((((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31))))
96 #define ICMP6_FILTER_SETBLOCK(type, filterp) \
97 ((((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31))))
99 #define ICMP6_FILTER_SETPASSALL(filterp) \
100 memset (filterp, 0, sizeof (struct icmp6_filter));
102 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
103 memset (filterp, 0xFF, sizeof (struct icmp6_filter));
105 #define ND_ROUTER_SOLICIT 133
106 #define ND_ROUTER_ADVERT 134
107 #define ND_NEIGHBOR_SOLICIT 135
108 #define ND_NEIGHBOR_ADVERT 136
109 #define ND_REDIRECT 137
111 struct nd_router_solicit
/* router solicitation */
113 struct icmp6_hdr nd_rs_hdr
;
114 /* could be followed by options */
117 #define nd_rs_type nd_rs_hdr.icmp6_type
118 #define nd_rs_code nd_rs_hdr.icmp6_code
119 #define nd_rs_cksum nd_rs_hdr.icmp6_cksum
120 #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
122 struct nd_router_advert
/* router advertisement */
124 struct icmp6_hdr nd_ra_hdr
;
125 uint32_t nd_ra_reachable
; /* reachable time */
126 uint32_t nd_ra_retransmit
; /* retransmit timer */
127 /* could be followed by options */
130 #define nd_ra_type nd_ra_hdr.icmp6_type
131 #define nd_ra_code nd_ra_hdr.icmp6_code
132 #define nd_ra_cksum nd_ra_hdr.icmp6_cksum
133 #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
134 #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
135 #define ND_RA_FLAG_MANAGED 0x80
136 #define ND_RA_FLAG_OTHER 0x40
137 #define ND_RA_FLAG_HOME_AGENT 0x20
138 #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
140 struct nd_neighbor_solicit
/* neighbor solicitation */
142 struct icmp6_hdr nd_ns_hdr
;
143 struct in6_addr nd_ns_target
; /* target address */
144 /* could be followed by options */
147 #define nd_ns_type nd_ns_hdr.icmp6_type
148 #define nd_ns_code nd_ns_hdr.icmp6_code
149 #define nd_ns_cksum nd_ns_hdr.icmp6_cksum
150 #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
152 struct nd_neighbor_advert
/* neighbor advertisement */
154 struct icmp6_hdr nd_na_hdr
;
155 struct in6_addr nd_na_target
; /* target address */
156 /* could be followed by options */
159 #define nd_na_type nd_na_hdr.icmp6_type
160 #define nd_na_code nd_na_hdr.icmp6_code
161 #define nd_na_cksum nd_na_hdr.icmp6_cksum
162 #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
163 #if BYTE_ORDER == BIG_ENDIAN
164 #define ND_NA_FLAG_ROUTER 0x80000000
165 #define ND_NA_FLAG_SOLICITED 0x40000000
166 #define ND_NA_FLAG_OVERRIDE 0x20000000
167 #else /* BYTE_ORDER == LITTLE_ENDIAN */
168 #define ND_NA_FLAG_ROUTER 0x00000080
169 #define ND_NA_FLAG_SOLICITED 0x00000040
170 #define ND_NA_FLAG_OVERRIDE 0x00000020
173 struct nd_redirect
/* redirect */
175 struct icmp6_hdr nd_rd_hdr
;
176 struct in6_addr nd_rd_target
; /* target address */
177 struct in6_addr nd_rd_dst
; /* destination address */
178 /* could be followed by options */
181 #define nd_rd_type nd_rd_hdr.icmp6_type
182 #define nd_rd_code nd_rd_hdr.icmp6_code
183 #define nd_rd_cksum nd_rd_hdr.icmp6_cksum
184 #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
186 struct nd_opt_hdr
/* Neighbor discovery option header */
189 uint8_t nd_opt_len
; /* in units of 8 octets */
190 /* followed by option specific data */
193 #define ND_OPT_SOURCE_LINKADDR 1
194 #define ND_OPT_TARGET_LINKADDR 2
195 #define ND_OPT_PREFIX_INFORMATION 3
196 #define ND_OPT_REDIRECTED_HEADER 4
198 #define ND_OPT_RTR_ADV_INTERVAL 7
199 #define ND_OPT_HOME_AGENT_INFO 8
201 struct nd_opt_prefix_info
/* prefix information */
203 uint8_t nd_opt_pi_type
;
204 uint8_t nd_opt_pi_len
;
205 uint8_t nd_opt_pi_prefix_len
;
206 uint8_t nd_opt_pi_flags_reserved
;
207 uint32_t nd_opt_pi_valid_time
;
208 uint32_t nd_opt_pi_preferred_time
;
209 uint32_t nd_opt_pi_reserved2
;
210 struct in6_addr nd_opt_pi_prefix
;
213 #define ND_OPT_PI_FLAG_ONLINK 0x80
214 #define ND_OPT_PI_FLAG_AUTO 0x40
215 #define ND_OPT_PI_FLAG_RADDR 0x20
217 struct nd_opt_rd_hdr
/* redirected header */
219 uint8_t nd_opt_rh_type
;
220 uint8_t nd_opt_rh_len
;
221 uint16_t nd_opt_rh_reserved1
;
222 uint32_t nd_opt_rh_reserved2
;
223 /* followed by IP header and data */
226 struct nd_opt_mtu
/* MTU option */
228 uint8_t nd_opt_mtu_type
;
229 uint8_t nd_opt_mtu_len
;
230 uint16_t nd_opt_mtu_reserved
;
231 uint32_t nd_opt_mtu_mtu
;
236 struct icmp6_hdr mld_icmp6_hdr
;
237 struct in6_addr mld_addr
; /* multicast address */
240 #define mld_type mld_icmp6_hdr.icmp6_type
241 #define mld_code mld_icmp6_hdr.icmp6_code
242 #define mld_cksum mld_icmp6_hdr.icmp6_cksum
243 #define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0]
244 #define mld_reserved mld_icmp6_hdr.icmp6_data16[1]
246 #define ICMP6_ROUTER_RENUMBERING 138
248 struct icmp6_router_renum
/* router renumbering header */
250 struct icmp6_hdr rr_hdr
;
253 uint16_t rr_maxdelay
;
254 uint32_t rr_reserved
;
257 #define rr_type rr_hdr.icmp6_type
258 #define rr_code rr_hdr.icmp6_code
259 #define rr_cksum rr_hdr.icmp6_cksum
260 #define rr_seqnum rr_hdr.icmp6_data32[0]
262 /* Router renumbering flags */
263 #define ICMP6_RR_FLAGS_TEST 0x80
264 #define ICMP6_RR_FLAGS_REQRESULT 0x40
265 #define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
266 #define ICMP6_RR_FLAGS_SPECSITE 0x10
267 #define ICMP6_RR_FLAGS_PREVDONE 0x08
269 struct rr_pco_match
/* match prefix part */
274 uint8_t rpm_matchlen
;
277 uint16_t rpm_reserved
;
278 struct in6_addr rpm_prefix
;
281 /* PCO code values */
282 #define RPM_PCO_ADD 1
283 #define RPM_PCO_CHANGE 2
284 #define RPM_PCO_SETGLOBAL 3
286 struct rr_pco_use
/* use prefix part */
295 struct in6_addr rpu_prefix
;
298 #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x20
299 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x10
301 #if BYTE_ORDER == BIG_ENDIAN
302 # define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
303 # define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
304 #elif BYTE_ORDER == LITTLE_ENDIAN
305 # define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
306 # define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
309 struct rr_result
/* router renumbering result message */
313 uint8_t rrr_matchedlen
;
315 struct in6_addr rrr_prefix
;
318 #if BYTE_ORDER == BIG_ENDIAN
319 # define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
320 # define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
321 #elif BYTE_ORDER == LITTLE_ENDIAN
322 # define ICMP6_RR_RESULT_FLAGS_OOB 0x0200
323 # define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
326 /* Mobile IPv6 extension: Advertisement Interval. */
327 struct nd_opt_adv_interval
329 uint8_t nd_opt_adv_interval_type
;
330 uint8_t nd_opt_adv_interval_len
;
331 uint16_t nd_opt_adv_interval_reserved
;
332 uint32_t nd_opt_adv_interval_ival
;
335 /* Mobile IPv6 extension: Home Agent Info. */
336 struct nd_opt_home_agent_info
338 uint8_t nd_opt_home_agent_info_type
;
339 uint8_t nd_opt_home_agent_info_len
;
340 uint16_t nd_opt_home_agent_info_reserved
;
341 uint16_t nd_opt_home_agent_info_preference
;
342 uint16_t nd_opt_home_agent_info_lifetime
;
345 #endif /* netinet/icmpv6.h */