cpp-d1064d
[cross.git] / i686-linux-gnu-4.7 / usr / include / netinet / icmp6.h
1 /* Copyright (C) 1991-2018 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, see
16    <http://www.gnu.org/licenses/>.  */
17
18 #ifndef _NETINET_ICMP6_H
19 #define _NETINET_ICMP6_H 1
20
21 #include <inttypes.h>
22 #include <string.h>
23 #include <sys/types.h>
24 #include <netinet/in.h>
25
26 #define ICMP6_FILTER 1
27
28 #define ICMP6_FILTER_BLOCK              1
29 #define ICMP6_FILTER_PASS               2
30 #define ICMP6_FILTER_BLOCKOTHERS        3
31 #define ICMP6_FILTER_PASSONLY           4
32
33 struct icmp6_filter
34   {
35     uint32_t icmp6_filt[8];
36   };
37
38 struct icmp6_hdr
39   {
40     uint8_t     icmp6_type;   /* type field */
41     uint8_t     icmp6_code;   /* code field */
42     uint16_t    icmp6_cksum;  /* checksum field */
43     union
44       {
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 */
48       } icmp6_dataun;
49   };
50
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 */
59
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
64
65 #define ICMP6_INFOMSG_MASK  0x80    /* all informational messages */
66
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
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 */
79
80 #define ICMP6_TIME_EXCEED_TRANSIT     0 /* Hop Limit == 0 in transit */
81 #define ICMP6_TIME_EXCEED_REASSEMBLY  1 /* Reassembly time out */
82
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 */
86
87 #define ICMP6_FILTER_WILLPASS(type, filterp) \
88         ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
89
90 #define ICMP6_FILTER_WILLBLOCK(type, filterp) \
91         ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
92
93 #define ICMP6_FILTER_SETPASS(type, filterp) \
94         ((((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31))))
95
96 #define ICMP6_FILTER_SETBLOCK(type, filterp) \
97         ((((filterp)->icmp6_filt[(type) >> 5]) |=  (1 << ((type) & 31))))
98
99 #define ICMP6_FILTER_SETPASSALL(filterp) \
100         memset (filterp, 0, sizeof (struct icmp6_filter));
101
102 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
103         memset (filterp, 0xFF, sizeof (struct icmp6_filter));
104
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
110
111 struct nd_router_solicit      /* router solicitation */
112   {
113     struct icmp6_hdr  nd_rs_hdr;
114     /* could be followed by options */
115   };
116
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]
121
122 struct nd_router_advert       /* router advertisement */
123   {
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 */
128   };
129
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]
139
140 struct nd_neighbor_solicit    /* neighbor solicitation */
141   {
142     struct icmp6_hdr  nd_ns_hdr;
143     struct in6_addr   nd_ns_target; /* target address */
144     /* could be followed by options */
145   };
146
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]
151
152 struct nd_neighbor_advert     /* neighbor advertisement */
153   {
154     struct icmp6_hdr  nd_na_hdr;
155     struct in6_addr   nd_na_target; /* target address */
156     /* could be followed by options */
157   };
158
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
171 #endif
172
173 struct nd_redirect            /* redirect */
174   {
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 */
179   };
180
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]
185
186 struct nd_opt_hdr             /* Neighbor discovery option header */
187   {
188     uint8_t  nd_opt_type;
189     uint8_t  nd_opt_len;        /* in units of 8 octets */
190     /* followed by option specific data */
191   };
192
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
197 #define ND_OPT_MTU                      5
198 #define ND_OPT_RTR_ADV_INTERVAL         7
199 #define ND_OPT_HOME_AGENT_INFO          8
200
201 struct nd_opt_prefix_info     /* prefix information */
202   {
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;
211   };
212
213 #define ND_OPT_PI_FLAG_ONLINK   0x80
214 #define ND_OPT_PI_FLAG_AUTO     0x40
215 #define ND_OPT_PI_FLAG_RADDR    0x20
216
217 struct nd_opt_rd_hdr          /* redirected header */
218   {
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 */
224   };
225
226 struct nd_opt_mtu             /* MTU option */
227   {
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;
232   };
233
234 struct mld_hdr
235   {
236     struct icmp6_hdr    mld_icmp6_hdr;
237     struct in6_addr     mld_addr; /* multicast address */
238   };
239
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]
245
246 #define ICMP6_ROUTER_RENUMBERING    138
247
248 struct icmp6_router_renum    /* router renumbering header */
249   {
250     struct icmp6_hdr    rr_hdr;
251     uint8_t             rr_segnum;
252     uint8_t             rr_flags;
253     uint16_t            rr_maxdelay;
254     uint32_t            rr_reserved;
255   };
256
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]
261
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
268
269 struct rr_pco_match    /* match prefix part */
270   {
271     uint8_t             rpm_code;
272     uint8_t             rpm_len;
273     uint8_t             rpm_ordinal;
274     uint8_t             rpm_matchlen;
275     uint8_t             rpm_minlen;
276     uint8_t             rpm_maxlen;
277     uint16_t            rpm_reserved;
278     struct in6_addr     rpm_prefix;
279   };
280
281 /* PCO code values */
282 #define RPM_PCO_ADD             1
283 #define RPM_PCO_CHANGE          2
284 #define RPM_PCO_SETGLOBAL       3
285
286 struct rr_pco_use      /* use prefix part */
287   {
288     uint8_t             rpu_uselen;
289     uint8_t             rpu_keeplen;
290     uint8_t             rpu_ramask;
291     uint8_t             rpu_raflags;
292     uint32_t            rpu_vltime;
293     uint32_t            rpu_pltime;
294     uint32_t            rpu_flags;
295     struct in6_addr     rpu_prefix;
296   };
297
298 #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK  0x20
299 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO    0x10
300
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
307 #endif
308
309 struct rr_result       /* router renumbering result message */
310   {
311     uint16_t            rrr_flags;
312     uint8_t             rrr_ordinal;
313     uint8_t             rrr_matchedlen;
314     uint32_t            rrr_ifid;
315     struct in6_addr     rrr_prefix;
316   };
317
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
324 #endif
325
326 /* Mobile IPv6 extension: Advertisement Interval.  */
327 struct nd_opt_adv_interval
328   {
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;
333   };
334
335 /* Mobile IPv6 extension: Home Agent Info.  */
336 struct nd_opt_home_agent_info
337   {
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;
343   };
344
345 #endif /* netinet/icmpv6.h */