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