VirtualBox

source: vbox/trunk/src/VBox/Devices/Network/slirp/libalias/alias.h@ 26495

最後變更 在這個檔案從26495是 26495,由 vboxsync 提交於 15 年 前

Devices: whitespace cleanup

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 10.6 KB
 
1/* lint -save -library Flexelint comment for external headers */
2
3/*-
4 * Copyright (c) 2001 Charles Mott <[email protected]>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * $FreeBSD: src/sys/netinet/libalias/alias.h,v 1.34.8.1 2009/04/15 03:14:26 kensmith Exp $
29 */
30
31/*
32 * Alias.h defines the outside world interfaces for the packet aliasing
33 * software.
34 *
35 * This software is placed into the public domain with no restrictions on its
36 * distribution.
37 */
38
39#ifndef _ALIAS_H_
40#define _ALIAS_H_
41
42#ifndef VBOX
43#include <netinet/in_systm.h>
44#include <netinet/in.h>
45#include <netinet/ip.h>
46#else
47# include <slirp.h>
48#endif
49
50#define LIBALIAS_BUF_SIZE 128
51#ifdef _KERNEL
52/*
53 * The kernel version of libalias does not support these features.
54 */
55#define NO_FW_PUNCH
56#define NO_USE_SOCKETS
57#endif
58
59/*
60 * The external interface to libalias, the packet aliasing engine.
61 *
62 * There are two sets of functions:
63 *
64 * PacketAlias*() the old API which doesn't take an instance pointer
65 * and therefore can only have one packet engine at a time.
66 *
67 * LibAlias*() the new API which takes as first argument a pointer to
68 * the instance of the packet aliasing engine.
69 *
70 * The functions otherwise correspond to each other one for one, except
71 * for the LibAliasUnaliasOut()/PacketUnaliasOut() function which were
72 * were misnamed in the old API.
73 */
74
75/*
76 * The instance structure
77 */
78struct libalias;
79#if defined(VBOX) && !defined(VBOX_SLIRP_ALIAS)
80/* XXX: used only for browsing */
81struct libalias {
82 LIST_ENTRY(libalias) instancelist;
83};
84#endif
85
86/*
87 * An anonymous structure, a pointer to which is returned from
88 * PacketAliasRedirectAddr(), PacketAliasRedirectPort() or
89 * PacketAliasRedirectProto(), passed to PacketAliasAddServer(),
90 * and freed by PacketAliasRedirectDelete().
91 */
92struct alias_link;
93
94
95/* OLD API */
96
97/* Initialization and control functions. */
98void PacketAliasInit(void);
99void PacketAliasSetAddress(struct in_addr _addr);
100void PacketAliasSetFWBase(unsigned int _base, unsigned int _num);
101void PacketAliasSetSkinnyPort(unsigned int _port);
102unsigned int
103 PacketAliasSetMode(unsigned int _flags, unsigned int _mask);
104void PacketAliasUninit(void);
105
106/* Packet Handling functions. */
107int PacketAliasIn(char *_ptr, int _maxpacketsize);
108int PacketAliasOut(char *_ptr, int _maxpacketsize);
109int PacketUnaliasOut(char *_ptr, int _maxpacketsize);
110
111/* Port and address redirection functions. */
112
113
114int
115PacketAliasAddServer(struct alias_link *_lnk,
116 struct in_addr _addr, unsigned short _port);
117struct alias_link *
118PacketAliasRedirectAddr(struct in_addr _src_addr,
119 struct in_addr _alias_addr);
120int PacketAliasRedirectDynamic(struct alias_link *_lnk);
121void PacketAliasRedirectDelete(struct alias_link *_lnk);
122struct alias_link *
123PacketAliasRedirectPort(struct in_addr _src_addr,
124 unsigned short _src_port, struct in_addr _dst_addr,
125 unsigned short _dst_port, struct in_addr _alias_addr,
126 unsigned short _alias_port, unsigned char _proto);
127struct alias_link *
128PacketAliasRedirectProto(struct in_addr _src_addr,
129 struct in_addr _dst_addr, struct in_addr _alias_addr,
130 unsigned char _proto);
131
132/* Fragment Handling functions. */
133void PacketAliasFragmentIn(char *_ptr, char *_ptr_fragment);
134char *PacketAliasGetFragment(char *_ptr);
135int PacketAliasSaveFragment(char *_ptr);
136
137/* Miscellaneous functions. */
138int PacketAliasCheckNewLink(void);
139unsigned short
140 PacketAliasInternetChecksum(unsigned short *_ptr, int _nbytes);
141void PacketAliasSetTarget(struct in_addr _target_addr);
142
143/* Transparent proxying routines. */
144int PacketAliasProxyRule(const char *_cmd);
145
146/* NEW API */
147
148/* Initialization and control functions. */
149#ifndef VBOX
150struct libalias *LibAliasInit(struct libalias *);
151#else
152struct libalias *LibAliasInit(PNATState, struct libalias *);
153#endif
154void LibAliasSetAddress(struct libalias *, struct in_addr _addr);
155void LibAliasSetFWBase(struct libalias *, unsigned int _base, unsigned int _num);
156void LibAliasSetSkinnyPort(struct libalias *, unsigned int _port);
157unsigned int
158 LibAliasSetMode(struct libalias *, unsigned int _flags, unsigned int _mask);
159void LibAliasUninit(struct libalias *);
160
161/* Packet Handling functions. */
162int LibAliasIn (struct libalias *, char *_ptr, int _maxpacketsize);
163int LibAliasOut(struct libalias *, char *_ptr, int _maxpacketsize);
164int LibAliasOutTry(struct libalias *, char *_ptr, int _maxpacketsize, int _create);
165int LibAliasUnaliasOut(struct libalias *, char *_ptr, int _maxpacketsize);
166
167/* Port and address redirection functions. */
168
169int
170LibAliasAddServer(struct libalias *, struct alias_link *_lnk,
171 struct in_addr _addr, unsigned short _port);
172struct alias_link *
173LibAliasRedirectAddr(struct libalias *, struct in_addr _src_addr,
174 struct in_addr _alias_addr);
175int LibAliasRedirectDynamic(struct libalias *, struct alias_link *_lnk);
176void LibAliasRedirectDelete(struct libalias *, struct alias_link *_lnk);
177struct alias_link *
178LibAliasRedirectPort(struct libalias *, struct in_addr _src_addr,
179 unsigned short _src_port, struct in_addr _dst_addr,
180 unsigned short _dst_port, struct in_addr _alias_addr,
181 unsigned short _alias_port, unsigned char _proto);
182struct alias_link *
183LibAliasRedirectProto(struct libalias *, struct in_addr _src_addr,
184 struct in_addr _dst_addr, struct in_addr _alias_addr,
185 unsigned char _proto);
186
187/* Fragment Handling functions. */
188void LibAliasFragmentIn(struct libalias *, char *_ptr, char *_ptr_fragment);
189char *LibAliasGetFragment(struct libalias *, char *_ptr);
190int LibAliasSaveFragment(struct libalias *, char *_ptr);
191
192/* Miscellaneous functions. */
193int LibAliasCheckNewLink(struct libalias *);
194unsigned short
195 LibAliasInternetChecksum(struct libalias *, unsigned short *_ptr, int _nbytes);
196void LibAliasSetTarget(struct libalias *, struct in_addr _target_addr);
197
198/* Transparent proxying routines. */
199int LibAliasProxyRule(struct libalias *, const char *_cmd);
200
201/* Module handling API */
202int LibAliasLoadModule(char *);
203int LibAliasUnLoadAllModule(void);
204int LibAliasRefreshModules(void);
205
206/* Mbuf helper function. */
207#ifndef VBOX
208struct mbuf *m_megapullup(struct mbuf *, int);
209#else
210struct mbuf *m_megapullup(PNATState, struct mbuf *, int);
211#endif
212
213/*
214 * Mode flags and other constants.
215 */
216
217
218/* Mode flags, set using PacketAliasSetMode() */
219
220/*
221 * If PKT_ALIAS_LOG is set, a message will be printed to /var/log/alias.log
222 * every time a link is created or deleted. This is useful for debugging.
223 */
224#define PKT_ALIAS_LOG 0x01
225
226/*
227 * If PKT_ALIAS_DENY_INCOMING is set, then incoming connections (e.g. to ftp,
228 * telnet or web servers will be prevented by the aliasing mechanism.
229 */
230#define PKT_ALIAS_DENY_INCOMING 0x02
231
232/*
233 * If PKT_ALIAS_SAME_PORTS is set, packets will be attempted sent from the
234 * same port as they originated on. This allows e.g. rsh to work *99% of the
235 * time*, but _not_ 100% (it will be slightly flakey instead of not working
236 * at all). This mode bit is set by PacketAliasInit(), so it is a default
237 * mode of operation.
238 */
239#define PKT_ALIAS_SAME_PORTS 0x04
240
241/*
242 * If PKT_ALIAS_USE_SOCKETS is set, then when partially specified links (e.g.
243 * destination port and/or address is zero), the packet aliasing engine will
244 * attempt to allocate a socket for the aliasing port it chooses. This will
245 * avoid interference with the host machine. Fully specified links do not
246 * require this. This bit is set after a call to PacketAliasInit(), so it is
247 * a default mode of operation.
248 */
249#ifndef NO_USE_SOCKETS
250#define PKT_ALIAS_USE_SOCKETS 0x08
251#endif
252/*-
253 * If PKT_ALIAS_UNREGISTERED_ONLY is set, then only packets with
254 * unregistered source addresses will be aliased. Private
255 * addresses are those in the following ranges:
256 *
257 * 10.0.0.0 -> 10.255.255.255
258 * 172.16.0.0 -> 172.31.255.255
259 * 192.168.0.0 -> 192.168.255.255
260 */
261#define PKT_ALIAS_UNREGISTERED_ONLY 0x10
262
263/*
264 * If PKT_ALIAS_RESET_ON_ADDR_CHANGE is set, then the table of dynamic
265 * aliasing links will be reset whenever PacketAliasSetAddress() changes the
266 * default aliasing address. If the default aliasing address is left
267 * unchanged by this function call, then the table of dynamic aliasing links
268 * will be left intact. This bit is set after a call to PacketAliasInit().
269 */
270#define PKT_ALIAS_RESET_ON_ADDR_CHANGE 0x20
271
272#ifndef NO_FW_PUNCH
273/*
274 * If PKT_ALIAS_PUNCH_FW is set, active FTP and IRC DCC connections will
275 * create a 'hole' in the firewall to allow the transfers to work. The
276 * ipfw rule number that the hole is created with is controlled by
277 * PacketAliasSetFWBase(). The hole will be attached to that
278 * particular alias_link, so when the link goes away the hole is deleted.
279 */
280#define PKT_ALIAS_PUNCH_FW 0x100
281#endif
282
283/*
284 * If PKT_ALIAS_PROXY_ONLY is set, then NAT will be disabled and only
285 * transparent proxying is performed.
286 */
287#define PKT_ALIAS_PROXY_ONLY 0x40
288
289/*
290 * If PKT_ALIAS_REVERSE is set, the actions of PacketAliasIn() and
291 * PacketAliasOut() are reversed.
292 */
293#define PKT_ALIAS_REVERSE 0x80
294
295/* Function return codes. */
296#define PKT_ALIAS_ERROR -1
297#define PKT_ALIAS_OK 1
298#define PKT_ALIAS_IGNORED 2
299#define PKT_ALIAS_UNRESOLVED_FRAGMENT 3
300#define PKT_ALIAS_FOUND_HEADER_FRAGMENT 4
301
302#endif /* !_ALIAS_H_ */
303
304/* lint -restore */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette