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