Watt-32 tcp/ip  2.2 dev-rel.10
ip6_var.h
Go to the documentation of this file.
1 
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 #ifndef __SYS_QUEUE_H
76 #include <sys/queue.h>
77 #endif
78 
79 #ifndef __SYS_MBUF_H
80 #include <sys/mbuf.h>
81 #endif
82 
83 #if !defined(__BORLANDC__) /* stop warnings for undefined structs */
84 /*
85  * IP6 reassembly queue structure. Each fragment
86  * being reassembled is attached to one of these structures.
87  */
88 struct ip6q {
89  u_int32_t ip6q_head;
90  u_int16_t ip6q_len;
91  u_int8_t ip6q_nxt; /* ip6f_nxt in first fragment */
92  u_int8_t ip6q_hlim;
93  struct ip6asfrag *ip6q_down;
94  struct ip6asfrag *ip6q_up;
95  u_int32_t ip6q_ident;
96  u_int8_t ip6q_arrive;
97  u_int8_t ip6q_ttl;
98  struct in6_addr ip6q_src, ip6q_dst;
99  struct ip6q *ip6q_next;
100  struct ip6q *ip6q_prev;
101  int ip6q_unfrglen; /* len of unfragmentable part */
102 #ifdef notyet
103  u_char *ip6q_nxtp;
104 #endif
105 };
106 
107 struct ip6asfrag {
108  u_int32_t ip6af_head;
109  u_int16_t ip6af_len;
110  u_int8_t ip6af_nxt;
111  u_int8_t ip6af_hlim;
112  /* must not override the above members during reassembling */
113  struct ip6asfrag *ip6af_down;
114  struct ip6asfrag *ip6af_up;
115  struct mbuf *ip6af_m;
116  int ip6af_offset; /* offset in ip6af_m to next header */
117  int ip6af_frglen; /* fragmentable part length */
118  int ip6af_off; /* fragment offset */
119  u_int16_t ip6af_mff; /* more fragment bit in frag off */
120 };
121 
122 #define IP6_REASS_MBUF(ip6af) (*(struct mbuf **)&((ip6af)->ip6af_m))
123 
124 struct ip6_moptions {
125  struct ifnet *im6o_multicast_ifp; /* ifp for outgoing multicasts */
126  u_char im6o_multicast_hlim; /* hoplimit for outgoing multicasts */
127  u_char im6o_multicast_loop; /* 1 >= hear sends if a member */
128  LIST_HEAD(dummy, in6_multi_mship) im6o_memberships;
129 };
130 #endif /* __BORLANDC__ */
131 
132 #ifndef _NETINET6_IN6_H_
133 struct route_in6 {
134  struct rtentry *ro_rt;
135  struct sockaddr_in6 ro_dst;
136 };
137 #endif
138 
139 /*
140  * Control options for outgoing packets
141  */
142 
143 /* Routing header related info */
144 #if !defined(__BORLANDC__)
145 struct ip6po_rhinfo {
146  struct ip6_rthdr *ip6po_rhi_rthdr; /* Routing header */
147  struct route_in6 ip6po_rhi_route; /* Route to the 1st hop */
148 };
149 #define ip6po_rthdr ip6po_rhinfo.ip6po_rhi_rthdr
150 #define ip6po_route ip6po_rhinfo.ip6po_rhi_route
151 
152 struct ip6_pktopts {
153  struct mbuf *ip6po_m; /* Pointer to mbuf storing the data */
154  int ip6po_hlim; /* Hoplimit for outgoing packets */
155 
156  /* Outgoing IF/address information */
157  struct in6_pktinfo *ip6po_pktinfo;
158 
159  struct sockaddr *ip6po_nexthop; /* Next-hop address */
160 
161  struct ip6_hbh *ip6po_hbh; /* Hop-by-Hop options header */
162 
163  /* Destination options header (before a routing header) */
164  struct ip6_dest *ip6po_dest1;
165 
166  /* Routing header related info. */
167  struct ip6po_rhinfo ip6po_rhinfo;
168 
169  /* Destination options header (after a routing header) */
170  struct ip6_dest *ip6po_dest2;
171 };
172 #endif /* __BORLANDC__ */
173 
174 /*
175  * Control options for incoming packets
176  */
177 
178 struct ip6stat {
179  u_quad_t ip6s_total; /* total packets received */
180  u_quad_t ip6s_tooshort; /* packet too short */
181  u_quad_t ip6s_toosmall; /* not enough data */
182  u_quad_t ip6s_fragments; /* fragments received */
183  u_quad_t ip6s_fragdropped; /* frags dropped(dups, out of space) */
184  u_quad_t ip6s_fragtimeout; /* fragments timed out */
185  u_quad_t ip6s_fragoverflow; /* fragments that exceeded limit */
186  u_quad_t ip6s_forward; /* packets forwarded */
187  u_quad_t ip6s_cantforward; /* packets rcvd for unreachable dest */
188  u_quad_t ip6s_redirectsent; /* packets forwarded on same net */
189  u_quad_t ip6s_delivered; /* datagrams delivered to upper level*/
190  u_quad_t ip6s_localout; /* total ip packets generated here */
191  u_quad_t ip6s_odropped; /* lost packets due to nobufs, etc. */
192  u_quad_t ip6s_reassembled; /* total packets reassembled ok */
193  u_quad_t ip6s_fragmented; /* datagrams sucessfully fragmented */
194  u_quad_t ip6s_ofragments; /* output fragments created */
195  u_quad_t ip6s_cantfrag; /* don't fragment flag was set, etc. */
196  u_quad_t ip6s_badoptions; /* error in option processing */
197  u_quad_t ip6s_noroute; /* packets discarded due to no route */
198  u_quad_t ip6s_badvers; /* ip6 version != 6 */
199  u_quad_t ip6s_rawout; /* total raw ip packets generated */
200  u_quad_t ip6s_badscope; /* scope error */
201  u_quad_t ip6s_notmember; /* don't join this multicast group */
202  u_quad_t ip6s_nxthist[256]; /* next header history */
203  u_quad_t ip6s_m1; /* one mbuf */
204  u_quad_t ip6s_m2m[32]; /* two or more mbuf */
205  u_quad_t ip6s_mext1; /* one ext mbuf */
206  u_quad_t ip6s_mext2m; /* two or more ext mbuf */
207  u_quad_t ip6s_exthdrtoolong; /* ext hdr are not continuous */
208  u_quad_t ip6s_nogif; /* no match gif found */
209  u_quad_t ip6s_toomanyhdr; /* discarded due to too many headers */
210 
211  /*
212  * statistics for improvement of the source address selection
213  * algorithm:
214  * XXX: hardcoded 16 = # of ip6 multicast scope types + 1
215  */
216  /* number of times that address selection fails */
217  u_quad_t ip6s_sources_none;
218  /* number of times that an address on the outgoing I/F is chosen */
219  u_quad_t ip6s_sources_sameif[16];
220  /* number of times that an address on a non-outgoing I/F is chosen */
221  u_quad_t ip6s_sources_otherif[16];
222  /*
223  * number of times that an address that has the same scope
224  * from the destination is chosen.
225  */
226  u_quad_t ip6s_sources_samescope[16];
227  /*
228  * number of times that an address that has a different scope
229  * from the destination is chosen.
230  */
231  u_quad_t ip6s_sources_otherscope[16];
232  /* number of times that an deprecated address is chosen */
233  u_quad_t ip6s_sources_deprecated[16];
234 
235  u_quad_t ip6s_forward_cachehit;
236  u_quad_t ip6s_forward_cachemiss;
237 };
238 
239 #ifdef _KERNEL
240 /*
241  * IPv6 onion peeling state.
242  * it will be initialized when we come into ip6_input().
243  * XXX do not make it a kitchen sink!
244  */
245 struct ip6aux {
246  u_int32_t ip6a_flags;
247 #define IP6A_SWAP 0x01 /* swapped home/care-of on packet */
248 #define IP6A_HASEEN 0x02 /* HA was present */
249 #define IP6A_BRUID 0x04 /* BR Unique Identifier was present */
250 #define IP6A_RTALERTSEEN 0x08 /* rtalert present */
251 
252  /* ip6.ip6_src */
253  struct in6_addr ip6a_careof; /* care-of address of the peer */
254  struct in6_addr ip6a_home; /* home address of the peer */
255  u_int16_t ip6a_bruid; /* BR unique identifier */
256 
257  /* ip6.ip6_dst */
258  struct in6_ifaddr *ip6a_dstia6; /* my ifaddr that matches ip6_dst */
259 
260  /* rtalert */
261  u_int16_t ip6a_rtalert; /* rtalert option value */
262 
263  /*
264  * decapsulation history will be here.
265  * with IPsec it may not be accurate.
266  */
267 };
268 #endif
269 
270 #ifdef _KERNEL
271 /* flags passed to ip6_output as last parameter */
272 #define IPV6_DADOUTPUT 0x01 /* DAD */
273 #define IPV6_FORWARDING 0x02 /* most of IPv6 header exists */
274 #define IPV6_MINMTU 0x04 /* use minimum MTU (IPV6_USE_MIN_MTU) */
275 
276 extern struct ip6stat ip6stat; /* statistics */
277 extern u_int32_t ip6_id; /* fragment identifier */
278 extern int ip6_defhlim; /* default hop limit */
279 extern int ip6_defmcasthlim; /* default multicast hop limit */
280 extern int ip6_forwarding; /* act as router? */
281 extern int ip6_forward_srcrt; /* forward src-routed? */
282 extern int ip6_gif_hlim; /* Hop limit for gif encap packet */
283 extern int ip6_use_deprecated; /* allow deprecated addr as source */
284 extern int ip6_rr_prune; /* router renumbering prefix
285  * walk list every 5 sec. */
286 extern int ip6_v6only;
287 
288 extern struct socket *ip6_mrouter; /* multicast routing daemon */
289 extern int ip6_sendredirects; /* send IP redirects when forwarding? */
290 extern int ip6_maxfragpackets; /* Maximum packets in reassembly queue */
291 extern int ip6_sourcecheck; /* Verify source interface */
292 extern int ip6_sourcecheck_interval; /* Interval between log messages */
293 extern int ip6_accept_rtadv; /* Acts as a host not a router */
294 extern int ip6_keepfaith; /* Firewall Aided Internet Translator */
295 extern int ip6_log_interval;
296 extern time_t ip6_log_time;
297 extern int ip6_hdrnestlimit; /* upper limit of # of extension headers */
298 extern int ip6_dad_count; /* DupAddrDetectionTransmits */
299 
300 extern u_int32_t ip6_flow_seq;
301 extern int ip6_auto_flowlabel;
302 extern int ip6_auto_linklocal;
303 
304 extern int ip6_anonportmin; /* minimum ephemeral port */
305 extern int ip6_anonportmax; /* maximum ephemeral port */
306 extern int ip6_lowportmin; /* minimum reserved port */
307 extern int ip6_lowportmax; /* maximum reserved port */
308 
309 extern int ip6_use_tempaddr; /* whether to use temporary addresses. */
310 
311 extern struct pr_usrreqs rip6_usrreqs;
312 struct sockopt;
313 
314 struct inpcb;
315 
316 int icmp6_ctloutput __P((struct socket *, struct sockopt *sopt));
317 
318 struct in6_ifaddr;
319 void ip6_init __P((void));
320 void ip6intr __P((void));
321 void ip6_input __P((struct mbuf *));
322 struct in6_ifaddr *ip6_getdstifaddr __P((struct mbuf *));
323 void ip6_freepcbopts __P((struct ip6_pktopts *));
324 void ip6_freemoptions __P((struct ip6_moptions *));
325 int ip6_unknown_opt __P((u_int8_t *, struct mbuf *, int));
326 char * ip6_get_prevhdr __P((struct mbuf *, int));
327 int ip6_nexthdr __P((struct mbuf *, int, int, int *));
328 int ip6_lasthdr __P((struct mbuf *, int, int, int *));
329 
330 struct mbuf *ip6_addaux __P((struct mbuf *));
331 struct mbuf *ip6_findaux __P((struct mbuf *));
332 void ip6_delaux __P((struct mbuf *));
333 
334 int ip6_mforward __P((struct ip6_hdr *, struct ifnet *, struct mbuf *));
335 int ip6_process_hopopts __P((struct mbuf *, u_int8_t *, int, u_int32_t *,
336  u_int32_t *));
337 void ip6_savecontrol __P((struct inpcb *, struct mbuf **, struct ip6_hdr *,
338  struct mbuf *));
339 void ip6_notify_pmtu __P((struct inpcb *, struct sockaddr_in6 *,
340  u_int32_t *));
341 int ip6_sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
342 
343 void ip6_forward __P((struct mbuf *, int));
344 
345 void ip6_mloopback __P((struct ifnet *, struct mbuf *, struct sockaddr_in6 *));
346 int ip6_output __P((struct mbuf *, struct ip6_pktopts *,
347  struct route_in6 *,
348  int,
349  struct ip6_moptions *, struct ifnet **));
350 int ip6_ctloutput __P((struct socket *, struct sockopt *sopt));
351 void init_ip6pktopts __P((struct ip6_pktopts *));
352 int ip6_setpktoptions __P((struct mbuf *, struct ip6_pktopts *, int, int));
353 void ip6_clearpktopts __P((struct ip6_pktopts *, int, int));
354 struct ip6_pktopts *ip6_copypktopts __P((struct ip6_pktopts *, int));
355 int ip6_optlen __P((struct inpcb *));
356 
357 int route6_input __P((struct mbuf **, int *, int));
358 
359 void frag6_init __P((void));
360 int frag6_input __P((struct mbuf **, int *, int));
361 void frag6_slowtimo __P((void));
362 void frag6_drain __P((void));
363 
364 void rip6_init __P((void));
365 int rip6_input __P((struct mbuf **mp, int *offp, int proto));
366 void rip6_ctlinput __P((int, struct sockaddr *, void *));
367 int rip6_ctloutput __P((struct socket *so, struct sockopt *sopt));
368 int rip6_output __P((struct mbuf *, ...));
369 int rip6_usrreq __P((struct socket *,
370  int, struct mbuf *, struct mbuf *, struct mbuf *, struct thread *));
371 
372 int dest6_input __P((struct mbuf **, int *, int));
373 int none_input __P((struct mbuf **, int *, int));
374 #endif /* _KERNEL */
375 
376 #endif /* !_NETINET6_IP6_VAR_H_ */
Definition: ip6.h:186
Definition: ip6.h:149
Definition: if.h:84
Definition: in_pcb.h:61
Definition: in.h:153
Definition: if.h:130
Definition: mbuf.h:6
Definition: ip6.h:141
Definition: in6.h:395
Definition: ip6_var.h:88
Definition: ip6.h:90
Definition: route.h:98