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