ip_proxy.h revision 1.2.2.2 1 1.2.2.2 joerg /* $NetBSD: ip_proxy.h,v 1.2.2.2 2012/04/17 19:25:21 joerg Exp $ */
2 1.2.2.2 joerg
3 1.2.2.2 joerg /*
4 1.2.2.2 joerg * Copyright (C) 2011 by Darren Reed.
5 1.2.2.2 joerg *
6 1.2.2.2 joerg * See the IPFILTER.LICENCE file for details on licencing.
7 1.2.2.2 joerg *
8 1.2.2.2 joerg * Id: ip_proxy.h,v 2.46.2.3 2012/01/26 05:29:12 darrenr Exp
9 1.2.2.2 joerg */
10 1.2.2.2 joerg
11 1.2.2.2 joerg #ifndef _NETINET_IP_PROXY_H_
12 1.2.2.2 joerg #define _NETINET_IP_PROXY_H_
13 1.2.2.2 joerg
14 1.2.2.2 joerg #ifndef SOLARIS
15 1.2.2.2 joerg #define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4)))
16 1.2.2.2 joerg #endif
17 1.2.2.2 joerg
18 1.2.2.2 joerg #if defined(__STDC__) || defined(__GNUC__) || defined(_AIX51)
19 1.2.2.2 joerg #define SIOCPROXY _IOWR('r', 64, struct ap_control)
20 1.2.2.2 joerg #else
21 1.2.2.2 joerg #define SIOCPROXY _IOWR(r, 64, struct ap_control)
22 1.2.2.2 joerg #endif
23 1.2.2.2 joerg
24 1.2.2.2 joerg #ifndef APR_LABELLEN
25 1.2.2.2 joerg #define APR_LABELLEN 16
26 1.2.2.2 joerg #endif
27 1.2.2.2 joerg #define AP_SESS_SIZE 53
28 1.2.2.2 joerg
29 1.2.2.2 joerg struct nat;
30 1.2.2.2 joerg struct ipnat;
31 1.2.2.2 joerg struct ipstate;
32 1.2.2.2 joerg
33 1.2.2.2 joerg typedef struct ap_tcp {
34 1.2.2.2 joerg u_short apt_sport; /* source port */
35 1.2.2.2 joerg u_short apt_dport; /* destination port */
36 1.2.2.2 joerg short apt_sel[2]; /* {seq,ack}{off,min} set selector */
37 1.2.2.2 joerg short apt_seqoff[2]; /* sequence # difference */
38 1.2.2.2 joerg u_32_t apt_seqmin[2]; /* don't change seq-off until after this */
39 1.2.2.2 joerg short apt_ackoff[2]; /* sequence # difference */
40 1.2.2.2 joerg u_32_t apt_ackmin[2]; /* don't change seq-off until after this */
41 1.2.2.2 joerg u_char apt_state[2]; /* connection state */
42 1.2.2.2 joerg } ap_tcp_t;
43 1.2.2.2 joerg
44 1.2.2.2 joerg typedef struct ap_udp {
45 1.2.2.2 joerg u_short apu_sport; /* source port */
46 1.2.2.2 joerg u_short apu_dport; /* destination port */
47 1.2.2.2 joerg } ap_udp_t;
48 1.2.2.2 joerg
49 1.2.2.2 joerg typedef struct ap_session {
50 1.2.2.2 joerg struct aproxy *aps_apr;
51 1.2.2.2 joerg union {
52 1.2.2.2 joerg struct ap_tcp apu_tcp;
53 1.2.2.2 joerg struct ap_udp apu_udp;
54 1.2.2.2 joerg } aps_un;
55 1.2.2.2 joerg U_QUAD_T aps_bytes; /* bytes sent */
56 1.2.2.2 joerg U_QUAD_T aps_pkts; /* packets sent */
57 1.2.2.2 joerg void *aps_nat; /* pointer back to nat struct */
58 1.2.2.2 joerg void *aps_data; /* private data */
59 1.2.2.2 joerg int aps_psiz; /* size of private data */
60 1.2.2.2 joerg struct ap_session *aps_next;
61 1.2.2.2 joerg } ap_session_t;
62 1.2.2.2 joerg
63 1.2.2.2 joerg #define aps_sport aps_un.apu_tcp.apt_sport
64 1.2.2.2 joerg #define aps_dport aps_un.apu_tcp.apt_dport
65 1.2.2.2 joerg #define aps_sel aps_un.apu_tcp.apt_sel
66 1.2.2.2 joerg #define aps_seqoff aps_un.apu_tcp.apt_seqoff
67 1.2.2.2 joerg #define aps_seqmin aps_un.apu_tcp.apt_seqmin
68 1.2.2.2 joerg #define aps_state aps_un.apu_tcp.apt_state
69 1.2.2.2 joerg #define aps_ackoff aps_un.apu_tcp.apt_ackoff
70 1.2.2.2 joerg #define aps_ackmin aps_un.apu_tcp.apt_ackmin
71 1.2.2.2 joerg
72 1.2.2.2 joerg
73 1.2.2.2 joerg typedef struct ap_control {
74 1.2.2.2 joerg char apc_label[APR_LABELLEN];
75 1.2.2.2 joerg char apc_config[APR_LABELLEN];
76 1.2.2.2 joerg u_char apc_p;
77 1.2.2.2 joerg /*
78 1.2.2.2 joerg * The following fields are upto the proxy's apr_ctl routine to deal
79 1.2.2.2 joerg * with. When the proxy gets this in kernel space, apc_data will
80 1.2.2.2 joerg * point to a malloc'd region of memory of apc_dsize bytes. If the
81 1.2.2.2 joerg * proxy wants to keep that memory, it must set apc_data to NULL
82 1.2.2.2 joerg * before it returns. It is expected if this happens that it will
83 1.2.2.2 joerg * take care to free it in apr_fini or otherwise as appropriate.
84 1.2.2.2 joerg * apc_cmd is provided as a standard place to put simple commands,
85 1.2.2.2 joerg * with apc_arg being available to put a simple arg.
86 1.2.2.2 joerg */
87 1.2.2.2 joerg u_long apc_cmd;
88 1.2.2.2 joerg u_long apc_arg;
89 1.2.2.2 joerg void *apc_data;
90 1.2.2.2 joerg size_t apc_dsize;
91 1.2.2.2 joerg } ap_ctl_t;
92 1.2.2.2 joerg
93 1.2.2.2 joerg #define APC_CMD_ADD 0
94 1.2.2.2 joerg #define APC_CMD_DEL 1
95 1.2.2.2 joerg
96 1.2.2.2 joerg
97 1.2.2.2 joerg typedef struct aproxy {
98 1.2.2.2 joerg struct aproxy *apr_next;
99 1.2.2.2 joerg struct aproxy *apr_parent;
100 1.2.2.2 joerg char apr_label[APR_LABELLEN]; /* Proxy label # */
101 1.2.2.2 joerg u_char apr_p; /* protocol */
102 1.2.2.2 joerg int apr_flags;
103 1.2.2.2 joerg int apr_ref;
104 1.2.2.2 joerg int apr_clones;
105 1.2.2.2 joerg void (* apr_load)(void);
106 1.2.2.2 joerg void (* apr_unload)(void);
107 1.2.2.2 joerg void *(* apr_create)(ipf_main_softc_t *);
108 1.2.2.2 joerg void (* apr_destroy)(ipf_main_softc_t *, void *);
109 1.2.2.2 joerg int (* apr_init)(ipf_main_softc_t *, void *);
110 1.2.2.2 joerg void (* apr_fini)(ipf_main_softc_t *, void *);
111 1.2.2.2 joerg int (* apr_new)(void *, fr_info_t *, ap_session_t *,
112 1.2.2.2 joerg struct nat *);
113 1.2.2.2 joerg void (* apr_del)(ipf_main_softc_t *, ap_session_t *);
114 1.2.2.2 joerg int (* apr_inpkt)(void *, fr_info_t *, ap_session_t *,
115 1.2.2.2 joerg struct nat *);
116 1.2.2.2 joerg int (* apr_outpkt)(void *, fr_info_t *, ap_session_t *,
117 1.2.2.2 joerg struct nat *);
118 1.2.2.2 joerg int (* apr_match)(fr_info_t *, ap_session_t *, struct nat *);
119 1.2.2.2 joerg int (* apr_ctl)(ipf_main_softc_t *, void *, ap_ctl_t *);
120 1.2.2.2 joerg int (* apr_clear)(struct aproxy *);
121 1.2.2.2 joerg int (* apr_flush)(struct aproxy *, int);
122 1.2.2.2 joerg void *apr_soft;
123 1.2.2.2 joerg } aproxy_t;
124 1.2.2.2 joerg
125 1.2.2.2 joerg #define APR_DELETE 1
126 1.2.2.2 joerg
127 1.2.2.2 joerg #define APR_ERR(x) ((x) << 16)
128 1.2.2.2 joerg #define APR_EXIT(x) (((x) >> 16) & 0xffff)
129 1.2.2.2 joerg #define APR_INC(x) ((x) & 0xffff)
130 1.2.2.2 joerg
131 1.2.2.2 joerg
132 1.2.2.2 joerg #ifdef _KERNEL
133 1.2.2.2 joerg /*
134 1.2.2.2 joerg * Generic #define's to cover missing things in the kernel
135 1.2.2.2 joerg */
136 1.2.2.2 joerg # ifndef isdigit
137 1.2.2.2 joerg # define isdigit(x) ((x) >= '0' && (x) <= '9')
138 1.2.2.2 joerg # endif
139 1.2.2.2 joerg # ifndef isupper
140 1.2.2.2 joerg # define isupper(x) (((unsigned)(x) >= 'A') && ((unsigned)(x) <= 'Z'))
141 1.2.2.2 joerg # endif
142 1.2.2.2 joerg # ifndef islower
143 1.2.2.2 joerg # define islower(x) (((unsigned)(x) >= 'a') && ((unsigned)(x) <= 'z'))
144 1.2.2.2 joerg # endif
145 1.2.2.2 joerg # ifndef isalpha
146 1.2.2.2 joerg # define isalpha(x) (isupper(x) || islower(x))
147 1.2.2.2 joerg # endif
148 1.2.2.2 joerg # ifndef toupper
149 1.2.2.2 joerg # define toupper(x) (isupper(x) ? (x) : (x) - 'a' + 'A')
150 1.2.2.2 joerg # endif
151 1.2.2.2 joerg # ifndef isspace
152 1.2.2.2 joerg # define isspace(x) (((x) == ' ') || ((x) == '\r') || ((x) == '\n') || \
153 1.2.2.2 joerg ((x) == '\t') || ((x) == '\b'))
154 1.2.2.2 joerg # endif
155 1.2.2.2 joerg #endif /* _KERNEL */
156 1.2.2.2 joerg
157 1.2.2.2 joerg /*
158 1.2.2.2 joerg * For the ftp proxy.
159 1.2.2.2 joerg */
160 1.2.2.2 joerg #define FTP_BUFSZ 160
161 1.2.2.2 joerg #define IPF_FTPBUFSZ 160
162 1.2.2.2 joerg
163 1.2.2.2 joerg typedef struct ftpside {
164 1.2.2.2 joerg char *ftps_rptr;
165 1.2.2.2 joerg char *ftps_wptr;
166 1.2.2.2 joerg void *ftps_ifp;
167 1.2.2.2 joerg u_32_t ftps_seq[2];
168 1.2.2.2 joerg u_32_t ftps_len;
169 1.2.2.2 joerg int ftps_junk;
170 1.2.2.2 joerg int ftps_cmds;
171 1.2.2.2 joerg int ftps_cmd;
172 1.2.2.2 joerg char ftps_buf[FTP_BUFSZ];
173 1.2.2.2 joerg } ftpside_t;
174 1.2.2.2 joerg
175 1.2.2.2 joerg typedef struct ftpinfo {
176 1.2.2.2 joerg int ftp_passok;
177 1.2.2.2 joerg int ftp_incok;
178 1.2.2.2 joerg void *ftp_pendstate;
179 1.2.2.2 joerg nat_t *ftp_pendnat;
180 1.2.2.2 joerg ftpside_t ftp_side[2];
181 1.2.2.2 joerg } ftpinfo_t;
182 1.2.2.2 joerg
183 1.2.2.2 joerg
184 1.2.2.2 joerg /*
185 1.2.2.2 joerg * For the irc proxy.
186 1.2.2.2 joerg */
187 1.2.2.2 joerg typedef struct ircinfo {
188 1.2.2.2 joerg size_t irc_len;
189 1.2.2.2 joerg char *irc_snick;
190 1.2.2.2 joerg char *irc_dnick;
191 1.2.2.2 joerg char *irc_type;
192 1.2.2.2 joerg char *irc_arg;
193 1.2.2.2 joerg char *irc_addr;
194 1.2.2.2 joerg u_32_t irc_ipnum;
195 1.2.2.2 joerg u_short irc_port;
196 1.2.2.2 joerg } ircinfo_t;
197 1.2.2.2 joerg
198 1.2.2.2 joerg
199 1.2.2.2 joerg /*
200 1.2.2.2 joerg * For the rcmd proxy. rcmd_rule must be last for names in ipnat_t
201 1.2.2.2 joerg */
202 1.2.2.2 joerg typedef struct rcmdinfo {
203 1.2.2.2 joerg u_32_t rcmd_port; /* Port number seen */
204 1.2.2.2 joerg u_32_t rcmd_portseq; /* Sequence number where port is first seen */
205 1.2.2.2 joerg ipnat_t rcmd_rule; /* Template rule for back connection */
206 1.2.2.2 joerg } rcmdinfo_t;
207 1.2.2.2 joerg
208 1.2.2.2 joerg /*
209 1.2.2.2 joerg * For the DNS "proxy"
210 1.2.2.2 joerg */
211 1.2.2.2 joerg typedef struct dnsinfo {
212 1.2.2.2 joerg ipfmutex_t dnsi_lock;
213 1.2.2.2 joerg u_short dnsi_id;
214 1.2.2.2 joerg char dnsi_buffer[512];
215 1.2.2.2 joerg } dnsinfo_t;
216 1.2.2.2 joerg
217 1.2.2.2 joerg
218 1.2.2.2 joerg /*
219 1.2.2.2 joerg * Real audio proxy structure and #defines
220 1.2.2.2 joerg */
221 1.2.2.2 joerg typedef struct raudio_s {
222 1.2.2.2 joerg int rap_seenpna;
223 1.2.2.2 joerg int rap_seenver;
224 1.2.2.2 joerg int rap_version;
225 1.2.2.2 joerg int rap_eos; /* End Of Startup */
226 1.2.2.2 joerg int rap_gotid;
227 1.2.2.2 joerg int rap_gotlen;
228 1.2.2.2 joerg int rap_mode;
229 1.2.2.2 joerg int rap_sdone;
230 1.2.2.2 joerg u_short rap_plport;
231 1.2.2.2 joerg u_short rap_prport;
232 1.2.2.2 joerg u_short rap_srport;
233 1.2.2.2 joerg char rap_svr[19];
234 1.2.2.2 joerg u_32_t rap_sbf; /* flag to indicate which of the 19 bytes have
235 1.2.2.2 joerg * been filled
236 1.2.2.2 joerg */
237 1.2.2.2 joerg u_32_t rap_sseq;
238 1.2.2.2 joerg } raudio_t;
239 1.2.2.2 joerg
240 1.2.2.2 joerg #define RA_ID_END 0
241 1.2.2.2 joerg #define RA_ID_UDP 1
242 1.2.2.2 joerg #define RA_ID_ROBUST 7
243 1.2.2.2 joerg
244 1.2.2.2 joerg #define RAP_M_UDP 1
245 1.2.2.2 joerg #define RAP_M_ROBUST 2
246 1.2.2.2 joerg #define RAP_M_TCP 4
247 1.2.2.2 joerg #define RAP_M_UDP_ROBUST (RAP_M_UDP|RAP_M_ROBUST)
248 1.2.2.2 joerg
249 1.2.2.2 joerg
250 1.2.2.2 joerg /*
251 1.2.2.2 joerg * MSN RPC proxy
252 1.2.2.2 joerg */
253 1.2.2.2 joerg typedef struct msnrpcinfo {
254 1.2.2.2 joerg u_int mri_flags;
255 1.2.2.2 joerg int mri_cmd[2];
256 1.2.2.2 joerg u_int mri_valid;
257 1.2.2.2 joerg struct in_addr mri_raddr;
258 1.2.2.2 joerg u_short mri_rport;
259 1.2.2.2 joerg } msnrpcinfo_t;
260 1.2.2.2 joerg
261 1.2.2.2 joerg
262 1.2.2.2 joerg /*
263 1.2.2.2 joerg * IPSec proxy. ipsc_rule must be last for names in ipnat_t
264 1.2.2.2 joerg */
265 1.2.2.2 joerg typedef u_32_t ipsec_cookie_t[2];
266 1.2.2.2 joerg
267 1.2.2.2 joerg typedef struct ipsec_pxy {
268 1.2.2.2 joerg ipsec_cookie_t ipsc_icookie;
269 1.2.2.2 joerg ipsec_cookie_t ipsc_rcookie;
270 1.2.2.2 joerg int ipsc_rckset;
271 1.2.2.2 joerg nat_t *ipsc_nat;
272 1.2.2.2 joerg struct ipstate *ipsc_state;
273 1.2.2.2 joerg ipnat_t ipsc_rule;
274 1.2.2.2 joerg } ipsec_pxy_t;
275 1.2.2.2 joerg
276 1.2.2.2 joerg /*
277 1.2.2.2 joerg * PPTP proxy. pptp_rule must be last for names in ipnat_t
278 1.2.2.2 joerg */
279 1.2.2.2 joerg typedef struct pptp_side {
280 1.2.2.2 joerg u_32_t pptps_nexthdr;
281 1.2.2.2 joerg u_32_t pptps_next;
282 1.2.2.2 joerg int pptps_state;
283 1.2.2.2 joerg int pptps_gothdr;
284 1.2.2.2 joerg int pptps_len;
285 1.2.2.2 joerg int pptps_bytes;
286 1.2.2.2 joerg char *pptps_wptr;
287 1.2.2.2 joerg char pptps_buffer[512];
288 1.2.2.2 joerg } pptp_side_t;
289 1.2.2.2 joerg
290 1.2.2.2 joerg typedef struct pptp_pxy {
291 1.2.2.2 joerg nat_t *pptp_nat;
292 1.2.2.2 joerg struct ipstate *pptp_state;
293 1.2.2.2 joerg u_short pptp_call[2];
294 1.2.2.2 joerg pptp_side_t pptp_side[2];
295 1.2.2.2 joerg ipnat_t pptp_rule;
296 1.2.2.2 joerg } pptp_pxy_t;
297 1.2.2.2 joerg
298 1.2.2.2 joerg
299 1.2.2.2 joerg /*
300 1.2.2.2 joerg * Sun RPCBIND proxy
301 1.2.2.2 joerg */
302 1.2.2.2 joerg #define RPCB_MAXMSG 888
303 1.2.2.2 joerg #define RPCB_RES_PMAP 0 /* Response contains a v2 port. */
304 1.2.2.2 joerg #define RPCB_RES_STRING 1 /* " " " v3 (GETADDR) string. */
305 1.2.2.2 joerg #define RPCB_RES_LIST 2 /* " " " v4 (GETADDRLIST) list. */
306 1.2.2.2 joerg #define RPCB_MAXREQS 32 /* Arbitrary limit on tracked transactions */
307 1.2.2.2 joerg
308 1.2.2.2 joerg #define RPCB_REQMIN 40
309 1.2.2.2 joerg #define RPCB_REQMAX 888
310 1.2.2.2 joerg #define RPCB_REPMIN 20
311 1.2.2.2 joerg #define RPCB_REPMAX 604 /* XXX double check this! */
312 1.2.2.2 joerg
313 1.2.2.2 joerg /*
314 1.2.2.2 joerg * These macros determine the number of bytes between p and the end of
315 1.2.2.2 joerg * r->rs_buf relative to l.
316 1.2.2.2 joerg */
317 1.2.2.2 joerg #define RPCB_BUF_END(r) (char *)((r)->rm_msgbuf + (r)->rm_buflen)
318 1.2.2.2 joerg #define RPCB_BUF_GEQ(r, p, l) \
319 1.2.2.2 joerg ((RPCB_BUF_END((r)) > (char *)(p)) && \
320 1.2.2.2 joerg ((RPCB_BUF_END((r)) - (char *)(p)) >= (l)))
321 1.2.2.2 joerg #define RPCB_BUF_EQ(r, p, l) \
322 1.2.2.2 joerg (RPCB_BUF_END((r)) == ((char *)(p) + (l)))
323 1.2.2.2 joerg
324 1.2.2.2 joerg /*
325 1.2.2.2 joerg * The following correspond to RPC(B) detailed in RFC183[13].
326 1.2.2.2 joerg */
327 1.2.2.2 joerg #define RPCB_CALL 0
328 1.2.2.2 joerg #define RPCB_REPLY 1
329 1.2.2.2 joerg #define RPCB_MSG_VERSION 2
330 1.2.2.2 joerg #define RPCB_PROG 100000
331 1.2.2.2 joerg #define RPCB_GETPORT 3
332 1.2.2.2 joerg #define RPCB_GETADDR 3
333 1.2.2.2 joerg #define RPCB_GETADDRLIST 11
334 1.2.2.2 joerg #define RPCB_MSG_ACCEPTED 0
335 1.2.2.2 joerg #define RPCB_MSG_DENIED 1
336 1.2.2.2 joerg
337 1.2.2.2 joerg /* BEGIN (Generic XDR structures) */
338 1.2.2.2 joerg typedef struct xdr_string {
339 1.2.2.2 joerg u_32_t *xs_len;
340 1.2.2.2 joerg char *xs_str;
341 1.2.2.2 joerg } xdr_string_t;
342 1.2.2.2 joerg
343 1.2.2.2 joerg typedef struct xdr_auth {
344 1.2.2.2 joerg /* u_32_t xa_flavor; */
345 1.2.2.2 joerg xdr_string_t xa_string;
346 1.2.2.2 joerg } xdr_auth_t;
347 1.2.2.2 joerg
348 1.2.2.2 joerg typedef struct xdr_uaddr {
349 1.2.2.2 joerg u_32_t xu_ip;
350 1.2.2.2 joerg u_short xu_port;
351 1.2.2.2 joerg xdr_string_t xu_str;
352 1.2.2.2 joerg } xdr_uaddr_t;
353 1.2.2.2 joerg
354 1.2.2.2 joerg typedef struct xdr_proto {
355 1.2.2.2 joerg u_int xp_proto;
356 1.2.2.2 joerg xdr_string_t xp_str;
357 1.2.2.2 joerg } xdr_proto_t;
358 1.2.2.2 joerg
359 1.2.2.2 joerg #define xu_xslen xu_str.xs_len
360 1.2.2.2 joerg #define xu_xsstr xu_str.xs_str
361 1.2.2.2 joerg #define xp_xslen xp_str.xs_len
362 1.2.2.2 joerg #define xp_xsstr xp_str.xs_str
363 1.2.2.2 joerg /* END (Generic XDR structures) */
364 1.2.2.2 joerg
365 1.2.2.2 joerg /* BEGIN (RPC call structures) */
366 1.2.2.2 joerg typedef struct pmap_args {
367 1.2.2.2 joerg /* u_32_t pa_prog; */
368 1.2.2.2 joerg /* u_32_t pa_vers; */
369 1.2.2.2 joerg u_32_t *pa_prot;
370 1.2.2.2 joerg /* u_32_t pa_port; */
371 1.2.2.2 joerg } pmap_args_t;
372 1.2.2.2 joerg
373 1.2.2.2 joerg typedef struct rpcb_args {
374 1.2.2.2 joerg /* u_32_t *ra_prog; */
375 1.2.2.2 joerg /* u_32_t *ra_vers; */
376 1.2.2.2 joerg xdr_proto_t ra_netid;
377 1.2.2.2 joerg xdr_uaddr_t ra_maddr;
378 1.2.2.2 joerg /* xdr_string_t ra_owner; */
379 1.2.2.2 joerg } rpcb_args_t;
380 1.2.2.2 joerg
381 1.2.2.2 joerg typedef struct rpc_call {
382 1.2.2.2 joerg /* u_32_t rc_rpcvers; */
383 1.2.2.2 joerg /* u_32_t rc_prog; */
384 1.2.2.2 joerg u_32_t *rc_vers;
385 1.2.2.2 joerg u_32_t *rc_proc;
386 1.2.2.2 joerg xdr_auth_t rc_authcred;
387 1.2.2.2 joerg xdr_auth_t rc_authverf;
388 1.2.2.2 joerg union {
389 1.2.2.2 joerg pmap_args_t ra_pmapargs;
390 1.2.2.2 joerg rpcb_args_t ra_rpcbargs;
391 1.2.2.2 joerg } rpcb_args;
392 1.2.2.2 joerg } rpc_call_t;
393 1.2.2.2 joerg
394 1.2.2.2 joerg #define rc_pmapargs rpcb_args.ra_pmapargs
395 1.2.2.2 joerg #define rc_rpcbargs rpcb_args.ra_rpcbargs
396 1.2.2.2 joerg /* END (RPC call structures) */
397 1.2.2.2 joerg
398 1.2.2.2 joerg /* BEGIN (RPC reply structures) */
399 1.2.2.2 joerg typedef struct rpcb_entry {
400 1.2.2.2 joerg xdr_uaddr_t re_maddr;
401 1.2.2.2 joerg xdr_proto_t re_netid;
402 1.2.2.2 joerg /* u_32_t re_semantics; */
403 1.2.2.2 joerg xdr_string_t re_family;
404 1.2.2.2 joerg xdr_proto_t re_proto;
405 1.2.2.2 joerg u_32_t *re_more; /* 1 == another entry follows */
406 1.2.2.2 joerg } rpcb_entry_t;
407 1.2.2.2 joerg
408 1.2.2.2 joerg typedef struct rpcb_listp {
409 1.2.2.2 joerg u_32_t *rl_list; /* 1 == list follows */
410 1.2.2.2 joerg int rl_cnt;
411 1.2.2.2 joerg rpcb_entry_t rl_entries[2]; /* TCP / UDP only */
412 1.2.2.2 joerg } rpcb_listp_t;
413 1.2.2.2 joerg
414 1.2.2.2 joerg typedef struct rpc_resp {
415 1.2.2.2 joerg /* u_32_t rr_acceptdeny; */
416 1.2.2.2 joerg /* Omitted 'message denied' fork; we don't care about rejects. */
417 1.2.2.2 joerg xdr_auth_t rr_authverf;
418 1.2.2.2 joerg /* u_32_t *rr_astat; */
419 1.2.2.2 joerg union {
420 1.2.2.2 joerg u_32_t *resp_pmap;
421 1.2.2.2 joerg xdr_uaddr_t resp_getaddr;
422 1.2.2.2 joerg rpcb_listp_t resp_getaddrlist;
423 1.2.2.2 joerg } rpcb_reply;
424 1.2.2.2 joerg } rpc_resp_t;
425 1.2.2.2 joerg
426 1.2.2.2 joerg #define rr_v2 rpcb_reply.resp_pmap
427 1.2.2.2 joerg #define rr_v3 rpcb_reply.resp_getaddr
428 1.2.2.2 joerg #define rr_v4 rpcb_reply.resp_getaddrlist
429 1.2.2.2 joerg /* END (RPC reply structures) */
430 1.2.2.2 joerg
431 1.2.2.2 joerg /* BEGIN (RPC message structure & macros) */
432 1.2.2.2 joerg typedef struct rpc_msg {
433 1.2.2.2 joerg char rm_msgbuf[RPCB_MAXMSG]; /* RPCB data buffer */
434 1.2.2.2 joerg u_int rm_buflen;
435 1.2.2.2 joerg u_32_t *rm_xid;
436 1.2.2.2 joerg /* u_32_t Call vs Reply */
437 1.2.2.2 joerg union {
438 1.2.2.2 joerg rpc_call_t rb_call;
439 1.2.2.2 joerg rpc_resp_t rb_resp;
440 1.2.2.2 joerg } rm_body;
441 1.2.2.2 joerg } rpc_msg_t;
442 1.2.2.2 joerg
443 1.2.2.2 joerg #define rm_call rm_body.rb_call
444 1.2.2.2 joerg #define rm_resp rm_body.rb_resp
445 1.2.2.2 joerg /* END (RPC message structure & macros) */
446 1.2.2.2 joerg
447 1.2.2.2 joerg /*
448 1.2.2.2 joerg * These code paths aren't hot enough to warrant per transaction
449 1.2.2.2 joerg * mutexes.
450 1.2.2.2 joerg */
451 1.2.2.2 joerg typedef struct rpcb_xact {
452 1.2.2.2 joerg struct rpcb_xact *rx_next;
453 1.2.2.2 joerg struct rpcb_xact **rx_pnext;
454 1.2.2.2 joerg u_32_t rx_xid; /* RPC transmission ID */
455 1.2.2.2 joerg u_int rx_type; /* RPCB response type */
456 1.2.2.2 joerg u_int rx_ref; /* reference count */
457 1.2.2.2 joerg u_int rx_proto; /* transport protocol (v2 only) */
458 1.2.2.2 joerg } rpcb_xact_t;
459 1.2.2.2 joerg
460 1.2.2.2 joerg typedef struct rpcb_session {
461 1.2.2.2 joerg ipfmutex_t rs_rxlock;
462 1.2.2.2 joerg rpcb_xact_t *rs_rxlist;
463 1.2.2.2 joerg } rpcb_session_t;
464 1.2.2.2 joerg
465 1.2.2.2 joerg /*
466 1.2.2.2 joerg * For an explanation, please see the following:
467 1.2.2.2 joerg * RFC1832 - Sections 3.11, 4.4, and 4.5.
468 1.2.2.2 joerg */
469 1.2.2.2 joerg #define XDRALIGN(x) ((((x) % 4) != 0) ? ((((x) + 3) / 4) * 4) : (x))
470 1.2.2.2 joerg
471 1.2.2.2 joerg extern int ipf_proxy_add(void *, aproxy_t *);
472 1.2.2.2 joerg extern int ipf_proxy_check(fr_info_t *, struct nat *);
473 1.2.2.2 joerg extern int ipf_proxy_ctl(ipf_main_softc_t *, void *, ap_ctl_t *);
474 1.2.2.2 joerg extern int ipf_proxy_del(aproxy_t *);
475 1.2.2.2 joerg extern void ipf_proxy_flush(void *, int);
476 1.2.2.2 joerg extern void ipf_proxy_free(aproxy_t *);
477 1.2.2.2 joerg extern int ipf_proxy_init(void);
478 1.2.2.2 joerg extern int ipf_proxy_ioctl(ipf_main_softc_t *, void *, ioctlcmd_t, int, void *);
479 1.2.2.2 joerg extern aproxy_t *ipf_proxy_lookup(void *, u_int, char *);
480 1.2.2.2 joerg extern int ipf_proxy_match(fr_info_t *, struct nat *);
481 1.2.2.2 joerg extern int ipf_proxy_new(fr_info_t *, struct nat *);
482 1.2.2.2 joerg extern int ipf_proxy_ok(fr_info_t *, tcphdr_t *, struct ipnat *);
483 1.2.2.2 joerg extern void aps_free(ipf_main_softc_t *, void *, ap_session_t *);
484 1.2.2.2 joerg extern int ipf_proxy_main_load(void);
485 1.2.2.2 joerg extern int ipf_proxy_main_unload(void);
486 1.2.2.2 joerg extern void *ipf_proxy_soft_create(ipf_main_softc_t *);
487 1.2.2.2 joerg extern void ipf_proxy_soft_destroy(ipf_main_softc_t *, void *);
488 1.2.2.2 joerg extern int ipf_proxy_soft_init(ipf_main_softc_t *, void *);
489 1.2.2.2 joerg extern int ipf_proxy_soft_fini(ipf_main_softc_t *, void *);
490 1.2.2.2 joerg
491 1.2.2.2 joerg #endif /* _NETINET_IP_PROXY_H_ */
492