1 #ifndef _NETINET_ICMP6_H
2 #define _NETINET_ICMP6_H
10 #include <sys/types.h>
11 #include <netinet/in.h>
14 #define ICMP6_FILTER 1
16 #define ICMP6_FILTER_BLOCK 1
17 #define ICMP6_FILTER_PASS 2
18 #define ICMP6_FILTER_BLOCKOTHERS 3
19 #define ICMP6_FILTER_PASSONLY 4
22 uint32_t icmp6_filt
[8];
30 uint32_t icmp6_un_data32
[1];
31 uint16_t icmp6_un_data16
[2];
32 uint8_t icmp6_un_data8
[4];
36 #define icmp6_data32 icmp6_dataun.icmp6_un_data32
37 #define icmp6_data16 icmp6_dataun.icmp6_un_data16
38 #define icmp6_data8 icmp6_dataun.icmp6_un_data8
39 #define icmp6_pptr icmp6_data32[0]
40 #define icmp6_mtu icmp6_data32[0]
41 #define icmp6_id icmp6_data16[0]
42 #define icmp6_seq icmp6_data16[1]
43 #define icmp6_maxdelay icmp6_data16[0]
45 #define ICMP6_DST_UNREACH 1
46 #define ICMP6_PACKET_TOO_BIG 2
47 #define ICMP6_TIME_EXCEEDED 3
48 #define ICMP6_PARAM_PROB 4
50 #define ICMP6_INFOMSG_MASK 0x80
52 #define ICMP6_ECHO_REQUEST 128
53 #define ICMP6_ECHO_REPLY 129
54 #define MLD_LISTENER_QUERY 130
55 #define MLD_LISTENER_REPORT 131
56 #define MLD_LISTENER_REDUCTION 132
58 #define ICMP6_DST_UNREACH_NOROUTE 0
59 #define ICMP6_DST_UNREACH_ADMIN 1
60 #define ICMP6_DST_UNREACH_BEYONDSCOPE 2
61 #define ICMP6_DST_UNREACH_ADDR 3
62 #define ICMP6_DST_UNREACH_NOPORT 4
64 #define ICMP6_TIME_EXCEED_TRANSIT 0
65 #define ICMP6_TIME_EXCEED_REASSEMBLY 1
67 #define ICMP6_PARAMPROB_HEADER 0
68 #define ICMP6_PARAMPROB_NEXTHEADER 1
69 #define ICMP6_PARAMPROB_OPTION 2
71 #define ICMP6_FILTER_WILLPASS(type, filterp) \
72 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
74 #define ICMP6_FILTER_WILLBLOCK(type, filterp) \
75 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
77 #define ICMP6_FILTER_SETPASS(type, filterp) \
78 ((((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31))))
80 #define ICMP6_FILTER_SETBLOCK(type, filterp) \
81 ((((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31))))
83 #define ICMP6_FILTER_SETPASSALL(filterp) \
84 memset (filterp, 0, sizeof (struct icmp6_filter));
86 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
87 memset (filterp, 0xFF, sizeof (struct icmp6_filter));
89 #define ND_ROUTER_SOLICIT 133
90 #define ND_ROUTER_ADVERT 134
91 #define ND_NEIGHBOR_SOLICIT 135
92 #define ND_NEIGHBOR_ADVERT 136
93 #define ND_REDIRECT 137
95 struct nd_router_solicit
{
96 struct icmp6_hdr nd_rs_hdr
;
99 #define nd_rs_type nd_rs_hdr.icmp6_type
100 #define nd_rs_code nd_rs_hdr.icmp6_code
101 #define nd_rs_cksum nd_rs_hdr.icmp6_cksum
102 #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
104 struct nd_router_advert
{
105 struct icmp6_hdr nd_ra_hdr
;
106 uint32_t nd_ra_reachable
;
107 uint32_t nd_ra_retransmit
;
110 #define nd_ra_type nd_ra_hdr.icmp6_type
111 #define nd_ra_code nd_ra_hdr.icmp6_code
112 #define nd_ra_cksum nd_ra_hdr.icmp6_cksum
113 #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
114 #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
115 #define ND_RA_FLAG_MANAGED 0x80
116 #define ND_RA_FLAG_OTHER 0x40
117 #define ND_RA_FLAG_HOME_AGENT 0x20
118 #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
120 struct nd_neighbor_solicit
{
121 struct icmp6_hdr nd_ns_hdr
;
122 struct in6_addr nd_ns_target
;
125 #define nd_ns_type nd_ns_hdr.icmp6_type
126 #define nd_ns_code nd_ns_hdr.icmp6_code
127 #define nd_ns_cksum nd_ns_hdr.icmp6_cksum
128 #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
130 struct nd_neighbor_advert
{
131 struct icmp6_hdr nd_na_hdr
;
132 struct in6_addr nd_na_target
;
135 #define nd_na_type nd_na_hdr.icmp6_type
136 #define nd_na_code nd_na_hdr.icmp6_code
137 #define nd_na_cksum nd_na_hdr.icmp6_cksum
138 #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
139 #if __BYTE_ORDER == __BIG_ENDIAN
140 #define ND_NA_FLAG_ROUTER 0x80000000
141 #define ND_NA_FLAG_SOLICITED 0x40000000
142 #define ND_NA_FLAG_OVERRIDE 0x20000000
144 #define ND_NA_FLAG_ROUTER 0x00000080
145 #define ND_NA_FLAG_SOLICITED 0x00000040
146 #define ND_NA_FLAG_OVERRIDE 0x00000020
150 struct icmp6_hdr nd_rd_hdr
;
151 struct in6_addr nd_rd_target
;
152 struct in6_addr nd_rd_dst
;
155 #define nd_rd_type nd_rd_hdr.icmp6_type
156 #define nd_rd_code nd_rd_hdr.icmp6_code
157 #define nd_rd_cksum nd_rd_hdr.icmp6_cksum
158 #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
165 #define ND_OPT_SOURCE_LINKADDR 1
166 #define ND_OPT_TARGET_LINKADDR 2
167 #define ND_OPT_PREFIX_INFORMATION 3
168 #define ND_OPT_REDIRECTED_HEADER 4
170 #define ND_OPT_RTR_ADV_INTERVAL 7
171 #define ND_OPT_HOME_AGENT_INFO 8
173 struct nd_opt_prefix_info
{
174 uint8_t nd_opt_pi_type
;
175 uint8_t nd_opt_pi_len
;
176 uint8_t nd_opt_pi_prefix_len
;
177 uint8_t nd_opt_pi_flags_reserved
;
178 uint32_t nd_opt_pi_valid_time
;
179 uint32_t nd_opt_pi_preferred_time
;
180 uint32_t nd_opt_pi_reserved2
;
181 struct in6_addr nd_opt_pi_prefix
;
184 #define ND_OPT_PI_FLAG_ONLINK 0x80
185 #define ND_OPT_PI_FLAG_AUTO 0x40
186 #define ND_OPT_PI_FLAG_RADDR 0x20
188 struct nd_opt_rd_hdr
{
189 uint8_t nd_opt_rh_type
;
190 uint8_t nd_opt_rh_len
;
191 uint16_t nd_opt_rh_reserved1
;
192 uint32_t nd_opt_rh_reserved2
;
196 uint8_t nd_opt_mtu_type
;
197 uint8_t nd_opt_mtu_len
;
198 uint16_t nd_opt_mtu_reserved
;
199 uint32_t nd_opt_mtu_mtu
;
203 struct icmp6_hdr mld_icmp6_hdr
;
204 struct in6_addr mld_addr
;
207 #define mld_type mld_icmp6_hdr.icmp6_type
208 #define mld_code mld_icmp6_hdr.icmp6_code
209 #define mld_cksum mld_icmp6_hdr.icmp6_cksum
210 #define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0]
211 #define mld_reserved mld_icmp6_hdr.icmp6_data16[1]
213 #define ICMP6_ROUTER_RENUMBERING 138
215 struct icmp6_router_renum
{
216 struct icmp6_hdr rr_hdr
;
219 uint16_t rr_maxdelay
;
220 uint32_t rr_reserved
;
223 #define rr_type rr_hdr.icmp6_type
224 #define rr_code rr_hdr.icmp6_code
225 #define rr_cksum rr_hdr.icmp6_cksum
226 #define rr_seqnum rr_hdr.icmp6_data32[0]
228 #define ICMP6_RR_FLAGS_TEST 0x80
229 #define ICMP6_RR_FLAGS_REQRESULT 0x40
230 #define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
231 #define ICMP6_RR_FLAGS_SPECSITE 0x10
232 #define ICMP6_RR_FLAGS_PREVDONE 0x08
234 struct rr_pco_match
{
238 uint8_t rpm_matchlen
;
241 uint16_t rpm_reserved
;
242 struct in6_addr rpm_prefix
;
245 #define RPM_PCO_ADD 1
246 #define RPM_PCO_CHANGE 2
247 #define RPM_PCO_SETGLOBAL 3
257 struct in6_addr rpu_prefix
;
260 #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x20
261 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x10
263 #if __BYTE_ORDER == __BIG_ENDIAN
264 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
265 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
267 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
268 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
274 uint8_t rrr_matchedlen
;
276 struct in6_addr rrr_prefix
;
279 #if __BYTE_ORDER == __BIG_ENDIAN
280 #define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
281 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
283 #define ICMP6_RR_RESULT_FLAGS_OOB 0x0200
284 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
287 struct nd_opt_adv_interval
{
288 uint8_t nd_opt_adv_interval_type
;
289 uint8_t nd_opt_adv_interval_len
;
290 uint16_t nd_opt_adv_interval_reserved
;
291 uint32_t nd_opt_adv_interval_ival
;
294 struct nd_opt_home_agent_info
{
295 uint8_t nd_opt_home_agent_info_type
;
296 uint8_t nd_opt_home_agent_info_len
;
297 uint16_t nd_opt_home_agent_info_reserved
;
298 uint16_t nd_opt_home_agent_info_preference
;
299 uint16_t nd_opt_home_agent_info_lifetime
;