1 #ifndef __IP_HTABLE_H__ 2 #define __IP_HTABLE_H__ 3 4 #include "netinet/ip_lookup.h" 5 6 typedef struct iphtent_s { 7 struct iphtent_s *ipe_next, **ipe_pnext; 8 struct iphtent_s *ipe_hnext, **ipe_phnext; 9 struct iphtent_s *ipe_dnext, **ipe_pdnext; 10 struct iphtable_s *ipe_owner; 11 void *ipe_ptr; 12 i6addr_t ipe_addr; 13 i6addr_t ipe_mask; 14 U_QUAD_T ipe_hits; 15 U_QUAD_T ipe_bytes; 16 u_long ipe_die; 17 int ipe_uid; 18 int ipe_ref; 19 int ipe_unit; 20 char ipe_family; 21 char ipe_xxx[3]; 22 union { 23 char ipeu_char[16]; 24 u_long ipeu_long; 25 u_int ipeu_int; 26 } ipe_un; 27 } iphtent_t; 28 29 #define ipe_value ipe_un.ipeu_int 30 #define ipe_group ipe_un.ipeu_char 31 32 #define IPE_V4_HASH_FN(a, m, s) ((((m) ^ (a)) - 1 - ((a) >> 8)) % (s)) 33 #define IPE_V6_HASH_FN(a, m, s) (((((m)[0] ^ (a)[0]) - ((a)[0] >> 8)) + \ 34 (((m)[1] & (a)[1]) - ((a)[1] >> 8)) + \ 35 (((m)[2] & (a)[2]) - ((a)[2] >> 8)) + \ 36 (((m)[3] & (a)[3]) - ((a)[3] >> 8))) % (s)) 37 38 typedef struct iphtable_s { 39 ipfrwlock_t iph_rwlock; 40 struct iphtable_s *iph_next, **iph_pnext; 41 struct iphtent_s **iph_table; 42 struct iphtent_s *iph_list; 43 struct iphtent_s **iph_tail; 44 #ifdef USE_INET6 45 ipf_v6_masktab_t iph_v6_masks; 46 #endif 47 ipf_v4_masktab_t iph_v4_masks; 48 size_t iph_size; /* size of hash table */ 49 u_long iph_seed; /* hashing seed */ 50 u_32_t iph_flags; 51 u_int iph_unit; /* IPL_LOG* */ 52 u_int iph_ref; 53 u_int iph_type; /* lookup or group map - IPHASH_* */ 54 u_int iph_maskset[4]; /* netmasks in use */ 55 char iph_name[FR_GROUPLEN]; /* hash table number */ 56 } iphtable_t; 57 58 /* iph_type */ 59 #define IPHASH_LOOKUP 0 60 #define IPHASH_GROUPMAP 1 61 #define IPHASH_DELETE 2 62 #define IPHASH_ANON 0x80000000 63 64 65 typedef struct iphtstat_s { 66 iphtable_t *iphs_tables; 67 u_long iphs_numtables; 68 u_long iphs_numnodes; 69 u_long iphs_nomem; 70 u_long iphs_pad[16]; 71 } iphtstat_t; 72 73 74 extern void *ipf_iphmfindgroup(ipf_main_softc_t *, void *, void *); 75 extern iphtable_t *ipf_htable_find(void *, int, char *); 76 extern ipf_lookup_t ipf_htable_backend; 77 #ifndef _KERNEL 78 extern void ipf_htable_dump(ipf_main_softc_t *, void *); 79 #endif 80 81 #endif /* __IP_HTABLE_H__ */ 82