ip_frag.h revision 303975
184954Sobrien/*	$FreeBSD: releng/11.0/sys/contrib/ipfilter/netinet/ip_frag.h 300259 2016-05-20 03:04:22Z cy $	*/
284954Sobrien
3218822Sdim/*
4107508Sobrien * Copyright (C) 2012 by Darren Reed.
5131832Sobrien *
6131832Sobrien * See the IPFILTER.LICENCE file for details on licencing.
7131832Sobrien *
8131832Sobrien * @(#)ip_frag.h	1.5 3/24/96
9131832Sobrien * $FreeBSD: releng/11.0/sys/contrib/ipfilter/netinet/ip_frag.h 300259 2016-05-20 03:04:22Z cy $
10131832Sobrien * Id: ip_frag.h,v 2.23.2.1 2004/03/29 16:21:56 darrenr Exp
11131832Sobrien */
12131832Sobrien
13131832Sobrien#ifndef	__IP_FRAG_H__
14131832Sobrien#define	__IP_FRAG_H__
15131832Sobrien
16218822Sdim#define	IPFT_SIZE	257
17218822Sdim
1884954Sobrientypedef	struct	ipfr	{
19107508Sobrien	struct	ipfr	*ipfr_hnext, **ipfr_hprev;
20107644Sobrien	struct	ipfr	*ipfr_next, **ipfr_prev;
21218822Sdim	void	*ipfr_data;
22107508Sobrien	frentry_t *ipfr_rule;
2384954Sobrien	u_long	ipfr_ttl;
2484954Sobrien	u_int	ipfr_pkts;
2584954Sobrien	u_int	ipfr_bytes;
26218822Sdim	u_int	ipfr_badorder;
2784954Sobrien	int	ipfr_ref;
28218822Sdim	u_short	ipfr_off;
29218822Sdim	u_short	ipfr_firstend;
3084954Sobrien	u_char	ipfr_p;
3184954Sobrien	u_char	ipfr_seen0;
3284954Sobrien	/*
3384954Sobrien	 * All of the fields, from ipfr_ifp to ipfr_pass, are compared
34218822Sdim	 * using bcmp to see if an identical entry is present.  It is
35218822Sdim	 * therefore important for this set to remain together.
36	 */
37	void	*ipfr_ifp;
38	i6addr_t	ipfr_source;
39	i6addr_t	ipfr_dest;
40	u_32_t	ipfr_optmsk;
41	u_short	ipfr_secmsk;
42	u_short	ipfr_auth;
43	u_32_t	ipfr_id;
44	u_32_t	ipfr_pass;
45	int	ipfr_v;
46} ipfr_t;
47
48#define	ipfr_src	ipfr_source.in4
49#define	ipfr_dst	ipfr_dest.in4
50
51
52typedef	struct	ipfrstat {
53	u_long	ifs_exists;	/* add & already exists */
54	u_long	ifs_nomem;
55	u_long	ifs_new;
56	u_long	ifs_hits;
57	u_long	ifs_expire;
58	u_long	ifs_inuse;
59	u_long	ifs_retrans0;
60	u_long	ifs_short;
61	u_long	ifs_bad;
62	u_long	ifs_overlap;
63	u_long	ifs_unordered;
64	u_long	ifs_strict;
65	u_long	ifs_miss;
66	u_long	ifs_maximum;
67	u_long	ifs_newbad;
68	u_long	ifs_newrestrictnot0;
69	struct	ipfr	**ifs_table;
70	struct	ipfr	**ifs_nattab;
71} ipfrstat_t;
72
73typedef struct ipf_frag_softc_s  {
74	ipfrwlock_t	ipfr_ipidfrag;
75	ipfrwlock_t	ipfr_frag;
76	ipfrwlock_t	ipfr_natfrag;
77	int		ipfr_size;
78	int		ipfr_ttl;
79	int		ipfr_lock;
80	int		ipfr_inited;
81	ipftuneable_t	*ipf_frag_tune;
82	ipfr_t		*ipfr_list;
83	ipfr_t		**ipfr_tail;
84	ipfr_t		*ipfr_natlist;
85	ipfr_t		**ipfr_nattail;
86	ipfr_t		*ipfr_ipidlist;
87	ipfr_t		**ipfr_ipidtail;
88	ipfr_t		**ipfr_heads;
89	ipfr_t		**ipfr_nattab;
90	ipfr_t		**ipfr_ipidtab;
91	ipfrstat_t	ipfr_stats;
92} ipf_frag_softc_t;
93
94#define	IPFR_CMPSZ	(offsetof(ipfr_t, ipfr_pass) - \
95			 offsetof(ipfr_t, ipfr_ifp))
96
97extern	void	*ipf_frag_soft_create __P((ipf_main_softc_t *));
98extern	int	ipf_frag_soft_init __P((ipf_main_softc_t *, void *));
99extern	int	ipf_frag_soft_fini __P((ipf_main_softc_t *, void *));
100extern	void	ipf_frag_soft_destroy __P((ipf_main_softc_t *, void *));
101extern	int	ipf_frag_main_load __P((void));
102extern	int	ipf_frag_main_unload __P((void));
103extern	int	ipf_frag_load __P((void));
104extern	void	ipf_frag_clear __P((ipf_main_softc_t *));
105extern	void	ipf_frag_expire __P((ipf_main_softc_t *));
106extern	void	ipf_frag_forget __P((void *));
107extern	int	ipf_frag_init __P((void));
108extern	u_32_t	ipf_frag_ipidknown __P((fr_info_t *));
109extern	int	ipf_frag_ipidnew __P((fr_info_t *, u_32_t));
110extern	frentry_t *ipf_frag_known __P((fr_info_t *, u_32_t *));
111extern	void	ipf_frag_natforget __P((ipf_main_softc_t *, void *));
112extern	int	ipf_frag_natnew __P((ipf_main_softc_t *, fr_info_t *, u_32_t, struct nat *));
113extern	nat_t	*ipf_frag_natknown __P((fr_info_t *));
114extern	int	ipf_frag_new __P((ipf_main_softc_t *, fr_info_t *, u_32_t));
115extern	ipfrstat_t	*ipf_frag_stats __P((void *));
116extern	void	ipf_frag_setlock __P((void *, int));
117extern	void	ipf_frag_pkt_deref __P((ipf_main_softc_t *, void *));
118extern	int	ipf_frag_pkt_next __P((ipf_main_softc_t *, ipftoken_t *,
119				       ipfgeniter_t *));
120extern	void	ipf_frag_nat_deref __P((ipf_main_softc_t *, void *));
121extern	int	ipf_frag_nat_next __P((ipf_main_softc_t *, ipftoken_t *,
122				       ipfgeniter_t *));
123extern	void	ipf_slowtimer __P((ipf_main_softc_t *));
124
125#endif	/* __IP_FRAG_H__ */
126