Update.
[glibc.git] / inet / netinet / icmp6.h
blob5a38639539523e0f3cbb477db487fc214968adb5
1 /* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 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 Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 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 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
19 #ifndef _NETINET_ICMP6_H
20 #define _NETINET_ICMP6_H 1
22 #include <inttypes.h>
23 #include <string.h>
24 #include <sys/types.h>
25 #include <netinet/in.h>
27 #define ICMP6_FILTER 1
29 #define ICMP6_FILTER_BLOCK 1
30 #define ICMP6_FILTER_PASS 2
31 #define ICMP6_FILTER_BLOCKOTHERS 3
32 #define ICMP6_FILTER_PASSONLY 4
34 struct icmp6_filter
36 uint32_t data[8];
39 struct icmp6_hdr
41 uint8_t icmp6_type; /* type field */
42 uint8_t icmp6_code; /* code field */
43 uint16_t icmp6_cksum; /* checksum field */
44 union
46 uint32_t icmp6_un_data32[1]; /* type-specific field */
47 uint16_t icmp6_un_data16[2]; /* type-specific field */
48 uint8_t icmp6_un_data8[4]; /* type-specific field */
49 } icmp6_dataun;
50 };
52 #define icmp6_data32 icmp6_dataun.icmp6_un_data32
53 #define icmp6_data16 icmp6_dataun.icmp6_un_data16
54 #define icmp6_data8 icmp6_dataun.icmp6_un_data8
55 #define icmp6_pptr icmp6_data32[0] /* parameter prob */
56 #define icmp6_mtu icmp6_data32[0] /* packet too big */
57 #define icmp6_id icmp6_data16[0] /* echo request/reply */
58 #define icmp6_seq icmp6_data16[1] /* echo request/reply */
59 #define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
61 #define ICMP6_DST_UNREACH 1
62 #define ICMP6_PACKET_TOO_BIG 2
63 #define ICMP6_TIME_EXCEEDED 3
64 #define ICMP6_PARAM_PROB 4
66 #define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
68 #define ICMP6_ECHO_REQUEST 128
69 #define ICMP6_ECHO_REPLY 129
70 #define ICMP6_MEMBERSHIP_QUERY 130
71 #define ICMP6_MEMBERSHIP_REPORT 131
72 #define ICMP6_MEMBERSHIP_REDUCTION 132
74 #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
75 #define ICMP6_DST_UNREACH_ADMIN 1 /* communication with destination */
76 /* administratively prohibited */
77 #define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor */
78 #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
79 #define ICMP6_DST_UNREACH_NOPORT 4 /* bad port */
81 #define ICMP6_TIME_EXCEED_TRANSIT 0 /* Hop Limit == 0 in transit */
82 #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* Reassembly time out */
84 #define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
85 #define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized Next Header */
86 #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized IPv6 option */
88 #define ICMP6_FILTER_WILLPASS(type, filterp) \
89 ((((filterp)->data[(type) >> 5]) & (1 << ((type) & 31))) == 0)
91 #define ICMP6_FILTER_WILLBLOCK(type, filterp) \
92 ((((filterp)->data[(type) >> 5]) & (1 << ((type) & 31))) != 0)
94 #define ICMP6_FILTER_SETPASS(type, filterp) \
95 ((((filterp)->data[(type) >> 5]) &= ~(1 << ((type) & 31))))
97 #define ICMP6_FILTER_SETBLOCK(type, filterp) \
98 ((((filterp)->data[(type) >> 5]) |= (1 << ((type) & 31))))
100 #define ICMP6_FILTER_SETPASSALL(filterp) \
101 memset (filterp, 0, sizeof (struct icmp6_filter));
103 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
104 memset (filterp, 0xFF, sizeof (struct icmp6_filter));
106 #define ND_ROUTER_SOLICIT 133
107 #define ND_ROUTER_ADVERT 134
108 #define ND_NEIGHBOR_SOLICIT 135
109 #define ND_NEIGHBOR_ADVERT 136
110 #define ND_REDIRECT 137
112 struct nd_router_solicit /* router solicitation */
114 struct icmp6_hdr nd_rs_hdr;
115 /* could be followed by options */
118 #define nd_rs_type nd_rs_hdr.icmp6_type
119 #define nd_rs_code nd_rs_hdr.icmp6_code
120 #define nd_rs_cksum nd_rs_hdr.icmp6_cksum
121 #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
123 struct nd_router_advert /* router advertisement */
125 struct icmp6_hdr nd_ra_hdr;
126 uint32_t nd_ra_reachable; /* reachable time */
127 uint32_t nd_ra_retransmit; /* retransmit timer */
128 /* could be followed by options */
131 #define nd_ra_type nd_ra_hdr.icmp6_type
132 #define nd_ra_code nd_ra_hdr.icmp6_code
133 #define nd_ra_cksum nd_ra_hdr.icmp6_cksum
134 #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
135 #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
136 #define ND_RA_FLAG_MANAGED 0x80
137 #define ND_RA_FLAG_OTHER 0x40
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
171 #endif
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 */
188 uint8_t nd_opt_type;
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
197 #define ND_OPT_MTU 5
199 struct nd_opt_prefix_info /* prefix information */
201 uint8_t nd_opt_pi_type;
202 uint8_t nd_opt_pi_len;
203 uint8_t nd_opt_pi_prefix_len;
204 uint8_t nd_opt_pi_flags_reserved;
205 uint32_t nd_opt_pi_valid_time;
206 uint32_t nd_opt_pi_preferred_time;
207 uint32_t nd_opt_pi_reserved2;
208 struct in6_addr nd_opt_pi_prefix;
211 #define ND_OPT_PI_FLAG_ONLINK 0x80
212 #define ND_OPT_PI_FLAG_AUTO 0x40
214 struct nd_opt_rd_hdr /* redirected header */
216 uint8_t nd_opt_rh_type;
217 uint8_t nd_opt_rh_len;
218 uint16_t nd_opt_rh_reserved1;
219 uint32_t nd_opt_rh_reserved2;
220 /* followed by IP header and data */
223 struct nd_opt_mtu /* MTU option */
225 uint8_t nd_opt_mtu_type;
226 uint8_t nd_opt_mtu_len;
227 uint16_t nd_opt_mtu_reserved;
228 uint32_t nd_opt_mtu_mtu;
232 #endif /* netinet/icmpv6.h */