1 
2 /*
3  * Copyright (C) 2012 by Darren Reed.
4  *
5  * See the IPFILTER.LICENCE file for details on licencing.
6  *
7  * @(#)ip_frag.h	1.5 3/24/96
8  * Id: ip_frag.h,v 2.23.2.1 2004/03/29 16:21:56 darrenr Exp
9  */
10 
11 #ifndef	__IP_FRAG_H__
12 #define	__IP_FRAG_H__
13 
14 #define	IPFT_SIZE	257
15 
16 typedef	struct	ipfr	{
17 	struct	ipfr	*ipfr_hnext, **ipfr_hprev;
18 	struct	ipfr	*ipfr_next, **ipfr_prev;
19 	void	*ipfr_data;
20 	frentry_t *ipfr_rule;
21 	u_long	ipfr_ttl;
22 	u_int	ipfr_pkts;
23 	u_int	ipfr_bytes;
24 	u_int	ipfr_badorder;
25 	int	ipfr_ref;
26 	u_short	ipfr_off;
27 	u_short	ipfr_firstend;
28 	u_char	ipfr_p;
29 	u_char	ipfr_seen0;
30 	/*
31 	 * All of the fields, from ipfr_ifp to ipfr_pass, are compared
32 	 * using bcmp to see if an identical entry is present.  It is
33 	 * therefore important for this set to remain together.
34 	 */
35 	void	*ipfr_ifp;
36 	i6addr_t	ipfr_source;
37 	i6addr_t	ipfr_dest;
38 	u_32_t	ipfr_optmsk;
39 	u_short	ipfr_secmsk;
40 	u_short	ipfr_auth;
41 	u_32_t	ipfr_id;
42 	u_32_t	ipfr_pass;
43 	int	ipfr_v;
44 } ipfr_t;
45 
46 #define	ipfr_src	ipfr_source.in4
47 #define	ipfr_dst	ipfr_dest.in4
48 
49 
50 typedef	struct	ipfrstat {
51 	u_long	ifs_exists;	/* add & already exists */
52 	u_long	ifs_nomem;
53 	u_long	ifs_new;
54 	u_long	ifs_hits;
55 	u_long	ifs_expire;
56 	u_long	ifs_inuse;
57 	u_long	ifs_retrans0;
58 	u_long	ifs_short;
59 	u_long	ifs_bad;
60 	u_long	ifs_overlap;
61 	u_long	ifs_unordered;
62 	u_long	ifs_strict;
63 	u_long	ifs_miss;
64 	u_long	ifs_maximum;
65 	u_long	ifs_newbad;
66 	u_long	ifs_newrestrictnot0;
67 	struct	ipfr	**ifs_table;
68 	struct	ipfr	**ifs_nattab;
69 } ipfrstat_t;
70 
71 typedef struct ipf_frag_softc_s  {
72 	ipfrwlock_t	ipfr_ipidfrag;
73 	ipfrwlock_t	ipfr_frag;
74 	ipfrwlock_t	ipfr_natfrag;
75 	int		ipfr_size;
76 	int		ipfr_ttl;
77 	int		ipfr_lock;
78 	int		ipfr_inited;
79 	ipftuneable_t	*ipf_frag_tune;
80 	ipfr_t		*ipfr_list;
81 	ipfr_t		**ipfr_tail;
82 	ipfr_t		*ipfr_natlist;
83 	ipfr_t		**ipfr_nattail;
84 	ipfr_t		*ipfr_ipidlist;
85 	ipfr_t		**ipfr_ipidtail;
86 	ipfr_t		**ipfr_heads;
87 	ipfr_t		**ipfr_nattab;
88 	ipfr_t		**ipfr_ipidtab;
89 	ipfrstat_t	ipfr_stats;
90 } ipf_frag_softc_t;
91 
92 #define	IPFR_CMPSZ	(offsetof(ipfr_t, ipfr_pass) - \
93 			 offsetof(ipfr_t, ipfr_ifp))
94 
95 extern	void	*ipf_frag_soft_create(ipf_main_softc_t *);
96 extern	int	ipf_frag_soft_init(ipf_main_softc_t *, void *);
97 extern	int	ipf_frag_soft_fini(ipf_main_softc_t *, void *);
98 extern	void	ipf_frag_soft_destroy(ipf_main_softc_t *, void *);
99 extern	int	ipf_frag_main_load(void);
100 extern	int	ipf_frag_main_unload(void);
101 extern	int	ipf_frag_load(void);
102 extern	void	ipf_frag_clear(ipf_main_softc_t *);
103 extern	void	ipf_frag_expire(ipf_main_softc_t *);
104 extern	void	ipf_frag_forget(void *);
105 extern	int	ipf_frag_init(void);
106 extern	u_32_t	ipf_frag_ipidknown(fr_info_t *);
107 extern	int	ipf_frag_ipidnew(fr_info_t *, u_32_t);
108 extern	frentry_t *ipf_frag_known(fr_info_t *, u_32_t *);
109 extern	void	ipf_frag_natforget(ipf_main_softc_t *, void *);
110 extern	int	ipf_frag_natnew(ipf_main_softc_t *, fr_info_t *, u_32_t, struct nat *);
111 extern	nat_t	*ipf_frag_natknown(fr_info_t *);
112 extern	int	ipf_frag_new(ipf_main_softc_t *, fr_info_t *, u_32_t);
113 extern	ipfrstat_t	*ipf_frag_stats(void *);
114 extern	void	ipf_frag_setlock(void *, int);
115 extern	void	ipf_frag_pkt_deref(ipf_main_softc_t *, void *);
116 extern	int	ipf_frag_pkt_next(ipf_main_softc_t *, ipftoken_t *,
117 				       ipfgeniter_t *);
118 extern	void	ipf_frag_nat_deref(ipf_main_softc_t *, void *);
119 extern	int	ipf_frag_nat_next(ipf_main_softc_t *, ipftoken_t *,
120 				       ipfgeniter_t *);
121 extern	void	ipf_slowtimer(ipf_main_softc_t *);
122 
123 #endif	/* __IP_FRAG_H__ */
124