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