1#ifndef __IP_HTABLE_H__ 2#define __IP_HTABLE_H__ 3 4#include "netinet/ip_lookup.h" 5 6typedef struct iphtent_s { 7 struct iphtent_s *ipe_next, **ipe_pnext; 8 struct iphtent_s *ipe_hnext, **ipe_phnext; 9 void *ipe_ptr; 10 i6addr_t ipe_addr; 11 i6addr_t ipe_mask; 12 int ipe_ref; 13 int ipe_unit; 14 union { 15 char ipeu_char[16]; 16 u_long ipeu_long; 17 u_int ipeu_int; 18 }ipe_un; 19} iphtent_t; 20 21#define ipe_value ipe_un.ipeu_int 22#define ipe_group ipe_un.ipeu_char 23 24#define IPE_HASH_FN(a, m, s) (((a) * (m)) % (s)) 25 26 27typedef struct iphtable_s { 28 ipfrwlock_t iph_rwlock; 29 struct iphtable_s *iph_next, **iph_pnext; 30 struct iphtent_s **iph_table; 31 struct iphtent_s *iph_list; 32 size_t iph_size; /* size of hash table */ 33 u_long iph_seed; /* hashing seed */ 34 u_32_t iph_flags; 35 u_int iph_unit; /* IPL_LOG* */ 36 u_int iph_ref; 37 u_int iph_type; /* lookup or group map - IPHASH_* */ 38 u_int iph_masks; /* IPv4 netmasks in use */ 39 char iph_name[FR_GROUPLEN]; /* hash table number */ 40} iphtable_t; 41 42/* iph_type */ 43#define IPHASH_LOOKUP 0 44#define IPHASH_GROUPMAP 1 45#define IPHASH_DELETE 2 46#define IPHASH_ANON 0x80000000 47 48 49typedef struct iphtstat_s { 50 iphtable_t *iphs_tables; 51 u_long iphs_numtables; 52 u_long iphs_numnodes; 53 u_long iphs_nomem; 54 u_long iphs_pad[16]; 55} iphtstat_t; 56 57 58extern iphtable_t *ipf_htables[IPL_LOGSIZE]; 59 60extern iphtable_t *fr_existshtable __P((int, char *)); 61extern int fr_clearhtable __P((iphtable_t *)); 62extern void fr_htable_unload __P((void)); 63extern int fr_newhtable __P((iplookupop_t *)); 64extern iphtable_t *fr_findhtable __P((int, char *)); 65extern int fr_removehtable __P((int, char *)); 66extern size_t fr_flushhtable __P((iplookupflush_t *)); 67extern int fr_addhtent __P((iphtable_t *, iphtent_t *)); 68extern int fr_delhtent __P((iphtable_t *, iphtent_t *)); 69extern int fr_derefhtable __P((iphtable_t *)); 70extern int fr_derefhtent __P((iphtent_t *)); 71extern int fr_delhtable __P((iphtable_t *)); 72extern void *fr_iphmfindgroup __P((void *, void *)); 73extern int fr_iphmfindip __P((void *, int, void *)); 74extern int fr_gethtablestat __P((iplookupop_t *)); 75extern int fr_htable_getnext __P((ipftoken_t *, ipflookupiter_t *)); 76extern void fr_htable_iterderef __P((u_int, int, void *)); 77 78#endif /* __IP_HTABLE_H__ */ 79