2001-06-04 15:09:51 +00:00
|
|
|
/*-
|
2001-11-03 11:34:09 +00:00
|
|
|
* Copyright (c) 2001 Charles Mott <cm@linktel.net>
|
2001-06-04 15:09:51 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
1999-02-27 02:16:01 +00:00
|
|
|
/*
|
2001-03-25 12:05:10 +00:00
|
|
|
* Alias_local.h contains the function prototypes for alias.c,
|
|
|
|
* alias_db.c, alias_util.c and alias_ftp.c, alias_irc.c (as well
|
|
|
|
* as any future add-ons). It also includes macros, globals and
|
|
|
|
* struct definitions shared by more than one alias*.c file.
|
|
|
|
*
|
|
|
|
* This include file is intended to be used only within the aliasing
|
|
|
|
* software. Outside world interfaces are defined in alias.h
|
|
|
|
*
|
|
|
|
* This software is placed into the public domain with no restrictions
|
|
|
|
* on its distribution.
|
|
|
|
*
|
2002-07-01 11:19:40 +00:00
|
|
|
* Initial version: August, 1996 (cjm)
|
2001-03-25 12:05:10 +00:00
|
|
|
*
|
|
|
|
* <updated several times by original author and Eivind Eklund>
|
1999-02-27 02:16:01 +00:00
|
|
|
*/
|
|
|
|
|
2001-03-25 12:05:10 +00:00
|
|
|
#ifndef _ALIAS_LOCAL_H_
|
|
|
|
#define _ALIAS_LOCAL_H_
|
1999-02-27 02:16:01 +00:00
|
|
|
|
2001-03-25 12:05:10 +00:00
|
|
|
/* Macros */
|
1999-02-27 02:16:01 +00:00
|
|
|
|
|
|
|
/*
|
2001-03-25 12:05:10 +00:00
|
|
|
* The following macro is used to update an
|
|
|
|
* internet checksum. "delta" is a 32-bit
|
|
|
|
* accumulation of all the changes to the
|
|
|
|
* checksum (adding in new 16-bit words and
|
|
|
|
* subtracting out old words), and "cksum"
|
|
|
|
* is the checksum value to be updated.
|
|
|
|
*/
|
|
|
|
#define ADJUST_CHECKSUM(acc, cksum) \
|
|
|
|
do { \
|
|
|
|
acc += cksum; \
|
|
|
|
if (acc < 0) { \
|
|
|
|
acc = -acc; \
|
|
|
|
acc = (acc >> 16) + (acc & 0xffff); \
|
|
|
|
acc += acc >> 16; \
|
|
|
|
cksum = (u_short) ~acc; \
|
|
|
|
} else { \
|
|
|
|
acc = (acc >> 16) + (acc & 0xffff); \
|
|
|
|
acc += acc >> 16; \
|
|
|
|
cksum = (u_short) acc; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
/* Globals */
|
1999-02-27 02:16:01 +00:00
|
|
|
|
1997-05-23 04:41:31 +00:00
|
|
|
extern int packetAliasMode;
|
|
|
|
|
2001-03-25 12:05:10 +00:00
|
|
|
/* Prototypes */
|
1997-05-23 04:41:31 +00:00
|
|
|
|
|
|
|
/* General utilities */
|
2001-03-25 12:05:10 +00:00
|
|
|
u_short IpChecksum(struct ip *_pip);
|
|
|
|
u_short TcpChecksum(struct ip *_pip);
|
|
|
|
void DifferentialChecksum(u_short *_cksum, u_short *_new, u_short *_old,
|
|
|
|
int _n);
|
1997-05-23 04:41:31 +00:00
|
|
|
|
|
|
|
/* Internal data access */
|
|
|
|
struct alias_link *
|
2001-03-25 12:05:10 +00:00
|
|
|
FindIcmpIn(struct in_addr _dst_addr, struct in_addr _alias_addr,
|
|
|
|
u_short _id_alias, int _create);
|
1997-05-23 04:41:31 +00:00
|
|
|
struct alias_link *
|
2001-03-25 12:05:10 +00:00
|
|
|
FindIcmpOut(struct in_addr _src_addr, struct in_addr _dst_addr,
|
|
|
|
u_short _id, int _create);
|
1997-05-23 04:41:31 +00:00
|
|
|
struct alias_link *
|
2001-03-25 12:05:10 +00:00
|
|
|
FindFragmentIn1(struct in_addr _dst_addr, struct in_addr _alias_addr,
|
|
|
|
u_short _ip_id);
|
1997-05-23 04:41:31 +00:00
|
|
|
struct alias_link *
|
2001-03-25 12:05:10 +00:00
|
|
|
FindFragmentIn2(struct in_addr _dst_addr, struct in_addr _alias_addr,
|
|
|
|
u_short _ip_id);
|
1997-05-23 04:41:31 +00:00
|
|
|
struct alias_link *
|
2001-03-25 12:05:10 +00:00
|
|
|
AddFragmentPtrLink(struct in_addr _dst_addr, u_short _ip_id);
|
1997-05-23 04:41:31 +00:00
|
|
|
struct alias_link *
|
2001-03-25 12:05:10 +00:00
|
|
|
FindFragmentPtr(struct in_addr _dst_addr, u_short _ip_id);
|
2000-04-18 10:18:21 +00:00
|
|
|
struct alias_link *
|
2001-03-25 12:05:10 +00:00
|
|
|
FindProtoIn(struct in_addr _dst_addr, struct in_addr _alias_addr,
|
|
|
|
u_char _proto);
|
2000-04-18 10:18:21 +00:00
|
|
|
struct alias_link *
|
2001-03-25 12:05:10 +00:00
|
|
|
FindProtoOut(struct in_addr _src_addr, struct in_addr _dst_addr,
|
|
|
|
u_char _proto);
|
1997-05-23 04:41:31 +00:00
|
|
|
struct alias_link *
|
2001-03-25 12:05:10 +00:00
|
|
|
FindUdpTcpIn(struct in_addr _dst_addr, struct in_addr _alias_addr,
|
|
|
|
u_short _dst_port, u_short _alias_port, u_char _proto, int _create);
|
1997-05-23 04:41:31 +00:00
|
|
|
struct alias_link *
|
2001-03-25 12:05:10 +00:00
|
|
|
FindUdpTcpOut(struct in_addr _src_addr, struct in_addr _dst_addr,
|
|
|
|
u_short _src_port, u_short _dst_port, u_char _proto, int _create);
|
2000-06-20 11:41:48 +00:00
|
|
|
struct alias_link *
|
2001-03-25 12:05:10 +00:00
|
|
|
AddPptp(struct in_addr _src_addr, struct in_addr _dst_addr,
|
|
|
|
struct in_addr _alias_addr, u_int16_t _src_call_id);
|
2000-06-20 11:41:48 +00:00
|
|
|
struct alias_link *
|
2001-03-25 12:05:10 +00:00
|
|
|
FindPptpOutByCallId(struct in_addr _src_addr,
|
|
|
|
struct in_addr _dst_addr, u_int16_t _src_call_id);
|
2000-10-30 12:39:41 +00:00
|
|
|
struct alias_link *
|
2001-03-25 12:05:10 +00:00
|
|
|
FindPptpInByCallId(struct in_addr _dst_addr,
|
|
|
|
struct in_addr _alias_addr, u_int16_t _dst_call_id);
|
2000-10-30 12:39:41 +00:00
|
|
|
struct alias_link *
|
2001-03-25 12:05:10 +00:00
|
|
|
FindPptpOutByPeerCallId(struct in_addr _src_addr,
|
|
|
|
struct in_addr _dst_addr, u_int16_t _dst_call_id);
|
2000-10-30 12:39:41 +00:00
|
|
|
struct alias_link *
|
2001-03-25 12:05:10 +00:00
|
|
|
FindPptpInByPeerCallId(struct in_addr _dst_addr,
|
|
|
|
struct in_addr _alias_addr, u_int16_t _alias_call_id);
|
2000-07-26 23:15:46 +00:00
|
|
|
struct alias_link *
|
2001-03-25 12:05:10 +00:00
|
|
|
FindRtspOut(struct in_addr _src_addr, struct in_addr _dst_addr,
|
|
|
|
u_short _src_port, u_short _alias_port, u_char _proto);
|
1997-05-23 04:41:31 +00:00
|
|
|
struct in_addr
|
2001-03-25 12:05:10 +00:00
|
|
|
FindOriginalAddress(struct in_addr _alias_addr);
|
1997-05-23 04:41:31 +00:00
|
|
|
struct in_addr
|
2001-03-25 12:05:10 +00:00
|
|
|
FindAliasAddress(struct in_addr _original_addr);
|
1997-05-23 04:41:31 +00:00
|
|
|
|
|
|
|
/* External data access/modification */
|
2001-03-25 12:05:10 +00:00
|
|
|
int FindNewPortGroup(struct in_addr _dst_addr, struct in_addr _alias_addr,
|
|
|
|
u_short _src_port, u_short _dst_port, u_short _port_count,
|
|
|
|
u_char _proto, u_char _align);
|
|
|
|
void GetFragmentAddr(struct alias_link *_link, struct in_addr *_src_addr);
|
|
|
|
void SetFragmentAddr(struct alias_link *_link, struct in_addr _src_addr);
|
|
|
|
void GetFragmentPtr(struct alias_link *_link, char **_fptr);
|
|
|
|
void SetFragmentPtr(struct alias_link *_link, char *fptr);
|
|
|
|
void SetStateIn(struct alias_link *_link, int _state);
|
|
|
|
void SetStateOut(struct alias_link *_link, int _state);
|
|
|
|
int GetStateIn(struct alias_link *_link);
|
|
|
|
int GetStateOut(struct alias_link *_link);
|
|
|
|
struct in_addr
|
|
|
|
GetOriginalAddress(struct alias_link *_link);
|
|
|
|
struct in_addr
|
|
|
|
GetDestAddress(struct alias_link *_link);
|
|
|
|
struct in_addr
|
|
|
|
GetAliasAddress(struct alias_link *_link);
|
|
|
|
struct in_addr
|
|
|
|
GetDefaultAliasAddress(void);
|
|
|
|
void SetDefaultAliasAddress(struct in_addr _alias_addr);
|
|
|
|
u_short GetOriginalPort(struct alias_link *_link);
|
|
|
|
u_short GetAliasPort(struct alias_link *_link);
|
|
|
|
struct in_addr
|
|
|
|
GetProxyAddress(struct alias_link *_link);
|
|
|
|
void SetProxyAddress(struct alias_link *_link, struct in_addr _addr);
|
|
|
|
u_short GetProxyPort(struct alias_link *_link);
|
|
|
|
void SetProxyPort(struct alias_link *_link, u_short _port);
|
|
|
|
void SetAckModified(struct alias_link *_link);
|
|
|
|
int GetAckModified(struct alias_link *_link);
|
|
|
|
int GetDeltaAckIn(struct ip *_pip, struct alias_link *_link);
|
|
|
|
int GetDeltaSeqOut(struct ip *_pip, struct alias_link *_link);
|
|
|
|
void AddSeq(struct ip *_pip, struct alias_link *_link, int _delta);
|
|
|
|
void SetExpire(struct alias_link *_link, int _expire);
|
|
|
|
void ClearCheckNewLink(void);
|
2001-05-30 14:24:35 +00:00
|
|
|
void SetProtocolFlags(struct alias_link *_link, int _pflags);
|
|
|
|
int GetProtocolFlags(struct alias_link *_link);
|
2001-03-25 12:05:10 +00:00
|
|
|
void SetDestCallId(struct alias_link *_link, u_int16_t _cid);
|
1998-06-06 21:52:37 +00:00
|
|
|
#ifndef NO_FW_PUNCH
|
2001-03-25 12:05:10 +00:00
|
|
|
void PunchFWHole(struct alias_link *_link);
|
1998-06-06 21:52:37 +00:00
|
|
|
#endif
|
1998-01-09 21:13:35 +00:00
|
|
|
|
1997-05-23 04:41:31 +00:00
|
|
|
/* Housekeeping function */
|
2001-03-25 12:05:10 +00:00
|
|
|
void HouseKeeping(void);
|
1997-05-23 04:41:31 +00:00
|
|
|
|
|
|
|
/* Tcp specfic routines */
|
2001-03-25 12:05:10 +00:00
|
|
|
/* lint -save -library Suppress flexelint warnings */
|
1999-02-27 02:16:01 +00:00
|
|
|
|
|
|
|
/* FTP routines */
|
2001-03-25 12:05:10 +00:00
|
|
|
void AliasHandleFtpOut(struct ip *_pip, struct alias_link *_link,
|
|
|
|
int _maxpacketsize);
|
1999-02-27 02:16:01 +00:00
|
|
|
|
|
|
|
/* IRC routines */
|
2001-03-25 12:05:10 +00:00
|
|
|
void AliasHandleIrcOut(struct ip *_pip, struct alias_link *_link,
|
|
|
|
int _maxsize);
|
1999-02-27 02:16:01 +00:00
|
|
|
|
2000-07-26 23:15:46 +00:00
|
|
|
/* RTSP routines */
|
2001-03-25 12:05:10 +00:00
|
|
|
void AliasHandleRtspOut(struct ip *_pip, struct alias_link *_link,
|
|
|
|
int _maxpacketsize);
|
2000-07-26 23:15:46 +00:00
|
|
|
|
2000-06-20 11:41:48 +00:00
|
|
|
/* PPTP routines */
|
2001-03-25 12:05:10 +00:00
|
|
|
void AliasHandlePptpOut(struct ip *_pip, struct alias_link *_link);
|
|
|
|
void AliasHandlePptpIn(struct ip *_pip, struct alias_link *_link);
|
|
|
|
int AliasHandlePptpGreOut(struct ip *_pip);
|
|
|
|
int AliasHandlePptpGreIn(struct ip *_pip);
|
2000-06-20 11:41:48 +00:00
|
|
|
|
1999-02-27 02:16:01 +00:00
|
|
|
/* NetBIOS routines */
|
2001-03-25 12:05:10 +00:00
|
|
|
int AliasHandleUdpNbt(struct ip *_pip, struct alias_link *_link,
|
|
|
|
struct in_addr *_alias_address, u_short _alias_port);
|
|
|
|
int AliasHandleUdpNbtNS(struct ip *_pip, struct alias_link *_link,
|
|
|
|
struct in_addr *_alias_address, u_short *_alias_port,
|
|
|
|
struct in_addr *_original_address, u_short *_original_port);
|
1999-02-27 02:16:01 +00:00
|
|
|
|
|
|
|
/* CUSeeMe routines */
|
2001-03-25 12:05:10 +00:00
|
|
|
void AliasHandleCUSeeMeOut(struct ip *_pip, struct alias_link *_link);
|
|
|
|
void AliasHandleCUSeeMeIn(struct ip *_pip, struct in_addr _original_addr);
|
1998-05-24 03:03:10 +00:00
|
|
|
|
1999-02-27 02:16:01 +00:00
|
|
|
/* Transparent proxy routines */
|
2001-03-25 12:05:10 +00:00
|
|
|
int ProxyCheck(struct ip *_pip, struct in_addr *_proxy_server_addr,
|
|
|
|
u_short *_proxy_server_port);
|
|
|
|
void ProxyModify(struct alias_link *_link, struct ip *_pip,
|
|
|
|
int _maxpacketsize, int _proxy_type);
|
1997-08-03 18:20:03 +00:00
|
|
|
|
1998-01-09 21:13:35 +00:00
|
|
|
enum alias_tcp_state {
|
2001-03-25 12:05:10 +00:00
|
|
|
ALIAS_TCP_STATE_NOT_CONNECTED,
|
|
|
|
ALIAS_TCP_STATE_CONNECTED,
|
|
|
|
ALIAS_TCP_STATE_DISCONNECTED
|
1998-01-09 21:13:35 +00:00
|
|
|
};
|
2001-03-25 12:05:10 +00:00
|
|
|
|
1997-05-23 04:41:31 +00:00
|
|
|
/*lint -restore */
|
2001-03-25 12:05:10 +00:00
|
|
|
|
|
|
|
#endif /* !_ALIAS_LOCAL_H_ */
|