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