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