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