1 //==========================================================================
3 // include/netinet6_ipv6_icmp.h
7 //==========================================================================
8 //####BSDCOPYRIGHTBEGIN####
10 // -------------------------------------------
12 // Portions of this software may have been derived from OpenBSD or other sources,
13 // and are covered by the appropriate copyright disclaimers included herein.
15 // -------------------------------------------
17 //####BSDCOPYRIGHTEND####
18 //==========================================================================
19 //#####DESCRIPTIONBEGIN####
22 // Contributors: gthomas
28 //####DESCRIPTIONEND####
30 //==========================================================================
35 This software is Copyright 1995-1998 by Randall Atkinson, Ronald Lee,
36 Daniel McDonald, Bao Phan, and Chris Winters. All Rights Reserved. All
37 rights under this copyright have been assigned to the US Naval Research
38 Laboratory (NRL). The NRL Copyright Notice and License Agreement Version
39 1.1 (January 17, 1995) applies to this software.
40 You should have received a copy of the license with this software. If you
41 didn't get a copy, you may request one from <license@ipv6.nrl.navy.mil>.
45 #ifndef _NETINET6_IPV6_ICMP_H
46 #define _NETINET6_IPV6_ICMP_H 1
69 uint16_t ihr_lifetime;
72 #define icmp_unused icmp_hun.ih_reserved
73 #define icmp_nexthopmtu icmp_hun.ih_reserved
74 #define icmp_paramptr icmp_hun.ih_reserved
75 #define icmp_echoid icmp_hun.ih_idseq.ihs_id
76 #define icmp_echoseq icmp_hun.ih_idseq.ihs_seq
77 #define icmp_grpdelay icmp_hun.ih_idseq.ihs_id
78 #define icmp_grpunused icmp_hun.ih_idseq.ihs_seq
79 #define icmp_nadvbits icmp_hun.ih_reserved
80 #define icmp_radvhop icmp_hun.ih_radv.ihr_hoplimit
81 #define icmp_radvbits icmp_hun.ih_radv.ihr_bits
82 #define icmp_radvlifetime icmp_hun.ih_radv.ihr_lifetime
88 uint8_t ido_remaining[1];
93 struct in6_addr idn_addr;
98 struct in6_addr idr_addr1;
99 struct in6_addr idr_addr2;
104 uint32_t ida_reachable;
105 uint32_t ida_retrans;
109 #define icmp_offending icmp_dun.id_offending
110 #define icmp_ipv6 icmp_dun.id_offending.ido_ipv6
112 #define icmp_echodata icmp_dun.id_data
114 #define icmp_grpaddr icmp_dun.id_neighbor.idn_addr
116 #define icmp_radvreach icmp_dun.id_radv.ida_reachable
117 #define icmp_radvretrans icmp_dun.id_radv.ida_retrans
118 #define icmp_radvext icmp_dun.id_radv.ida_opt
120 #define icmp_nsoltarg icmp_dun.id_neighbor.idn_addr
121 #define icmp_nsolext icmp_dun.id_neighbor.idn_ext
122 #define icmp_nadvaddr icmp_dun.id_neighbor.idn_addr
123 #define icmp_nadvext icmp_dun.id_neighbor.idn_ext
125 #define icmp_redirtarg icmp_dun.id_redirect.idr_addr1
126 #define icmp_redirdest icmp_dun.id_redirect.idr_addr2
127 #define icmp_redirext icmp_dun.id_redirect.idr_ext
131 * ICMPv6 extension constants.
134 #define EXT_SOURCELINK 1
135 #define EXT_TARGETLINK 2
141 * Extension structures for IPv6 discovery messages.
144 struct icmp_exthdr /* Generic extension */
147 uint8_t ext_length; /* Length is 8 * this field, 0 is invalid. */
148 uint8_t ext_data[6]; /* Padded to 8 bytes. */
151 struct ext_prefinfo /* Prefix information */
156 uint8_t pre_prefixsize;
160 uint32_t pre_preferred;
161 uint32_t pre_reserved;
163 struct in6_addr pre_prefix;
167 * Values for pre_bits
169 #define ICMPV6_PREFIX_ONLINK 0x80
170 #define ICMPV6_PREFIX_AUTO 0x40
172 struct ext_redir /* Redirected header */
176 uint8_t rd_reserved[6];
177 struct ipv6 rd_header;
180 struct ext_mtu /* Recommended link MTU. */
184 uint16_t mtu_reserved;
193 * Lower bounds on packet lengths for various types.
194 * For the error advice packets must first insure that the
195 * packet is large enought to contain the returned ip header.
196 * Only then can we do the check to see if enough bits of packet
197 * data have been returned, since we need to check the returned
198 * ipv6 header length.
200 #define ICMPV6_MINLEN 8 /* abs minimum */
201 #define ICMPV6_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */
202 #define ICMPV6_NADVMINLEN 24 /* min neighbor advertisement */
203 #define ICMPV6_NSOLMINLEN 24 /* min neighbor solicit */
204 #define ICMPV6_RADVMINLEN 16 /* min router advertisement */
205 #define ICMPV6_RSOLMINLEN 8 /* min router solicit */
206 #define ICMPV6_REDIRMINLEN 40 /* min redirect */
207 #define ICMPV6_HLPMINLEN (8 + sizeof(struct ipv6) + 8) /* HLP demux len. */
208 #define ICMPV6_MAXLEN 576 /* This should be whatever IPV6_MINMTU
209 will be. I take this to be the WHOLE
210 packet, including IPv6 header, and any
211 IPv6 options before the ICMP message. */
214 * Definition of type and code field values.
215 * ICMPv6 fixes things so that info messages are >= 128.
218 /* Error messages and codes. */
220 #define ICMPV6_UNREACH 1 /* dest unreachable, codes: */
221 #define ICMPV6_UNREACH_NOROUTE 0 /* No route to dest. */
222 #define ICMPV6_UNREACH_ADMIN 1 /* Admin. prohibited */
223 #define ICMPV6_UNREACH_NOTNEIGHBOR 2 /* For strict source
225 #define ICMPV6_UNREACH_ADDRESS 3 /* Address unreach. */
226 #define ICMPV6_UNREACH_PORT 4 /* Port unreachable */
227 #define ICMPV6_TOOBIG 2 /* Packet too big. */
228 #define ICMPV6_TIMXCEED 3 /* time exceeded, code: */
229 #define ICMPV6_TIMXCEED_INTRANS 0 /* ttl==0 in transit */
230 #define ICMPV6_TIMXCEED_REASS 1 /* Reassembly t.o. */
231 #define ICMPV6_PARAMPROB 4 /* ip header bad */
232 #define ICMPV6_PARAMPROB_PROB 0 /* Actual incorrect
234 #define ICMPV6_PARAMPROB_NEXTHDR 1 /* Bad next hdr. */
235 #define ICMPV6_PARAMPROB_BADOPT 2 /* Unrec. option */
239 #define ICMPV6_ECHO 128 /* echo service */
240 #define ICMPV6_ECHOREPLY 129 /* echo reply */
241 #define ICMPV6_GRPQUERY 130 /* Query group membership. */
242 #define ICMPV6_GRPREPORT 131 /* Join mcast group. */
243 #define ICMPV6_GRPTERM 132 /* Leave mcast group. */
245 #define ICMPV6_ROUTERSOL 133 /* Router solicit. */
246 #define ICMPV6_ROUTERADV 134 /* Router advertisement. */
247 #define ICMPV6_NEIGHBORSOL 135 /* Neighbor solicit. */
248 #define ICMPV6_NEIGHBORADV 136 /* Neighbor advertisement. */
250 #define ICMPV6_REDIRECT 137 /* ICMPv6 redirect. */
252 /* Defined this way to save some HTONL cycles on little-endian boxes. */
253 #if BYTE_ORDER == BIG_ENDIAN
254 #define ICMPV6_NEIGHBORADV_RTR 0x80000000 /* Router flag. */
255 #define ICMPV6_NEIGHBORADV_SOL 0x40000000 /* Solicited flag. */
256 #define ICMPV6_NEIGHBORADV_OVERRIDE 0x20000000 /* Override flag. */
257 #else /* BYTE_ORDER == LITTLE_ENDIAN */
258 #define ICMPV6_NEIGHBORADV_RTR 0x80 /* Router flag. */
259 #define ICMPV6_NEIGHBORADV_SOL 0x40 /* Solicited flag. */
260 #define ICMPV6_NEIGHBORADV_OVERRIDE 0x20 /* Override flag. */
263 #define ICMPV6_MAXTYPE 137
265 #define ICMPV6_INFOTYPE(type) ((type) >= 128)
267 #if defined(_KERNEL) || defined(KERNEL)
268 #include <netinet6/ipv6_var.h>
270 /* Function prototypes */
271 void ipv6_icmp_error(struct mbuf *, int, int, uint32_t);
272 void ipv6_icmp_input(struct mbuf *, int);
273 void ipv6_gsolicit(struct ifnet *, struct mbuf *, struct rtentry *);
274 void ipv6_rtrequest(int, struct rtentry *, struct sockaddr *);
275 int ipv6_icmp_output(struct mbuf *,struct socket *, struct in6_addr *);
276 int ipv6_icmp_sysctl(int *, u_int, void *, size_t *, void *, size_t);
277 #if __NetBSD__ || __FreeBSD__
278 int ipv6_icmp_usrreq(struct socket *,int, struct mbuf *,struct mbuf *, struct mbuf *, struct proc *);
279 #else /* __NetBSD__ || __FreeBSD__ */
280 int ipv6_icmp_usrreq(struct socket *,int, struct mbuf *,struct mbuf *, struct mbuf *);
281 #endif /* __NetBSD__ || __FreeBSD__ */
283 void ipv6_routersol_input(struct mbuf *, int);
284 void ipv6_routeradv_input(struct mbuf *, int);
285 void ipv6_neighborsol_input(struct mbuf *, int);
286 void ipv6_neighboradv_input(struct mbuf *, int);
287 void ipv6_redirect_input(struct mbuf *, int);
288 #endif /* defined(_KERNEL) || defined(KERNEL) */
290 #endif /* _NETINET6_IPV6_ICMP_H */