17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * Copyright (C) 1993-2001 by Darren Reed.
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * See the IPFILTER.LICENCE file for details on licencing.
57c478bd9Sstevel@tonic-gate  *
67c478bd9Sstevel@tonic-gate  * @(#)ip_frag.h	1.5 3/24/96
7ab25eeb5Syz  * $Id: ip_frag.h,v 2.23.2.2 2005/06/10 18:02:37 darrenr Exp $
87663b816Sml  *
9*72680cf5SDarren Reed  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
107663b816Sml  * Use is subject to license terms.
117c478bd9Sstevel@tonic-gate  */
127c478bd9Sstevel@tonic-gate 
137c478bd9Sstevel@tonic-gate #ifndef	__IP_FRAG_H__
147c478bd9Sstevel@tonic-gate #define	__IP_FRAG_H__
157c478bd9Sstevel@tonic-gate 
167c478bd9Sstevel@tonic-gate #define	IPFT_SIZE	257
177c478bd9Sstevel@tonic-gate 
187c478bd9Sstevel@tonic-gate typedef	struct	ipfr	{
197c478bd9Sstevel@tonic-gate 	struct	ipfr	*ipfr_hnext, **ipfr_hprev;
207c478bd9Sstevel@tonic-gate 	struct	ipfr	*ipfr_next, **ipfr_prev;
217c478bd9Sstevel@tonic-gate 	void	*ipfr_data;
227c478bd9Sstevel@tonic-gate 	void	*ipfr_ifp;
23*72680cf5SDarren Reed 	i6addr_t	ipfr_src;
24*72680cf5SDarren Reed 	i6addr_t	ipfr_dst;
257c478bd9Sstevel@tonic-gate 	u_32_t	ipfr_optmsk;
267c478bd9Sstevel@tonic-gate 	u_short	ipfr_secmsk;
277c478bd9Sstevel@tonic-gate 	u_short	ipfr_auth;
287663b816Sml 	u_32_t	ipfr_id;
29*72680cf5SDarren Reed 	u_32_t	ipfr_p;
30*72680cf5SDarren Reed 	u_32_t	ipfr_tos;
317c478bd9Sstevel@tonic-gate 	u_32_t	ipfr_pass;
327c478bd9Sstevel@tonic-gate 	u_short	ipfr_off;
33f4b3ec61Sdh 	u_long	ipfr_ttl;
347c478bd9Sstevel@tonic-gate 	u_char	ipfr_seen0;
357c478bd9Sstevel@tonic-gate 	frentry_t *ipfr_rule;
36f4b3ec61Sdh 	int	ipfr_ref;
377c478bd9Sstevel@tonic-gate } ipfr_t;
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate typedef	struct	ipfrstat {
407c478bd9Sstevel@tonic-gate 	u_long	ifs_exists;	/* add & already exists */
417c478bd9Sstevel@tonic-gate 	u_long	ifs_nomem;
427c478bd9Sstevel@tonic-gate 	u_long	ifs_new;
437c478bd9Sstevel@tonic-gate 	u_long	ifs_hits;
447c478bd9Sstevel@tonic-gate 	u_long	ifs_expire;
457c478bd9Sstevel@tonic-gate 	u_long	ifs_inuse;
467c478bd9Sstevel@tonic-gate 	u_long	ifs_retrans0;
477c478bd9Sstevel@tonic-gate 	u_long	ifs_short;
487c478bd9Sstevel@tonic-gate 	struct	ipfr	**ifs_table;
497c478bd9Sstevel@tonic-gate 	struct	ipfr	**ifs_nattab;
507c478bd9Sstevel@tonic-gate } ipfrstat_t;
517c478bd9Sstevel@tonic-gate 
527663b816Sml #define	IPFR_CMPSZ	(offsetof(ipfr_t, ipfr_tos) - \
537c478bd9Sstevel@tonic-gate 			 offsetof(ipfr_t, ipfr_ifp))
547c478bd9Sstevel@tonic-gate 
55f4b3ec61Sdh extern	int	fr_fraginit __P((ipf_stack_t *));
56f4b3ec61Sdh extern	void	fr_fragunload __P((ipf_stack_t *));
57f4b3ec61Sdh extern	ipfrstat_t	*fr_fragstats __P((ipf_stack_t *));
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate extern	int	fr_newfrag __P((fr_info_t *, u_32_t));
607c478bd9Sstevel@tonic-gate extern	frentry_t *fr_knownfrag __P((fr_info_t *, u_32_t *));
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate extern	int	fr_nat_newfrag __P((fr_info_t *, u_32_t, struct nat *));
637c478bd9Sstevel@tonic-gate extern	nat_t	*fr_nat_knownfrag __P((fr_info_t *));
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate extern	int	fr_ipid_newfrag __P((fr_info_t *, u_32_t));
667c478bd9Sstevel@tonic-gate extern	u_32_t	fr_ipid_knownfrag __P((fr_info_t *));
67f4b3ec61Sdh extern  void    fr_fragderef __P((ipfr_t **, ipfrwlock_t *, ipf_stack_t *));
687c478bd9Sstevel@tonic-gate 
69f4b3ec61Sdh extern	void	fr_forget __P((void *, ipf_stack_t *));
70f4b3ec61Sdh extern	void	fr_forgetnat __P((void *, ipf_stack_t *));
71f4b3ec61Sdh extern	void	fr_fragclear __P((ipf_stack_t *));
72f4b3ec61Sdh extern	void	fr_fragexpire __P((ipf_stack_t *));
73f4b3ec61Sdh extern	int	fr_nextfrag __P((ipftoken_t *, ipfgeniter_t *, ipfr_t **, \
74f4b3ec61Sdh 				 ipfr_t ***, ipfrwlock_t *, ipf_stack_t *));
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate #if     defined(_KERNEL) && ((BSD >= 199306) || SOLARIS || defined(__sgi) \
77ab25eeb5Syz 	        || defined(__osf__) || (defined(__sgi) && (IRIX >= 60500)))
787c478bd9Sstevel@tonic-gate # if defined(SOLARIS2) && (SOLARIS2 < 7)
79f4b3ec61Sdh extern	void	fr_slowtimer __P((void *));
807c478bd9Sstevel@tonic-gate # else
817c478bd9Sstevel@tonic-gate extern	void	fr_slowtimer __P((void *));
827c478bd9Sstevel@tonic-gate # endif
837c478bd9Sstevel@tonic-gate #else
84ab25eeb5Syz # if defined(linux) && defined(_KERNEL)
85ab25eeb5Syz extern	void	fr_slowtimer __P((long));
86ab25eeb5Syz # else
87f4b3ec61Sdh extern	int	fr_slowtimer __P((void *));
88ab25eeb5Syz # endif
897c478bd9Sstevel@tonic-gate #endif
907c478bd9Sstevel@tonic-gate 
917663b816Sml #endif	/* __IP_FRAG_H__ */
92