alias.h revision 35314
126026Sbrian/*lint -save -library Flexelint comment for external headers */ 226026Sbrian 326026Sbrian/* 426026Sbrian Alias.h defines the outside world interfaces for the packet 526026Sbrian aliasing software. 626026Sbrian 726026Sbrian This software is placed into the public domain with no restrictions 826026Sbrian on its distribution. 932560Sbde 1035314Sbrian $Id: alias.h,v 1.7 1998/01/16 12:56:07 bde Exp $ 1126026Sbrian*/ 1226026Sbrian 1326026Sbrian 1426026Sbrian#ifndef _ALIAS_H_ 1526026Sbrian#define _ALIAS_H_ 1626026Sbrian 1727864Sbrian#ifndef NULL 1827864Sbrian#define NULL 0 1927864Sbrian#endif 2027864Sbrian 2127864Sbrian/* Alias link representative (incomplete struct) */ 2226026Sbrianstruct alias_link; 2326026Sbrian 2426026Sbrian/* External interfaces (API) to packet aliasing engine */ 2527864Sbrian 2627864Sbrian/* Initialization and Control */ 2727864Sbrian extern void 2827864Sbrian PacketAliasInit(void); 2927864Sbrian 3027864Sbrian extern void 3132377Seivind PacketAliasUninit(void); 3232377Seivind 3332377Seivind extern void 3427864Sbrian PacketAliasSetAddress(struct in_addr); 3527864Sbrian 3627864Sbrian extern unsigned int 3727864Sbrian PacketAliasSetMode(unsigned int, unsigned int); 3827864Sbrian 3935314Sbrian#ifndef NO_FW_PUNCH 4032377Seivind extern void 4132377Seivind PacketAliasSetFWBase(unsigned int, unsigned int); 4235314Sbrian#endif 4332377Seivind 4427864Sbrian/* Packet Handling */ 4527864Sbrian extern int 4627864Sbrian PacketAliasIn(char *, int maxpacketsize); 4727864Sbrian 4827864Sbrian extern int 4927864Sbrian PacketAliasOut(char *, int maxpacketsize); 5027864Sbrian 5127864Sbrian/* Port and Address Redirection */ 5227864Sbrian extern struct alias_link * 5327864Sbrian PacketAliasRedirectPort(struct in_addr, u_short, 5427864Sbrian struct in_addr, u_short, 5527864Sbrian struct in_addr, u_short, 5627864Sbrian u_char); 5727864Sbrian 5827864Sbrian extern struct alias_link * 5927864Sbrian PacketAliasRedirectAddr(struct in_addr, 6027864Sbrian struct in_addr); 6127864Sbrian 6227864Sbrian extern void 6327864Sbrian PacketAliasRedirectDelete(struct alias_link *); 6427864Sbrian 6527864Sbrian/* Fragment Handling */ 6627864Sbrian extern int 6727864Sbrian PacketAliasSaveFragment(char *); 6827864Sbrian 6927864Sbrian extern char * 7027864Sbrian PacketAliasGetFragment(char *); 7127864Sbrian 7227864Sbrian extern void 7327864Sbrian PacketAliasFragmentIn(char *, char *); 7427864Sbrian 7527864Sbrian/* Miscellaneous Functions */ 7632560Sbde extern void 7732560Sbde PacketAliasSetTarget(struct in_addr addr); 7832560Sbde 7932560Sbde extern int 8032560Sbde PacketAliasCheckNewLink(void); 8132560Sbde 8227864Sbrian extern u_short 8327864Sbrian PacketAliasInternetChecksum(u_short *, int); 8427864Sbrian 8527864Sbrian 8627864Sbrian/* 8727864Sbrian In version 2.2, the function names were rationalized 8827864Sbrian to all be of the form PacketAlias... These are the 8927864Sbrian old function names for backwards compatibility 9027864Sbrian*/ 9126026Sbrianextern int SaveFragmentPtr(char *); 9226026Sbrianextern char *GetNextFragmentPtr(char *); 9326026Sbrianextern void FragmentAliasIn(char *, char *); 9426026Sbrianextern void SetPacketAliasAddress(struct in_addr); 9526026Sbrianextern void InitPacketAlias(void); 9626026Sbrianextern unsigned int SetPacketAliasMode(unsigned int, unsigned int); 9727864Sbrianextern int PacketAliasIn2(char *, struct in_addr, int maxpacketsize); 9827864Sbrianextern int PacketAliasOut2(char *, struct in_addr, int maxpacketsize); 9926026Sbrianextern int 10026026SbrianPacketAliasPermanentLink(struct in_addr, u_short, 10126026Sbrian struct in_addr, u_short, 10226026Sbrian u_short, u_char); 10326026Sbrianextern u_short InternetChecksum(u_short *, int); 10426026Sbrian 10527864Sbrian/* Obsolete constant */ 10627864Sbrian#define PKT_ALIAS_NEW_LINK 5 10726026Sbrian 10826026Sbrian/********************** Mode flags ********************/ 10926026Sbrian/* Set these flags using SetPacketAliasMode() */ 11026026Sbrian 11126026Sbrian/* If PKT_ALIAS_LOG is set, a message will be printed to 11226026Sbrian /var/log/alias.log every time a link is created or deleted. This 11326026Sbrian is useful for debugging */ 11427864Sbrian#define PKT_ALIAS_LOG 0x01 11526026Sbrian 11626026Sbrian/* If PKT_ALIAS_DENY_INCOMING is set, then incoming connections (e.g. 11726026Sbrian to ftp, telnet or web servers will be prevented by the aliasing 11826026Sbrian mechanism. */ 11927864Sbrian#define PKT_ALIAS_DENY_INCOMING 0x02 12026026Sbrian 12126026Sbrian/* If PKT_ALIAS_SAME_PORTS is set, packets will be attempted sent from 12227864Sbrian the same port as they originated on. This allows eg rsh to work 12326026Sbrian *99% of the time*, but _not_ 100%. (It will be slightly flakey 12427864Sbrian instead of not working at all.) This mode bit is set by 12527864Sbrian PacketAliasInit(), so it is a default mode of operation. */ 12627864Sbrian#define PKT_ALIAS_SAME_PORTS 0x04 12726026Sbrian 12826026Sbrian/* If PKT_ALIAS_USE_SOCKETS is set, then when partially specified 12926026Sbrian links (e.g. destination port and/or address is zero), the packet 13026026Sbrian aliasing engine will attempt to allocate a socket for the aliasing 13126026Sbrian port it chooses. This will avoid interference with the host 13227864Sbrian machine. Fully specified links do not require this. This bit 13327864Sbrian is set after a call to PacketAliasInit(), so it is a default 13427864Sbrian mode of operation.*/ 13527864Sbrian#define PKT_ALIAS_USE_SOCKETS 0x08 13626026Sbrian 13726026Sbrian/* If PKT_ALIAS_UNREGISTERED_ONLY is set, then only packets with with 13826026Sbrian unregistered source addresses will be aliased (along with those 13926026Sbrian of the ppp host maching itself. Private addresses are those 14026026Sbrian in the following ranges: 14126026Sbrian 14226026Sbrian 10.0.0.0 -> 10.255.255.255 14326026Sbrian 172.16.0.0 -> 172.31.255.255 14426026Sbrian 192.168.0.0 -> 192.168.255.255 */ 14527864Sbrian#define PKT_ALIAS_UNREGISTERED_ONLY 0x10 14626026Sbrian 14727864Sbrian/* If PKT_ALIAS_RESET_ON_ADDR_CHANGE is set, then the table of dynamic 14827864Sbrian aliasing links will be reset whenever PacketAliasSetAddress() 14927864Sbrian changes the default aliasing address. If the default aliasing 15027864Sbrian address is left unchanged by this functions call, then the 15127864Sbrian table of dynamic aliasing links will be left intact. This 15227864Sbrian bit is set after a call to PacketAliasInit(). */ 15327864Sbrian#define PKT_ALIAS_RESET_ON_ADDR_CHANGE 0x20 15426026Sbrian 15535314Sbrian#ifndef NO_FW_PUNCH 15632377Seivind/* If PKT_ALIAS_PUNCH_FW is set, active FTP and IRC DCC connections 15732377Seivind will create a 'hole' in the firewall to allow the transfers to 15832377Seivind work. Where (IPFW "line-numbers") the hole is created is 15932377Seivind controlled by PacketAliasSetFWBase(base, size). The hole will be 16032377Seivind attached to that particular alias_link, so when the link goes away 16132377Seivind so do the hole. */ 16232377Seivind#define PKT_ALIAS_PUNCH_FW 0x40 16335314Sbrian#endif 16432377Seivind 16526026Sbrian/* Return Codes */ 16626026Sbrian#define PKT_ALIAS_ERROR -1 16726026Sbrian#define PKT_ALIAS_OK 1 16826026Sbrian#define PKT_ALIAS_IGNORED 2 16926026Sbrian#define PKT_ALIAS_UNRESOLVED_FRAGMENT 3 17026026Sbrian#define PKT_ALIAS_FOUND_HEADER_FRAGMENT 4 17126026Sbrian 17226026Sbrian#endif 17326026Sbrian/*lint -restore */ 174