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