xref: /illumos-gate/usr/src/uts/common/inet/ipf/netinet/ip_pool.h (revision 8b80e8cb6855118d46f605e91b5ed4ce83417395)
1 /*
2  * Copyright (C) 1993-2001, 2003 by Darren Reed.
3  *
4  * See the IPFILTER.LICENCE file for details on licencing.
5  *
6  * $Id: ip_pool.h,v 2.26.2.3 2005/06/12 07:18:27 darrenr Exp $
7  *
8  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
9  * Use is subject to license terms.
10  */
11 
12 #pragma ident	"%Z%%M%	%I%	%E% SMI"
13 
14 #ifndef	__IP_POOL_H__
15 #define	__IP_POOL_H__
16 
17 #if defined(_KERNEL) && !defined(__osf__) && !defined(__hpux) && \
18     !defined(linux) && !defined(sun) && !defined(AIX)
19 # include <net/radix.h>
20 extern void rn_freehead __P((struct radix_node_head *));
21 # define FreeS(p, z)		KFREES(p, z)
22 extern int max_keylen;
23 #else
24 # if defined(__osf__) || defined(__hpux)
25 #  include "radix_ipf_local.h"
26 #  define radix_mask ipf_radix_mask
27 #  define radix_node ipf_radix_node
28 #  define radix_node_head ipf_radix_node_head
29 # else
30 #  include "radix_ipf.h"
31 # endif
32 #endif
33 #include "netinet/ip_lookup.h"
34 
35 #define	IP_POOL_NOMATCH		0
36 #define	IP_POOL_POSITIVE	1
37 
38 typedef	struct ip_pool_node {
39 	struct	radix_node	ipn_nodes[2];
40 	addrfamily_t		ipn_addr;
41 	addrfamily_t		ipn_mask;
42 	int			ipn_info;
43 	int			ipn_ref;
44 	char			ipn_name[FR_GROUPLEN];
45 	u_long			ipn_hits;
46 	struct ip_pool_node	*ipn_next, **ipn_pnext;
47 } ip_pool_node_t;
48 
49 
50 typedef	struct ip_pool_s {
51 	struct ip_pool_s	*ipo_next;
52 	struct ip_pool_s	**ipo_pnext;
53 	struct radix_node_head	*ipo_head;
54 	ip_pool_node_t	*ipo_list;
55 	u_long		ipo_hits;
56 	int		ipo_unit;
57 	int		ipo_flags;
58 	int		ipo_ref;
59 	char		ipo_name[FR_GROUPLEN];
60 } ip_pool_t;
61 
62 #define	IPOOL_ANON	0x80000000
63 
64 
65 typedef	struct	ip_pool_stat	{
66 	u_long		ipls_pools;
67 	u_long		ipls_tables;
68 	u_long		ipls_nodes;
69 	ip_pool_t	*ipls_list[IPL_LOGSIZE];
70 } ip_pool_stat_t;
71 
72 extern	int	ip_pool_search __P((void *, int, void *, ipf_stack_t *));
73 extern	int	ip_pool_init __P((ipf_stack_t *));
74 extern	void	ip_pool_fini __P((ipf_stack_t *));
75 extern	int	ip_pool_create __P((iplookupop_t *, ipf_stack_t *));
76 extern	int	ip_pool_insert __P((ip_pool_t *, addrfamily_t *,
77 				    addrfamily_t *, int, ipf_stack_t *));
78 extern	int	ip_pool_remove __P((ip_pool_t *, ip_pool_node_t *,
79 				    ipf_stack_t *));
80 extern	int	ip_pool_destroy __P((iplookupop_t *, ipf_stack_t *));
81 extern	void	ip_pool_free __P((ip_pool_t *, ipf_stack_t *));
82 extern	void	ip_pool_deref __P((ip_pool_t *, ipf_stack_t *));
83 extern	void	*ip_pool_find __P((int, char *, ipf_stack_t *));
84 extern	ip_pool_node_t *ip_pool_findeq __P((ip_pool_t *,
85 					  addrfamily_t *, addrfamily_t *));
86 extern	int	ip_pool_flush __P((iplookupflush_t *, ipf_stack_t *));
87 extern	int	ip_pool_statistics __P((iplookupop_t *, ipf_stack_t *));
88 extern	int	ip_pool_getnext __P((ipftoken_t *, ipflookupiter_t *, ipf_stack_t *));
89 extern	void	ip_pool_iterderef __P((u_int, int, void *, ipf_stack_t *));
90 #endif /* __IP_POOL_H__ */
91