alias.h revision 59702
1193326Sed/*lint -save -library Flexelint comment for external headers */
2193326Sed
3193326Sed/*
4193326Sed    Alias.h defines the outside world interfaces for the packet
5193326Sed    aliasing software.
6193326Sed
7193326Sed    This software is placed into the public domain with no restrictions
8193326Sed    on its distribution.
9193326Sed
10193326Sed $FreeBSD: head/sys/netinet/libalias/alias.h 59702 2000-04-27 17:37:03Z ru $
11193326Sed*/
12193326Sed
13193326Sed
14193326Sed#ifndef _ALIAS_H_
15193326Sed#define _ALIAS_H_
16193326Sed
17193326Sed/* Alias link representative (incomplete struct) */
18193326Sedstruct alias_link;
19193326Sed
20193326Sed/* External interfaces (API) to packet aliasing engine */
21193326Sed
22193326Sed/* Initialization and Control */
23193326Sed    extern void
24193326Sed    PacketAliasInit(void);
25193326Sed
26193326Sed    extern void
27193326Sed    PacketAliasUninit(void);
28193326Sed
29218893Sdim    extern void
30193326Sed    PacketAliasSetAddress(struct in_addr);
31193326Sed
32193326Sed    extern unsigned int
33193326Sed    PacketAliasSetMode(unsigned int, unsigned int);
34218893Sdim
35218893Sdim#ifndef NO_FW_PUNCH
36218893Sdim    extern void
37218893Sdim    PacketAliasSetFWBase(unsigned int, unsigned int);
38218893Sdim#endif
39218893Sdim
40193326Sed/* Packet Handling */
41193326Sed    extern int
42193326Sed    PacketAliasIn(char *, int maxpacketsize);
43193326Sed
44193326Sed    extern int
45    PacketAliasOut(char *, int maxpacketsize);
46
47/* Port and Address Redirection */
48    extern struct alias_link *
49    PacketAliasRedirectPort(struct in_addr, u_short,
50                            struct in_addr, u_short,
51                            struct in_addr, u_short,
52                            u_char);
53
54    extern int
55    PacketAliasAddServer(struct alias_link *link,
56                         struct in_addr addr,
57                         u_short port);
58
59    extern int
60    PacketAliasPptp(struct in_addr);
61
62    extern struct alias_link *
63    PacketAliasRedirectPptp(struct in_addr, struct in_addr, struct in_addr);
64
65    extern struct alias_link *
66    PacketAliasRedirectAddr(struct in_addr,
67                            struct in_addr);
68
69    extern void
70    PacketAliasRedirectDelete(struct alias_link *);
71
72/* Fragment Handling */
73    extern int
74    PacketAliasSaveFragment(char *);
75
76    extern char *
77    PacketAliasGetFragment(char *);
78
79    extern void
80    PacketAliasFragmentIn(char *, char *);
81
82/* Miscellaneous Functions */
83    extern void
84    PacketAliasSetTarget(struct in_addr addr);
85
86    extern int
87    PacketAliasCheckNewLink(void);
88
89    extern u_short
90    PacketAliasInternetChecksum(u_short *, int);
91
92/* Transparent Proxying */
93    extern int
94    PacketAliasProxyRule(const char *);
95
96
97/********************** Mode flags ********************/
98/* Set these flags using PacketAliasSetMode() */
99
100/* If PKT_ALIAS_LOG is set, a message will be printed to
101	/var/log/alias.log every time a link is created or deleted.  This
102	is useful for debugging */
103#define PKT_ALIAS_LOG 0x01
104
105/* If PKT_ALIAS_DENY_INCOMING is set, then incoming connections (e.g.
106	to ftp, telnet or web servers will be prevented by the aliasing
107	mechanism.  */
108#define PKT_ALIAS_DENY_INCOMING 0x02
109
110/* If PKT_ALIAS_SAME_PORTS is set, packets will be attempted sent from
111	the same port as they originated on.  This allows e.g. rsh to work
112	*99% of the time*, but _not_ 100%.  (It will be slightly flakey
113	instead of not working at all.)  This mode bit is set by
114        PacketAliasInit(), so it is a default mode of operation. */
115#define PKT_ALIAS_SAME_PORTS 0x04
116
117/* If PKT_ALIAS_USE_SOCKETS is set, then when partially specified
118	links (e.g. destination port and/or address is zero), the packet
119	aliasing engine will attempt to allocate a socket for the aliasing
120	port it chooses.  This will avoid interference with the host
121	machine.  Fully specified links do not require this.  This bit
122        is set after a call to PacketAliasInit(), so it is a default
123        mode of operation. */
124#define PKT_ALIAS_USE_SOCKETS 0x08
125
126/* If PKT_ALIAS_UNREGISTERED_ONLY is set, then only packets with
127	unregistered source addresses will be aliased.  Private
128	addresses are those in the following ranges:
129		10.0.0.0     ->   10.255.255.255
130		172.16.0.0   ->   172.31.255.255
131		192.168.0.0  ->   192.168.255.255  */
132#define PKT_ALIAS_UNREGISTERED_ONLY 0x10
133
134/* If PKT_ALIAS_RESET_ON_ADDR_CHANGE is set, then the table of dynamic
135	aliasing links will be reset whenever PacketAliasSetAddress()
136        changes the default aliasing address.  If the default aliasing
137        address is left unchanged by this function call, then the
138        table of dynamic aliasing links will be left intact.  This
139        bit is set after a call to PacketAliasInit(). */
140#define PKT_ALIAS_RESET_ON_ADDR_CHANGE 0x20
141
142#ifndef NO_FW_PUNCH
143/* If PKT_ALIAS_PUNCH_FW is set, active FTP and IRC DCC connections
144   will create a 'hole' in the firewall to allow the transfers to
145   work.  Where (IPFW "line-numbers") the hole is created is
146   controlled by PacketAliasSetFWBase(base, size). The hole will be
147   attached to that particular alias_link, so when the link goes away
148   so do the hole.  */
149#define PKT_ALIAS_PUNCH_FW 0x100
150#endif
151
152/* If PKT_ALIAS_PROXY_ONLY is set, then NAT will be disabled and only
153      transparent proxying performed */
154#define PKT_ALIAS_PROXY_ONLY 0x40
155
156/* If PKT_ALIAS_REVERSE is set, the actions of PacketAliasIn()
157      and PacketAliasOut() are reversed */
158#define PKT_ALIAS_REVERSE 0x80
159
160/* If PKT_ALIAS_DENY_PPTP is set, then PPTP sessions will be
161	prevented by the aliasing engine.  */
162#define PKT_ALIAS_DENY_PPTP 0x200
163
164/* Return Codes */
165#define PKT_ALIAS_ERROR -1
166#define PKT_ALIAS_OK 1
167#define PKT_ALIAS_IGNORED 2
168#define PKT_ALIAS_UNRESOLVED_FRAGMENT 3
169#define PKT_ALIAS_FOUND_HEADER_FRAGMENT 4
170
171#endif
172/*lint -restore */
173