17c478bd9Sstevel@tonic-gate /*
2ab25eeb5Syz  * Copyright (C) 1993-2001, 2003 by Darren Reed.
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * See the IPFILTER.LICENCE file for details on licencing.
57c478bd9Sstevel@tonic-gate  *
6ab25eeb5Syz  * $Id: ip_pool.h,v 2.26.2.3 2005/06/12 07:18:27 darrenr Exp $
77663b816Sml  *
8*de22af4eSJohn Ojemann  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
97c478bd9Sstevel@tonic-gate  */
107c478bd9Sstevel@tonic-gate 
117c478bd9Sstevel@tonic-gate #ifndef	__IP_POOL_H__
127c478bd9Sstevel@tonic-gate #define	__IP_POOL_H__
137c478bd9Sstevel@tonic-gate 
14ab25eeb5Syz #if defined(_KERNEL) && !defined(__osf__) && !defined(__hpux) && \
15ab25eeb5Syz     !defined(linux) && !defined(sun) && !defined(AIX)
167c478bd9Sstevel@tonic-gate # include <net/radix.h>
17ab25eeb5Syz extern void rn_freehead __P((struct radix_node_head *));
18ab25eeb5Syz # define FreeS(p, z)		KFREES(p, z)
19ab25eeb5Syz extern int max_keylen;
207c478bd9Sstevel@tonic-gate #else
21ab25eeb5Syz # if defined(__osf__) || defined(__hpux)
22ab25eeb5Syz #  include "radix_ipf_local.h"
23ab25eeb5Syz #  define radix_mask ipf_radix_mask
24ab25eeb5Syz #  define radix_node ipf_radix_node
25ab25eeb5Syz #  define radix_node_head ipf_radix_node_head
26ab25eeb5Syz # else
27ab25eeb5Syz #  include "radix_ipf.h"
28ab25eeb5Syz # endif
297c478bd9Sstevel@tonic-gate #endif
307c478bd9Sstevel@tonic-gate #include "netinet/ip_lookup.h"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #define	IP_POOL_NOMATCH		0
337c478bd9Sstevel@tonic-gate #define	IP_POOL_POSITIVE	1
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate typedef	struct ip_pool_node {
367c478bd9Sstevel@tonic-gate 	struct	radix_node	ipn_nodes[2];
377c478bd9Sstevel@tonic-gate 	addrfamily_t		ipn_addr;
387c478bd9Sstevel@tonic-gate 	addrfamily_t		ipn_mask;
397c478bd9Sstevel@tonic-gate 	int			ipn_info;
40f4b3ec61Sdh 	int			ipn_ref;
417c478bd9Sstevel@tonic-gate 	char			ipn_name[FR_GROUPLEN];
42*de22af4eSJohn Ojemann 	U_QUAD_T		ipn_hits;
43*de22af4eSJohn Ojemann 	U_QUAD_T		ipn_bytes;
447c478bd9Sstevel@tonic-gate 	struct ip_pool_node	*ipn_next, **ipn_pnext;
457c478bd9Sstevel@tonic-gate } ip_pool_node_t;
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate typedef	struct ip_pool_s {
497c478bd9Sstevel@tonic-gate 	struct ip_pool_s	*ipo_next;
507c478bd9Sstevel@tonic-gate 	struct ip_pool_s	**ipo_pnext;
517c478bd9Sstevel@tonic-gate 	struct radix_node_head	*ipo_head;
527c478bd9Sstevel@tonic-gate 	ip_pool_node_t	*ipo_list;
53*de22af4eSJohn Ojemann 	U_QUAD_T	ipo_hits;
547c478bd9Sstevel@tonic-gate 	int		ipo_unit;
557c478bd9Sstevel@tonic-gate 	int		ipo_flags;
567c478bd9Sstevel@tonic-gate 	int		ipo_ref;
577c478bd9Sstevel@tonic-gate 	char		ipo_name[FR_GROUPLEN];
587c478bd9Sstevel@tonic-gate } ip_pool_t;
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate #define	IPOOL_ANON	0x80000000
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate typedef	struct	ip_pool_stat	{
647c478bd9Sstevel@tonic-gate 	u_long		ipls_pools;
65ab25eeb5Syz 	u_long		ipls_tables;
667c478bd9Sstevel@tonic-gate 	u_long		ipls_nodes;
677c478bd9Sstevel@tonic-gate 	ip_pool_t	*ipls_list[IPL_LOGSIZE];
687c478bd9Sstevel@tonic-gate } ip_pool_stat_t;
697c478bd9Sstevel@tonic-gate 
70*de22af4eSJohn Ojemann extern	int	ip_pool_search __P((void *, int, void *, fr_info_t *, ipf_stack_t *));
71f4b3ec61Sdh extern	int	ip_pool_init __P((ipf_stack_t *));
72f4b3ec61Sdh extern	void	ip_pool_fini __P((ipf_stack_t *));
73f4b3ec61Sdh extern	int	ip_pool_create __P((iplookupop_t *, ipf_stack_t *));
747663b816Sml extern	int	ip_pool_insert __P((ip_pool_t *, addrfamily_t *,
75f4b3ec61Sdh 				    addrfamily_t *, int, ipf_stack_t *));
76f4b3ec61Sdh extern	int	ip_pool_remove __P((ip_pool_t *, ip_pool_node_t *,
77f4b3ec61Sdh 				    ipf_stack_t *));
78f4b3ec61Sdh extern	int	ip_pool_destroy __P((iplookupop_t *, ipf_stack_t *));
79f4b3ec61Sdh extern	void	ip_pool_free __P((ip_pool_t *, ipf_stack_t *));
80f4b3ec61Sdh extern	void	ip_pool_deref __P((ip_pool_t *, ipf_stack_t *));
81f4b3ec61Sdh extern	void	*ip_pool_find __P((int, char *, ipf_stack_t *));
827c478bd9Sstevel@tonic-gate extern	ip_pool_node_t *ip_pool_findeq __P((ip_pool_t *,
83ab25eeb5Syz 					  addrfamily_t *, addrfamily_t *));
84f4b3ec61Sdh extern	int	ip_pool_flush __P((iplookupflush_t *, ipf_stack_t *));
85f4b3ec61Sdh extern	int	ip_pool_statistics __P((iplookupop_t *, ipf_stack_t *));
86f4b3ec61Sdh extern	int	ip_pool_getnext __P((ipftoken_t *, ipflookupiter_t *, ipf_stack_t *));
87f4b3ec61Sdh extern	void	ip_pool_iterderef __P((u_int, int, void *, ipf_stack_t *));
887c478bd9Sstevel@tonic-gate #endif /* __IP_POOL_H__ */
89