]>
Commit | Line | Data |
---|---|---|
b7080c8e | 1 | /* |
7ba0088d A |
2 | * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
921c0aec A |
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. | |
7ba0088d | 11 | * |
921c0aec A |
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 | |
7ba0088d A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
921c0aec A |
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. | |
7ba0088d A |
19 | * |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | /*- | |
23 | * Copyright (c) 2001 Charles Mott <cmott@scientech.com> | |
24 | * All rights reserved. | |
25 | * | |
26 | * Redistribution and use in source and binary forms, with or without | |
27 | * modification, are permitted provided that the following conditions | |
28 | * are met: | |
29 | * 1. Redistributions of source code must retain the above copyright | |
30 | * notice, this list of conditions and the following disclaimer. | |
31 | * 2. Redistributions in binary form must reproduce the above copyright | |
32 | * notice, this list of conditions and the following disclaimer in the | |
33 | * documentation and/or other materials provided with the distribution. | |
34 | * | |
35 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | |
36 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
37 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
38 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
39 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
40 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
41 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
42 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
43 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
44 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
45 | * SUCH DAMAGE. | |
46 | * | |
47 | * Based upon: | |
48 | * $FreeBSD: src/lib/libalias/alias.h,v 1.12.2.4 2001/08/01 09:36:40 obrien Exp $ | |
49 | */ | |
50 | ||
51 | /*- | |
52 | * Alias.h defines the outside world interfaces for the packet aliasing | |
53 | * software. | |
54 | * | |
55 | * This software is placed into the public domain with no restrictions on its | |
56 | * distribution. | |
57 | */ | |
b7080c8e A |
58 | |
59 | #ifndef _ALIAS_H_ | |
7ba0088d | 60 | #define _ALIAS_H_ |
b7080c8e A |
61 | |
62 | /* Alias link representative (incomplete struct) */ | |
63 | struct alias_link; | |
64 | ||
65 | /* External interfaces (API) to packet aliasing engine */ | |
66 | ||
67 | /* Initialization and Control */ | |
68 | extern void | |
69 | PacketAliasInit(void); | |
70 | ||
71 | extern void | |
72 | PacketAliasUninit(void); | |
73 | ||
74 | extern void | |
75 | PacketAliasSetAddress(struct in_addr); | |
76 | ||
77 | extern unsigned int | |
78 | PacketAliasSetMode(unsigned int, unsigned int); | |
79 | ||
80 | #ifndef NO_FW_PUNCH | |
81 | extern void | |
82 | PacketAliasSetFWBase(unsigned int, unsigned int); | |
83 | #endif | |
84 | ||
285dd90c A |
85 | extern void |
86 | PacketAliasClampMSS(u_short mss); | |
87 | ||
b7080c8e A |
88 | /* Packet Handling */ |
89 | extern int | |
90 | PacketAliasIn(char *, int maxpacketsize); | |
91 | ||
92 | extern int | |
93 | PacketAliasOut(char *, int maxpacketsize); | |
94 | ||
7ba0088d A |
95 | extern int |
96 | PacketUnaliasOut(char *, int maxpacketsize); | |
97 | ||
b7080c8e A |
98 | /* Port and Address Redirection */ |
99 | extern struct alias_link * | |
100 | PacketAliasRedirectPort(struct in_addr, u_short, | |
101 | struct in_addr, u_short, | |
102 | struct in_addr, u_short, | |
103 | u_char); | |
104 | ||
105 | extern int | |
7ba0088d A |
106 | PacketAliasAddServer(struct alias_link *link, |
107 | struct in_addr addr, | |
108 | u_short port); | |
b7080c8e | 109 | |
7ba0088d A |
110 | extern struct alias_link * |
111 | PacketAliasRedirectProto(struct in_addr, | |
112 | struct in_addr, | |
113 | struct in_addr, | |
114 | u_char); | |
b7080c8e A |
115 | |
116 | extern struct alias_link * | |
117 | PacketAliasRedirectAddr(struct in_addr, | |
118 | struct in_addr); | |
119 | ||
120 | extern void | |
121 | PacketAliasRedirectDelete(struct alias_link *); | |
122 | ||
123 | /* Fragment Handling */ | |
124 | extern int | |
125 | PacketAliasSaveFragment(char *); | |
126 | ||
127 | extern char * | |
128 | PacketAliasGetFragment(char *); | |
129 | ||
130 | extern void | |
131 | PacketAliasFragmentIn(char *, char *); | |
132 | ||
133 | /* Miscellaneous Functions */ | |
134 | extern void | |
135 | PacketAliasSetTarget(struct in_addr addr); | |
136 | ||
137 | extern int | |
138 | PacketAliasCheckNewLink(void); | |
139 | ||
140 | extern u_short | |
141 | PacketAliasInternetChecksum(u_short *, int); | |
142 | ||
143 | /* Transparent Proxying */ | |
144 | extern int | |
145 | PacketAliasProxyRule(const char *); | |
146 | ||
147 | ||
148 | /********************** Mode flags ********************/ | |
7ba0088d | 149 | /* Set these flags using PacketAliasSetMode() */ |
b7080c8e A |
150 | |
151 | /* If PKT_ALIAS_LOG is set, a message will be printed to | |
152 | /var/log/alias.log every time a link is created or deleted. This | |
153 | is useful for debugging */ | |
154 | #define PKT_ALIAS_LOG 0x01 | |
155 | ||
156 | /* If PKT_ALIAS_DENY_INCOMING is set, then incoming connections (e.g. | |
157 | to ftp, telnet or web servers will be prevented by the aliasing | |
158 | mechanism. */ | |
159 | #define PKT_ALIAS_DENY_INCOMING 0x02 | |
160 | ||
161 | /* If PKT_ALIAS_SAME_PORTS is set, packets will be attempted sent from | |
7ba0088d | 162 | the same port as they originated on. This allows e.g. rsh to work |
b7080c8e A |
163 | *99% of the time*, but _not_ 100%. (It will be slightly flakey |
164 | instead of not working at all.) This mode bit is set by | |
165 | PacketAliasInit(), so it is a default mode of operation. */ | |
166 | #define PKT_ALIAS_SAME_PORTS 0x04 | |
167 | ||
168 | /* If PKT_ALIAS_USE_SOCKETS is set, then when partially specified | |
169 | links (e.g. destination port and/or address is zero), the packet | |
170 | aliasing engine will attempt to allocate a socket for the aliasing | |
171 | port it chooses. This will avoid interference with the host | |
172 | machine. Fully specified links do not require this. This bit | |
173 | is set after a call to PacketAliasInit(), so it is a default | |
7ba0088d | 174 | mode of operation. */ |
b7080c8e A |
175 | #define PKT_ALIAS_USE_SOCKETS 0x08 |
176 | ||
7ba0088d A |
177 | /* If PKT_ALIAS_UNREGISTERED_ONLY is set, then only packets with |
178 | unregistered source addresses will be aliased. Private | |
179 | addresses are those in the following ranges: | |
b7080c8e A |
180 | 10.0.0.0 -> 10.255.255.255 |
181 | 172.16.0.0 -> 172.31.255.255 | |
182 | 192.168.0.0 -> 192.168.255.255 */ | |
183 | #define PKT_ALIAS_UNREGISTERED_ONLY 0x10 | |
184 | ||
185 | /* If PKT_ALIAS_RESET_ON_ADDR_CHANGE is set, then the table of dynamic | |
186 | aliasing links will be reset whenever PacketAliasSetAddress() | |
187 | changes the default aliasing address. If the default aliasing | |
7ba0088d | 188 | address is left unchanged by this function call, then the |
b7080c8e A |
189 | table of dynamic aliasing links will be left intact. This |
190 | bit is set after a call to PacketAliasInit(). */ | |
191 | #define PKT_ALIAS_RESET_ON_ADDR_CHANGE 0x20 | |
192 | ||
193 | #ifndef NO_FW_PUNCH | |
194 | /* If PKT_ALIAS_PUNCH_FW is set, active FTP and IRC DCC connections | |
195 | will create a 'hole' in the firewall to allow the transfers to | |
196 | work. Where (IPFW "line-numbers") the hole is created is | |
197 | controlled by PacketAliasSetFWBase(base, size). The hole will be | |
198 | attached to that particular alias_link, so when the link goes away | |
199 | so do the hole. */ | |
7ba0088d | 200 | #define PKT_ALIAS_PUNCH_FW 0x100 |
b7080c8e A |
201 | #endif |
202 | ||
203 | /* If PKT_ALIAS_PROXY_ONLY is set, then NAT will be disabled and only | |
204 | transparent proxying performed */ | |
205 | #define PKT_ALIAS_PROXY_ONLY 0x40 | |
206 | ||
207 | /* If PKT_ALIAS_REVERSE is set, the actions of PacketAliasIn() | |
208 | and PacketAliasOut() are reversed */ | |
209 | #define PKT_ALIAS_REVERSE 0x80 | |
210 | ||
211 | /* Return Codes */ | |
212 | #define PKT_ALIAS_ERROR -1 | |
213 | #define PKT_ALIAS_OK 1 | |
214 | #define PKT_ALIAS_IGNORED 2 | |
215 | #define PKT_ALIAS_UNRESOLVED_FRAGMENT 3 | |
216 | #define PKT_ALIAS_FOUND_HEADER_FRAGMENT 4 | |
217 | ||
218 | #endif | |
7ba0088d | 219 | /* lint -restore */ |