1 /* -*- mode: c; tab-width: 3; c-basic-offset: 3; -*- 2 Alias_local.h contains the function prototypes for alias.c, 3 alias_db.c, alias_util.c and alias_ftp.c, alias_irc.c (as well 4 as any future add-ons). It also includes macros, globals and 5 struct definitions shared by more than one alias*.c file. 6 7 This include file is intended to be used only within the aliasing 8 software. Outside world interfaces are defined in alias.h 9 10 This software is placed into the public domain with no restrictions 11 on its distribution. 12 13 Initial version: August, 1996 (cjm) 14 15 <updated several times by original author and Eivind Eklund> 16 17 $FreeBSD$ 18 */ 19 #ifndef ALIAS_LOCAL_H 20 #define ALIAS_LOCAL_H 21 22 #ifndef NULL 23 #define NULL 0 24 #endif 25 26 /* 27 Macros 28 */ 29 30 /* 31 The following macro is used to update an 32 internet checksum. "delta" is a 32-bit 33 accumulation of all the changes to the 34 checksum (adding in new 16-bit words and 35 subtracting out old words), and "cksum" 36 is the checksum value to be updated. 37 */ 38 #define ADJUST_CHECKSUM(acc, cksum) { \ 39 acc += cksum; \ 40 if (acc < 0) \ 41 { \ 42 acc = -acc; \ 43 acc = (acc >> 16) + (acc & 0xffff); \ 44 acc += acc >> 16; \ 45 cksum = (u_short) ~acc; \ 46 } \ 47 else \ 48 { \ 49 acc = (acc >> 16) + (acc & 0xffff); \ 50 acc += acc >> 16; \ 51 cksum = (u_short) acc; \ 52 } \ 53 } 54 55 56 /* 57 Globals 58 */ 59 60 extern int packetAliasMode; 61 62 63 /* 64 Structs 65 */ 66 67 struct alias_link; /* Incomplete structure */ 68 69 70 /* 71 Prototypes 72 */ 73 74 /* General utilities */ 75 u_short IpChecksum(struct ip *); 76 u_short TcpChecksum(struct ip *); 77 void DifferentialChecksum(u_short *, u_short *, u_short *, int); 78 79 /* Internal data access */ 80 struct alias_link * 81 FindIcmpIn(struct in_addr, struct in_addr, u_short); 82 83 struct alias_link * 84 FindIcmpOut(struct in_addr, struct in_addr, u_short); 85 86 struct alias_link * 87 FindFragmentIn1(struct in_addr, struct in_addr, u_short); 88 89 struct alias_link * 90 FindFragmentIn2(struct in_addr, struct in_addr, u_short); 91 92 struct alias_link * 93 AddFragmentPtrLink(struct in_addr, u_short); 94 95 struct alias_link * 96 FindFragmentPtr(struct in_addr, u_short); 97 98 struct alias_link * 99 FindUdpTcpIn (struct in_addr, struct in_addr, u_short, u_short, u_char); 100 101 struct alias_link * 102 FindUdpTcpOut(struct in_addr, struct in_addr, u_short, u_short, u_char); 103 104 struct in_addr 105 FindOriginalAddress(struct in_addr); 106 107 struct in_addr 108 FindAliasAddress(struct in_addr); 109 110 /* External data access/modification */ 111 void GetFragmentAddr(struct alias_link *, struct in_addr *); 112 void SetFragmentAddr(struct alias_link *, struct in_addr); 113 void GetFragmentPtr(struct alias_link *, char **); 114 void SetFragmentPtr(struct alias_link *, char *); 115 void SetStateIn(struct alias_link *, int); 116 void SetStateOut(struct alias_link *, int); 117 int GetStateIn(struct alias_link *); 118 int GetStateOut(struct alias_link *); 119 struct in_addr GetOriginalAddress(struct alias_link *); 120 struct in_addr GetDestAddress(struct alias_link *); 121 struct in_addr GetAliasAddress(struct alias_link *); 122 struct in_addr GetDefaultAliasAddress(void); 123 void SetDefaultAliasAddress(struct in_addr); 124 u_short GetOriginalPort(struct alias_link *); 125 u_short GetAliasPort(struct alias_link *); 126 struct in_addr GetProxyAddress(struct alias_link *); 127 void SetProxyAddress(struct alias_link *, struct in_addr); 128 u_short GetProxyPort(struct alias_link *); 129 void SetProxyPort(struct alias_link *, u_short); 130 void SetAckModified(struct alias_link *); 131 int GetAckModified(struct alias_link *); 132 int GetDeltaAckIn(struct ip *, struct alias_link *); 133 int GetDeltaSeqOut(struct ip *, struct alias_link *); 134 void AddSeq(struct ip *, struct alias_link *, int); 135 void SetExpire(struct alias_link *, int); 136 void ClearCheckNewLink(void); 137 #ifndef NO_FW_PUNCH 138 void PunchFWHole(struct alias_link *); 139 #endif 140 141 142 /* Housekeeping function */ 143 void HouseKeeping(void); 144 145 /* Tcp specfic routines */ 146 /*lint -save -library Suppress flexelint warnings */ 147 148 /* FTP routines */ 149 void AliasHandleFtpOut(struct ip *, struct alias_link *, int); 150 151 /* IRC routines */ 152 void AliasHandleIrcOut(struct ip *, struct alias_link *, int); 153 154 /* NetBIOS routines */ 155 int AliasHandleUdpNbt(struct ip *, struct alias_link *, struct in_addr *, u_short); 156 int AliasHandleUdpNbtNS(struct ip *, struct alias_link *, struct in_addr *, u_short *, struct in_addr *, u_short *); 157 158 /* CUSeeMe routines */ 159 void AliasHandleCUSeeMeOut(struct ip *, struct alias_link *); 160 void AliasHandleCUSeeMeIn(struct ip *, struct in_addr); 161 162 /* Transparent proxy routines */ 163 int ProxyCheck(struct ip *, struct in_addr *, u_short *); 164 void ProxyModify(struct alias_link *, struct ip *, int, int); 165 166 167 enum alias_tcp_state { 168 ALIAS_TCP_STATE_NOT_CONNECTED, 169 ALIAS_TCP_STATE_CONNECTED, 170 ALIAS_TCP_STATE_DISCONNECTED 171 }; 172 173 int GetPptpAlias (struct in_addr*); 174 /*lint -restore */ 175 #endif /* defined(ALIAS_LOCAL_H) */ 176