rework langinfo code for ABI compat and for use by time code
[musl] / include / netinet / icmp6.h
1 #ifndef _NETINET_ICMP6_H
2 #define _NETINET_ICMP6_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 #include <stdint.h>
9 #include <string.h>
10 #include <sys/types.h>
11 #include <netinet/in.h>
12
13 #define ICMP6_FILTER 1
14
15 #define ICMP6_FILTER_BLOCK              1
16 #define ICMP6_FILTER_PASS               2
17 #define ICMP6_FILTER_BLOCKOTHERS        3
18 #define ICMP6_FILTER_PASSONLY           4
19
20 struct icmp6_filter {
21         uint32_t icmp6_filt[8];
22 };
23
24 struct icmp6_hdr {
25         uint8_t     icmp6_type;
26         uint8_t     icmp6_code;
27         uint16_t    icmp6_cksum;
28         union {
29                 uint32_t  icmp6_un_data32[1];
30                 uint16_t  icmp6_un_data16[2];
31                 uint8_t   icmp6_un_data8[4];
32         } icmp6_dataun;
33 };
34
35 #define icmp6_data32    icmp6_dataun.icmp6_un_data32
36 #define icmp6_data16    icmp6_dataun.icmp6_un_data16
37 #define icmp6_data8     icmp6_dataun.icmp6_un_data8
38 #define icmp6_pptr      icmp6_data32[0]
39 #define icmp6_mtu       icmp6_data32[0]
40 #define icmp6_id        icmp6_data16[0]
41 #define icmp6_seq       icmp6_data16[1]
42 #define icmp6_maxdelay  icmp6_data16[0]
43
44 #define ICMP6_DST_UNREACH             1
45 #define ICMP6_PACKET_TOO_BIG          2
46 #define ICMP6_TIME_EXCEEDED           3
47 #define ICMP6_PARAM_PROB              4
48
49 #define ICMP6_INFOMSG_MASK  0x80
50
51 #define ICMP6_ECHO_REQUEST          128
52 #define ICMP6_ECHO_REPLY            129
53 #define MLD_LISTENER_QUERY          130
54 #define MLD_LISTENER_REPORT         131
55 #define MLD_LISTENER_REDUCTION      132
56
57 #define ICMP6_DST_UNREACH_NOROUTE     0
58 #define ICMP6_DST_UNREACH_ADMIN       1
59 #define ICMP6_DST_UNREACH_BEYONDSCOPE 2
60 #define ICMP6_DST_UNREACH_ADDR        3
61 #define ICMP6_DST_UNREACH_NOPORT      4
62
63 #define ICMP6_TIME_EXCEED_TRANSIT     0
64 #define ICMP6_TIME_EXCEED_REASSEMBLY  1
65
66 #define ICMP6_PARAMPROB_HEADER        0
67 #define ICMP6_PARAMPROB_NEXTHEADER    1
68 #define ICMP6_PARAMPROB_OPTION        2
69
70 #define ICMP6_FILTER_WILLPASS(type, filterp) \
71         ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
72
73 #define ICMP6_FILTER_WILLBLOCK(type, filterp) \
74         ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
75
76 #define ICMP6_FILTER_SETPASS(type, filterp) \
77         ((((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31))))
78
79 #define ICMP6_FILTER_SETBLOCK(type, filterp) \
80         ((((filterp)->icmp6_filt[(type) >> 5]) |=  (1 << ((type) & 31))))
81
82 #define ICMP6_FILTER_SETPASSALL(filterp) \
83         memset (filterp, 0, sizeof (struct icmp6_filter));
84
85 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
86         memset (filterp, 0xFF, sizeof (struct icmp6_filter));
87
88 #define ND_ROUTER_SOLICIT           133
89 #define ND_ROUTER_ADVERT            134
90 #define ND_NEIGHBOR_SOLICIT         135
91 #define ND_NEIGHBOR_ADVERT          136
92 #define ND_REDIRECT                 137
93
94 struct nd_router_solicit {
95         struct icmp6_hdr  nd_rs_hdr;
96 };
97
98 #define nd_rs_type               nd_rs_hdr.icmp6_type
99 #define nd_rs_code               nd_rs_hdr.icmp6_code
100 #define nd_rs_cksum              nd_rs_hdr.icmp6_cksum
101 #define nd_rs_reserved           nd_rs_hdr.icmp6_data32[0]
102
103 struct nd_router_advert {
104         struct icmp6_hdr  nd_ra_hdr;
105         uint32_t   nd_ra_reachable;
106         uint32_t   nd_ra_retransmit;
107 };
108
109 #define nd_ra_type               nd_ra_hdr.icmp6_type
110 #define nd_ra_code               nd_ra_hdr.icmp6_code
111 #define nd_ra_cksum              nd_ra_hdr.icmp6_cksum
112 #define nd_ra_curhoplimit        nd_ra_hdr.icmp6_data8[0]
113 #define nd_ra_flags_reserved     nd_ra_hdr.icmp6_data8[1]
114 #define ND_RA_FLAG_MANAGED       0x80
115 #define ND_RA_FLAG_OTHER         0x40
116 #define ND_RA_FLAG_HOME_AGENT    0x20
117 #define nd_ra_router_lifetime    nd_ra_hdr.icmp6_data16[1]
118
119 struct nd_neighbor_solicit {
120         struct icmp6_hdr  nd_ns_hdr;
121         struct in6_addr   nd_ns_target;
122 };
123
124 #define nd_ns_type               nd_ns_hdr.icmp6_type
125 #define nd_ns_code               nd_ns_hdr.icmp6_code
126 #define nd_ns_cksum              nd_ns_hdr.icmp6_cksum
127 #define nd_ns_reserved           nd_ns_hdr.icmp6_data32[0]
128
129 struct nd_neighbor_advert {
130         struct icmp6_hdr  nd_na_hdr;
131         struct in6_addr   nd_na_target;
132 };
133
134 #define nd_na_type               nd_na_hdr.icmp6_type
135 #define nd_na_code               nd_na_hdr.icmp6_code
136 #define nd_na_cksum              nd_na_hdr.icmp6_cksum
137 #define nd_na_flags_reserved     nd_na_hdr.icmp6_data32[0]
138 #if     __BYTE_ORDER == __BIG_ENDIAN
139 #define ND_NA_FLAG_ROUTER        0x80000000
140 #define ND_NA_FLAG_SOLICITED     0x40000000
141 #define ND_NA_FLAG_OVERRIDE      0x20000000
142 #else
143 #define ND_NA_FLAG_ROUTER        0x00000080
144 #define ND_NA_FLAG_SOLICITED     0x00000040
145 #define ND_NA_FLAG_OVERRIDE      0x00000020
146 #endif
147
148 struct nd_redirect {
149         struct icmp6_hdr  nd_rd_hdr;
150         struct in6_addr   nd_rd_target;
151         struct in6_addr   nd_rd_dst;
152 };
153
154 #define nd_rd_type               nd_rd_hdr.icmp6_type
155 #define nd_rd_code               nd_rd_hdr.icmp6_code
156 #define nd_rd_cksum              nd_rd_hdr.icmp6_cksum
157 #define nd_rd_reserved           nd_rd_hdr.icmp6_data32[0]
158
159 struct nd_opt_hdr {
160         uint8_t  nd_opt_type;
161         uint8_t  nd_opt_len;
162 };
163
164 #define ND_OPT_SOURCE_LINKADDR          1
165 #define ND_OPT_TARGET_LINKADDR          2
166 #define ND_OPT_PREFIX_INFORMATION       3
167 #define ND_OPT_REDIRECTED_HEADER        4
168 #define ND_OPT_MTU                      5
169 #define ND_OPT_RTR_ADV_INTERVAL         7
170 #define ND_OPT_HOME_AGENT_INFO          8
171
172 struct nd_opt_prefix_info {
173         uint8_t   nd_opt_pi_type;
174         uint8_t   nd_opt_pi_len;
175         uint8_t   nd_opt_pi_prefix_len;
176         uint8_t   nd_opt_pi_flags_reserved;
177         uint32_t  nd_opt_pi_valid_time;
178         uint32_t  nd_opt_pi_preferred_time;
179         uint32_t  nd_opt_pi_reserved2;
180         struct in6_addr  nd_opt_pi_prefix;
181 };
182
183 #define ND_OPT_PI_FLAG_ONLINK   0x80
184 #define ND_OPT_PI_FLAG_AUTO     0x40
185 #define ND_OPT_PI_FLAG_RADDR    0x20
186
187 struct nd_opt_rd_hdr {
188         uint8_t   nd_opt_rh_type;
189         uint8_t   nd_opt_rh_len;
190         uint16_t  nd_opt_rh_reserved1;
191         uint32_t  nd_opt_rh_reserved2;
192 };
193
194 struct nd_opt_mtu {
195         uint8_t   nd_opt_mtu_type;
196         uint8_t   nd_opt_mtu_len;
197         uint16_t  nd_opt_mtu_reserved;
198         uint32_t  nd_opt_mtu_mtu;
199 };
200
201 struct mld_hdr {
202         struct icmp6_hdr    mld_icmp6_hdr;
203         struct in6_addr     mld_addr;
204 };
205
206 #define mld_type        mld_icmp6_hdr.icmp6_type
207 #define mld_code        mld_icmp6_hdr.icmp6_code
208 #define mld_cksum       mld_icmp6_hdr.icmp6_cksum
209 #define mld_maxdelay    mld_icmp6_hdr.icmp6_data16[0]
210 #define mld_reserved    mld_icmp6_hdr.icmp6_data16[1]
211
212 #define ICMP6_ROUTER_RENUMBERING    138
213
214 struct icmp6_router_renum {
215         struct icmp6_hdr    rr_hdr;
216         uint8_t             rr_segnum;
217         uint8_t             rr_flags;
218         uint16_t            rr_maxdelay;
219         uint32_t            rr_reserved;
220 };
221
222 #define rr_type         rr_hdr.icmp6_type
223 #define rr_code         rr_hdr.icmp6_code
224 #define rr_cksum        rr_hdr.icmp6_cksum
225 #define rr_seqnum       rr_hdr.icmp6_data32[0]
226
227 #define ICMP6_RR_FLAGS_TEST             0x80
228 #define ICMP6_RR_FLAGS_REQRESULT        0x40
229 #define ICMP6_RR_FLAGS_FORCEAPPLY       0x20
230 #define ICMP6_RR_FLAGS_SPECSITE         0x10
231 #define ICMP6_RR_FLAGS_PREVDONE         0x08
232
233 struct rr_pco_match {
234         uint8_t             rpm_code;
235         uint8_t             rpm_len;
236         uint8_t             rpm_ordinal;
237         uint8_t             rpm_matchlen;
238         uint8_t             rpm_minlen;
239         uint8_t             rpm_maxlen;
240         uint16_t            rpm_reserved;
241         struct in6_addr     rpm_prefix;
242 };
243
244 #define RPM_PCO_ADD             1
245 #define RPM_PCO_CHANGE          2
246 #define RPM_PCO_SETGLOBAL       3
247
248 struct rr_pco_use {
249         uint8_t             rpu_uselen;
250         uint8_t             rpu_keeplen;
251         uint8_t             rpu_ramask;
252         uint8_t             rpu_raflags;
253         uint32_t            rpu_vltime;
254         uint32_t            rpu_pltime;
255         uint32_t            rpu_flags;
256         struct in6_addr     rpu_prefix;
257 };
258
259 #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK  0x20
260 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO    0x10
261
262 #if __BYTE_ORDER == __BIG_ENDIAN
263 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
264 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
265 #else
266 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
267 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
268 #endif
269
270 struct rr_result {
271         uint16_t            rrr_flags;
272         uint8_t             rrr_ordinal;
273         uint8_t             rrr_matchedlen;
274         uint32_t            rrr_ifid;
275         struct in6_addr     rrr_prefix;
276 };
277
278 #if __BYTE_ORDER == __BIG_ENDIAN
279 #define ICMP6_RR_RESULT_FLAGS_OOB       0x0002
280 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
281 #else
282 #define ICMP6_RR_RESULT_FLAGS_OOB       0x0200
283 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
284 #endif
285
286 struct nd_opt_adv_interval {
287         uint8_t   nd_opt_adv_interval_type;
288         uint8_t   nd_opt_adv_interval_len;
289         uint16_t  nd_opt_adv_interval_reserved;
290         uint32_t  nd_opt_adv_interval_ival;
291 };
292
293 struct nd_opt_home_agent_info {
294         uint8_t   nd_opt_home_agent_info_type;
295         uint8_t   nd_opt_home_agent_info_len;
296         uint16_t  nd_opt_home_agent_info_reserved;
297         uint16_t  nd_opt_home_agent_info_preference;
298         uint16_t  nd_opt_home_agent_info_lifetime;
299 };
300
301 #ifdef __cplusplus
302 }
303 #endif
304
305 #endif