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