]>
git.saurik.com Git - apple/network_cmds.git/blob - alias/alias.h
2 * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 2001 Charles Mott <cmott@scientech.com>
24 * All rights reserved.
26 * Redistribution and use in source and binary forms, with or without
27 * modification, are permitted provided that the following conditions
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.
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
48 * $FreeBSD: src/lib/libalias/alias.h,v 1.12.2.4 2001/08/01 09:36:40 obrien Exp $
52 * Alias.h defines the outside world interfaces for the packet aliasing
55 * This software is placed into the public domain with no restrictions on its
62 /* Alias link representative (incomplete struct) */
65 /* External interfaces (API) to packet aliasing engine */
67 /* Initialization and Control */
69 PacketAliasInit(void);
72 PacketAliasUninit(void);
75 PacketAliasSetAddress(struct in_addr
);
78 PacketAliasSetMode(unsigned int, unsigned int);
82 PacketAliasSetFWBase(unsigned int, unsigned int);
86 PacketAliasClampMSS(u_short mss
);
90 PacketAliasIn(char *, int maxpacketsize
);
93 PacketAliasOut(char *, int maxpacketsize
);
96 PacketUnaliasOut(char *, int maxpacketsize
);
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
,
106 PacketAliasAddServer(struct alias_link
*link
,
110 extern struct alias_link
*
111 PacketAliasRedirectProto(struct in_addr
,
116 extern struct alias_link
*
117 PacketAliasRedirectAddr(struct in_addr
,
121 PacketAliasRedirectDelete(struct alias_link
*);
123 /* Fragment Handling */
125 PacketAliasSaveFragment(char *);
128 PacketAliasGetFragment(char *);
131 PacketAliasFragmentIn(char *, char *);
133 /* Miscellaneous Functions */
135 PacketAliasSetTarget(struct in_addr addr
);
138 PacketAliasCheckNewLink(void);
141 PacketAliasInternetChecksum(u_short
*, int);
143 /* Transparent Proxying */
145 PacketAliasProxyRule(const char *);
148 /********************** Mode flags ********************/
149 /* Set these flags using PacketAliasSetMode() */
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
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
159 #define PKT_ALIAS_DENY_INCOMING 0x02
161 /* If PKT_ALIAS_SAME_PORTS is set, packets will be attempted sent from
162 the same port as they originated on. This allows e.g. rsh to work
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
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
174 mode of operation. */
175 #define PKT_ALIAS_USE_SOCKETS 0x08
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:
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
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
188 address is left unchanged by this function call, then the
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
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
200 #define PKT_ALIAS_PUNCH_FW 0x100
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
207 /* If PKT_ALIAS_REVERSE is set, the actions of PacketAliasIn()
208 and PacketAliasOut() are reversed */
209 #define PKT_ALIAS_REVERSE 0x80
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