]>
git.saurik.com Git - apple/network_cmds.git/blob - alias/alias.h
5e6412e496fb383232fa557f811f39610db6d692
2 * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 * Copyright (c) 2001 Charles Mott <cmott@scientech.com>
25 * All rights reserved.
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
36 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
37 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
39 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
40 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
41 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
42 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
44 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
45 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49 * $FreeBSD: src/lib/libalias/alias.h,v 1.12.2.4 2001/08/01 09:36:40 obrien Exp $
53 * Alias.h defines the outside world interfaces for the packet aliasing
56 * This software is placed into the public domain with no restrictions on its
63 /* Alias link representative (incomplete struct) */
66 /* External interfaces (API) to packet aliasing engine */
68 /* Initialization and Control */
70 PacketAliasInit(void);
73 PacketAliasUninit(void);
76 PacketAliasSetAddress(struct in_addr
);
79 PacketAliasSetMode(unsigned int, unsigned int);
83 PacketAliasSetFWBase(unsigned int, unsigned int);
87 PacketAliasClampMSS(u_short mss
);
91 PacketAliasIn(char *, int maxpacketsize
);
94 PacketAliasOut(char *, int maxpacketsize
);
97 PacketUnaliasOut(char *, int maxpacketsize
);
99 /* Port and Address Redirection */
100 extern struct alias_link
*
101 PacketAliasRedirectPort(struct in_addr
, u_short
,
102 struct in_addr
, u_short
,
103 struct in_addr
, u_short
,
107 PacketAliasAddServer(struct alias_link
*link
,
111 extern struct alias_link
*
112 PacketAliasRedirectProto(struct in_addr
,
117 extern struct alias_link
*
118 PacketAliasRedirectAddr(struct in_addr
,
122 PacketAliasRedirectDelete(struct alias_link
*);
124 /* Fragment Handling */
126 PacketAliasSaveFragment(char *);
129 PacketAliasGetFragment(char *);
132 PacketAliasFragmentIn(char *, char *);
134 /* Miscellaneous Functions */
136 PacketAliasSetTarget(struct in_addr addr
);
139 PacketAliasCheckNewLink(void);
142 PacketAliasInternetChecksum(u_short
*, int);
144 /* Transparent Proxying */
146 PacketAliasProxyRule(const char *);
149 /********************** Mode flags ********************/
150 /* Set these flags using PacketAliasSetMode() */
152 /* If PKT_ALIAS_LOG is set, a message will be printed to
153 /var/log/alias.log every time a link is created or deleted. This
154 is useful for debugging */
155 #define PKT_ALIAS_LOG 0x01
157 /* If PKT_ALIAS_DENY_INCOMING is set, then incoming connections (e.g.
158 to ftp, telnet or web servers will be prevented by the aliasing
160 #define PKT_ALIAS_DENY_INCOMING 0x02
162 /* If PKT_ALIAS_SAME_PORTS is set, packets will be attempted sent from
163 the same port as they originated on. This allows e.g. rsh to work
164 *99% of the time*, but _not_ 100%. (It will be slightly flakey
165 instead of not working at all.) This mode bit is set by
166 PacketAliasInit(), so it is a default mode of operation. */
167 #define PKT_ALIAS_SAME_PORTS 0x04
169 /* If PKT_ALIAS_USE_SOCKETS is set, then when partially specified
170 links (e.g. destination port and/or address is zero), the packet
171 aliasing engine will attempt to allocate a socket for the aliasing
172 port it chooses. This will avoid interference with the host
173 machine. Fully specified links do not require this. This bit
174 is set after a call to PacketAliasInit(), so it is a default
175 mode of operation. */
176 #define PKT_ALIAS_USE_SOCKETS 0x08
178 /* If PKT_ALIAS_UNREGISTERED_ONLY is set, then only packets with
179 unregistered source addresses will be aliased. Private
180 addresses are those in the following ranges:
181 10.0.0.0 -> 10.255.255.255
182 172.16.0.0 -> 172.31.255.255
183 192.168.0.0 -> 192.168.255.255 */
184 #define PKT_ALIAS_UNREGISTERED_ONLY 0x10
186 /* If PKT_ALIAS_RESET_ON_ADDR_CHANGE is set, then the table of dynamic
187 aliasing links will be reset whenever PacketAliasSetAddress()
188 changes the default aliasing address. If the default aliasing
189 address is left unchanged by this function call, then the
190 table of dynamic aliasing links will be left intact. This
191 bit is set after a call to PacketAliasInit(). */
192 #define PKT_ALIAS_RESET_ON_ADDR_CHANGE 0x20
195 /* If PKT_ALIAS_PUNCH_FW is set, active FTP and IRC DCC connections
196 will create a 'hole' in the firewall to allow the transfers to
197 work. Where (IPFW "line-numbers") the hole is created is
198 controlled by PacketAliasSetFWBase(base, size). The hole will be
199 attached to that particular alias_link, so when the link goes away
201 #define PKT_ALIAS_PUNCH_FW 0x100
204 /* If PKT_ALIAS_PROXY_ONLY is set, then NAT will be disabled and only
205 transparent proxying performed */
206 #define PKT_ALIAS_PROXY_ONLY 0x40
208 /* If PKT_ALIAS_REVERSE is set, the actions of PacketAliasIn()
209 and PacketAliasOut() are reversed */
210 #define PKT_ALIAS_REVERSE 0x80
213 #define PKT_ALIAS_ERROR -1
214 #define PKT_ALIAS_OK 1
215 #define PKT_ALIAS_IGNORED 2
216 #define PKT_ALIAS_UNRESOLVED_FRAGMENT 3
217 #define PKT_ALIAS_FOUND_HEADER_FRAGMENT 4