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