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