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