]>
git.saurik.com Git - apple/network_cmds.git/blob - alias/alias.h
02d332d31bc57ac5b55f532d569505eaadff9e7d
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);
87 PacketAliasIn(char *, int maxpacketsize
);
90 PacketAliasOut(char *, int maxpacketsize
);
93 PacketUnaliasOut(char *, int maxpacketsize
);
95 /* Port and Address Redirection */
96 extern struct alias_link
*
97 PacketAliasRedirectPort(struct in_addr
, u_short
,
98 struct in_addr
, u_short
,
99 struct in_addr
, u_short
,
103 PacketAliasAddServer(struct alias_link
*link
,
107 extern struct alias_link
*
108 PacketAliasRedirectProto(struct in_addr
,
113 extern struct alias_link
*
114 PacketAliasRedirectAddr(struct in_addr
,
118 PacketAliasRedirectDelete(struct alias_link
*);
120 /* Fragment Handling */
122 PacketAliasSaveFragment(char *);
125 PacketAliasGetFragment(char *);
128 PacketAliasFragmentIn(char *, char *);
130 /* Miscellaneous Functions */
132 PacketAliasSetTarget(struct in_addr addr
);
135 PacketAliasCheckNewLink(void);
138 PacketAliasInternetChecksum(u_short
*, int);
140 /* Transparent Proxying */
142 PacketAliasProxyRule(const char *);
145 /********************** Mode flags ********************/
146 /* Set these flags using PacketAliasSetMode() */
148 /* If PKT_ALIAS_LOG is set, a message will be printed to
149 /var/log/alias.log every time a link is created or deleted. This
150 is useful for debugging */
151 #define PKT_ALIAS_LOG 0x01
153 /* If PKT_ALIAS_DENY_INCOMING is set, then incoming connections (e.g.
154 to ftp, telnet or web servers will be prevented by the aliasing
156 #define PKT_ALIAS_DENY_INCOMING 0x02
158 /* If PKT_ALIAS_SAME_PORTS is set, packets will be attempted sent from
159 the same port as they originated on. This allows e.g. rsh to work
160 *99% of the time*, but _not_ 100%. (It will be slightly flakey
161 instead of not working at all.) This mode bit is set by
162 PacketAliasInit(), so it is a default mode of operation. */
163 #define PKT_ALIAS_SAME_PORTS 0x04
165 /* If PKT_ALIAS_USE_SOCKETS is set, then when partially specified
166 links (e.g. destination port and/or address is zero), the packet
167 aliasing engine will attempt to allocate a socket for the aliasing
168 port it chooses. This will avoid interference with the host
169 machine. Fully specified links do not require this. This bit
170 is set after a call to PacketAliasInit(), so it is a default
171 mode of operation. */
172 #define PKT_ALIAS_USE_SOCKETS 0x08
174 /* If PKT_ALIAS_UNREGISTERED_ONLY is set, then only packets with
175 unregistered source addresses will be aliased. Private
176 addresses are those in the following ranges:
177 10.0.0.0 -> 10.255.255.255
178 172.16.0.0 -> 172.31.255.255
179 192.168.0.0 -> 192.168.255.255 */
180 #define PKT_ALIAS_UNREGISTERED_ONLY 0x10
182 /* If PKT_ALIAS_RESET_ON_ADDR_CHANGE is set, then the table of dynamic
183 aliasing links will be reset whenever PacketAliasSetAddress()
184 changes the default aliasing address. If the default aliasing
185 address is left unchanged by this function call, then the
186 table of dynamic aliasing links will be left intact. This
187 bit is set after a call to PacketAliasInit(). */
188 #define PKT_ALIAS_RESET_ON_ADDR_CHANGE 0x20
191 /* If PKT_ALIAS_PUNCH_FW is set, active FTP and IRC DCC connections
192 will create a 'hole' in the firewall to allow the transfers to
193 work. Where (IPFW "line-numbers") the hole is created is
194 controlled by PacketAliasSetFWBase(base, size). The hole will be
195 attached to that particular alias_link, so when the link goes away
197 #define PKT_ALIAS_PUNCH_FW 0x100
200 /* If PKT_ALIAS_PROXY_ONLY is set, then NAT will be disabled and only
201 transparent proxying performed */
202 #define PKT_ALIAS_PROXY_ONLY 0x40
204 /* If PKT_ALIAS_REVERSE is set, the actions of PacketAliasIn()
205 and PacketAliasOut() are reversed */
206 #define PKT_ALIAS_REVERSE 0x80
209 #define PKT_ALIAS_ERROR -1
210 #define PKT_ALIAS_OK 1
211 #define PKT_ALIAS_IGNORED 2
212 #define PKT_ALIAS_UNRESOLVED_FRAGMENT 3
213 #define PKT_ALIAS_FOUND_HEADER_FRAGMENT 4