]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/net/tcpip/v2_0/include/netinet6/ipv6_icmp.h
Initial revision
[karo-tx-redboot.git] / packages / net / tcpip / v2_0 / include / netinet6 / ipv6_icmp.h
1 //==========================================================================
2 //
3 //      include/netinet6_ipv6_icmp.h
4 //
5 //      
6 //
7 //==========================================================================
8 //####BSDCOPYRIGHTBEGIN####
9 //
10 // -------------------------------------------
11 //
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.
14 //
15 // -------------------------------------------
16 //
17 //####BSDCOPYRIGHTEND####
18 //==========================================================================
19 //#####DESCRIPTIONBEGIN####
20 //
21 // Author(s):    gthomas
22 // Contributors: gthomas
23 // Date:         2000-01-10
24 // Purpose:      
25 // Description:  
26 //              
27 //
28 //####DESCRIPTIONEND####
29 //
30 //==========================================================================
31
32
33 /*
34 %%% copyright-nrl-95
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>.
42
43 */
44
45 #ifndef _NETINET6_IPV6_ICMP_H
46 #define _NETINET6_IPV6_ICMP_H 1
47
48 /*
49  * ICMPv6 header.
50  */
51
52 struct ipv6_icmp
53 {
54   uint8_t icmp_type;
55   uint8_t icmp_code;
56   uint16_t icmp_cksum;
57   union
58     {
59       uint32_t ih_reserved;
60       struct
61         {
62           uint16_t ihs_id;
63           uint16_t ihs_seq;
64         } ih_idseq;
65       struct
66         {
67           uint8_t ihr_hoplimit;
68           uint8_t ihr_bits;
69           uint16_t ihr_lifetime;
70         } ih_radv;
71     } icmp_hun;
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
83   union
84     {
85       struct
86         {
87           struct ipv6 ido_ipv6;
88           uint8_t ido_remaining[1];
89         } id_offending;
90       uint8_t id_data[1];
91       struct
92         {
93           struct in6_addr idn_addr;
94           uint8_t idn_ext[1];
95         } id_neighbor;
96       struct
97         {
98           struct in6_addr idr_addr1;
99           struct in6_addr idr_addr2;
100           uint8_t idr_ext[1];
101         } id_redirect;
102       struct
103         {
104           uint32_t ida_reachable;
105           uint32_t ida_retrans;
106           uint8_t ida_opt[1];
107         } id_radv;
108     } icmp_dun;
109 #define icmp_offending icmp_dun.id_offending
110 #define icmp_ipv6 icmp_dun.id_offending.ido_ipv6
111
112 #define icmp_echodata icmp_dun.id_data
113
114 #define icmp_grpaddr icmp_dun.id_neighbor.idn_addr
115
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
119
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
124
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
128 };
129
130 /*
131  * ICMPv6 extension constants.
132  */
133
134 #define EXT_SOURCELINK 1
135 #define EXT_TARGETLINK 2
136 #define EXT_PREFIX 3
137 #define EXT_REDIR 4
138 #define EXT_MTU 5
139
140 /*
141  * Extension structures for IPv6 discovery messages.
142  */
143
144 struct icmp_exthdr    /* Generic extension */
145 {
146   uint8_t ext_id;
147   uint8_t ext_length;    /* Length is 8 * this field, 0 is invalid. */
148   uint8_t ext_data[6];   /* Padded to 8 bytes. */
149 };
150
151 struct ext_prefinfo    /* Prefix information */
152 {
153   uint8_t pre_extid;
154   uint8_t pre_length;
155
156   uint8_t pre_prefixsize;
157   uint8_t pre_bits;
158
159   uint32_t pre_valid;
160   uint32_t pre_preferred;
161   uint32_t pre_reserved;
162
163   struct in6_addr pre_prefix;
164 };
165
166 /*
167  * Values for pre_bits
168  */
169 #define ICMPV6_PREFIX_ONLINK 0x80
170 #define ICMPV6_PREFIX_AUTO 0x40
171
172 struct ext_redir    /* Redirected header */
173 {
174   uint8_t rd_extid;
175   uint8_t rd_length;
176   uint8_t rd_reserved[6];
177   struct ipv6 rd_header;
178 };
179
180 struct ext_mtu      /* Recommended link MTU. */
181 {
182   uint8_t mtu_extid;
183   uint8_t mtu_length;
184   uint16_t mtu_reserved;
185   uint32_t mtu_mtu;
186 };
187
188 /*
189  * Constants
190  */
191
192 /*
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.
199  */
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. */
212
213 /*
214  * Definition of type and code field values.
215  * ICMPv6 fixes things so that info messages are >= 128.
216  */
217
218 /* Error messages and codes. */
219
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
224                                                            routing. */
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
233                                                            parameter. */
234 #define         ICMPV6_PARAMPROB_NEXTHDR 1              /* Bad next hdr. */
235 #define         ICMPV6_PARAMPROB_BADOPT  2                /* Unrec. option */
236
237 /* Info messages. */
238
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. */
244
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. */
249
250 #define ICMPV6_REDIRECT         137             /* ICMPv6 redirect. */
251
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. */
261 #endif
262
263 #define ICMPV6_MAXTYPE          137
264
265 #define ICMPV6_INFOTYPE(type) ((type) >= 128)
266
267 #if defined(_KERNEL) || defined(KERNEL)
268 #include <netinet6/ipv6_var.h>
269
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__ */
282
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) */
289
290 #endif /* _NETINET6_IPV6_ICMP_H */