]> git.saurik.com Git - apple/network_cmds.git/blame - alias/alias_local.h
network_cmds-245.8.tar.gz
[apple/network_cmds.git] / alias / alias_local.h
CommitLineData
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
102extern int packetAliasMode;
103
104
7ba0088d 105/* Structs */
b7080c8e
A
106
107struct alias_link; /* Incomplete structure */
108
109
7ba0088d 110/* Prototypes */
b7080c8e
A
111
112/* General utilities */
113u_short IpChecksum(struct ip *);
114u_short TcpChecksum(struct ip *);
115void DifferentialChecksum(u_short *, u_short *, u_short *, int);
116
117/* Internal data access */
118struct alias_link *
7ba0088d 119FindIcmpIn(struct in_addr, struct in_addr, u_short, int);
b7080c8e
A
120
121struct alias_link *
7ba0088d 122FindIcmpOut(struct in_addr, struct in_addr, u_short, int);
b7080c8e
A
123
124struct alias_link *
125FindFragmentIn1(struct in_addr, struct in_addr, u_short);
126
127struct alias_link *
128FindFragmentIn2(struct in_addr, struct in_addr, u_short);
129
130struct alias_link *
131AddFragmentPtrLink(struct in_addr, u_short);
132
133struct alias_link *
134FindFragmentPtr(struct in_addr, u_short);
135
136struct alias_link *
7ba0088d
A
137FindProtoIn(struct in_addr, struct in_addr, u_char);
138
139struct alias_link *
140FindProtoOut(struct in_addr, struct in_addr, u_char);
141
142struct alias_link *
143FindUdpTcpIn (struct in_addr, struct in_addr, u_short, u_short, u_char, int);
144
145struct alias_link *
146FindUdpTcpOut(struct in_addr, struct in_addr, u_short, u_short, u_char, int);
147
148struct alias_link *
149AddPptp(struct in_addr, struct in_addr, struct in_addr, u_int16_t);
150
151struct alias_link *
152FindPptpOutByCallId(struct in_addr, struct in_addr, u_int16_t);
153
154struct alias_link *
155FindPptpInByCallId(struct in_addr, struct in_addr, u_int16_t);
156
157struct alias_link *
158FindPptpOutByPeerCallId(struct in_addr, struct in_addr, u_int16_t);
159
160struct alias_link *
161FindPptpInByPeerCallId(struct in_addr, struct in_addr, u_int16_t);
b7080c8e
A
162
163struct alias_link *
7ba0088d 164FindRtspOut(struct in_addr, struct in_addr, u_short, u_short, u_char);
b7080c8e
A
165
166struct in_addr
167FindOriginalAddress(struct in_addr);
168
169struct in_addr
170FindAliasAddress(struct in_addr);
171
172/* External data access/modification */
7ba0088d
A
173int FindNewPortGroup(struct in_addr, struct in_addr,
174 u_short, u_short, u_short, u_char, u_char);
b7080c8e
A
175void GetFragmentAddr(struct alias_link *, struct in_addr *);
176void SetFragmentAddr(struct alias_link *, struct in_addr);
177void GetFragmentPtr(struct alias_link *, char **);
178void SetFragmentPtr(struct alias_link *, char *);
179void SetStateIn(struct alias_link *, int);
180void SetStateOut(struct alias_link *, int);
181int GetStateIn(struct alias_link *);
182int GetStateOut(struct alias_link *);
183struct in_addr GetOriginalAddress(struct alias_link *);
184struct in_addr GetDestAddress(struct alias_link *);
185struct in_addr GetAliasAddress(struct alias_link *);
186struct in_addr GetDefaultAliasAddress(void);
187void SetDefaultAliasAddress(struct in_addr);
188u_short GetOriginalPort(struct alias_link *);
189u_short GetAliasPort(struct alias_link *);
190struct in_addr GetProxyAddress(struct alias_link *);
191void SetProxyAddress(struct alias_link *, struct in_addr);
192u_short GetProxyPort(struct alias_link *);
193void SetProxyPort(struct alias_link *, u_short);
194void SetAckModified(struct alias_link *);
195int GetAckModified(struct alias_link *);
196int GetDeltaAckIn(struct ip *, struct alias_link *);
197int GetDeltaSeqOut(struct ip *, struct alias_link *);
198void AddSeq(struct ip *, struct alias_link *, int);
199void SetExpire(struct alias_link *, int);
200void ClearCheckNewLink(void);
7ba0088d
A
201void SetLastLineCrlfTermed(struct alias_link *, int);
202int GetLastLineCrlfTermed(struct alias_link *);
203void SetDestCallId(struct alias_link *, u_int16_t);
b7080c8e
A
204#ifndef NO_FW_PUNCH
205void PunchFWHole(struct alias_link *);
206#endif
207
208
209/* Housekeeping function */
210void HouseKeeping(void);
211
212/* Tcp specfic routines */
213/*lint -save -library Suppress flexelint warnings */
214
215/* FTP routines */
216void AliasHandleFtpOut(struct ip *, struct alias_link *, int);
217
218/* IRC routines */
219void AliasHandleIrcOut(struct ip *, struct alias_link *, int);
220
7ba0088d
A
221/* RTSP routines */
222void AliasHandleRtspOut(struct ip *, struct alias_link *, int);
223
224/* PPTP routines */
225void AliasHandlePptpOut(struct ip *, struct alias_link *);
226void AliasHandlePptpIn(struct ip *, struct alias_link *);
227int AliasHandlePptpGreOut(struct ip *);
228int AliasHandlePptpGreIn(struct ip *);
229
b7080c8e
A
230/* NetBIOS routines */
231int AliasHandleUdpNbt(struct ip *, struct alias_link *, struct in_addr *, u_short);
232int AliasHandleUdpNbtNS(struct ip *, struct alias_link *, struct in_addr *, u_short *, struct in_addr *, u_short *);
233
234/* CUSeeMe routines */
235void AliasHandleCUSeeMeOut(struct ip *, struct alias_link *);
236void AliasHandleCUSeeMeIn(struct ip *, struct in_addr);
237
238/* Transparent proxy routines */
239int ProxyCheck(struct ip *, struct in_addr *, u_short *);
240void ProxyModify(struct alias_link *, struct ip *, int, int);
241
242
243enum 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_ */