alias_local.h revision 63899
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: head/sys/netinet/libalias/alias_local.h 63899 2000-07-26 23:15:46Z archie $ 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 60extern int packetAliasMode; 61 62 63/* 64 Structs 65*/ 66 67struct alias_link; /* Incomplete structure */ 68 69 70/* 71 Prototypes 72*/ 73 74/* General utilities */ 75u_short IpChecksum(struct ip *); 76u_short TcpChecksum(struct ip *); 77void DifferentialChecksum(u_short *, u_short *, u_short *, int); 78 79/* Internal data access */ 80struct alias_link * 81FindIcmpIn(struct in_addr, struct in_addr, u_short); 82 83struct alias_link * 84FindIcmpOut(struct in_addr, struct in_addr, u_short); 85 86struct alias_link * 87FindFragmentIn1(struct in_addr, struct in_addr, u_short); 88 89struct alias_link * 90FindFragmentIn2(struct in_addr, struct in_addr, u_short); 91 92struct alias_link * 93AddFragmentPtrLink(struct in_addr, u_short); 94 95struct alias_link * 96FindFragmentPtr(struct in_addr, u_short); 97 98struct alias_link * 99FindProtoIn(struct in_addr, struct in_addr, u_char); 100 101struct alias_link * 102FindProtoOut(struct in_addr, struct in_addr, u_char); 103 104struct alias_link * 105FindUdpTcpIn (struct in_addr, struct in_addr, u_short, u_short, u_char); 106 107struct alias_link * 108FindUdpTcpOut(struct in_addr, struct in_addr, u_short, u_short, u_char); 109 110struct alias_link * 111FindPptpIn(struct in_addr, struct in_addr, u_short); 112 113struct alias_link * 114FindPptpOut(struct in_addr, struct in_addr, u_short); 115 116struct alias_link * 117QueryUdpTcpIn (struct in_addr, struct in_addr, u_short, u_short, u_char); 118 119struct alias_link * 120QueryUdpTcpOut(struct in_addr, struct in_addr, u_short, u_short, u_char); 121 122struct alias_link * 123FindRtspOut(struct in_addr, struct in_addr, u_short, u_short, u_char); 124 125struct in_addr 126FindOriginalAddress(struct in_addr); 127 128struct in_addr 129FindAliasAddress(struct in_addr); 130 131/* External data access/modification */ 132int FindNewPortGroup(struct in_addr, struct in_addr, 133 u_short, u_short, u_short, u_char, u_char); 134void GetFragmentAddr(struct alias_link *, struct in_addr *); 135void SetFragmentAddr(struct alias_link *, struct in_addr); 136void GetFragmentPtr(struct alias_link *, char **); 137void SetFragmentPtr(struct alias_link *, char *); 138void SetStateIn(struct alias_link *, int); 139void SetStateOut(struct alias_link *, int); 140int GetStateIn(struct alias_link *); 141int GetStateOut(struct alias_link *); 142struct in_addr GetOriginalAddress(struct alias_link *); 143struct in_addr GetDestAddress(struct alias_link *); 144struct in_addr GetAliasAddress(struct alias_link *); 145struct in_addr GetDefaultAliasAddress(void); 146void SetDefaultAliasAddress(struct in_addr); 147u_short GetOriginalPort(struct alias_link *); 148u_short GetAliasPort(struct alias_link *); 149struct in_addr GetProxyAddress(struct alias_link *); 150void SetProxyAddress(struct alias_link *, struct in_addr); 151u_short GetProxyPort(struct alias_link *); 152void SetProxyPort(struct alias_link *, u_short); 153void SetAckModified(struct alias_link *); 154int GetAckModified(struct alias_link *); 155int GetDeltaAckIn(struct ip *, struct alias_link *); 156int GetDeltaSeqOut(struct ip *, struct alias_link *); 157void AddSeq(struct ip *, struct alias_link *, int); 158void SetExpire(struct alias_link *, int); 159void ClearCheckNewLink(void); 160void SetLastLineCrlfTermed(struct alias_link *, int); 161int GetLastLineCrlfTermed(struct alias_link *); 162#ifndef NO_FW_PUNCH 163void PunchFWHole(struct alias_link *); 164#endif 165 166 167/* Housekeeping function */ 168void HouseKeeping(void); 169 170/* Tcp specfic routines */ 171/*lint -save -library Suppress flexelint warnings */ 172 173/* FTP routines */ 174void AliasHandleFtpOut(struct ip *, struct alias_link *, int); 175 176/* IRC routines */ 177void AliasHandleIrcOut(struct ip *, struct alias_link *, int); 178 179/* RTSP routines */ 180void AliasHandleRtspOut(struct ip *, struct alias_link *, int); 181 182/* PPTP routines */ 183int PptpGetCallID(struct ip *, u_short *); 184void PptpSetCallID(struct ip *, u_short); 185void AliasHandlePptpOut(struct ip *, struct alias_link *); 186void AliasHandlePptpIn(struct ip *, struct alias_link *); 187 188/* NetBIOS routines */ 189int AliasHandleUdpNbt(struct ip *, struct alias_link *, struct in_addr *, u_short); 190int AliasHandleUdpNbtNS(struct ip *, struct alias_link *, struct in_addr *, u_short *, struct in_addr *, u_short *); 191 192/* CUSeeMe routines */ 193void AliasHandleCUSeeMeOut(struct ip *, struct alias_link *); 194void AliasHandleCUSeeMeIn(struct ip *, struct in_addr); 195 196/* Transparent proxy routines */ 197int ProxyCheck(struct ip *, struct in_addr *, u_short *); 198void ProxyModify(struct alias_link *, struct ip *, int, int); 199 200 201enum alias_tcp_state { 202 ALIAS_TCP_STATE_NOT_CONNECTED, 203 ALIAS_TCP_STATE_CONNECTED, 204 ALIAS_TCP_STATE_DISCONNECTED 205}; 206/*lint -restore */ 207#endif /* defined(ALIAS_LOCAL_H) */ 208