]>
Commit | Line | Data |
---|---|---|
b7080c8e | 1 | /* |
7ba0088d A |
2 | * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
a2c93a76 A |
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. | |
7ba0088d | 11 | * |
a2c93a76 A |
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 | |
7ba0088d A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
a2c93a76 A |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
7ba0088d A |
19 | * |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | /*- | |
23 | * Copyright (c) 2001 Charles Mott <cmott@scientech.com> | |
24 | * All rights reserved. | |
25 | * | |
26 | * Redistribution and use in source and binary forms, with or without | |
27 | * modification, are permitted provided that the following conditions | |
28 | * are met: | |
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. | |
34 | * | |
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 | |
45 | * SUCH DAMAGE. | |
46 | * | |
47 | * Based upon: | |
48 | * $FreeBSD: src/lib/libalias/alias_local.h,v 1.10.2.5 2001/08/01 09:52:26 obrien Exp $ | |
b7080c8e A |
49 | */ |
50 | ||
51 | /* | |
7ba0088d A |
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. | |
56 | * | |
57 | * This include file is intended to be used only within the aliasing | |
58 | * software. Outside world interfaces are defined in alias.h | |
59 | * | |
60 | * This software is placed into the public domain with no restrictions | |
61 | * on its distribution. | |
62 | * | |
63 | * Initial version: August, 1996 (cjm) | |
64 | * | |
65 | * <updated several times by original author and Eivind Eklund> | |
66 | */ | |
67 | ||
68 | #ifndef _ALIAS_LOCAL_H_ | |
69 | #define _ALIAS_LOCAL_H_ | |
b7080c8e | 70 | |
7ba0088d A |
71 | #ifndef NULL |
72 | #define NULL 0 | |
73 | #endif | |
74 | ||
75 | /* Macros */ | |
b7080c8e A |
76 | |
77 | /* | |
7ba0088d A |
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. | |
84 | */ | |
85 | #define ADJUST_CHECKSUM(acc, cksum) \ | |
86 | do { \ | |
87 | acc += cksum; \ | |
88 | if (acc < 0) { \ | |
89 | acc = -acc; \ | |
90 | acc = (acc >> 16) + (acc & 0xffff); \ | |
91 | acc += acc >> 16; \ | |
92 | cksum = (u_short) ~acc; \ | |
93 | } else { \ | |
94 | acc = (acc >> 16) + (acc & 0xffff); \ | |
95 | acc += acc >> 16; \ | |
96 | cksum = (u_short) acc; \ | |
97 | } \ | |
98 | } while (0) | |
99 | ||
100 | /* Globals */ | |
b7080c8e A |
101 | |
102 | extern int packetAliasMode; | |
103 | ||
104 | ||
7ba0088d | 105 | /* Structs */ |
b7080c8e A |
106 | |
107 | struct alias_link; /* Incomplete structure */ | |
108 | ||
109 | ||
7ba0088d | 110 | /* Prototypes */ |
b7080c8e A |
111 | |
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); | |
116 | ||
117 | /* Internal data access */ | |
118 | struct alias_link * | |
7ba0088d | 119 | FindIcmpIn(struct in_addr, struct in_addr, u_short, int); |
b7080c8e A |
120 | |
121 | struct alias_link * | |
7ba0088d | 122 | FindIcmpOut(struct in_addr, struct in_addr, u_short, int); |
b7080c8e A |
123 | |
124 | struct alias_link * | |
125 | FindFragmentIn1(struct in_addr, struct in_addr, u_short); | |
126 | ||
127 | struct alias_link * | |
128 | FindFragmentIn2(struct in_addr, struct in_addr, u_short); | |
129 | ||
130 | struct alias_link * | |
131 | AddFragmentPtrLink(struct in_addr, u_short); | |
132 | ||
133 | struct alias_link * | |
134 | FindFragmentPtr(struct in_addr, u_short); | |
135 | ||
136 | struct alias_link * | |
7ba0088d A |
137 | FindProtoIn(struct in_addr, struct in_addr, u_char); |
138 | ||
139 | struct alias_link * | |
140 | FindProtoOut(struct in_addr, struct in_addr, u_char); | |
141 | ||
142 | struct alias_link * | |
143 | FindUdpTcpIn (struct in_addr, struct in_addr, u_short, u_short, u_char, int); | |
144 | ||
145 | struct alias_link * | |
146 | FindUdpTcpOut(struct in_addr, struct in_addr, u_short, u_short, u_char, int); | |
147 | ||
148 | struct alias_link * | |
149 | AddPptp(struct in_addr, struct in_addr, struct in_addr, u_int16_t); | |
150 | ||
151 | struct alias_link * | |
152 | FindPptpOutByCallId(struct in_addr, struct in_addr, u_int16_t); | |
153 | ||
154 | struct alias_link * | |
155 | FindPptpInByCallId(struct in_addr, struct in_addr, u_int16_t); | |
156 | ||
157 | struct alias_link * | |
158 | FindPptpOutByPeerCallId(struct in_addr, struct in_addr, u_int16_t); | |
159 | ||
160 | struct alias_link * | |
161 | FindPptpInByPeerCallId(struct in_addr, struct in_addr, u_int16_t); | |
b7080c8e A |
162 | |
163 | struct alias_link * | |
7ba0088d | 164 | FindRtspOut(struct in_addr, struct in_addr, u_short, u_short, u_char); |
b7080c8e A |
165 | |
166 | struct in_addr | |
167 | FindOriginalAddress(struct in_addr); | |
168 | ||
169 | struct in_addr | |
170 | FindAliasAddress(struct in_addr); | |
171 | ||
172 | /* External data access/modification */ | |
7ba0088d A |
173 | int FindNewPortGroup(struct in_addr, struct in_addr, |
174 | u_short, u_short, u_short, u_char, u_char); | |
b7080c8e A |
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); | |
7ba0088d A |
201 | void SetLastLineCrlfTermed(struct alias_link *, int); |
202 | int GetLastLineCrlfTermed(struct alias_link *); | |
203 | void SetDestCallId(struct alias_link *, u_int16_t); | |
b7080c8e A |
204 | #ifndef NO_FW_PUNCH |
205 | void PunchFWHole(struct alias_link *); | |
206 | #endif | |
207 | ||
208 | ||
209 | /* Housekeeping function */ | |
210 | void HouseKeeping(void); | |
211 | ||
212 | /* Tcp specfic routines */ | |
213 | /*lint -save -library Suppress flexelint warnings */ | |
214 | ||
215 | /* FTP routines */ | |
216 | void AliasHandleFtpOut(struct ip *, struct alias_link *, int); | |
217 | ||
218 | /* IRC routines */ | |
219 | void AliasHandleIrcOut(struct ip *, struct alias_link *, int); | |
220 | ||
7ba0088d A |
221 | /* RTSP routines */ |
222 | void AliasHandleRtspOut(struct ip *, struct alias_link *, int); | |
223 | ||
224 | /* PPTP routines */ | |
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 *); | |
229 | ||
b7080c8e A |
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 *); | |
233 | ||
234 | /* CUSeeMe routines */ | |
235 | void AliasHandleCUSeeMeOut(struct ip *, struct alias_link *); | |
236 | void AliasHandleCUSeeMeIn(struct ip *, struct in_addr); | |
237 | ||
238 | /* Transparent proxy routines */ | |
239 | int ProxyCheck(struct ip *, struct in_addr *, u_short *); | |
240 | void ProxyModify(struct alias_link *, struct ip *, int, int); | |
241 | ||
242 | ||
243 | enum alias_tcp_state { | |
7ba0088d A |
244 | ALIAS_TCP_STATE_NOT_CONNECTED, |
245 | ALIAS_TCP_STATE_CONNECTED, | |
246 | ALIAS_TCP_STATE_DISCONNECTED | |
b7080c8e A |
247 | }; |
248 | ||
b7080c8e | 249 | /*lint -restore */ |
7ba0088d A |
250 | |
251 | #endif /* !_ALIAS_LOCAL_H_ */ |