2 * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 * Copyright (c) 2001 Charles Mott <cmott@scientech.com>
27 * All rights reserved.
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
32 * 1. Redistributions of source code must retain the above copyright
33 * notice, this list of conditions and the following disclaimer.
34 * 2. Redistributions in binary form must reproduce the above copyright
35 * notice, this list of conditions and the following disclaimer in the
36 * documentation and/or other materials provided with the distribution.
38 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
39 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
41 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
42 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
43 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
44 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
45 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
46 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
47 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * $FreeBSD: src/lib/libalias/alias_local.h,v 1.10.2.5 2001/08/01 09:52:26 obrien Exp $
55 * Alias_local.h contains the function prototypes for alias.c,
56 * alias_db.c, alias_util.c and alias_ftp.c, alias_irc.c (as well
57 * as any future add-ons). It also includes macros, globals and
58 * struct definitions shared by more than one alias*.c file.
60 * This include file is intended to be used only within the aliasing
61 * software. Outside world interfaces are defined in alias.h
63 * This software is placed into the public domain with no restrictions
64 * on its distribution.
66 * Initial version: August, 1996 (cjm)
68 * <updated several times by original author and Eivind Eklund>
71 #ifndef _ALIAS_LOCAL_H_
72 #define _ALIAS_LOCAL_H_
81 * The following macro is used to update an
82 * internet checksum. "delta" is a 32-bit
83 * accumulation of all the changes to the
84 * checksum (adding in new 16-bit words and
85 * subtracting out old words), and "cksum"
86 * is the checksum value to be updated.
88 #define ADJUST_CHECKSUM(acc, cksum) \
93 acc = (acc >> 16) + (acc & 0xffff); \
95 cksum = (u_short) ~acc; \
97 acc = (acc >> 16) + (acc & 0xffff); \
99 cksum = (u_short) acc; \
105 extern int packetAliasMode
;
110 struct alias_link
; /* Incomplete structure */
115 /* General utilities */
116 u_short
IpChecksum(struct ip
*);
117 u_short
TcpChecksum(struct ip
*);
118 void DifferentialChecksum(u_short
*, u_short
*, u_short
*, int);
120 /* Internal data access */
122 FindIcmpIn(struct in_addr
, struct in_addr
, u_short
, int);
125 FindIcmpOut(struct in_addr
, struct in_addr
, u_short
, int);
128 FindFragmentIn1(struct in_addr
, struct in_addr
, u_short
);
131 FindFragmentIn2(struct in_addr
, struct in_addr
, u_short
);
134 AddFragmentPtrLink(struct in_addr
, u_short
);
137 FindFragmentPtr(struct in_addr
, u_short
);
140 FindProtoIn(struct in_addr
, struct in_addr
, u_char
);
143 FindProtoOut(struct in_addr
, struct in_addr
, u_char
);
146 FindUdpTcpIn (struct in_addr
, struct in_addr
, u_short
, u_short
, u_char
, int);
149 FindUdpTcpOut(struct in_addr
, struct in_addr
, u_short
, u_short
, u_char
, int);
152 AddPptp(struct in_addr
, struct in_addr
, struct in_addr
, u_int16_t
);
155 FindPptpOutByCallId(struct in_addr
, struct in_addr
, u_int16_t
);
158 FindPptpInByCallId(struct in_addr
, struct in_addr
, u_int16_t
);
161 FindPptpOutByPeerCallId(struct in_addr
, struct in_addr
, u_int16_t
);
164 FindPptpInByPeerCallId(struct in_addr
, struct in_addr
, u_int16_t
);
167 FindRtspOut(struct in_addr
, struct in_addr
, u_short
, u_short
, u_char
);
170 FindOriginalAddress(struct in_addr
);
173 FindAliasAddress(struct in_addr
);
175 /* External data access/modification */
176 int FindNewPortGroup(struct in_addr
, struct in_addr
,
177 u_short
, u_short
, u_short
, u_char
, u_char
);
178 void GetFragmentAddr(struct alias_link
*, struct in_addr
*);
179 void SetFragmentAddr(struct alias_link
*, struct in_addr
);
180 void GetFragmentPtr(struct alias_link
*, char **);
181 void SetFragmentPtr(struct alias_link
*, char *);
182 void SetStateIn(struct alias_link
*, int);
183 void SetStateOut(struct alias_link
*, int);
184 int GetStateIn(struct alias_link
*);
185 int GetStateOut(struct alias_link
*);
186 struct in_addr
GetOriginalAddress(struct alias_link
*);
187 struct in_addr
GetDestAddress(struct alias_link
*);
188 struct in_addr
GetAliasAddress(struct alias_link
*);
189 struct in_addr
GetDefaultAliasAddress(void);
190 void SetDefaultAliasAddress(struct in_addr
);
191 u_short
GetOriginalPort(struct alias_link
*);
192 u_short
GetAliasPort(struct alias_link
*);
193 struct in_addr
GetProxyAddress(struct alias_link
*);
194 void SetProxyAddress(struct alias_link
*, struct in_addr
);
195 u_short
GetProxyPort(struct alias_link
*);
196 void SetProxyPort(struct alias_link
*, u_short
);
197 void SetAckModified(struct alias_link
*);
198 int GetAckModified(struct alias_link
*);
199 int GetDeltaAckIn(struct ip
*, struct alias_link
*);
200 int GetDeltaSeqOut(struct ip
*, struct alias_link
*);
201 void AddSeq(struct ip
*, struct alias_link
*, int);
202 void SetExpire(struct alias_link
*, int);
203 void ClearCheckNewLink(void);
204 void SetLastLineCrlfTermed(struct alias_link
*, int);
205 int GetLastLineCrlfTermed(struct alias_link
*);
206 void SetDestCallId(struct alias_link
*, u_int16_t
);
208 void PunchFWHole(struct alias_link
*);
212 /* Housekeeping function */
213 void HouseKeeping(void);
215 /* Tcp specfic routines */
216 /*lint -save -library Suppress flexelint warnings */
219 void AliasHandleFtpOut(struct ip
*, struct alias_link
*, int);
222 void AliasHandleIrcOut(struct ip
*, struct alias_link
*, int);
225 void AliasHandleRtspOut(struct ip
*, struct alias_link
*, int);
228 void AliasHandlePptpOut(struct ip
*, struct alias_link
*);
229 void AliasHandlePptpIn(struct ip
*, struct alias_link
*);
230 int AliasHandlePptpGreOut(struct ip
*);
231 int AliasHandlePptpGreIn(struct ip
*);
233 /* NetBIOS routines */
234 int AliasHandleUdpNbt(struct ip
*, struct alias_link
*, struct in_addr
*, u_short
);
235 int AliasHandleUdpNbtNS(struct ip
*, struct alias_link
*, struct in_addr
*, u_short
*, struct in_addr
*, u_short
*);
237 /* CUSeeMe routines */
238 void AliasHandleCUSeeMeOut(struct ip
*, struct alias_link
*);
239 void AliasHandleCUSeeMeIn(struct ip
*, struct in_addr
);
241 /* Transparent proxy routines */
242 int ProxyCheck(struct ip
*, struct in_addr
*, u_short
*);
243 void ProxyModify(struct alias_link
*, struct ip
*, int, int);
246 enum alias_tcp_state
{
247 ALIAS_TCP_STATE_NOT_CONNECTED
,
248 ALIAS_TCP_STATE_CONNECTED
,
249 ALIAS_TCP_STATE_DISCONNECTED
254 #endif /* !_ALIAS_LOCAL_H_ */