ip6_var.h revision 1.2.2.2 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
30 /*
31 * Copyright (c) 1982, 1986, 1993
32 * The Regents of the University of California. All rights reserved.
33 *
34 * Redistribution and use in source and binary forms, with or without
35 * modification, are permitted provided that the following conditions
36 * are met:
37 * 1. Redistributions of source code must retain the above copyright
38 * notice, this list of conditions and the following disclaimer.
39 * 2. Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in the
41 * documentation and/or other materials provided with the distribution.
42 * 3. All advertising materials mentioning features or use of this software
43 * must display the following acknowledgement:
44 * This product includes software developed by the University of
45 * California, Berkeley and its contributors.
46 * 4. Neither the name of the University nor the names of its contributors
47 * may be used to endorse or promote products derived from this software
48 * without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
51 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
53 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
54 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
55 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
56 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * SUCH DAMAGE.
61 *
62 * @(#)ip_var.h 8.1 (Berkeley) 6/10/93
63 */
64
65 #ifndef _NETINET6_IP6_VAR_H_
66 #define _NETINET6_IP6_VAR_H_
67
68 /*
69 * IP6 reassembly queue structure. Each fragment
70 * being reassembled is attached to one of these structures.
71 */
72 struct ip6q {
73 u_long ip6q_head;
74 u_short ip6q_len;
75 u_char ip6q_nxt;
76 u_char ip6q_hlim;
77 struct ip6asfrag *ip6q_down;
78 struct ip6asfrag *ip6q_up;
79 u_long ip6q_ident;
80 u_char ip6q_arrive;
81 u_char ip6q_ttl;
82 struct in6_addr ip6q_src, ip6q_dst;
83 struct ip6q *ip6q_next;
84 struct ip6q *ip6q_prev;
85 int ip6q_unfrglen;
86 #ifdef notyet
87 u_char *ip6q_nxtp;
88 #endif
89 };
90
91 struct ip6asfrag {
92 u_long ip6af_head;
93 u_short ip6af_len;
94 u_char ip6af_nxt;
95 u_char ip6af_hlim;
96 /* must not override the above members during reassembling */
97 struct ip6asfrag *ip6af_down;
98 struct ip6asfrag *ip6af_up;
99 u_short ip6af_mff;
100 u_short ip6af_off;
101 struct mbuf *ip6af_m;
102 u_long ip6af_offset; /* offset where next header starts */
103 u_short ip6af_frglen; /* fragmentable part length */
104 u_char ip6af_x1[10];
105 };
106
107 #define IP6_REASS_MBUF(ip6af) (*(struct mbuf **)&((ip6af)->ip6af_m))
108
109 struct ip6_moptions {
110 struct ifnet *im6o_multicast_ifp; /* ifp for outgoing multicasts */
111 u_char im6o_multicast_hlim; /* hoplimit for outgoing multicasts */
112 u_char im6o_multicast_loop; /* 1 >= hear sends if a member */
113 LIST_HEAD(, in6_multi_mship) im6o_memberships;
114 };
115
116 /*
117 * Control options for outgoing packets
118 */
119
120 /* Routing header related info */
121 struct ip6po_rhinfo {
122 struct ip6_rthdr *ip6po_rhi_rthdr; /* Routing header */
123 struct route_in6 ip6po_rhi_route; /* Route to the 1st hop */
124 };
125 #define ip6po_rthdr ip6po_rhinfo.ip6po_rhi_rthdr
126 #define ip6po_route ip6po_rhinfo.ip6po_rhi_route
127
128 struct ip6_pktopts {
129 struct mbuf *ip6po_m; /* Pointer to mbuf storing the data */
130 int ip6po_hlim; /* Hoplimit for outgoing packets */
131 struct in6_pktinfo *ip6po_pktinfo; /* Outgoing IF/address information */
132 struct sockaddr *ip6po_nexthop; /* Next-hop address */
133 struct ip6_hbh *ip6po_hbh; /* Hop-by-Hop options header */
134 struct ip6_dest *ip6po_dest1; /* Destination options header(1st part) */
135 struct ip6po_rhinfo ip6po_rhinfo; /* Routing header related info. */
136 struct ip6_dest *ip6po_dest2; /* Destination options header(2nd part) */
137 };
138
139 struct ip6stat {
140 u_long ip6s_total; /* total packets received */
141 u_long ip6s_tooshort; /* packet too short */
142 u_long ip6s_toosmall; /* not enough data */
143 u_long ip6s_fragments; /* fragments received */
144 u_long ip6s_fragdropped; /* frags dropped(dups, out of space) */
145 u_long ip6s_fragtimeout; /* fragments timed out */
146 u_long ip6s_fragoverflow; /* fragments that exceeded limit */
147 u_long ip6s_forward; /* packets forwarded */
148 u_long ip6s_cantforward; /* packets rcvd for unreachable dest */
149 u_long ip6s_redirectsent; /* packets forwarded on same net */
150 u_long ip6s_delivered; /* datagrams delivered to upper level*/
151 u_long ip6s_localout; /* total ip packets generated here */
152 u_long ip6s_odropped; /* lost packets due to nobufs, etc. */
153 u_long ip6s_reassembled; /* total packets reassembled ok */
154 u_long ip6s_fragmented; /* datagrams sucessfully fragmented */
155 u_long ip6s_ofragments; /* output fragments created */
156 u_long ip6s_cantfrag; /* don't fragment flag was set, etc. */
157 u_long ip6s_badoptions; /* error in option processing */
158 u_long ip6s_noroute; /* packets discarded due to no route */
159 u_long ip6s_badvers; /* ip6 version != 6 */
160 u_long ip6s_rawout; /* total raw ip packets generated */
161 u_long ip6s_badscope; /* scope error */
162 u_long ip6s_notmember; /* don't join this multicast group */
163 u_long ip6s_nxthist[256]; /* next header history */
164 u_long ip6s_m1; /* one mbuf */
165 u_long ip6s_m2m[32]; /* two or more mbuf */
166 u_long ip6s_mext1; /* one ext mbuf */
167 u_long ip6s_mext2m; /* two or more ext mbuf */
168 u_long ip6s_exthdrtoolong; /* ext hdr are not continuous */
169 u_long ip6s_nogif; /* no match gif found */
170 u_long ip6s_toomanyhdr; /* discarded due to too many headers */
171 };
172
173 #ifdef _KERNEL
174 /* flags passed to ip6_output as last parameter */
175 #define IPV6_DADOUTPUT 0x01 /* DAD */
176 #define IPV6_FORWARDING 0x02 /* most of IPv6 header exists */
177
178 extern struct ip6stat ip6stat; /* statistics */
179 extern u_long ip6_id; /* fragment identifier */
180 extern int ip6_defhlim; /* default hop limit */
181 extern int ip6_defmcasthlim; /* default multicast hop limit */
182 extern int ip6_forwarding; /* act as router? */
183 extern int ip6_forward_srcrt; /* forward src-routed? */
184 extern int ip6_gif_hlim; /* Hop limit for gif encap packet */
185 extern struct socket *ip6_mrouter; /* multicast routing daemon */
186 extern int ip6_sendredirects; /* send IP redirects when forwarding? */
187 extern int ip6_maxfragpackets; /* Maximum packets in reassembly queue */
188 extern int ip6_sourcecheck; /* Verify source interface */
189 extern int ip6_sourcecheck_interval; /* Interval between log messages */
190 extern int ip6_accept_rtadv; /* Acts as a host not a router */
191 extern int ip6_keepfaith; /* Firewall Aided Internet Translator */
192 extern int ip6_log_interval;
193 extern time_t ip6_log_time;
194 extern int ip6_hdrnestlimit; /* upper limit of # of extension headers */
195 extern int ip6_dad_count; /* DupAddrDetectionTransmits */
196
197 extern u_int32_t ip6_flow_seq;
198 extern int ip6_auto_flowlabel;
199
200 #if !defined(__FreeBSD__) || __FreeBSD__ < 3
201 struct in6pcb;
202 #endif
203
204 int icmp6_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
205 void ip6_init __P((void));
206 void ip6intr __P((void));
207 void ip6_input __P((struct mbuf *));
208 void ip6_freemoptions __P((struct ip6_moptions *));
209 int ip6_unknown_opt __P((u_int8_t *, struct mbuf *, int));
210 char * ip6_get_prevhdr __P((struct mbuf *, int));
211 int ip6_mforward __P((struct ip6_hdr *, struct ifnet *, struct mbuf *));
212 int ip6_process_hopopts __P((struct mbuf *, u_int8_t *, int, long *,
213 u_int32_t *));
214 void ip6_savecontrol __P((struct in6pcb *, struct mbuf **, struct ip6_hdr *,
215 struct mbuf *));
216 int ip6_sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
217
218 void ip6_forward __P((struct mbuf *, int));
219
220 void ip6_mloopback __P((struct ifnet *, struct mbuf *, struct sockaddr_in6 *));
221 int ip6_output __P((struct mbuf *, struct ip6_pktopts *,
222 struct route_in6 *, int,
223 struct ip6_moptions *));
224 int ip6_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
225 int ip6_setpktoptions __P((struct mbuf *, struct ip6_pktopts *, int));
226 int ip6_optlen __P((struct in6pcb *));
227
228 int route6_input __P((struct mbuf **, int *, int));
229
230 void frag6_init __P((void));
231 int frag6_input __P((struct mbuf **, int *, int));
232 void frag6_slowtimo __P((void));
233 void frag6_drain __P((void));
234
235 void rip6_init __P((void));
236 int rip6_input __P((struct mbuf **mp, int *offp, int proto));
237 int rip6_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
238 int rip6_output __P((struct mbuf *, ...));
239 int rip6_usrreq __P((struct socket *,
240 int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *));
241
242 int dest6_input __P((struct mbuf **, int *, int));
243 int none_input __P((struct mbuf **, int *, int));
244 #endif /* _KERNEL */
245
246 #endif /* !_NETINET6_IP6_VAR_H_ */
247