17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * Copyright (C) 1997-2001 by Darren Reed.
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * See the IPFILTER.LICENCE file for details on licencing.
57c478bd9Sstevel@tonic-gate  *
6ab25eeb5Syz  * $Id: ip_proxy.h,v 2.31.2.3 2005/06/18 02:41:33 darrenr Exp $
7f4b3ec61Sdh  *
8f4b3ec61Sdh  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
9f4b3ec61Sdh  * Use is subject to license terms.
107c478bd9Sstevel@tonic-gate  */
117c478bd9Sstevel@tonic-gate 
127c478bd9Sstevel@tonic-gate #ifndef	__IP_PROXY_H__
137c478bd9Sstevel@tonic-gate #define	__IP_PROXY_H__
147c478bd9Sstevel@tonic-gate 
15ae7a42b1SToomas Soome #ifdef	SOLARIS
16ae7a42b1SToomas Soome #undef	SOLARIS
17ae7a42b1SToomas Soome #endif
18ae7a42b1SToomas Soome #if (defined(sun) && (defined(__svr4__) || defined(__SVR4)))
19ae7a42b1SToomas Soome #define	SOLARIS	(1)
20ae7a42b1SToomas Soome #else
21ae7a42b1SToomas Soome #define	SOLARIS	(0)
227c478bd9Sstevel@tonic-gate #endif
237c478bd9Sstevel@tonic-gate 
24ab25eeb5Syz #if defined(__STDC__) || defined(__GNUC__) || defined(_AIX51)
25ab25eeb5Syz #define	SIOCPROXY	_IOWR('r', 64, struct ap_control)
26ab25eeb5Syz #else
27ab25eeb5Syz #define	SIOCPROXY	_IOWR(r, 64, struct ap_control)
28ab25eeb5Syz #endif
29ab25eeb5Syz 
307c478bd9Sstevel@tonic-gate #ifndef	APR_LABELLEN
317c478bd9Sstevel@tonic-gate #define	APR_LABELLEN	16
327c478bd9Sstevel@tonic-gate #endif
337c478bd9Sstevel@tonic-gate #define	AP_SESS_SIZE	53
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate struct	nat;
367c478bd9Sstevel@tonic-gate struct	ipnat;
37ab25eeb5Syz struct	ipstate;
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate typedef	struct	ap_tcp {
407c478bd9Sstevel@tonic-gate 	u_short	apt_sport;	/* source port */
417c478bd9Sstevel@tonic-gate 	u_short	apt_dport;	/* destination port */
427c478bd9Sstevel@tonic-gate 	short	apt_sel[2];	/* {seq,ack}{off,min} set selector */
437c478bd9Sstevel@tonic-gate 	short	apt_seqoff[2];	/* sequence # difference */
44ab25eeb5Syz 	u_32_t	apt_seqmin[2];	/* don't change seq-off until after this */
457c478bd9Sstevel@tonic-gate 	short	apt_ackoff[2];	/* sequence # difference */
46ab25eeb5Syz 	u_32_t	apt_ackmin[2];	/* don't change seq-off until after this */
477c478bd9Sstevel@tonic-gate 	u_char	apt_state[2];	/* connection state */
487c478bd9Sstevel@tonic-gate } ap_tcp_t;
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate typedef	struct	ap_udp {
517c478bd9Sstevel@tonic-gate 	u_short	apu_sport;	/* source port */
527c478bd9Sstevel@tonic-gate 	u_short	apu_dport;	/* destination port */
537c478bd9Sstevel@tonic-gate } ap_udp_t;
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate typedef	struct ap_session {
567c478bd9Sstevel@tonic-gate 	struct	aproxy	*aps_apr;
577c478bd9Sstevel@tonic-gate 	union {
587c478bd9Sstevel@tonic-gate 		struct	ap_tcp	apu_tcp;
597c478bd9Sstevel@tonic-gate 		struct	ap_udp	apu_udp;
607c478bd9Sstevel@tonic-gate 	} aps_un;
617c478bd9Sstevel@tonic-gate 	u_int	aps_flags;
627c478bd9Sstevel@tonic-gate 	U_QUAD_T aps_bytes;	/* bytes sent */
637c478bd9Sstevel@tonic-gate 	U_QUAD_T aps_pkts;	/* packets sent */
647c478bd9Sstevel@tonic-gate 	void	*aps_nat;	/* pointer back to nat struct */
657c478bd9Sstevel@tonic-gate 	void	*aps_data;	/* private data */
667c478bd9Sstevel@tonic-gate 	int	aps_p;		/* protocol */
677c478bd9Sstevel@tonic-gate 	int	aps_psiz;	/* size of private data */
687c478bd9Sstevel@tonic-gate 	struct	ap_session	*aps_hnext;
697c478bd9Sstevel@tonic-gate 	struct	ap_session	*aps_next;
707c478bd9Sstevel@tonic-gate } ap_session_t;
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate #define	aps_sport	aps_un.apu_tcp.apt_sport
737c478bd9Sstevel@tonic-gate #define	aps_dport	aps_un.apu_tcp.apt_dport
747c478bd9Sstevel@tonic-gate #define	aps_sel		aps_un.apu_tcp.apt_sel
757c478bd9Sstevel@tonic-gate #define	aps_seqoff	aps_un.apu_tcp.apt_seqoff
767c478bd9Sstevel@tonic-gate #define	aps_seqmin	aps_un.apu_tcp.apt_seqmin
777c478bd9Sstevel@tonic-gate #define	aps_state	aps_un.apu_tcp.apt_state
787c478bd9Sstevel@tonic-gate #define	aps_ackoff	aps_un.apu_tcp.apt_ackoff
797c478bd9Sstevel@tonic-gate #define	aps_ackmin	aps_un.apu_tcp.apt_ackmin
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate typedef	struct	ap_control {
837c478bd9Sstevel@tonic-gate 	char	apc_label[APR_LABELLEN];
847c478bd9Sstevel@tonic-gate 	u_char	apc_p;
857c478bd9Sstevel@tonic-gate 	/*
867c478bd9Sstevel@tonic-gate 	 * The following fields are upto the proxy's apr_ctl routine to deal
877c478bd9Sstevel@tonic-gate 	 * with.  When the proxy gets this in kernel space, apc_data will
887c478bd9Sstevel@tonic-gate 	 * point to a malloc'd region of memory of apc_dsize bytes.  If the
897c478bd9Sstevel@tonic-gate 	 * proxy wants to keep that memory, it must set apc_data to NULL
907c478bd9Sstevel@tonic-gate 	 * before it returns.  It is expected if this happens that it will
917c478bd9Sstevel@tonic-gate 	 * take care to free it in apr_fini or otherwise as appropriate.
927c478bd9Sstevel@tonic-gate 	 * apc_cmd is provided as a standard place to put simple commands,
937c478bd9Sstevel@tonic-gate 	 * with apc_arg being available to put a simple arg.
947c478bd9Sstevel@tonic-gate 	 */
957c478bd9Sstevel@tonic-gate 	u_long	apc_cmd;
967c478bd9Sstevel@tonic-gate 	u_long	apc_arg;
977c478bd9Sstevel@tonic-gate 	void	*apc_data;
987c478bd9Sstevel@tonic-gate 	size_t	apc_dsize;
997c478bd9Sstevel@tonic-gate } ap_ctl_t;
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate typedef	struct	aproxy	{
1037c478bd9Sstevel@tonic-gate 	struct	aproxy	*apr_next;
1047c478bd9Sstevel@tonic-gate 	char	apr_label[APR_LABELLEN];	/* Proxy label # */
1057c478bd9Sstevel@tonic-gate 	u_char	apr_p;		/* protocol */
1067c478bd9Sstevel@tonic-gate 	int	apr_ref;	/* +1 per rule referencing it */
1077c478bd9Sstevel@tonic-gate 	int	apr_flags;
108f4b3ec61Sdh 	void	*apr_private;	/* proxy private data */
109f4b3ec61Sdh 	int	(* apr_init) __P((void **, ipf_stack_t *));
110f4b3ec61Sdh 	void	(* apr_fini) __P((void **, ipf_stack_t *));
111f4b3ec61Sdh 	int	(* apr_new) __P((fr_info_t *, ap_session_t *, struct nat *, void *));
112f4b3ec61Sdh 	void	(* apr_del) __P((ap_session_t *, void *, ipf_stack_t *));
113f4b3ec61Sdh 	int	(* apr_inpkt) __P((fr_info_t *, ap_session_t *, struct nat *, void *));
114f4b3ec61Sdh 	int	(* apr_outpkt) __P((fr_info_t *, ap_session_t *, struct nat *, void *));
115f4b3ec61Sdh 	int	(* apr_match) __P((fr_info_t *, ap_session_t *, struct nat *, void *));
116f4b3ec61Sdh 	int	(* apr_ctl) __P((struct aproxy *, struct ap_control *, void *));
1177c478bd9Sstevel@tonic-gate } aproxy_t;
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate #define	APR_DELETE	1
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate #define	APR_ERR(x)	((x) << 16)
1227c478bd9Sstevel@tonic-gate #define	APR_EXIT(x)	(((x) >> 16) & 0xffff)
1237c478bd9Sstevel@tonic-gate #define	APR_INC(x)	((x) & 0xffff)
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate /*
1267c478bd9Sstevel@tonic-gate  * Generic #define's to cover missing things in the kernel
1277c478bd9Sstevel@tonic-gate  */
1287c478bd9Sstevel@tonic-gate #ifndef isdigit
1297c478bd9Sstevel@tonic-gate #define isdigit(x)	((x) >= '0' && (x) <= '9')
1307c478bd9Sstevel@tonic-gate #endif
1317c478bd9Sstevel@tonic-gate #ifndef isupper
1327c478bd9Sstevel@tonic-gate #define isupper(x)	(((unsigned)(x) >= 'A') && ((unsigned)(x) <= 'Z'))
1337c478bd9Sstevel@tonic-gate #endif
1347c478bd9Sstevel@tonic-gate #ifndef islower
1357c478bd9Sstevel@tonic-gate #define islower(x)	(((unsigned)(x) >= 'a') && ((unsigned)(x) <= 'z'))
1367c478bd9Sstevel@tonic-gate #endif
1377c478bd9Sstevel@tonic-gate #ifndef isalpha
1387c478bd9Sstevel@tonic-gate #define isalpha(x)	(isupper(x) || islower(x))
1397c478bd9Sstevel@tonic-gate #endif
1407c478bd9Sstevel@tonic-gate #ifndef toupper
1417c478bd9Sstevel@tonic-gate #define toupper(x)	(isupper(x) ? (x) : (x) - 'a' + 'A')
1427c478bd9Sstevel@tonic-gate #endif
1437c478bd9Sstevel@tonic-gate #ifndef isspace
1447c478bd9Sstevel@tonic-gate #define isspace(x)	(((x) == ' ') || ((x) == '\r') || ((x) == '\n') || \
1457c478bd9Sstevel@tonic-gate 			 ((x) == '\t') || ((x) == '\b'))
1467c478bd9Sstevel@tonic-gate #endif
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate /*
149ab25eeb5Syz  * This is the scratch buffer size used to hold strings from the TCP stream
150ab25eeb5Syz  * that we may want to parse.  It's an arbitrary size, really, but it must
151ab25eeb5Syz  * be at least as large as IPF_FTPBUFSZ.
152*55fea89dSDan Cross  */
153ab25eeb5Syz #define	FTP_BUFSZ	120
154ab25eeb5Syz 
155ab25eeb5Syz /*
156ab25eeb5Syz  * This buffer, however, doesn't need to be nearly so big.  It just needs to
157ab25eeb5Syz  * be able to squeeze in the largest command it needs to rewrite, Which ones
158ab25eeb5Syz  * does it rewrite? EPRT, PORT, 227 replies.
1597c478bd9Sstevel@tonic-gate  */
160ab25eeb5Syz #define	IPF_FTPBUFSZ	80	/* This *MUST* be >= 53! */
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate typedef struct  ftpside {
1637c478bd9Sstevel@tonic-gate 	char	*ftps_rptr;
1647c478bd9Sstevel@tonic-gate 	char	*ftps_wptr;
1657c478bd9Sstevel@tonic-gate 	void	*ftps_ifp;
1667c478bd9Sstevel@tonic-gate 	u_32_t	ftps_seq[2];
1677c478bd9Sstevel@tonic-gate 	u_32_t	ftps_len;
168ab25eeb5Syz 	int	ftps_junk;	/* 2 = no cr/lf yet, 1 = cannot parse */
1697c478bd9Sstevel@tonic-gate 	int	ftps_cmds;
1707c478bd9Sstevel@tonic-gate 	char	ftps_buf[FTP_BUFSZ];
1717c478bd9Sstevel@tonic-gate } ftpside_t;
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate typedef struct  ftpinfo {
1747c478bd9Sstevel@tonic-gate 	int 	  	ftp_passok;
1757c478bd9Sstevel@tonic-gate 	int		ftp_incok;
1767c478bd9Sstevel@tonic-gate 	ftpside_t	ftp_side[2];
1777c478bd9Sstevel@tonic-gate } ftpinfo_t;
1787c478bd9Sstevel@tonic-gate 
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate /*
1817c478bd9Sstevel@tonic-gate  * For the irc proxy.
1827c478bd9Sstevel@tonic-gate  */
1837c478bd9Sstevel@tonic-gate typedef	struct	ircinfo {
1847c478bd9Sstevel@tonic-gate 	size_t	irc_len;
1857c478bd9Sstevel@tonic-gate 	char	*irc_snick;
1867c478bd9Sstevel@tonic-gate 	char	*irc_dnick;
1877c478bd9Sstevel@tonic-gate 	char	*irc_type;
1887c478bd9Sstevel@tonic-gate 	char	*irc_arg;
1897c478bd9Sstevel@tonic-gate 	char	*irc_addr;
1907c478bd9Sstevel@tonic-gate 	u_32_t	irc_ipnum;
1917c478bd9Sstevel@tonic-gate 	u_short	irc_port;
1927c478bd9Sstevel@tonic-gate } ircinfo_t;
1937c478bd9Sstevel@tonic-gate 
1947c478bd9Sstevel@tonic-gate 
1957c478bd9Sstevel@tonic-gate /*
1967c478bd9Sstevel@tonic-gate  * Real audio proxy structure and #defines
1977c478bd9Sstevel@tonic-gate  */
1987c478bd9Sstevel@tonic-gate typedef	struct	raudio_s {
1997c478bd9Sstevel@tonic-gate 	int	rap_seenpna;
2007c478bd9Sstevel@tonic-gate 	int	rap_seenver;
2017c478bd9Sstevel@tonic-gate 	int	rap_version;
2027c478bd9Sstevel@tonic-gate 	int	rap_eos;	/* End Of Startup */
2037c478bd9Sstevel@tonic-gate 	int	rap_gotid;
2047c478bd9Sstevel@tonic-gate 	int	rap_gotlen;
2057c478bd9Sstevel@tonic-gate 	int	rap_mode;
2067c478bd9Sstevel@tonic-gate 	int	rap_sdone;
2077c478bd9Sstevel@tonic-gate 	u_short	rap_plport;
2087c478bd9Sstevel@tonic-gate 	u_short	rap_prport;
2097c478bd9Sstevel@tonic-gate 	u_short	rap_srport;
2107c478bd9Sstevel@tonic-gate 	char	rap_svr[19];
2117c478bd9Sstevel@tonic-gate 	u_32_t	rap_sbf;	/* flag to indicate which of the 19 bytes have
2127c478bd9Sstevel@tonic-gate 				 * been filled
2137c478bd9Sstevel@tonic-gate 				 */
214ab25eeb5Syz 	u_32_t	rap_sseq;
2157c478bd9Sstevel@tonic-gate } raudio_t;
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate #define	RA_ID_END	0
2187c478bd9Sstevel@tonic-gate #define	RA_ID_UDP	1
2197c478bd9Sstevel@tonic-gate #define	RA_ID_ROBUST	7
2207c478bd9Sstevel@tonic-gate 
2217c478bd9Sstevel@tonic-gate #define	RAP_M_UDP	1
2227c478bd9Sstevel@tonic-gate #define	RAP_M_ROBUST	2
2237c478bd9Sstevel@tonic-gate #define	RAP_M_TCP	4
2247c478bd9Sstevel@tonic-gate #define	RAP_M_UDP_ROBUST	(RAP_M_UDP|RAP_M_ROBUST)
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate 
227ab25eeb5Syz /*
228ab25eeb5Syz  * MSN RPC proxy
229ab25eeb5Syz  */
2307c478bd9Sstevel@tonic-gate typedef	struct	msnrpcinfo	{
2317c478bd9Sstevel@tonic-gate 	u_int		mri_flags;
2327c478bd9Sstevel@tonic-gate 	int		mri_cmd[2];
2337c478bd9Sstevel@tonic-gate 	u_int		mri_valid;
2347c478bd9Sstevel@tonic-gate 	struct	in_addr	mri_raddr;
2357c478bd9Sstevel@tonic-gate 	u_short		mri_rport;
2367c478bd9Sstevel@tonic-gate } msnrpcinfo_t;
2377c478bd9Sstevel@tonic-gate 
2387c478bd9Sstevel@tonic-gate 
2397c478bd9Sstevel@tonic-gate /*
2407c478bd9Sstevel@tonic-gate  * IPSec proxy
2417c478bd9Sstevel@tonic-gate  */
2427c478bd9Sstevel@tonic-gate typedef	u_32_t	ipsec_cookie_t[2];
2437c478bd9Sstevel@tonic-gate 
2447c478bd9Sstevel@tonic-gate typedef struct ipsec_pxy {
2457c478bd9Sstevel@tonic-gate 	ipsec_cookie_t	ipsc_icookie;
2467c478bd9Sstevel@tonic-gate 	ipsec_cookie_t	ipsc_rcookie;
2477c478bd9Sstevel@tonic-gate 	int		ipsc_rckset;
2487c478bd9Sstevel@tonic-gate 	ipnat_t		ipsc_rule;
2497c478bd9Sstevel@tonic-gate 	nat_t		*ipsc_nat;
250ab25eeb5Syz 	struct ipstate	*ipsc_state;
2517c478bd9Sstevel@tonic-gate } ipsec_pxy_t;
2527c478bd9Sstevel@tonic-gate 
253ab25eeb5Syz /*
254ab25eeb5Syz  * PPTP proxy
255ab25eeb5Syz  */
256ab25eeb5Syz typedef	struct pptp_side {
257ab25eeb5Syz 	u_32_t		pptps_nexthdr;
258ab25eeb5Syz 	u_32_t		pptps_next;
259ab25eeb5Syz 	int		pptps_state;
260ab25eeb5Syz 	int		pptps_gothdr;
261ab25eeb5Syz 	int		pptps_len;
262ab25eeb5Syz 	int		pptps_bytes;
263ab25eeb5Syz 	char		*pptps_wptr;
264ab25eeb5Syz 	char		pptps_buffer[512];
265ab25eeb5Syz } pptp_side_t;
266ab25eeb5Syz 
267ab25eeb5Syz typedef	struct pptp_pxy {
268ab25eeb5Syz 	ipnat_t		pptp_rule;
269ab25eeb5Syz 	nat_t		*pptp_nat;
270ab25eeb5Syz 	struct ipstate	*pptp_state;
271ab25eeb5Syz 	u_short		pptp_call[2];
272ab25eeb5Syz 	pptp_side_t	pptp_side[2];
273ab25eeb5Syz } pptp_pxy_t;
274ab25eeb5Syz 
275ab25eeb5Syz 
2767c478bd9Sstevel@tonic-gate /*
2777c478bd9Sstevel@tonic-gate  * Sun RPCBIND proxy
2787c478bd9Sstevel@tonic-gate  */
2797c478bd9Sstevel@tonic-gate #define RPCB_MAXMSG	888
2807c478bd9Sstevel@tonic-gate #define RPCB_RES_PMAP	0	/* Response contains a v2 port. */
2817c478bd9Sstevel@tonic-gate #define RPCB_RES_STRING	1	/* " " " v3 (GETADDR) string. */
2827c478bd9Sstevel@tonic-gate #define RPCB_RES_LIST	2	/* " " " v4 (GETADDRLIST) list. */
2837c478bd9Sstevel@tonic-gate #define RPCB_MAXREQS	32	/* Arbitrary limit on tracked transactions */
2847c478bd9Sstevel@tonic-gate 
2857c478bd9Sstevel@tonic-gate #define RPCB_REQMIN	40
2867c478bd9Sstevel@tonic-gate #define RPCB_REQMAX	888
2877c478bd9Sstevel@tonic-gate #define RPCB_REPMIN	20
2887c478bd9Sstevel@tonic-gate #define	RPCB_REPMAX	604	/* XXX double check this! */
2897c478bd9Sstevel@tonic-gate 
2907c478bd9Sstevel@tonic-gate /*
2917c478bd9Sstevel@tonic-gate  * These macros determine the number of bytes between p and the end of
2927c478bd9Sstevel@tonic-gate  * r->rs_buf relative to l.
2937c478bd9Sstevel@tonic-gate  */
2947c478bd9Sstevel@tonic-gate #define RPCB_BUF_END(r) (char *)((r)->rm_msgbuf + (r)->rm_buflen)
2957c478bd9Sstevel@tonic-gate #define RPCB_BUF_GEQ(r, p, l)   \
2967c478bd9Sstevel@tonic-gate         ((RPCB_BUF_END((r)) > (char *)(p)) &&           \
2977c478bd9Sstevel@tonic-gate          ((RPCB_BUF_END((r)) - (char *)(p)) >= (l)))
2987c478bd9Sstevel@tonic-gate #define	RPCB_BUF_EQ(r, p, l)                            \
2997c478bd9Sstevel@tonic-gate         (RPCB_BUF_END((r)) == ((char *)(p) + (l)))
3007c478bd9Sstevel@tonic-gate 
3017c478bd9Sstevel@tonic-gate /*
3027c478bd9Sstevel@tonic-gate  * The following correspond to RPC(B) detailed in RFC183[13].
3037c478bd9Sstevel@tonic-gate  */
3047c478bd9Sstevel@tonic-gate #define RPCB_CALL		0
3057c478bd9Sstevel@tonic-gate #define RPCB_REPLY		1
3067c478bd9Sstevel@tonic-gate #define RPCB_MSG_VERSION	2
3077c478bd9Sstevel@tonic-gate #define RPCB_PROG		100000
3087c478bd9Sstevel@tonic-gate #define RPCB_GETPORT		3
3097c478bd9Sstevel@tonic-gate #define RPCB_GETADDR		3
3107c478bd9Sstevel@tonic-gate #define RPCB_GETADDRLIST	11
3117c478bd9Sstevel@tonic-gate #define RPCB_MSG_ACCEPTED	0
3127c478bd9Sstevel@tonic-gate #define RPCB_MSG_DENIED		1
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate /* BEGIN (Generic XDR structures) */
3157c478bd9Sstevel@tonic-gate typedef struct xdr_string {
3167c478bd9Sstevel@tonic-gate 	u_32_t	*xs_len;
3177c478bd9Sstevel@tonic-gate 	char	*xs_str;
3187c478bd9Sstevel@tonic-gate } xdr_string_t;
3197c478bd9Sstevel@tonic-gate 
3207c478bd9Sstevel@tonic-gate typedef struct xdr_auth {
3217c478bd9Sstevel@tonic-gate 	/* u_32_t	xa_flavor; */
3227c478bd9Sstevel@tonic-gate 	xdr_string_t	xa_string;
3237c478bd9Sstevel@tonic-gate } xdr_auth_t;
3247c478bd9Sstevel@tonic-gate 
3257c478bd9Sstevel@tonic-gate typedef struct xdr_uaddr {
3267c478bd9Sstevel@tonic-gate 	u_32_t		xu_ip;
3277c478bd9Sstevel@tonic-gate 	u_short         xu_port;
3287c478bd9Sstevel@tonic-gate 	xdr_string_t	xu_str;
3297c478bd9Sstevel@tonic-gate } xdr_uaddr_t;
3307c478bd9Sstevel@tonic-gate 
3317c478bd9Sstevel@tonic-gate typedef	struct xdr_proto {
3327c478bd9Sstevel@tonic-gate 	u_int		xp_proto;
3337c478bd9Sstevel@tonic-gate 	xdr_string_t	xp_str;
3347c478bd9Sstevel@tonic-gate } xdr_proto_t;
3357c478bd9Sstevel@tonic-gate 
3367c478bd9Sstevel@tonic-gate #define xu_xslen	xu_str.xs_len
3377c478bd9Sstevel@tonic-gate #define xu_xsstr	xu_str.xs_str
3387c478bd9Sstevel@tonic-gate #define	xp_xslen	xp_str.xs_len
3397c478bd9Sstevel@tonic-gate #define xp_xsstr	xp_str.xs_str
3407c478bd9Sstevel@tonic-gate /* END (Generic XDR structures) */
3417c478bd9Sstevel@tonic-gate 
3427c478bd9Sstevel@tonic-gate /* BEGIN (RPC call structures) */
3437c478bd9Sstevel@tonic-gate typedef struct pmap_args {
3447c478bd9Sstevel@tonic-gate 	/* u_32_t	pa_prog; */
3457c478bd9Sstevel@tonic-gate 	/* u_32_t	pa_vers; */
3467c478bd9Sstevel@tonic-gate 	u_32_t		*pa_prot;
3477c478bd9Sstevel@tonic-gate 	/* u_32_t	pa_port; */
3487c478bd9Sstevel@tonic-gate } pmap_args_t;
3497c478bd9Sstevel@tonic-gate 
3507c478bd9Sstevel@tonic-gate typedef struct rpcb_args {
3517c478bd9Sstevel@tonic-gate 	/* u_32_t	*ra_prog; */
3527c478bd9Sstevel@tonic-gate 	/* u_32_t	*ra_vers; */
3537c478bd9Sstevel@tonic-gate 	xdr_proto_t	ra_netid;
3547c478bd9Sstevel@tonic-gate 	xdr_uaddr_t	ra_maddr;
3557c478bd9Sstevel@tonic-gate 	/* xdr_string_t	ra_owner; */
3567c478bd9Sstevel@tonic-gate } rpcb_args_t;
3577c478bd9Sstevel@tonic-gate 
3587c478bd9Sstevel@tonic-gate typedef struct rpc_call {
3597c478bd9Sstevel@tonic-gate 	/* u_32_t	rc_rpcvers; */
3607c478bd9Sstevel@tonic-gate 	/* u_32_t	rc_prog; */
3617c478bd9Sstevel@tonic-gate 	u_32_t	*rc_vers;
3627c478bd9Sstevel@tonic-gate 	u_32_t	*rc_proc;
3637c478bd9Sstevel@tonic-gate 	xdr_auth_t	rc_authcred;
3647c478bd9Sstevel@tonic-gate 	xdr_auth_t	rc_authverf;
3657c478bd9Sstevel@tonic-gate 	union {
3667c478bd9Sstevel@tonic-gate 		pmap_args_t	ra_pmapargs;
3677c478bd9Sstevel@tonic-gate 		rpcb_args_t	ra_rpcbargs;
3687c478bd9Sstevel@tonic-gate 	} rpcb_args;
3697c478bd9Sstevel@tonic-gate } rpc_call_t;
3707c478bd9Sstevel@tonic-gate 
3717c478bd9Sstevel@tonic-gate #define	rc_pmapargs	rpcb_args.ra_pmapargs
3727c478bd9Sstevel@tonic-gate #define rc_rpcbargs	rpcb_args.ra_rpcbargs
3737c478bd9Sstevel@tonic-gate /* END (RPC call structures) */
3747c478bd9Sstevel@tonic-gate 
3757c478bd9Sstevel@tonic-gate /* BEGIN (RPC reply structures) */
3767c478bd9Sstevel@tonic-gate typedef struct rpcb_entry {
3777c478bd9Sstevel@tonic-gate 	xdr_uaddr_t	re_maddr;
3787c478bd9Sstevel@tonic-gate 	xdr_proto_t	re_netid;
3797c478bd9Sstevel@tonic-gate 	/* u_32_t	re_semantics; */
3807c478bd9Sstevel@tonic-gate 	xdr_string_t	re_family;
3817c478bd9Sstevel@tonic-gate 	xdr_proto_t	re_proto;
3827c478bd9Sstevel@tonic-gate 	u_32_t		*re_more; /* 1 == another entry follows */
3837c478bd9Sstevel@tonic-gate } rpcb_entry_t;
3847c478bd9Sstevel@tonic-gate 
3857c478bd9Sstevel@tonic-gate typedef struct rpcb_listp {
3867c478bd9Sstevel@tonic-gate 	u_32_t		*rl_list; /* 1 == list follows */
3877c478bd9Sstevel@tonic-gate 	int		rl_cnt;
3887c478bd9Sstevel@tonic-gate 	rpcb_entry_t	rl_entries[2]; /* TCP / UDP only */
3897c478bd9Sstevel@tonic-gate } rpcb_listp_t;
3907c478bd9Sstevel@tonic-gate 
3917c478bd9Sstevel@tonic-gate typedef struct rpc_resp {
3927c478bd9Sstevel@tonic-gate 	/* u_32_t	rr_acceptdeny; */
3937c478bd9Sstevel@tonic-gate 	/* Omitted 'message denied' fork; we don't care about rejects. */
3947c478bd9Sstevel@tonic-gate 	xdr_auth_t	rr_authverf;
3957c478bd9Sstevel@tonic-gate 	/* u_32_t		*rr_astat;	*/
3967c478bd9Sstevel@tonic-gate 	union {
3977c478bd9Sstevel@tonic-gate 		u_32_t		*resp_pmap;
3987c478bd9Sstevel@tonic-gate 		xdr_uaddr_t	resp_getaddr;
3997c478bd9Sstevel@tonic-gate 		rpcb_listp_t	resp_getaddrlist;
4007c478bd9Sstevel@tonic-gate 	} rpcb_reply;
4017c478bd9Sstevel@tonic-gate } rpc_resp_t;
4027c478bd9Sstevel@tonic-gate 
4037c478bd9Sstevel@tonic-gate #define	rr_v2	rpcb_reply.resp_pmap
4047c478bd9Sstevel@tonic-gate #define rr_v3	rpcb_reply.resp_getaddr
4057c478bd9Sstevel@tonic-gate #define	rr_v4	rpcb_reply.resp_getaddrlist
4067c478bd9Sstevel@tonic-gate /* END (RPC reply structures) */
4077c478bd9Sstevel@tonic-gate 
4087c478bd9Sstevel@tonic-gate /* BEGIN (RPC message structure & macros) */
4097c478bd9Sstevel@tonic-gate typedef struct rpc_msg {
4107c478bd9Sstevel@tonic-gate 	char	rm_msgbuf[RPCB_MAXMSG];	/* RPCB data buffer */
4117c478bd9Sstevel@tonic-gate 	u_int	rm_buflen;
4127c478bd9Sstevel@tonic-gate 	u_32_t	*rm_xid;
4137c478bd9Sstevel@tonic-gate 	/* u_32_t Call vs Reply */
4147c478bd9Sstevel@tonic-gate 	union {
4157c478bd9Sstevel@tonic-gate 		rpc_call_t	rb_call;
4167c478bd9Sstevel@tonic-gate 		rpc_resp_t	rb_resp;
4177c478bd9Sstevel@tonic-gate 	} rm_body;
4187c478bd9Sstevel@tonic-gate } rpc_msg_t;
4197c478bd9Sstevel@tonic-gate 
4207c478bd9Sstevel@tonic-gate #define rm_call		rm_body.rb_call
4217c478bd9Sstevel@tonic-gate #define rm_resp		rm_body.rb_resp
4227c478bd9Sstevel@tonic-gate /* END (RPC message structure & macros) */
4237c478bd9Sstevel@tonic-gate 
4247c478bd9Sstevel@tonic-gate /*
4257c478bd9Sstevel@tonic-gate  * These code paths aren't hot enough to warrant per transaction
4267c478bd9Sstevel@tonic-gate  * mutexes.
4277c478bd9Sstevel@tonic-gate  */
4287c478bd9Sstevel@tonic-gate typedef struct rpcb_xact {
4297c478bd9Sstevel@tonic-gate 	struct	rpcb_xact	*rx_next;
4307c478bd9Sstevel@tonic-gate 	struct	rpcb_xact	**rx_pnext;
4317c478bd9Sstevel@tonic-gate 	u_32_t	rx_xid;		/* RPC transmission ID */
4327c478bd9Sstevel@tonic-gate 	u_int	rx_type;	/* RPCB response type */
4337c478bd9Sstevel@tonic-gate 	u_int	rx_ref;         /* reference count */
4347c478bd9Sstevel@tonic-gate 	u_int	rx_proto;	/* transport protocol (v2 only) */
4357c478bd9Sstevel@tonic-gate } rpcb_xact_t;
4367c478bd9Sstevel@tonic-gate 
4377c478bd9Sstevel@tonic-gate typedef struct rpcb_session {
4387c478bd9Sstevel@tonic-gate         ipfmutex_t	rs_rxlock;
4397c478bd9Sstevel@tonic-gate 	rpcb_xact_t	*rs_rxlist;
4407c478bd9Sstevel@tonic-gate } rpcb_session_t;
4417c478bd9Sstevel@tonic-gate 
4427c478bd9Sstevel@tonic-gate /*
4437c478bd9Sstevel@tonic-gate  * For an explanation, please see the following:
4447c478bd9Sstevel@tonic-gate  *   RFC1832 - Sections 3.11, 4.4, and 4.5.
4457c478bd9Sstevel@tonic-gate  */
4467c478bd9Sstevel@tonic-gate #define XDRALIGN(x)	((((x) % 4) != 0) ? ((((x) + 3) / 4) * 4) : (x))
4477c478bd9Sstevel@tonic-gate 
448f4b3ec61Sdh extern	int	appr_add __P((aproxy_t *, ipf_stack_t *));
449f4b3ec61Sdh extern	int	appr_ctl __P((ap_ctl_t *, ipf_stack_t *));
450f4b3ec61Sdh extern	int	appr_del __P((aproxy_t *, ipf_stack_t *));
451f4b3ec61Sdh extern	int	appr_init __P((ipf_stack_t *));
452f4b3ec61Sdh extern	void	appr_unload __P((ipf_stack_t *));
4537c478bd9Sstevel@tonic-gate extern	int	appr_ok __P((fr_info_t *, tcphdr_t *, struct ipnat *));
4547c478bd9Sstevel@tonic-gate extern	int	appr_match __P((fr_info_t *, struct nat *));
4557c478bd9Sstevel@tonic-gate extern	void	appr_free __P((aproxy_t *));
456f4b3ec61Sdh extern	void	aps_free __P((ap_session_t *, ipf_stack_t *));
4577c478bd9Sstevel@tonic-gate extern	int	appr_check __P((fr_info_t *, struct nat *));
458f4b3ec61Sdh extern	aproxy_t	*appr_lookup __P((u_int, char *, ipf_stack_t *));
4597c478bd9Sstevel@tonic-gate extern	int	appr_new __P((fr_info_t *, struct nat *));
460f4b3ec61Sdh extern	int	appr_ioctl __P((caddr_t, ioctlcmd_t, int, ipf_stack_t *));
4617c478bd9Sstevel@tonic-gate 
4627c478bd9Sstevel@tonic-gate #endif /* __IP_PROXY_H__ */
463