added watt32 headers and brought the DOS version up to parity with UNIX
[oftp] / libs / watt32 / netinet6 / ip6_var.h
1 /*!\file netinet6/ip6_var.h
2  *
3  */
4
5 /*      $FreeBSD: src/sys/netinet6/ip6_var.h,v 1.9 2002/07/25 17:40:45 ume Exp $        */
6 /*      $KAME: ip6_var.h,v 1.62 2001/05/03 14:51:48 itojun Exp $        */
7
8 /*
9  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  * 3. Neither the name of the project nor the names of its contributors
21  *    may be used to endorse or promote products derived from this software
22  *    without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  */
36
37 /*
38  * Copyright (c) 1982, 1986, 1993
39  *      The Regents of the University of California.  All rights reserved.
40  *
41  * Redistribution and use in source and binary forms, with or without
42  * modification, are permitted provided that the following conditions
43  * are met:
44  * 1. Redistributions of source code must retain the above copyright
45  *    notice, this list of conditions and the following disclaimer.
46  * 2. Redistributions in binary form must reproduce the above copyright
47  *    notice, this list of conditions and the following disclaimer in the
48  *    documentation and/or other materials provided with the distribution.
49  * 3. All advertising materials mentioning features or use of this software
50  *    must display the following acknowledgement:
51  *      This product includes software developed by the University of
52  *      California, Berkeley and its contributors.
53  * 4. Neither the name of the University nor the names of its contributors
54  *    may be used to endorse or promote products derived from this software
55  *    without specific prior written permission.
56  *
57  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
58  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
60  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
61  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
62  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
63  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
65  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
66  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
67  * SUCH DAMAGE.
68  *
69  *      @(#)ip_var.h    8.1 (Berkeley) 6/10/93
70  */
71
72 #ifndef _NETINET6_IP6_VAR_H_
73 #define _NETINET6_IP6_VAR_H_
74
75 #include <sys/queue.h>
76
77 #if !defined(__BORLANDC__) /* stop warnings for undefined structs */
78 /*
79  * IP6 reassembly queue structure.  Each fragment
80  * being reassembled is attached to one of these structures.
81  */
82 struct  ip6q {
83         u_int32_t       ip6q_head;
84         u_int16_t       ip6q_len;
85         u_int8_t        ip6q_nxt;       /* ip6f_nxt in first fragment */
86         u_int8_t        ip6q_hlim;
87         struct ip6asfrag *ip6q_down;
88         struct ip6asfrag *ip6q_up;
89         u_int32_t       ip6q_ident;
90         u_int8_t        ip6q_arrive;
91         u_int8_t        ip6q_ttl;
92         struct in6_addr ip6q_src, ip6q_dst;
93         struct ip6q     *ip6q_next;
94         struct ip6q     *ip6q_prev;
95         int             ip6q_unfrglen;  /* len of unfragmentable part */
96 #ifdef notyet
97         u_char          *ip6q_nxtp;
98 #endif
99 };
100
101 struct  ip6asfrag {
102         u_int32_t       ip6af_head;
103         u_int16_t       ip6af_len;
104         u_int8_t        ip6af_nxt;
105         u_int8_t        ip6af_hlim;
106         /* must not override the above members during reassembling */
107         struct ip6asfrag *ip6af_down;
108         struct ip6asfrag *ip6af_up;
109         struct mbuf     *ip6af_m;
110         int             ip6af_offset;   /* offset in ip6af_m to next header */
111         int             ip6af_frglen;   /* fragmentable part length */
112         int             ip6af_off;      /* fragment offset */
113         u_int16_t       ip6af_mff;      /* more fragment bit in frag off */
114 };
115
116 #define IP6_REASS_MBUF(ip6af) (*(struct mbuf **)&((ip6af)->ip6af_m))
117
118 struct  ip6_moptions {
119         struct  ifnet *im6o_multicast_ifp; /* ifp for outgoing multicasts */
120         u_char  im6o_multicast_hlim;    /* hoplimit for outgoing multicasts */
121         u_char  im6o_multicast_loop;    /* 1 >= hear sends if a member */
122         LIST_HEAD(dummy, in6_multi_mship) im6o_memberships;
123 };
124 #endif   /* __BORLANDC__ */
125
126 #ifndef _NETINET6_IN6_H_
127 struct  route_in6 {
128         struct  rtentry *ro_rt;
129         struct  sockaddr_in6 ro_dst;
130 };
131 #endif
132
133 /*
134  * Control options for outgoing packets
135  */
136
137 /* Routing header related info */
138 #if !defined(__BORLANDC__)
139 struct  ip6po_rhinfo {
140         struct  ip6_rthdr *ip6po_rhi_rthdr; /* Routing header */
141         struct  route_in6 ip6po_rhi_route; /* Route to the 1st hop */
142 };
143 #define ip6po_rthdr     ip6po_rhinfo.ip6po_rhi_rthdr
144 #define ip6po_route     ip6po_rhinfo.ip6po_rhi_route
145
146 struct  ip6_pktopts {
147         struct  mbuf *ip6po_m;  /* Pointer to mbuf storing the data */
148         int     ip6po_hlim;     /* Hoplimit for outgoing packets */
149
150         /* Outgoing IF/address information */
151         struct  in6_pktinfo *ip6po_pktinfo;
152
153         struct  sockaddr *ip6po_nexthop; /* Next-hop address */
154         
155         struct  ip6_hbh *ip6po_hbh; /* Hop-by-Hop options header */
156
157         /* Destination options header (before a routing header) */
158         struct  ip6_dest *ip6po_dest1;
159
160         /* Routing header related info. */
161         struct  ip6po_rhinfo ip6po_rhinfo;
162
163         /* Destination options header (after a routing header) */
164         struct  ip6_dest *ip6po_dest2;
165 };
166 #endif   /* __BORLANDC__ */
167
168 /*
169  * Control options for incoming packets
170  */
171
172 struct  ip6stat {
173         u_quad_t ip6s_total;            /* total packets received */
174         u_quad_t ip6s_tooshort;         /* packet too short */
175         u_quad_t ip6s_toosmall;         /* not enough data */
176         u_quad_t ip6s_fragments;        /* fragments received */
177         u_quad_t ip6s_fragdropped;      /* frags dropped(dups, out of space) */
178         u_quad_t ip6s_fragtimeout;      /* fragments timed out */
179         u_quad_t ip6s_fragoverflow;     /* fragments that exceeded limit */
180         u_quad_t ip6s_forward;          /* packets forwarded */
181         u_quad_t ip6s_cantforward;      /* packets rcvd for unreachable dest */
182         u_quad_t ip6s_redirectsent;     /* packets forwarded on same net */
183         u_quad_t ip6s_delivered;        /* datagrams delivered to upper level*/
184         u_quad_t ip6s_localout;         /* total ip packets generated here */
185         u_quad_t ip6s_odropped;         /* lost packets due to nobufs, etc. */
186         u_quad_t ip6s_reassembled;      /* total packets reassembled ok */
187         u_quad_t ip6s_fragmented;       /* datagrams sucessfully fragmented */
188         u_quad_t ip6s_ofragments;       /* output fragments created */
189         u_quad_t ip6s_cantfrag;         /* don't fragment flag was set, etc. */
190         u_quad_t ip6s_badoptions;       /* error in option processing */
191         u_quad_t ip6s_noroute;          /* packets discarded due to no route */
192         u_quad_t ip6s_badvers;          /* ip6 version != 6 */
193         u_quad_t ip6s_rawout;           /* total raw ip packets generated */
194         u_quad_t ip6s_badscope;         /* scope error */
195         u_quad_t ip6s_notmember;        /* don't join this multicast group */
196         u_quad_t ip6s_nxthist[256];     /* next header history */
197         u_quad_t ip6s_m1;               /* one mbuf */
198         u_quad_t ip6s_m2m[32];          /* two or more mbuf */
199         u_quad_t ip6s_mext1;            /* one ext mbuf */
200         u_quad_t ip6s_mext2m;           /* two or more ext mbuf */
201         u_quad_t ip6s_exthdrtoolong;    /* ext hdr are not continuous */
202         u_quad_t ip6s_nogif;            /* no match gif found */
203         u_quad_t ip6s_toomanyhdr;       /* discarded due to too many headers */
204
205         /*
206          * statistics for improvement of the source address selection
207          * algorithm:
208          * XXX: hardcoded 16 = # of ip6 multicast scope types + 1
209          */
210         /* number of times that address selection fails */
211         u_quad_t ip6s_sources_none;
212         /* number of times that an address on the outgoing I/F is chosen */
213         u_quad_t ip6s_sources_sameif[16];
214         /* number of times that an address on a non-outgoing I/F is chosen */
215         u_quad_t ip6s_sources_otherif[16];
216         /*
217          * number of times that an address that has the same scope
218          * from the destination is chosen.
219          */
220         u_quad_t ip6s_sources_samescope[16];
221         /*
222          * number of times that an address that has a different scope
223          * from the destination is chosen.
224          */
225         u_quad_t ip6s_sources_otherscope[16];
226         /* number of times that an deprecated address is chosen */
227         u_quad_t ip6s_sources_deprecated[16];
228
229         u_quad_t ip6s_forward_cachehit;
230         u_quad_t ip6s_forward_cachemiss;
231 };
232
233 #ifdef _KERNEL
234 /*
235  * IPv6 onion peeling state.
236  * it will be initialized when we come into ip6_input().
237  * XXX do not make it a kitchen sink!
238  */
239 struct ip6aux {
240         u_int32_t ip6a_flags;
241 #define IP6A_SWAP       0x01            /* swapped home/care-of on packet */
242 #define IP6A_HASEEN     0x02            /* HA was present */
243 #define IP6A_BRUID      0x04            /* BR Unique Identifier was present */
244 #define IP6A_RTALERTSEEN 0x08           /* rtalert present */
245
246         /* ip6.ip6_src */
247         struct in6_addr ip6a_careof;    /* care-of address of the peer */
248         struct in6_addr ip6a_home;      /* home address of the peer */
249         u_int16_t       ip6a_bruid;     /* BR unique identifier */
250
251         /* ip6.ip6_dst */
252         struct in6_ifaddr *ip6a_dstia6; /* my ifaddr that matches ip6_dst */
253
254         /* rtalert */
255         u_int16_t ip6a_rtalert;         /* rtalert option value */
256
257         /*
258          * decapsulation history will be here.
259          * with IPsec it may not be accurate.
260          */
261 };
262 #endif
263
264 #ifdef _KERNEL
265 /* flags passed to ip6_output as last parameter */
266 #define IPV6_DADOUTPUT          0x01    /* DAD */
267 #define IPV6_FORWARDING         0x02    /* most of IPv6 header exists */
268 #define IPV6_MINMTU             0x04    /* use minimum MTU (IPV6_USE_MIN_MTU) */
269
270 extern struct   ip6stat ip6stat;        /* statistics */
271 extern u_int32_t ip6_id;                /* fragment identifier */
272 extern int      ip6_defhlim;            /* default hop limit */
273 extern int      ip6_defmcasthlim;       /* default multicast hop limit */
274 extern int      ip6_forwarding;         /* act as router? */
275 extern int      ip6_forward_srcrt;      /* forward src-routed? */
276 extern int      ip6_gif_hlim;           /* Hop limit for gif encap packet */
277 extern int      ip6_use_deprecated;     /* allow deprecated addr as source */
278 extern int      ip6_rr_prune;           /* router renumbering prefix
279                                          * walk list every 5 sec.    */
280 extern int      ip6_v6only;
281
282 extern struct socket *ip6_mrouter;      /* multicast routing daemon */
283 extern int      ip6_sendredirects;      /* send IP redirects when forwarding? */
284 extern int      ip6_maxfragpackets; /* Maximum packets in reassembly queue */
285 extern int      ip6_sourcecheck;        /* Verify source interface */
286 extern int      ip6_sourcecheck_interval; /* Interval between log messages */
287 extern int      ip6_accept_rtadv;       /* Acts as a host not a router */
288 extern int      ip6_keepfaith;          /* Firewall Aided Internet Translator */
289 extern int      ip6_log_interval;
290 extern time_t   ip6_log_time;
291 extern int      ip6_hdrnestlimit; /* upper limit of # of extension headers */
292 extern int      ip6_dad_count;          /* DupAddrDetectionTransmits */
293
294 extern u_int32_t ip6_flow_seq;
295 extern int ip6_auto_flowlabel;
296 extern int ip6_auto_linklocal;
297
298 extern int   ip6_anonportmin;           /* minimum ephemeral port */
299 extern int   ip6_anonportmax;           /* maximum ephemeral port */
300 extern int   ip6_lowportmin;            /* minimum reserved port */
301 extern int   ip6_lowportmax;            /* maximum reserved port */
302
303 extern int      ip6_use_tempaddr; /* whether to use temporary addresses. */
304
305 extern struct   pr_usrreqs rip6_usrreqs;
306 struct sockopt;
307
308 struct inpcb;
309
310 int     icmp6_ctloutput __P((struct socket *, struct sockopt *sopt));
311
312 struct in6_ifaddr;
313 void    ip6_init __P((void));
314 void    ip6intr __P((void));
315 void    ip6_input __P((struct mbuf *));
316 struct in6_ifaddr *ip6_getdstifaddr __P((struct mbuf *));
317 void    ip6_freepcbopts __P((struct ip6_pktopts *));
318 void    ip6_freemoptions __P((struct ip6_moptions *));
319 int     ip6_unknown_opt __P((u_int8_t *, struct mbuf *, int));
320 char *  ip6_get_prevhdr __P((struct mbuf *, int));
321 int     ip6_nexthdr __P((struct mbuf *, int, int, int *));
322 int     ip6_lasthdr __P((struct mbuf *, int, int, int *));
323
324 struct mbuf *ip6_addaux __P((struct mbuf *));
325 struct mbuf *ip6_findaux __P((struct mbuf *));
326 void    ip6_delaux __P((struct mbuf *));
327
328 int     ip6_mforward __P((struct ip6_hdr *, struct ifnet *, struct mbuf *));
329 int     ip6_process_hopopts __P((struct mbuf *, u_int8_t *, int, u_int32_t *,
330                                  u_int32_t *));
331 void    ip6_savecontrol __P((struct inpcb *, struct mbuf **, struct ip6_hdr *,
332                              struct mbuf *));
333 void    ip6_notify_pmtu __P((struct inpcb *, struct sockaddr_in6 *,
334                              u_int32_t *));
335 int     ip6_sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
336
337 void    ip6_forward __P((struct mbuf *, int));
338
339 void    ip6_mloopback __P((struct ifnet *, struct mbuf *, struct sockaddr_in6 *));
340 int     ip6_output __P((struct mbuf *, struct ip6_pktopts *,
341                         struct route_in6 *,
342                         int,
343                         struct ip6_moptions *, struct ifnet **));
344 int     ip6_ctloutput __P((struct socket *, struct sockopt *sopt));
345 void    init_ip6pktopts __P((struct ip6_pktopts *));
346 int     ip6_setpktoptions __P((struct mbuf *, struct ip6_pktopts *, int, int));
347 void    ip6_clearpktopts __P((struct ip6_pktopts *, int, int));
348 struct ip6_pktopts *ip6_copypktopts __P((struct ip6_pktopts *, int));
349 int     ip6_optlen __P((struct inpcb *));
350
351 int     route6_input __P((struct mbuf **, int *, int));
352
353 void    frag6_init __P((void));
354 int     frag6_input __P((struct mbuf **, int *, int));
355 void    frag6_slowtimo __P((void));
356 void    frag6_drain __P((void));
357
358 void    rip6_init __P((void));
359 int     rip6_input __P((struct mbuf **mp, int *offp, int proto));
360 void    rip6_ctlinput __P((int, struct sockaddr *, void *));
361 int     rip6_ctloutput __P((struct socket *so, struct sockopt *sopt));
362 int     rip6_output __P((struct mbuf *, ...));
363 int     rip6_usrreq __P((struct socket *,
364             int, struct mbuf *, struct mbuf *, struct mbuf *, struct thread *));
365
366 int     dest6_input __P((struct mbuf **, int *, int));
367 int     none_input __P((struct mbuf **, int *, int));
368 #endif /* _KERNEL */
369
370 #endif /* !_NETINET6_IP6_VAR_H_ */