2 * Copyright (c) 2001 Charles Mott <cm@linktel.net>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * $FreeBSD: src/lib/libalias/alias_local.h,v 1.10.2.7 2001/11/23 13:10:15 brian Exp $
27 * $DragonFly: src/lib/libalias/alias_local.h,v 1.2 2003/06/17 04:26:41 dillon Exp $
31 * Alias_local.h contains the function prototypes for alias.c,
32 * alias_db.c, alias_util.c and alias_ftp.c, alias_irc.c (as well
33 * as any future add-ons). It also includes macros, globals and
34 * struct definitions shared by more than one alias*.c file.
36 * This include file is intended to be used only within the aliasing
37 * software. Outside world interfaces are defined in alias.h
39 * This software is placed into the public domain with no restrictions
40 * on its distribution.
42 * Initial version: August, 1996 (cjm)
44 * <updated several times by original author and Eivind Eklund>
47 #ifndef _ALIAS_LOCAL_H_
48 #define _ALIAS_LOCAL_H_
53 * The following macro is used to update an
54 * internet checksum. "delta" is a 32-bit
55 * accumulation of all the changes to the
56 * checksum (adding in new 16-bit words and
57 * subtracting out old words), and "cksum"
58 * is the checksum value to be updated.
60 #define ADJUST_CHECKSUM(acc, cksum) \
65 acc = (acc >> 16) + (acc & 0xffff); \
67 cksum = (u_short) ~acc; \
69 acc = (acc >> 16) + (acc & 0xffff); \
71 cksum = (u_short) acc; \
77 extern int packetAliasMode
;
81 /* General utilities */
82 u_short
IpChecksum(struct ip
*_pip
);
83 u_short
TcpChecksum(struct ip
*_pip
);
84 void DifferentialChecksum(u_short
*_cksum
, u_short
*_new
, u_short
*_old
,
87 /* Internal data access */
89 FindIcmpIn(struct in_addr _dst_addr
, struct in_addr _alias_addr
,
90 u_short _id_alias
, int _create
);
92 FindIcmpOut(struct in_addr _src_addr
, struct in_addr _dst_addr
,
93 u_short _id
, int _create
);
95 FindFragmentIn1(struct in_addr _dst_addr
, struct in_addr _alias_addr
,
98 FindFragmentIn2(struct in_addr _dst_addr
, struct in_addr _alias_addr
,
101 AddFragmentPtrLink(struct in_addr _dst_addr
, u_short _ip_id
);
103 FindFragmentPtr(struct in_addr _dst_addr
, u_short _ip_id
);
105 FindProtoIn(struct in_addr _dst_addr
, struct in_addr _alias_addr
,
108 FindProtoOut(struct in_addr _src_addr
, struct in_addr _dst_addr
,
111 FindUdpTcpIn(struct in_addr _dst_addr
, struct in_addr _alias_addr
,
112 u_short _dst_port
, u_short _alias_port
, u_char _proto
, int _create
);
114 FindUdpTcpOut(struct in_addr _src_addr
, struct in_addr _dst_addr
,
115 u_short _src_port
, u_short _dst_port
, u_char _proto
, int _create
);
117 AddPptp(struct in_addr _src_addr
, struct in_addr _dst_addr
,
118 struct in_addr _alias_addr
, u_int16_t _src_call_id
);
120 FindPptpOutByCallId(struct in_addr _src_addr
,
121 struct in_addr _dst_addr
, u_int16_t _src_call_id
);
123 FindPptpInByCallId(struct in_addr _dst_addr
,
124 struct in_addr _alias_addr
, u_int16_t _dst_call_id
);
126 FindPptpOutByPeerCallId(struct in_addr _src_addr
,
127 struct in_addr _dst_addr
, u_int16_t _dst_call_id
);
129 FindPptpInByPeerCallId(struct in_addr _dst_addr
,
130 struct in_addr _alias_addr
, u_int16_t _alias_call_id
);
132 FindRtspOut(struct in_addr _src_addr
, struct in_addr _dst_addr
,
133 u_short _src_port
, u_short _alias_port
, u_char _proto
);
135 FindOriginalAddress(struct in_addr _alias_addr
);
137 FindAliasAddress(struct in_addr _original_addr
);
139 /* External data access/modification */
140 int FindNewPortGroup(struct in_addr _dst_addr
, struct in_addr _alias_addr
,
141 u_short _src_port
, u_short _dst_port
, u_short _port_count
,
142 u_char _proto
, u_char _align
);
143 void GetFragmentAddr(struct alias_link
*_link
, struct in_addr
*_src_addr
);
144 void SetFragmentAddr(struct alias_link
*_link
, struct in_addr _src_addr
);
145 void GetFragmentPtr(struct alias_link
*_link
, char **_fptr
);
146 void SetFragmentPtr(struct alias_link
*_link
, char *fptr
);
147 void SetStateIn(struct alias_link
*_link
, int _state
);
148 void SetStateOut(struct alias_link
*_link
, int _state
);
149 int GetStateIn(struct alias_link
*_link
);
150 int GetStateOut(struct alias_link
*_link
);
152 GetOriginalAddress(struct alias_link
*_link
);
154 GetDestAddress(struct alias_link
*_link
);
156 GetAliasAddress(struct alias_link
*_link
);
158 GetDefaultAliasAddress(void);
159 void SetDefaultAliasAddress(struct in_addr _alias_addr
);
160 u_short
GetOriginalPort(struct alias_link
*_link
);
161 u_short
GetAliasPort(struct alias_link
*_link
);
163 GetProxyAddress(struct alias_link
*_link
);
164 void SetProxyAddress(struct alias_link
*_link
, struct in_addr _addr
);
165 u_short
GetProxyPort(struct alias_link
*_link
);
166 void SetProxyPort(struct alias_link
*_link
, u_short _port
);
167 void SetAckModified(struct alias_link
*_link
);
168 int GetAckModified(struct alias_link
*_link
);
169 int GetDeltaAckIn(struct ip
*_pip
, struct alias_link
*_link
);
170 int GetDeltaSeqOut(struct ip
*_pip
, struct alias_link
*_link
);
171 void AddSeq(struct ip
*_pip
, struct alias_link
*_link
, int _delta
);
172 void SetExpire(struct alias_link
*_link
, int _expire
);
173 void ClearCheckNewLink(void);
174 void SetLastLineCrlfTermed(struct alias_link
*_link
, int _yes
);
175 int GetLastLineCrlfTermed(struct alias_link
*_link
);
176 void SetDestCallId(struct alias_link
*_link
, u_int16_t _cid
);
178 void PunchFWHole(struct alias_link
*_link
);
181 /* Housekeeping function */
182 void HouseKeeping(void);
184 /* Tcp specfic routines */
185 /* lint -save -library Suppress flexelint warnings */
188 void AliasHandleFtpOut(struct ip
*_pip
, struct alias_link
*_link
,
192 void AliasHandleIrcOut(struct ip
*_pip
, struct alias_link
*_link
,
196 void AliasHandleRtspOut(struct ip
*_pip
, struct alias_link
*_link
,
200 void AliasHandlePptpOut(struct ip
*_pip
, struct alias_link
*_link
);
201 void AliasHandlePptpIn(struct ip
*_pip
, struct alias_link
*_link
);
202 int AliasHandlePptpGreOut(struct ip
*_pip
);
203 int AliasHandlePptpGreIn(struct ip
*_pip
);
205 /* NetBIOS routines */
206 int AliasHandleUdpNbt(struct ip
*_pip
, struct alias_link
*_link
,
207 struct in_addr
*_alias_address
, u_short _alias_port
);
208 int AliasHandleUdpNbtNS(struct ip
*_pip
, struct alias_link
*_link
,
209 struct in_addr
*_alias_address
, u_short
*_alias_port
,
210 struct in_addr
*_original_address
, u_short
*_original_port
);
212 /* CUSeeMe routines */
213 void AliasHandleCUSeeMeOut(struct ip
*_pip
, struct alias_link
*_link
);
214 void AliasHandleCUSeeMeIn(struct ip
*_pip
, struct in_addr _original_addr
);
216 /* Transparent proxy routines */
217 int ProxyCheck(struct ip
*_pip
, struct in_addr
*_proxy_server_addr
,
218 u_short
*_proxy_server_port
);
219 void ProxyModify(struct alias_link
*_link
, struct ip
*_pip
,
220 int _maxpacketsize
, int _proxy_type
);
222 enum alias_tcp_state
{
223 ALIAS_TCP_STATE_NOT_CONNECTED
,
224 ALIAS_TCP_STATE_CONNECTED
,
225 ALIAS_TCP_STATE_DISCONNECTED
230 #endif /* !_ALIAS_LOCAL_H_ */