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