alias.h revision 74778
1/* lint -save -library Flexelint comment for external headers */ 2 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 */ 12 13#ifndef _ALIAS_H_ 14#define _ALIAS_H_ 15 16/* The external interface to libalias, the packet aliasing engine. */ 17 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); 25 26/* Packet Handling functions. */ 27int PacketAliasIn(char *_ptr, int _maxpacketsize); 28int PacketAliasOut(char *_ptr, int _maxpacketsize); 29int PacketUnaliasOut(char *_ptr, int _maxpacketsize); 30 31/* Port and address redirection functions. */ 32 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; 40 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); 56 57/* Fragment Handling functions. */ 58void PacketAliasFragmentIn(char *_ptr, char *_ptr_fragment); 59char *PacketAliasGetFragment(char *_ptr); 60int PacketAliasSaveFragment(char *_ptr); 61 62/* Miscellaneous functions. */ 63int PacketAliasCheckNewLink(void); 64unsigned short 65 PacketAliasInternetChecksum(unsigned short *_ptr, int _nbytes); 66void PacketAliasSetTarget(struct in_addr _target_addr); 67 68/* Transparent proxying routines. */ 69int PacketAliasProxyRule(const char *_cmd); 70 71/* Mode flags, set using PacketAliasSetMode() */ 72 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 78 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 84 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 93 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 103 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 114 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 123 124#ifndef NO_FW_PUNCH 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 133#endif 134 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 140 141/* 142 * If PKT_ALIAS_REVERSE is set, the actions of PacketAliasIn() and 143 * PacketAliasOut() are reversed. 144 */ 145#define PKT_ALIAS_REVERSE 0x80 146 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 153 154#endif /* !_ALIAS_H_ */ 155 156/* lint -restore */ 157