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