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 67980 2000-10-30 17:24:12Z ru $ 18*/ 19#ifndef ALIAS_LOCAL_H 20#define ALIAS_LOCAL_H 21 22#ifndef NULL 23#define NULL 0 24#endif 25
| |
26/*
| 1/*
|
27 Macros
| 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 74778 2001-03-25 12:05:10Z brian $
|
28 */ 29
| 18 */ 19
|
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}
| 20#ifndef _ALIAS_LOCAL_H_ 21#define _ALIAS_LOCAL_H_
|
54
| 22
|
| 23/* Macros */
|
55 56/*
| 24 25/*
|
57 Globals 58*/
| 26 * The following macro is used to update an 27 * internet checksum. "delta" is a 32-bit 28 * accumulation of all the changes to the 29 * checksum (adding in new 16-bit words and 30 * subtracting out old words), and "cksum" 31 * is the checksum value to be updated. 32 */ 33#define ADJUST_CHECKSUM(acc, cksum) \ 34 do { \ 35 acc += cksum; \ 36 if (acc < 0) { \ 37 acc = -acc; \ 38 acc = (acc >> 16) + (acc & 0xffff); \ 39 acc += acc >> 16; \ 40 cksum = (u_short) ~acc; \ 41 } else { \ 42 acc = (acc >> 16) + (acc & 0xffff); \ 43 acc += acc >> 16; \ 44 cksum = (u_short) acc; \ 45 } \ 46 } while (0)
|
59
| 47
|
| 48/* Globals */ 49
|
60extern int packetAliasMode; 61
| 50extern int packetAliasMode; 51
|
| 52/* Prototypes */
|
62
| 53
|
63/* 64 Structs 65*/ 66 67struct alias_link; /* Incomplete structure */ 68 69 70/* 71 Prototypes 72*/ 73
| |
74/* General utilities */
| 54/* General utilities */
|
75u_short IpChecksum(struct ip *); 76u_short TcpChecksum(struct ip *); 77void DifferentialChecksum(u_short *, u_short *, u_short *, int);
| 55u_short IpChecksum(struct ip *_pip); 56u_short TcpChecksum(struct ip *_pip); 57void DifferentialChecksum(u_short *_cksum, u_short *_new, u_short *_old, 58 int _n);
|
78 79/* Internal data access */ 80struct alias_link *
| 59 60/* Internal data access */ 61struct alias_link *
|
81FindIcmpIn(struct in_addr, struct in_addr, u_short, int); 82
| 62 FindIcmpIn(struct in_addr _dst_addr, struct in_addr _alias_addr, 63 u_short _id_alias, int _create);
|
83struct alias_link *
| 64struct alias_link *
|
84FindIcmpOut(struct in_addr, struct in_addr, u_short, int); 85
| 65 FindIcmpOut(struct in_addr _src_addr, struct in_addr _dst_addr, 66 u_short _id, int _create);
|
86struct alias_link *
| 67struct alias_link *
|
87FindFragmentIn1(struct in_addr, struct in_addr, u_short); 88
| 68 FindFragmentIn1(struct in_addr _dst_addr, struct in_addr _alias_addr, 69 u_short _ip_id);
|
89struct alias_link *
| 70struct alias_link *
|
90FindFragmentIn2(struct in_addr, struct in_addr, u_short); 91
| 71 FindFragmentIn2(struct in_addr _dst_addr, struct in_addr _alias_addr, 72 u_short _ip_id);
|
92struct alias_link *
| 73struct alias_link *
|
93AddFragmentPtrLink(struct in_addr, u_short); 94
| 74 AddFragmentPtrLink(struct in_addr _dst_addr, u_short _ip_id);
|
95struct alias_link *
| 75struct alias_link *
|
96FindFragmentPtr(struct in_addr, u_short); 97
| 76 FindFragmentPtr(struct in_addr _dst_addr, u_short _ip_id);
|
98struct alias_link *
| 77struct alias_link *
|
99FindProtoIn(struct in_addr, struct in_addr, u_char); 100
| 78 FindProtoIn(struct in_addr _dst_addr, struct in_addr _alias_addr, 79 u_char _proto);
|
101struct alias_link *
| 80struct alias_link *
|
102FindProtoOut(struct in_addr, struct in_addr, u_char); 103
| 81 FindProtoOut(struct in_addr _src_addr, struct in_addr _dst_addr, 82 u_char _proto);
|
104struct alias_link *
| 83struct alias_link *
|
105FindUdpTcpIn (struct in_addr, struct in_addr, u_short, u_short, u_char, int); 106
| 84 FindUdpTcpIn(struct in_addr _dst_addr, struct in_addr _alias_addr, 85 u_short _dst_port, u_short _alias_port, u_char _proto, int _create);
|
107struct alias_link *
| 86struct alias_link *
|
108FindUdpTcpOut(struct in_addr, struct in_addr, u_short, u_short, u_char, int); 109
| 87 FindUdpTcpOut(struct in_addr _src_addr, struct in_addr _dst_addr, 88 u_short _src_port, u_short _dst_port, u_char _proto, int _create);
|
110struct alias_link *
| 89struct alias_link *
|
111AddPptp(struct in_addr, struct in_addr, struct in_addr, u_int16_t); 112
| 90 AddPptp(struct in_addr _src_addr, struct in_addr _dst_addr, 91 struct in_addr _alias_addr, u_int16_t _src_call_id);
|
113struct alias_link *
| 92struct alias_link *
|
114FindPptpOutByCallId(struct in_addr, struct in_addr, u_int16_t); 115
| 93 FindPptpOutByCallId(struct in_addr _src_addr, 94 struct in_addr _dst_addr, u_int16_t _src_call_id);
|
116struct alias_link *
| 95struct alias_link *
|
117FindPptpInByCallId(struct in_addr, struct in_addr, u_int16_t); 118
| 96 FindPptpInByCallId(struct in_addr _dst_addr, 97 struct in_addr _alias_addr, u_int16_t _dst_call_id);
|
119struct alias_link *
| 98struct alias_link *
|
120FindPptpOutByPeerCallId(struct in_addr, struct in_addr, u_int16_t); 121
| 99 FindPptpOutByPeerCallId(struct in_addr _src_addr, 100 struct in_addr _dst_addr, u_int16_t _dst_call_id);
|
122struct alias_link *
| 101struct alias_link *
|
123FindPptpInByPeerCallId(struct in_addr, struct in_addr, u_int16_t); 124
| 102 FindPptpInByPeerCallId(struct in_addr _dst_addr, 103 struct in_addr _alias_addr, u_int16_t _alias_call_id);
|
125struct alias_link *
| 104struct alias_link *
|
126FindRtspOut(struct in_addr, struct in_addr, u_short, u_short, u_char); 127
| 105 FindRtspOut(struct in_addr _src_addr, struct in_addr _dst_addr, 106 u_short _src_port, u_short _alias_port, u_char _proto);
|
128struct in_addr
| 107struct in_addr
|
129FindOriginalAddress(struct in_addr); 130
| 108 FindOriginalAddress(struct in_addr _alias_addr);
|
131struct in_addr
| 109struct in_addr
|
132FindAliasAddress(struct in_addr);
| 110 FindAliasAddress(struct in_addr _original_addr);
|
133 134/* External data access/modification */
| 111 112/* External data access/modification */
|
135int FindNewPortGroup(struct in_addr, struct in_addr, 136 u_short, u_short, u_short, u_char, u_char); 137void GetFragmentAddr(struct alias_link *, struct in_addr *); 138void SetFragmentAddr(struct alias_link *, struct in_addr); 139void GetFragmentPtr(struct alias_link *, char **); 140void SetFragmentPtr(struct alias_link *, char *); 141void SetStateIn(struct alias_link *, int); 142void SetStateOut(struct alias_link *, int); 143int GetStateIn(struct alias_link *); 144int GetStateOut(struct alias_link *); 145struct in_addr GetOriginalAddress(struct alias_link *); 146struct in_addr GetDestAddress(struct alias_link *); 147struct in_addr GetAliasAddress(struct alias_link *); 148struct in_addr GetDefaultAliasAddress(void); 149void SetDefaultAliasAddress(struct in_addr); 150u_short GetOriginalPort(struct alias_link *); 151u_short GetAliasPort(struct alias_link *); 152struct in_addr GetProxyAddress(struct alias_link *); 153void SetProxyAddress(struct alias_link *, struct in_addr); 154u_short GetProxyPort(struct alias_link *); 155void SetProxyPort(struct alias_link *, u_short); 156void SetAckModified(struct alias_link *); 157int GetAckModified(struct alias_link *); 158int GetDeltaAckIn(struct ip *, struct alias_link *); 159int GetDeltaSeqOut(struct ip *, struct alias_link *); 160void AddSeq(struct ip *, struct alias_link *, int); 161void SetExpire(struct alias_link *, int); 162void ClearCheckNewLink(void); 163void SetLastLineCrlfTermed(struct alias_link *, int); 164int GetLastLineCrlfTermed(struct alias_link *); 165void SetDestCallId(struct alias_link *, u_int16_t);
| 113int FindNewPortGroup(struct in_addr _dst_addr, struct in_addr _alias_addr, 114 u_short _src_port, u_short _dst_port, u_short _port_count, 115 u_char _proto, u_char _align); 116void GetFragmentAddr(struct alias_link *_link, struct in_addr *_src_addr); 117void SetFragmentAddr(struct alias_link *_link, struct in_addr _src_addr); 118void GetFragmentPtr(struct alias_link *_link, char **_fptr); 119void SetFragmentPtr(struct alias_link *_link, char *fptr); 120void SetStateIn(struct alias_link *_link, int _state); 121void SetStateOut(struct alias_link *_link, int _state); 122int GetStateIn(struct alias_link *_link); 123int GetStateOut(struct alias_link *_link); 124struct in_addr 125 GetOriginalAddress(struct alias_link *_link); 126struct in_addr 127 GetDestAddress(struct alias_link *_link); 128struct in_addr 129 GetAliasAddress(struct alias_link *_link); 130struct in_addr 131 GetDefaultAliasAddress(void); 132void SetDefaultAliasAddress(struct in_addr _alias_addr); 133u_short GetOriginalPort(struct alias_link *_link); 134u_short GetAliasPort(struct alias_link *_link); 135struct in_addr 136 GetProxyAddress(struct alias_link *_link); 137void SetProxyAddress(struct alias_link *_link, struct in_addr _addr); 138u_short GetProxyPort(struct alias_link *_link); 139void SetProxyPort(struct alias_link *_link, u_short _port); 140void SetAckModified(struct alias_link *_link); 141int GetAckModified(struct alias_link *_link); 142int GetDeltaAckIn(struct ip *_pip, struct alias_link *_link); 143int GetDeltaSeqOut(struct ip *_pip, struct alias_link *_link); 144void AddSeq(struct ip *_pip, struct alias_link *_link, int _delta); 145void SetExpire(struct alias_link *_link, int _expire); 146void ClearCheckNewLink(void); 147void SetLastLineCrlfTermed(struct alias_link *_link, int _yes); 148int GetLastLineCrlfTermed(struct alias_link *_link); 149void SetDestCallId(struct alias_link *_link, u_int16_t _cid);
|
166#ifndef NO_FW_PUNCH
| 150#ifndef NO_FW_PUNCH
|
167void PunchFWHole(struct alias_link *);
| 151void PunchFWHole(struct alias_link *_link);
|
168#endif 169
| 152#endif 153
|
170
| |
171/* Housekeeping function */
| 154/* Housekeeping function */
|
172void HouseKeeping(void);
| 155void HouseKeeping(void);
|
173 174/* Tcp specfic routines */
| 156 157/* Tcp specfic routines */
|
175/*lint -save -library Suppress flexelint warnings */
| 158/* lint -save -library Suppress flexelint warnings */
|
176 177/* FTP routines */
| 159 160/* FTP routines */
|
178void AliasHandleFtpOut(struct ip *, struct alias_link *, int);
| 161void AliasHandleFtpOut(struct ip *_pip, struct alias_link *_link, 162 int _maxpacketsize);
|
179 180/* IRC routines */
| 163 164/* IRC routines */
|
181void AliasHandleIrcOut(struct ip *, struct alias_link *, int);
| 165void AliasHandleIrcOut(struct ip *_pip, struct alias_link *_link, 166 int _maxsize);
|
182 183/* RTSP routines */
| 167 168/* RTSP routines */
|
184void AliasHandleRtspOut(struct ip *, struct alias_link *, int);
| 169void AliasHandleRtspOut(struct ip *_pip, struct alias_link *_link, 170 int _maxpacketsize);
|
185 186/* PPTP routines */
| 171 172/* PPTP routines */
|
187void AliasHandlePptpOut(struct ip *, struct alias_link *); 188void AliasHandlePptpIn(struct ip *, struct alias_link *); 189int AliasHandlePptpGreOut(struct ip *); 190int AliasHandlePptpGreIn(struct ip *);
| 173void AliasHandlePptpOut(struct ip *_pip, struct alias_link *_link); 174void AliasHandlePptpIn(struct ip *_pip, struct alias_link *_link); 175int AliasHandlePptpGreOut(struct ip *_pip); 176int AliasHandlePptpGreIn(struct ip *_pip);
|
191 192/* NetBIOS routines */
| 177 178/* NetBIOS routines */
|
193int AliasHandleUdpNbt(struct ip *, struct alias_link *, struct in_addr *, u_short); 194int AliasHandleUdpNbtNS(struct ip *, struct alias_link *, struct in_addr *, u_short *, struct in_addr *, u_short *);
| 179int AliasHandleUdpNbt(struct ip *_pip, struct alias_link *_link, 180 struct in_addr *_alias_address, u_short _alias_port); 181int AliasHandleUdpNbtNS(struct ip *_pip, struct alias_link *_link, 182 struct in_addr *_alias_address, u_short *_alias_port, 183 struct in_addr *_original_address, u_short *_original_port);
|
195 196/* CUSeeMe routines */
| 184 185/* CUSeeMe routines */
|
197void AliasHandleCUSeeMeOut(struct ip *, struct alias_link *); 198void AliasHandleCUSeeMeIn(struct ip *, struct in_addr);
| 186void AliasHandleCUSeeMeOut(struct ip *_pip, struct alias_link *_link); 187void AliasHandleCUSeeMeIn(struct ip *_pip, struct in_addr _original_addr);
|
199 200/* Transparent proxy routines */
| 188 189/* Transparent proxy routines */
|
201int ProxyCheck(struct ip *, struct in_addr *, u_short *); 202void ProxyModify(struct alias_link *, struct ip *, int, int);
| 190int ProxyCheck(struct ip *_pip, struct in_addr *_proxy_server_addr, 191 u_short *_proxy_server_port); 192void ProxyModify(struct alias_link *_link, struct ip *_pip, 193 int _maxpacketsize, int _proxy_type);
|
203
| 194
|
204
| |
205enum alias_tcp_state {
| 195enum alias_tcp_state {
|
206 ALIAS_TCP_STATE_NOT_CONNECTED, 207 ALIAS_TCP_STATE_CONNECTED, 208 ALIAS_TCP_STATE_DISCONNECTED
| 196 ALIAS_TCP_STATE_NOT_CONNECTED, 197 ALIAS_TCP_STATE_CONNECTED, 198 ALIAS_TCP_STATE_DISCONNECTED
|
209};
| 199};
|
| 200
|
210/*lint -restore */
| 201/*lint -restore */
|
211#endif /* defined(ALIAS_LOCAL_H) */
| 202 203#endif /* !_ALIAS_LOCAL_H_ */
|
| |