]> git.saurik.com Git - apple/xnu.git/blob - bsd/netinet/ip_proxy.h
1447027e0ba2799319d023fb8c1b92582c242eb1
[apple/xnu.git] / bsd / netinet / ip_proxy.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /*
23 * Copyright (C) 1997 by Darren Reed.
24 *
25 * Redistribution and use in source and binary forms are permitted
26 * provided that this notice is preserved and due credit is given
27 * to the original author and the contributors.
28 *
29 */
30
31 #ifndef __IP_PROXY_H__
32 #define __IP_PROXY_H__
33
34 #ifndef SOLARIS
35 #define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4)))
36 #endif
37
38 #ifndef APR_LABELLEN
39 #define APR_LABELLEN 16
40 #endif
41 #define AP_SESS_SIZE 53
42
43 struct nat;
44 struct ipnat;
45
46 typedef struct ap_tcp {
47 u_short apt_sport; /* source port */
48 u_short apt_dport; /* destination port */
49 short apt_sel; /* seqoff/after set selector */
50 short apt_seqoff[2]; /* sequence # difference */
51 tcp_seq apt_after[2]; /* don't change seq-off until after this */
52 u_char apt_state[2]; /* connection state */
53 } ap_tcp_t;
54
55 typedef struct ap_udp {
56 u_short apu_sport; /* source port */
57 u_short apu_dport; /* destination port */
58 } ap_udp_t;
59
60 typedef struct ap_session {
61 struct aproxy *aps_apr;
62 struct in_addr aps_src; /* source IP# */
63 struct in_addr aps_dst; /* destination IP# */
64 u_char aps_p; /* protocol */
65 union {
66 struct ap_tcp apu_tcp;
67 struct ap_udp apu_udp;
68 } aps_un;
69 u_int aps_flags;
70 QUAD_T aps_bytes; /* bytes sent */
71 QUAD_T aps_pkts; /* packets sent */
72 u_long aps_tout; /* time left before expiring */
73 void *aps_data; /* private data */
74 int aps_psiz; /* size of private data */
75 struct ap_session *aps_next;
76 } ap_session_t ;
77
78 #define aps_sport aps_un.apu_tcp.apt_sport
79 #define aps_dport aps_un.apu_tcp.apt_dport
80 #define aps_sel aps_un.apu_tcp.apt_sel
81 #define aps_seqoff aps_un.apu_tcp.apt_seqoff
82 #define aps_after aps_un.apu_tcp.apt_after
83 #define aps_state aps_un.apu_tcp.apt_state
84
85
86 typedef struct aproxy {
87 char apr_label[APR_LABELLEN]; /* Proxy label # */
88 u_char apr_p; /* protocol */
89 int apr_ref; /* +1 per rule referencing it */
90 int apr_flags;
91 int (* apr_init) __P((fr_info_t *, ip_t *, tcphdr_t *,
92 ap_session_t *, struct nat *));
93 int (* apr_inpkt) __P((fr_info_t *, ip_t *, tcphdr_t *,
94 ap_session_t *, struct nat *));
95 int (* apr_outpkt) __P((fr_info_t *, ip_t *, tcphdr_t *,
96 ap_session_t *, struct nat *));
97 } aproxy_t;
98
99 #define APR_DELETE 1
100
101
102 extern ap_session_t *ap_sess_tab[AP_SESS_SIZE];
103 extern aproxy_t ap_proxies[];
104
105 extern int ap_ok __P((ip_t *, tcphdr_t *, struct ipnat *));
106 extern void ap_unload __P((void));
107 extern void ap_free __P((aproxy_t *));
108 extern void aps_free __P((ap_session_t *));
109 extern int ap_check __P((ip_t *, tcphdr_t *, fr_info_t *, struct nat *));
110 extern aproxy_t *ap_match __P((u_char, char *));
111 extern void ap_expire __P((void));
112
113 #endif /* __IP_PROXY_H__ */