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