145916cd2Sjpk /*
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  * @(#)ip_compat.h	1.8 1/14/96
7ab25eeb5Syz  * $Id: ip_compat.h,v 2.142.2.30 2005/08/11 15:13:49 darrenr Exp $
8ab25eeb5Syz  *
972680cf5SDarren Reed  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
107c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
117c478bd9Sstevel@tonic-gate  */
127c478bd9Sstevel@tonic-gate 
137c478bd9Sstevel@tonic-gate #ifndef	__IP_COMPAT_H__
147c478bd9Sstevel@tonic-gate #define	__IP_COMPAT_H__
157c478bd9Sstevel@tonic-gate 
167c478bd9Sstevel@tonic-gate #ifndef	__P
177c478bd9Sstevel@tonic-gate # ifdef	__STDC__
187c478bd9Sstevel@tonic-gate #  define	__P(x)  x
197c478bd9Sstevel@tonic-gate # else
207c478bd9Sstevel@tonic-gate #  define	__P(x)  ()
217c478bd9Sstevel@tonic-gate # endif
227c478bd9Sstevel@tonic-gate #endif
237c478bd9Sstevel@tonic-gate #ifndef	__STDC__
247c478bd9Sstevel@tonic-gate # undef		const
257c478bd9Sstevel@tonic-gate # define	const
267c478bd9Sstevel@tonic-gate #endif
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #if defined(_KERNEL) || defined(KERNEL) || defined(__KERNEL__)
297c478bd9Sstevel@tonic-gate # undef	KERNEL
307c478bd9Sstevel@tonic-gate # undef	_KERNEL
31*ae7a42b1SToomas Soome # undef		__KERNEL__
327c478bd9Sstevel@tonic-gate # define	KERNEL
337c478bd9Sstevel@tonic-gate # define	_KERNEL
34*ae7a42b1SToomas Soome # define	__KERNEL__
357c478bd9Sstevel@tonic-gate #endif
367c478bd9Sstevel@tonic-gate 
37*ae7a42b1SToomas Soome #ifdef	SOLARIS
38*ae7a42b1SToomas Soome #undef	SOLARIS
39*ae7a42b1SToomas Soome #endif
40*ae7a42b1SToomas Soome #if (defined(sun) && (defined(__svr4__) || defined(__SVR4)))
41*ae7a42b1SToomas Soome #define	SOLARIS	(1)
42*ae7a42b1SToomas Soome #else
43*ae7a42b1SToomas Soome #define	SOLARIS	(0)
447c478bd9Sstevel@tonic-gate #endif
45ab25eeb5Syz #if SOLARIS2 >= 8
467c478bd9Sstevel@tonic-gate # ifndef	USE_INET6
477c478bd9Sstevel@tonic-gate #  define	USE_INET6
487c478bd9Sstevel@tonic-gate # endif
497c478bd9Sstevel@tonic-gate #endif
507c478bd9Sstevel@tonic-gate #if defined(__FreeBSD_version) && (__FreeBSD_version >= 400000) && \
51ab25eeb5Syz     !defined(_KERNEL) && !defined(USE_INET6) && !defined(NOINET6)
527c478bd9Sstevel@tonic-gate # define	USE_INET6
537c478bd9Sstevel@tonic-gate #endif
547c478bd9Sstevel@tonic-gate #if defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 105000000) && \
55ab25eeb5Syz     !defined(_KERNEL) && !defined(USE_INET6)
567c478bd9Sstevel@tonic-gate # define	USE_INET6
57ab25eeb5Syz # define	IPFILTER_M_IPFILTER
587c478bd9Sstevel@tonic-gate #endif
59ab25eeb5Syz #if defined(OpenBSD) && (OpenBSD >= 200206) && \
60ab25eeb5Syz     !defined(_KERNEL) && !defined(USE_INET6)
617c478bd9Sstevel@tonic-gate # define	USE_INET6
627c478bd9Sstevel@tonic-gate #endif
637c478bd9Sstevel@tonic-gate #if defined(__osf__)
647c478bd9Sstevel@tonic-gate # define	USE_INET6
657c478bd9Sstevel@tonic-gate #endif
66ab25eeb5Syz #if defined(linux) && (!defined(_KERNEL) || defined(CONFIG_IPV6))
67ab25eeb5Syz # define	USE_INET6
68ab25eeb5Syz #endif
69ab25eeb5Syz #if defined(HPUXREV) && (HPUXREV >= 1111)
70ab25eeb5Syz # define	USE_INET6
71ab25eeb5Syz #endif
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate #if defined(BSD) && (BSD < 199103) && defined(__osf__)
747c478bd9Sstevel@tonic-gate # undef BSD
757c478bd9Sstevel@tonic-gate # define BSD 199103
767c478bd9Sstevel@tonic-gate #endif
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate #if defined(__SVR4) || defined(__svr4__) || defined(__sgi)
797c478bd9Sstevel@tonic-gate # define index   strchr
807c478bd9Sstevel@tonic-gate # if !defined(_KERNEL)
817c478bd9Sstevel@tonic-gate #  define	bzero(a,b)	memset(a,0,b)
827c478bd9Sstevel@tonic-gate #  define	bcmp		memcmp
837c478bd9Sstevel@tonic-gate #  define	bcopy(a,b,c)	memmove(b,a,c)
847c478bd9Sstevel@tonic-gate # endif
857c478bd9Sstevel@tonic-gate #endif
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate #ifndef LIFNAMSIZ
887c478bd9Sstevel@tonic-gate # ifdef IF_NAMESIZE
897c478bd9Sstevel@tonic-gate #  define	LIFNAMSIZ	IF_NAMESIZE
907c478bd9Sstevel@tonic-gate # else
917c478bd9Sstevel@tonic-gate #  ifdef	IFNAMSIZ
927c478bd9Sstevel@tonic-gate #   define	LIFNAMSIZ	IFNAMSIZ
937c478bd9Sstevel@tonic-gate #  else
947c478bd9Sstevel@tonic-gate #   define	LIFNAMSIZ	16
957c478bd9Sstevel@tonic-gate #  endif
967c478bd9Sstevel@tonic-gate # endif
977c478bd9Sstevel@tonic-gate #endif
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate #if defined(__sgi) || defined(bsdi) || defined(__hpux) || defined(hpux)
1007c478bd9Sstevel@tonic-gate struct  ether_addr {
1017c478bd9Sstevel@tonic-gate         u_char  ether_addr_octet[6];
1027c478bd9Sstevel@tonic-gate };
1037c478bd9Sstevel@tonic-gate #endif
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate #if defined(__sgi) && !defined(IPFILTER_LKM)
1067c478bd9Sstevel@tonic-gate # ifdef __STDC__
1077c478bd9Sstevel@tonic-gate #  define IPL_EXTERN(ep) ipfilter##ep
1087c478bd9Sstevel@tonic-gate # else
1097c478bd9Sstevel@tonic-gate #  define IPL_EXTERN(ep) ipfilter/**/ep
1107c478bd9Sstevel@tonic-gate # endif
1117c478bd9Sstevel@tonic-gate #else
1127c478bd9Sstevel@tonic-gate # ifdef __STDC__
1137c478bd9Sstevel@tonic-gate #  define IPL_EXTERN(ep) ipl##ep
1147c478bd9Sstevel@tonic-gate # else
1157c478bd9Sstevel@tonic-gate #  define IPL_EXTERN(ep) ipl/**/ep
1167c478bd9Sstevel@tonic-gate # endif
1177c478bd9Sstevel@tonic-gate #endif
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate /*
1207c478bd9Sstevel@tonic-gate  * This is a workaround for <sys/uio.h> troubles on FreeBSD and OpenBSD.
1217c478bd9Sstevel@tonic-gate  */
122ab25eeb5Syz #ifndef linux
123ab25eeb5Syz # ifndef _KERNEL
124ab25eeb5Syz #  define ADD_KERNEL
125ab25eeb5Syz #  define _KERNEL
126ab25eeb5Syz #  define KERNEL
127ab25eeb5Syz # endif
128ab25eeb5Syz # ifdef __OpenBSD__
1297c478bd9Sstevel@tonic-gate struct file;
130ab25eeb5Syz # endif
131ab25eeb5Syz # include <sys/uio.h>
132ab25eeb5Syz # ifdef ADD_KERNEL
133ab25eeb5Syz #  undef _KERNEL
134ab25eeb5Syz #  undef KERNEL
135ab25eeb5Syz # endif
1367c478bd9Sstevel@tonic-gate #endif
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate /* ----------------------------------------------------------------------- */
1407c478bd9Sstevel@tonic-gate /*                                  S O L A R I S                          */
1417c478bd9Sstevel@tonic-gate /* ----------------------------------------------------------------------- */
142af5f29ddSToomas Soome #ifdef SOLARIS
1437c478bd9Sstevel@tonic-gate # define	MENTAT	1
1447c478bd9Sstevel@tonic-gate # include	<sys/cmn_err.h>
1457c478bd9Sstevel@tonic-gate # include	<sys/isa_defs.h>
1467c478bd9Sstevel@tonic-gate # include	<sys/stream.h>
1477c478bd9Sstevel@tonic-gate # include	<sys/ioccom.h>
1487c478bd9Sstevel@tonic-gate # include	<sys/sysmacros.h>
1497c478bd9Sstevel@tonic-gate # include	<sys/kmem.h>
1507c478bd9Sstevel@tonic-gate # if SOLARIS2 >= 10
1517c478bd9Sstevel@tonic-gate #  include	<sys/procset.h>
1527c478bd9Sstevel@tonic-gate #  include	<sys/proc.h>
1537c478bd9Sstevel@tonic-gate #  include	<sys/devops.h>
1547c478bd9Sstevel@tonic-gate #  include	<sys/ddi_impldefs.h>
155f4b3ec61Sdh #  include	<sys/neti.h>
1567c478bd9Sstevel@tonic-gate # endif
157c793af95Ssangeeta 
158c793af95Ssangeeta /*
159c793af95Ssangeeta  * inet/ip.h would end up including radix.h with _KERNEL, which is not
160c793af95Ssangeeta  * what the tools intend, so include radix.h first.
161c793af95Ssangeeta  */
162c793af95Ssangeeta #if SOLARIS2 > 10
163c793af95Ssangeeta # include <net/radix.h>
164c793af95Ssangeeta #endif
1657c478bd9Sstevel@tonic-gate /*
1667c478bd9Sstevel@tonic-gate  * because Solaris 2 defines these in two places :-/
1677c478bd9Sstevel@tonic-gate  */
1687c478bd9Sstevel@tonic-gate # ifndef	KERNEL
169f4b3ec61Sdh #  define	ADD_KERNEL
1707c478bd9Sstevel@tonic-gate #  define	_KERNEL
1717c478bd9Sstevel@tonic-gate #  undef	RES_INIT
1727c478bd9Sstevel@tonic-gate # endif /* _KERNEL */
1737c478bd9Sstevel@tonic-gate 
1747c478bd9Sstevel@tonic-gate # if SOLARIS2 >= 8
1757c478bd9Sstevel@tonic-gate #  include <netinet/ip6.h>
1767c478bd9Sstevel@tonic-gate #  include <netinet/icmp6.h>
1777c478bd9Sstevel@tonic-gate # endif
1787c478bd9Sstevel@tonic-gate 
1797c478bd9Sstevel@tonic-gate # include <inet/common.h>
1807c478bd9Sstevel@tonic-gate /* These 5 are defined in <inet/ip.h> and <netinet/ip.h> */
1817c478bd9Sstevel@tonic-gate # undef	IPOPT_EOL
1827c478bd9Sstevel@tonic-gate # undef	IPOPT_NOP
1837c478bd9Sstevel@tonic-gate # undef	IPOPT_LSRR
1847c478bd9Sstevel@tonic-gate # undef	IPOPT_RR
1857c478bd9Sstevel@tonic-gate # undef	IPOPT_SSRR
186ab25eeb5Syz # ifdef i386
187ab25eeb5Syz #  define _SYS_PROMIF_H
188ab25eeb5Syz # endif
189f4b3ec61Sdh # ifdef ADD_KERNEL
190f4b3ec61Sdh #  undef _KERNEL
191f4b3ec61Sdh # endif
1927c478bd9Sstevel@tonic-gate # include <inet/ip.h>
1937c478bd9Sstevel@tonic-gate # undef COPYOUT
1947c478bd9Sstevel@tonic-gate # include <inet/ip_ire.h>
1957c478bd9Sstevel@tonic-gate # ifndef	KERNEL
1967c478bd9Sstevel@tonic-gate #  undef	_KERNEL
1977c478bd9Sstevel@tonic-gate # endif
1987c478bd9Sstevel@tonic-gate # if SOLARIS2 >= 8
199ab25eeb5Syz #  define SNPRINTF	snprintf
200ab25eeb5Syz 
2017c478bd9Sstevel@tonic-gate #  include <inet/ip_if.h>
2027c478bd9Sstevel@tonic-gate #  define	ipif_local_addr	ipif_lcl_addr
2037c478bd9Sstevel@tonic-gate /* Only defined in private include file */
2047c478bd9Sstevel@tonic-gate #  ifndef	V4_PART_OF_V6
2057c478bd9Sstevel@tonic-gate #   define	V4_PART_OF_V6(v6)	v6.s6_addr32[3]
2067c478bd9Sstevel@tonic-gate #  endif
2077c478bd9Sstevel@tonic-gate struct ip6_ext {
2087c478bd9Sstevel@tonic-gate 	u_char	ip6e_nxt;
2097c478bd9Sstevel@tonic-gate 	u_char	ip6e_len;
2107c478bd9Sstevel@tonic-gate };
2117c478bd9Sstevel@tonic-gate # endif /* SOLARIS2 >= 8 */
2127c478bd9Sstevel@tonic-gate 
213381a2a9aSdr # ifdef FW_HOOKS
214381a2a9aSdr 
215381a2a9aSdr #  define	SOLARIS_PFHOOKS	1
216381a2a9aSdr 
217381a2a9aSdr typedef	struct	qpktinfo	{
218381a2a9aSdr 	/* data that changes per-packet */
219381a2a9aSdr 	void		*qpi_ill;	/* COPIED */
220381a2a9aSdr 	mblk_t		*qpi_m;
221381a2a9aSdr 	void		*qpi_data;	/* where layer 3 header starts */
222381a2a9aSdr 	size_t		qpi_off;
2231b47e080Sdr 	int		qpi_flags;	/* Uses FI_* flags */
224381a2a9aSdr } qpktinfo_t;
225381a2a9aSdr 
226381a2a9aSdr extern void mb_copydata __P((mblk_t *, size_t , size_t, char *));
227381a2a9aSdr extern void mb_copyback __P((mblk_t *, size_t , size_t, char *));
228381a2a9aSdr # endif
229381a2a9aSdr 
2307c478bd9Sstevel@tonic-gate # if SOLARIS2 >= 6
2317c478bd9Sstevel@tonic-gate #  include <sys/atomic.h>
2327c478bd9Sstevel@tonic-gate typedef	uint32_t	u_32_t;
2337c478bd9Sstevel@tonic-gate # else
2347c478bd9Sstevel@tonic-gate typedef unsigned int	u_32_t;
2357c478bd9Sstevel@tonic-gate # endif
2367c478bd9Sstevel@tonic-gate # define	U_32_T	1
2377c478bd9Sstevel@tonic-gate 
2387c478bd9Sstevel@tonic-gate # ifdef _KERNEL
2397c478bd9Sstevel@tonic-gate #  define	KRWLOCK_T		krwlock_t
2407c478bd9Sstevel@tonic-gate #  define	KMUTEX_T		kmutex_t
24140cdc2e8SAlexandr Nedvedicky #  if SOLARIS2 >= 10
24240cdc2e8SAlexandr Nedvedicky #   include <sys/sdt.h>
243a1173273SAlexandr Nedvedicky 
244a1173273SAlexandr Nedvedicky #   define IPF_IS_LOOPBACK(f)	((f) & FI_NOCKSUM)
24540cdc2e8SAlexandr Nedvedicky #  endif /* SOLARIS2 >= 10 */
2467c478bd9Sstevel@tonic-gate #  if SOLARIS2 >= 6
2477c478bd9Sstevel@tonic-gate #   if SOLARIS2 == 6
2481a5e258fSJosef 'Jeff' Sipek #    define	ATOMIC_INCL(x)		atomic_inc_ulong((uint32_t *)&(x))
2491a5e258fSJosef 'Jeff' Sipek #    define	ATOMIC_DECL(x)		atomic_dec_ulong((uint32_t *)&(x))
2507c478bd9Sstevel@tonic-gate #   else
2511a5e258fSJosef 'Jeff' Sipek #    define	ATOMIC_INCL(x)		atomic_inc_ulong(&(x))
2521a5e258fSJosef 'Jeff' Sipek #    define	ATOMIC_DECL(x)		atomic_dec_ulong(&(x))
2537c478bd9Sstevel@tonic-gate #   endif /* SOLARIS2 == 6 */
2541a5e258fSJosef 'Jeff' Sipek #   define	ATOMIC_INC64(x)		atomic_inc_64((uint64_t *)&(x))
2551a5e258fSJosef 'Jeff' Sipek #   define	ATOMIC_INC32(x)		atomic_inc_32((uint32_t *)&(x))
2561a5e258fSJosef 'Jeff' Sipek #   define	ATOMIC_INC16(x)		atomic_inc_16((uint16_t *)&(x))
2571a5e258fSJosef 'Jeff' Sipek #   define	ATOMIC_DEC64(x)		atomic_dec_64((uint64_t *)&(x))
2581a5e258fSJosef 'Jeff' Sipek #   define	ATOMIC_DEC32(x)		atomic_dec_32((uint32_t *)&(x))
2591a5e258fSJosef 'Jeff' Sipek #   define	ATOMIC_DEC16(x)		atomic_dec_16((uint16_t *)&(x))
2607c478bd9Sstevel@tonic-gate #  else
2617c478bd9Sstevel@tonic-gate #   define	ATOMIC_INC(x)		{ mutex_enter(&ipf_rw); (x)++; \
2627c478bd9Sstevel@tonic-gate 					  mutex_exit(&ipf_rw); }
2637c478bd9Sstevel@tonic-gate #   define	ATOMIC_DEC(x)		{ mutex_enter(&ipf_rw); (x)--; \
2647c478bd9Sstevel@tonic-gate 					  mutex_exit(&ipf_rw); }
2657c478bd9Sstevel@tonic-gate #  endif /* SOLARIS2 >= 6 */
2667c478bd9Sstevel@tonic-gate #  define	USE_MUTEXES
2677c478bd9Sstevel@tonic-gate #  define	MUTEX_ENTER(x)		mutex_enter(&(x)->ipf_lk)
2687c478bd9Sstevel@tonic-gate #  define	READ_ENTER(x)		rw_enter(&(x)->ipf_lk, RW_READER)
2697c478bd9Sstevel@tonic-gate #  define	WRITE_ENTER(x)		rw_enter(&(x)->ipf_lk, RW_WRITER)
2707c478bd9Sstevel@tonic-gate #  define	MUTEX_DOWNGRADE(x)	rw_downgrade(&(x)->ipf_lk)
2717c478bd9Sstevel@tonic-gate #  define	RWLOCK_INIT(x, y)	rw_init(&(x)->ipf_lk, (y),  \
2727c478bd9Sstevel@tonic-gate 						RW_DRIVER, NULL)
2737c478bd9Sstevel@tonic-gate #  define	RWLOCK_EXIT(x)		rw_exit(&(x)->ipf_lk)
2747c478bd9Sstevel@tonic-gate #  define	RW_DESTROY(x)		rw_destroy(&(x)->ipf_lk)
2757c478bd9Sstevel@tonic-gate #  define	MUTEX_INIT(x, y)	mutex_init(&(x)->ipf_lk, (y), \
2767c478bd9Sstevel@tonic-gate 						   MUTEX_DRIVER, NULL)
2777c478bd9Sstevel@tonic-gate #  define	MUTEX_DESTROY(x)	mutex_destroy(&(x)->ipf_lk)
2787c478bd9Sstevel@tonic-gate #  define	MUTEX_NUKE(x)		bzero((x), sizeof(*(x)))
2797c478bd9Sstevel@tonic-gate #  define	MUTEX_EXIT(x)		mutex_exit(&(x)->ipf_lk)
2807c478bd9Sstevel@tonic-gate #  define	COPYIN(a,b,c)	copyin((caddr_t)(a), (caddr_t)(b), (c))
2817c478bd9Sstevel@tonic-gate #  define	COPYOUT(a,b,c)	copyout((caddr_t)(a), (caddr_t)(b), (c))
282bb1d9de5SJohn Ojemann #  define	BCOPYIN(a,b,c)	copyin((caddr_t)(a), (caddr_t)(b), (c))
283bb1d9de5SJohn Ojemann #  define	BCOPYOUT(a,b,c)	copyout((caddr_t)(a), (caddr_t)(b), (c))
2847c478bd9Sstevel@tonic-gate #  define	UIOMOVE(a,b,c,d)	uiomove((caddr_t)a,b,c,d)
2857c478bd9Sstevel@tonic-gate #  define	KFREE(x)	kmem_free((char *)(x), sizeof(*(x)))
2867c478bd9Sstevel@tonic-gate #  define	KFREES(x,s)	kmem_free((char *)(x), (s))
2877c478bd9Sstevel@tonic-gate #  define	SPL_NET(x)	;
2887c478bd9Sstevel@tonic-gate #  define	SPL_IMP(x)	;
2897c478bd9Sstevel@tonic-gate #  undef	SPL_X
2907c478bd9Sstevel@tonic-gate #  define	SPL_X(x)	;
2917c478bd9Sstevel@tonic-gate #  ifdef sparc
2927c478bd9Sstevel@tonic-gate #   define	ntohs(x)	(x)
2937c478bd9Sstevel@tonic-gate #   define	ntohl(x)	(x)
2947c478bd9Sstevel@tonic-gate #   define	htons(x)	(x)
2957c478bd9Sstevel@tonic-gate #   define	htonl(x)	(x)
2967c478bd9Sstevel@tonic-gate #  endif /* sparc */
2977c478bd9Sstevel@tonic-gate #  define	KMALLOC(a,b)	(a) = (b)kmem_alloc(sizeof(*(a)), KM_NOSLEEP)
2987c478bd9Sstevel@tonic-gate #  define	KMALLOCS(a,b,c)	(a) = (b)kmem_alloc((c), KM_NOSLEEP)
2997c478bd9Sstevel@tonic-gate #  define	GET_MINOR(x)	getminor(x)
300f4b3ec61Sdh /*extern	phy_if_t	get_unit __P((char *, int, ipf_stack_t *));*/
301f4b3ec61Sdh #  define	GETIFP(n, v, ifs)	(void *)get_unit(n, v, ifs)
302381a2a9aSdr #  define	IFNAME(x)	((ill_t *)x)->ill_name
303381a2a9aSdr #  define	COPYIFNAME(x, b, v)	(void) net_getifname(((v) == 4) ? \
304f4b3ec61Sdh 					ifs->ifs_ipf_ipv4 : ifs->ifs_ipf_ipv6,\
305f4b3ec61Sdh 					(phy_if_t)(x), (b), sizeof(b))
3067c478bd9Sstevel@tonic-gate #  define	GETKTIME(x)	uniqtime((struct timeval *)x)
3077c478bd9Sstevel@tonic-gate #  define	MSGDSIZE(x)	msgdsize(x)
3087c478bd9Sstevel@tonic-gate #  define	M_LEN(x)	((x)->b_wptr - (x)->b_rptr)
309201a9dc8SAlexandr Nedvedicky #  define	M_DUPLICATE(x)	copymsg((x))
310ab25eeb5Syz #  define	MTOD(m,t)	((t)((m)->b_rptr))
3117c478bd9Sstevel@tonic-gate #  define	MTYPE(m)	((m)->b_datap->db_type)
3127c478bd9Sstevel@tonic-gate #  define	FREE_MB_T(m)	freemsg(m)
313ab25eeb5Syz #  define	m_next		b_cont
314381a2a9aSdr #  define	CACHE_HASH(x)	(((phy_if_t)(x)->fin_ifp) & 7)
3157c478bd9Sstevel@tonic-gate #  define	IPF_PANIC(x,y)	if (x) { printf y; cmn_err(CE_PANIC, "ipf_panic"); }
3167c478bd9Sstevel@tonic-gate typedef mblk_t mb_t;
3177c478bd9Sstevel@tonic-gate # endif /* _KERNEL */
3187c478bd9Sstevel@tonic-gate 
3197c478bd9Sstevel@tonic-gate # if (SOLARIS2 >= 7)
3207c478bd9Sstevel@tonic-gate #  ifdef lint
3217c478bd9Sstevel@tonic-gate #   define ALIGN32(ptr)    (ptr ? 0L : 0L)
3227c478bd9Sstevel@tonic-gate #   define ALIGN16(ptr)    (ptr ? 0L : 0L)
3237c478bd9Sstevel@tonic-gate #  else
3247c478bd9Sstevel@tonic-gate #   define ALIGN32(ptr)    (ptr)
3257c478bd9Sstevel@tonic-gate #   define ALIGN16(ptr)    (ptr)
3267c478bd9Sstevel@tonic-gate #  endif
3277c478bd9Sstevel@tonic-gate # endif
3287c478bd9Sstevel@tonic-gate 
329ab25eeb5Syz # if SOLARIS2 < 6
330ab25eeb5Syz typedef	struct uio	uio_t;
331ab25eeb5Syz # endif
332ab25eeb5Syz typedef	int		ioctlcmd_t;
333ab073b32Sdr typedef	uint8_t		u_int8_t;
3347c478bd9Sstevel@tonic-gate 
3357c478bd9Sstevel@tonic-gate # define OS_RECOGNISED 1
3367c478bd9Sstevel@tonic-gate 
3377c478bd9Sstevel@tonic-gate #endif /* SOLARIS */
3387c478bd9Sstevel@tonic-gate 
3397c478bd9Sstevel@tonic-gate /* ----------------------------------------------------------------------- */
3407c478bd9Sstevel@tonic-gate /*                                  H P U X                                */
3417c478bd9Sstevel@tonic-gate /* ----------------------------------------------------------------------- */
3427c478bd9Sstevel@tonic-gate #ifdef __hpux
3437c478bd9Sstevel@tonic-gate # define	MENTAT	1
3447c478bd9Sstevel@tonic-gate # include	<sys/sysmacros.h>
3457c478bd9Sstevel@tonic-gate # include	<sys/spinlock.h>
3467c478bd9Sstevel@tonic-gate # include	<sys/lock.h>
3477c478bd9Sstevel@tonic-gate # include	<sys/stream.h>
348ab25eeb5Syz # ifdef USE_INET6
349ab25eeb5Syz #  include	<netinet/if_ether.h>
350ab25eeb5Syz #  include	<netinet/ip6.h>
351ab25eeb5Syz #  include	<netinet/icmp6.h>
352ab25eeb5Syz typedef	struct	ip6_hdr	ip6_t;
353ab25eeb5Syz # endif
3547c478bd9Sstevel@tonic-gate 
3557c478bd9Sstevel@tonic-gate # ifdef _KERNEL
356ab25eeb5Syz #  define SNPRINTF	sprintf
357ab25eeb5Syz #  if (HPUXREV >= 1111)
358ab25eeb5Syz #   define	IPL_SELECT
359ab25eeb5Syz #   ifdef	IPL_SELECT
360ab25eeb5Syz #    include	<machine/sys/user.h>
361ab25eeb5Syz #    include	<sys/kthread_iface.h>
362ab25eeb5Syz #    define	READ_COLLISION	0x01
363ab25eeb5Syz 
364ab25eeb5Syz typedef	struct	iplog_select_s {
365ab25eeb5Syz 	kthread_t	*read_waiter;
366ab25eeb5Syz 	int		state;
367ab25eeb5Syz } iplog_select_t;
368ab25eeb5Syz #   endif
369ab25eeb5Syz #  endif
3707c478bd9Sstevel@tonic-gate 
3717c478bd9Sstevel@tonic-gate #  define	GETKTIME(x)	uniqtime((struct timeval *)x)
3727c478bd9Sstevel@tonic-gate 
3737c478bd9Sstevel@tonic-gate #  if HPUXREV == 1111
3747c478bd9Sstevel@tonic-gate #   include	"kern_svcs.h"
3757c478bd9Sstevel@tonic-gate #  else
3767c478bd9Sstevel@tonic-gate #   include	<sys/kern_svcs.h>
3777c478bd9Sstevel@tonic-gate #  endif
3787c478bd9Sstevel@tonic-gate #  undef	ti_flags
3797c478bd9Sstevel@tonic-gate #  undef	TCP_NODELAY
3807c478bd9Sstevel@tonic-gate #  undef	TCP_MAXSEG
3817c478bd9Sstevel@tonic-gate #  include <sys/reg.h>
3827c478bd9Sstevel@tonic-gate #  include "../netinet/ip_info.h"
3837c478bd9Sstevel@tonic-gate /*
3847c478bd9Sstevel@tonic-gate  * According to /usr/include/sys/spinlock.h on HP-UX 11.00, these functions
3857c478bd9Sstevel@tonic-gate  * are available.  Attempting to use them actually results in unresolved
3867c478bd9Sstevel@tonic-gate  * symbols when it comes time to load the module.
387ab25eeb5Syz  * This has been fixed!  Yipee!
3887c478bd9Sstevel@tonic-gate  */
389ab25eeb5Syz #  if 1
3907c478bd9Sstevel@tonic-gate #   ifdef __LP64__
391ab25eeb5Syz #    define	ATOMIC_INCL(x)		lock_and_incr_int64(&ipf_rw.ipf_lk, &(x), 1)
392ab25eeb5Syz #    define	ATOMIC_DECL(x)		lock_and_incr_int64(&ipf_rw.ipf_lk, &(x), -1)
3937c478bd9Sstevel@tonic-gate #   else
394ab25eeb5Syz #    define	ATOMIC_INCL(x)		lock_and_incr_int32(&ipf_rw.ipf_lk, &(