Deleted Added
sdiff udiff text old ( 110916 ) new ( 145522 )
full compact
1/*
2 * Copyright (C) 1997-2001 by Darren Reed.
3 *
4 * See the IPFILTER.LICENCE file for details on licencing.
5 *
6 * $Id: ip_proxy.h,v 2.8.2.4 2000/12/02 00:15:03 darrenr Exp $
7 * $FreeBSD: head/sys/contrib/ipfilter/netinet/ip_proxy.h 110916 2003-02-15 06:25:25Z darrenr $
8 */
9
10#ifndef __IP_PROXY_H__
11#define __IP_PROXY_H__
12
13#ifndef SOLARIS
14#define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4)))
15#endif
16
17#ifndef APR_LABELLEN
18#define APR_LABELLEN 16
19#endif
20#define AP_SESS_SIZE 53
21
22struct nat;
23struct ipnat;
24
25typedef struct ap_tcp {
26 u_short apt_sport; /* source port */
27 u_short apt_dport; /* destination port */
28 short apt_sel[2]; /* {seq,ack}{off,min} set selector */
29 short apt_seqoff[2]; /* sequence # difference */
30 tcp_seq apt_seqmin[2]; /* don't change seq-off until after this */
31 short apt_ackoff[2]; /* sequence # difference */
32 tcp_seq apt_ackmin[2]; /* don't change seq-off until after this */
33 u_char apt_state[2]; /* connection state */
34} ap_tcp_t;
35
36typedef struct ap_udp {
37 u_short apu_sport; /* source port */
38 u_short apu_dport; /* destination port */
39} ap_udp_t;
40
41typedef struct ap_session {
42 struct aproxy *aps_apr;
43 union {
44 struct ap_tcp apu_tcp;
45 struct ap_udp apu_udp;
46 } aps_un;
47 u_int aps_flags;
48 U_QUAD_T aps_bytes; /* bytes sent */
49 U_QUAD_T aps_pkts; /* packets sent */
50 void *aps_nat; /* pointer back to nat struct */
51 void *aps_data; /* private data */
52 int aps_p; /* protocol */
53 int aps_psiz; /* size of private data */
54 struct ap_session *aps_hnext;
55 struct ap_session *aps_next;
56} ap_session_t;
57
58#define aps_sport aps_un.apu_tcp.apt_sport
59#define aps_dport aps_un.apu_tcp.apt_dport
60#define aps_sel aps_un.apu_tcp.apt_sel
61#define aps_seqoff aps_un.apu_tcp.apt_seqoff
62#define aps_seqmin aps_un.apu_tcp.apt_seqmin
63#define aps_state aps_un.apu_tcp.apt_state
64#define aps_ackoff aps_un.apu_tcp.apt_ackoff
65#define aps_ackmin aps_un.apu_tcp.apt_ackmin
66
67
68typedef struct aproxy {
69 struct aproxy *apr_next;
70 char apr_label[APR_LABELLEN]; /* Proxy label # */
71 u_char apr_p; /* protocol */
72 int apr_ref; /* +1 per rule referencing it */
73 int apr_flags;
74 int (* apr_init) __P((void));
75 void (* apr_fini) __P((void));
76 int (* apr_new) __P((fr_info_t *, ip_t *,
77 ap_session_t *, struct nat *));
78 void (* apr_del) __P((ap_session_t *));
79 int (* apr_inpkt) __P((fr_info_t *, ip_t *,
80 ap_session_t *, struct nat *));
81 int (* apr_outpkt) __P((fr_info_t *, ip_t *,
82 ap_session_t *, struct nat *));
83 int (* apr_match) __P((fr_info_t *, ap_session_t *, struct nat *));
84} aproxy_t;
85
86#define APR_DELETE 1
87
88#define APR_ERR(x) (((x) & 0xffff) << 16)
89#define APR_EXIT(x) (((x) >> 16) & 0xffff)
90#define APR_INC(x) ((x) & 0xffff)
91
92#define FTP_BUFSZ 160
93/*
94 * For the ftp proxy.
95 */
96typedef struct ftpside {
97 char *ftps_rptr;
98 char *ftps_wptr;
99 u_32_t ftps_seq[2];
100 u_32_t ftps_len;
101 int ftps_junk;
102 int ftps_cmds;
103 int ftps_cmd;
104 char ftps_buf[FTP_BUFSZ];
105} ftpside_t;
106
107typedef struct ftpinfo {
108 int ftp_passok;
109 int ftp_incok;
110 ftpside_t ftp_side[2];
111} ftpinfo_t;
112
113/*
114 * Real audio proxy structure and #defines
115 */
116typedef struct raudio_s {
117 int rap_seenpna;
118 int rap_seenver;
119 int rap_version;
120 int rap_eos; /* End Of Startup */
121 int rap_gotid;
122 int rap_gotlen;
123 int rap_mode;
124 int rap_sdone;
125 u_short rap_plport;
126 u_short rap_prport;
127 u_short rap_srport;
128 char rap_svr[19];
129 u_32_t rap_sbf; /* flag to indicate which of the 19 bytes have
130 * been filled
131 */
132 tcp_seq rap_sseq;
133} raudio_t;
134
135#define RA_ID_END 0
136#define RA_ID_UDP 1
137#define RA_ID_ROBUST 7
138
139#define RAP_M_UDP 1
140#define RAP_M_ROBUST 2
141#define RAP_M_TCP 4
142#define RAP_M_UDP_ROBUST (RAP_M_UDP|RAP_M_ROBUST)
143
144/*
145 * IPSec proxy
146 */
147typedef u_32_t ipsec_cookie_t[2];
148
149typedef struct ipsec_pxy {
150 ipsec_cookie_t ipsc_icookie;
151 ipsec_cookie_t ipsc_rcookie;
152 int ipsc_rckset;
153 ipnat_t ipsc_rule;
154 nat_t *ipsc_nat;
155 ipstate_t *ipsc_state;
156} ipsec_pxy_t;
157
158extern ap_session_t *ap_sess_tab[AP_SESS_SIZE];
159extern ap_session_t *ap_sess_list;
160extern aproxy_t ap_proxies[];
161extern int ippr_ftp_pasvonly;
162
163extern int appr_add __P((aproxy_t *));
164extern int appr_del __P((aproxy_t *));
165extern int appr_init __P((void));
166extern void appr_unload __P((void));
167extern int appr_ok __P((ip_t *, tcphdr_t *, struct ipnat *));
168extern int appr_match __P((fr_info_t *, struct nat *));
169extern void appr_free __P((aproxy_t *));
170extern void aps_free __P((ap_session_t *));
171extern int appr_check __P((ip_t *, fr_info_t *, struct nat *));
172extern aproxy_t *appr_lookup __P((u_int, char *));
173extern int appr_new __P((fr_info_t *, ip_t *, struct nat *));
174
175#endif /* __IP_PROXY_H__ */