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