Make header files conform to style(9).
Reviewed by (*): bde (*) alias_local.h only got a cursory glance.
This commit is contained in:
parent
3b34ddbb45
commit
71593f95e0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=74778
@ -97,6 +97,8 @@
|
||||
#include <netinet/tcp.h>
|
||||
#include <netinet/udp.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "alias_local.h"
|
||||
#include "alias.h"
|
||||
|
||||
@ -261,7 +263,7 @@ IcmpAliasIn1(struct ip *pip)
|
||||
/* Adjust ICMP checksum */
|
||||
accumulate = ic->icmp_id;
|
||||
accumulate -= original_id;
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum)
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum);
|
||||
|
||||
/* Put original sequence number back in */
|
||||
ic->icmp_id = original_id;
|
||||
@ -340,7 +342,7 @@ IcmpAliasIn2(struct ip *pip)
|
||||
accumulate -= *sptr;
|
||||
accumulate += ud->uh_sport;
|
||||
accumulate -= original_port;
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum)
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum);
|
||||
|
||||
/* Un-alias address in IP header */
|
||||
DifferentialChecksum(&pip->ip_sum,
|
||||
@ -373,7 +375,7 @@ fragment contained in ICMP data section */
|
||||
accumulate -= *sptr;
|
||||
accumulate += ic2->icmp_id;
|
||||
accumulate -= original_id;
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum)
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum);
|
||||
|
||||
/* Un-alias address in IP header */
|
||||
DifferentialChecksum(&pip->ip_sum,
|
||||
@ -454,7 +456,7 @@ IcmpAliasOut1(struct ip *pip)
|
||||
/* Since data field is being modified, adjust ICMP checksum */
|
||||
accumulate = ic->icmp_id;
|
||||
accumulate -= alias_id;
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum)
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum);
|
||||
|
||||
/* Alias sequence number */
|
||||
ic->icmp_id = alias_id;
|
||||
@ -534,7 +536,7 @@ IcmpAliasOut2(struct ip *pip)
|
||||
accumulate -= *sptr;
|
||||
accumulate += ud->uh_dport;
|
||||
accumulate -= alias_port;
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum)
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum);
|
||||
|
||||
/*
|
||||
* Alias address in IP header if it comes from the host
|
||||
@ -572,7 +574,7 @@ fragment contained in ICMP data section */
|
||||
accumulate -= *sptr;
|
||||
accumulate += ic2->icmp_id;
|
||||
accumulate -= alias_id;
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum)
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum);
|
||||
|
||||
/*
|
||||
* Alias address in IP header if it comes from the host
|
||||
@ -756,7 +758,7 @@ UdpAliasIn(struct ip *pip)
|
||||
sptr = (u_short *) &original_address;
|
||||
accumulate -= *sptr++;
|
||||
accumulate -= *sptr;
|
||||
ADJUST_CHECKSUM(accumulate, ud->uh_sum)
|
||||
ADJUST_CHECKSUM(accumulate, ud->uh_sum);
|
||||
}
|
||||
|
||||
/* Restore original IP address */
|
||||
@ -827,7 +829,7 @@ UdpAliasOut(struct ip *pip)
|
||||
sptr = (u_short *) &alias_address;
|
||||
accumulate -= *sptr++;
|
||||
accumulate -= *sptr;
|
||||
ADJUST_CHECKSUM(accumulate, ud->uh_sum)
|
||||
ADJUST_CHECKSUM(accumulate, ud->uh_sum);
|
||||
}
|
||||
|
||||
/* Put alias port in UDP header */
|
||||
@ -1084,7 +1086,7 @@ TcpAliasOut(struct ip *pip, int maxpacketsize)
|
||||
}
|
||||
}
|
||||
|
||||
ADJUST_CHECKSUM(accumulate, tc->th_sum)
|
||||
ADJUST_CHECKSUM(accumulate, tc->th_sum);
|
||||
|
||||
/* Change source address */
|
||||
sptr = (u_short *) &(pip->ip_src);
|
||||
@ -1095,7 +1097,7 @@ TcpAliasOut(struct ip *pip, int maxpacketsize)
|
||||
accumulate -= *sptr++;
|
||||
accumulate -= *sptr;
|
||||
|
||||
ADJUST_CHECKSUM(accumulate, pip->ip_sum)
|
||||
ADJUST_CHECKSUM(accumulate, pip->ip_sum);
|
||||
|
||||
return(PKT_ALIAS_OK);
|
||||
}
|
||||
@ -1475,11 +1477,11 @@ PacketUnaliasOut(char *ptr, /* valid IP packet */
|
||||
if (pip->ip_p == IPPROTO_UDP) {
|
||||
accumulate += ud->uh_sport;
|
||||
accumulate -= original_port;
|
||||
ADJUST_CHECKSUM(accumulate, ud->uh_sum)
|
||||
ADJUST_CHECKSUM(accumulate, ud->uh_sum);
|
||||
} else {
|
||||
accumulate += tc->th_sport;
|
||||
accumulate -= original_port;
|
||||
ADJUST_CHECKSUM(accumulate, tc->th_sum)
|
||||
ADJUST_CHECKSUM(accumulate, tc->th_sum);
|
||||
}
|
||||
|
||||
/* Adjust IP checksum */
|
||||
@ -1516,7 +1518,7 @@ PacketUnaliasOut(char *ptr, /* valid IP packet */
|
||||
accumulate -= *sptr;
|
||||
accumulate += ic->icmp_id;
|
||||
accumulate -= original_id;
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum)
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum);
|
||||
|
||||
/* Adjust IP checksum */
|
||||
DifferentialChecksum(&pip->ip_sum,
|
||||
|
@ -1,169 +1,156 @@
|
||||
/*lint -save -library Flexelint comment for external headers */
|
||||
|
||||
/*
|
||||
Alias.h defines the outside world interfaces for the packet
|
||||
aliasing software.
|
||||
|
||||
This software is placed into the public domain with no restrictions
|
||||
on its distribution.
|
||||
|
||||
$FreeBSD$
|
||||
*/
|
||||
/* lint -save -library Flexelint comment for external headers */
|
||||
|
||||
/*-
|
||||
* Alias.h defines the outside world interfaces for the packet aliasing
|
||||
* software.
|
||||
*
|
||||
* This software is placed into the public domain with no restrictions on its
|
||||
* distribution.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _ALIAS_H_
|
||||
#define _ALIAS_H_
|
||||
#define _ALIAS_H_
|
||||
|
||||
/* Alias link representative (incomplete struct) */
|
||||
struct alias_link;
|
||||
/* The external interface to libalias, the packet aliasing engine. */
|
||||
|
||||
/* External interfaces (API) to packet aliasing engine */
|
||||
/* Initialization and control functions. */
|
||||
void PacketAliasInit(void);
|
||||
void PacketAliasSetAddress(struct in_addr _addr);
|
||||
void PacketAliasSetFWBase(unsigned int _base, unsigned int _num);
|
||||
unsigned int
|
||||
PacketAliasSetMode(unsigned int _flags, unsigned int _mask);
|
||||
void PacketAliasUninit(void);
|
||||
|
||||
/* Initialization and Control */
|
||||
extern void
|
||||
PacketAliasInit(void);
|
||||
/* Packet Handling functions. */
|
||||
int PacketAliasIn(char *_ptr, int _maxpacketsize);
|
||||
int PacketAliasOut(char *_ptr, int _maxpacketsize);
|
||||
int PacketUnaliasOut(char *_ptr, int _maxpacketsize);
|
||||
|
||||
extern void
|
||||
PacketAliasUninit(void);
|
||||
/* Port and address redirection functions. */
|
||||
|
||||
extern void
|
||||
PacketAliasSetAddress(struct in_addr);
|
||||
/*
|
||||
* An anonymous structure, a pointer to which is returned from
|
||||
* PacketAliasRedirectAddr(), PacketAliasRedirectPort() or
|
||||
* PacketAliasRedirectProto(), passed to PacketAliasAddServer(),
|
||||
* and freed by PacketAliasRedirectDelete().
|
||||
*/
|
||||
struct alias_link;
|
||||
|
||||
extern unsigned int
|
||||
PacketAliasSetMode(unsigned int, unsigned int);
|
||||
int PacketAliasAddServer(struct alias_link *_link,
|
||||
struct in_addr _addr, unsigned short _port);
|
||||
struct alias_link *
|
||||
PacketAliasRedirectAddr(struct in_addr _src_addr,
|
||||
struct in_addr _alias_addr);
|
||||
void PacketAliasRedirectDelete(struct alias_link *_link);
|
||||
struct alias_link *
|
||||
PacketAliasRedirectPort(struct in_addr _src_addr,
|
||||
unsigned short _src_port, struct in_addr _dst_addr,
|
||||
unsigned short _dst_port, struct in_addr _alias_addr,
|
||||
unsigned short _alias_port, unsigned char _proto);
|
||||
struct alias_link *
|
||||
PacketAliasRedirectProto(struct in_addr _src_addr,
|
||||
struct in_addr _dst_addr, struct in_addr _alias_addr,
|
||||
unsigned char _proto);
|
||||
|
||||
/* Fragment Handling functions. */
|
||||
void PacketAliasFragmentIn(char *_ptr, char *_ptr_fragment);
|
||||
char *PacketAliasGetFragment(char *_ptr);
|
||||
int PacketAliasSaveFragment(char *_ptr);
|
||||
|
||||
/* Miscellaneous functions. */
|
||||
int PacketAliasCheckNewLink(void);
|
||||
unsigned short
|
||||
PacketAliasInternetChecksum(unsigned short *_ptr, int _nbytes);
|
||||
void PacketAliasSetTarget(struct in_addr _target_addr);
|
||||
|
||||
/* Transparent proxying routines. */
|
||||
int PacketAliasProxyRule(const char *_cmd);
|
||||
|
||||
/* Mode flags, set using PacketAliasSetMode() */
|
||||
|
||||
/*
|
||||
* If PKT_ALIAS_LOG is set, a message will be printed to /var/log/alias.log
|
||||
* every time a link is created or deleted. This is useful for debugging.
|
||||
*/
|
||||
#define PKT_ALIAS_LOG 0x01
|
||||
|
||||
/*
|
||||
* If PKT_ALIAS_DENY_INCOMING is set, then incoming connections (e.g. to ftp,
|
||||
* telnet or web servers will be prevented by the aliasing mechanism.
|
||||
*/
|
||||
#define PKT_ALIAS_DENY_INCOMING 0x02
|
||||
|
||||
/*
|
||||
* If PKT_ALIAS_SAME_PORTS is set, packets will be attempted sent from the
|
||||
* same port as they originated on. This allows e.g. rsh to work *99% of the
|
||||
* time*, but _not_ 100% (it will be slightly flakey instead of not working
|
||||
* at all). This mode bit is set by PacketAliasInit(), so it is a default
|
||||
* mode of operation.
|
||||
*/
|
||||
#define PKT_ALIAS_SAME_PORTS 0x04
|
||||
|
||||
/*
|
||||
* If PKT_ALIAS_USE_SOCKETS is set, then when partially specified links (e.g.
|
||||
* destination port and/or address is zero), the packet aliasing engine will
|
||||
* attempt to allocate a socket for the aliasing port it chooses. This will
|
||||
* avoid interference with the host machine. Fully specified links do not
|
||||
* require this. This bit is set after a call to PacketAliasInit(), so it is
|
||||
* a default mode of operation.
|
||||
*/
|
||||
#define PKT_ALIAS_USE_SOCKETS 0x08
|
||||
|
||||
/*-
|
||||
* If PKT_ALIAS_UNREGISTERED_ONLY is set, then only packets with
|
||||
* unregistered source addresses will be aliased. Private
|
||||
* addresses are those in the following ranges:
|
||||
*
|
||||
* 10.0.0.0 -> 10.255.255.255
|
||||
* 172.16.0.0 -> 172.31.255.255
|
||||
* 192.168.0.0 -> 192.168.255.255
|
||||
*/
|
||||
#define PKT_ALIAS_UNREGISTERED_ONLY 0x10
|
||||
|
||||
/*
|
||||
* If PKT_ALIAS_RESET_ON_ADDR_CHANGE is set, then the table of dynamic
|
||||
* aliasing links will be reset whenever PacketAliasSetAddress() changes the
|
||||
* default aliasing address. If the default aliasing address is left
|
||||
* unchanged by this function call, then the table of dynamic aliasing links
|
||||
* will be left intact. This bit is set after a call to PacketAliasInit().
|
||||
*/
|
||||
#define PKT_ALIAS_RESET_ON_ADDR_CHANGE 0x20
|
||||
|
||||
#ifndef NO_FW_PUNCH
|
||||
extern void
|
||||
PacketAliasSetFWBase(unsigned int, unsigned int);
|
||||
/*
|
||||
* If PKT_ALIAS_PUNCH_FW is set, active FTP and IRC DCC connections will
|
||||
* create a 'hole' in the firewall to allow the transfers to work. The
|
||||
* ipfw rule number that the hole is created with is controlled by
|
||||
* PacketAliasSetFWBase(). The hole will be attached to that
|
||||
* particular alias_link, so when the link goes away the hole is deleted.
|
||||
*/
|
||||
#define PKT_ALIAS_PUNCH_FW 0x100
|
||||
#endif
|
||||
|
||||
/* Packet Handling */
|
||||
extern int
|
||||
PacketAliasIn(char *, int);
|
||||
/*
|
||||
* If PKT_ALIAS_PROXY_ONLY is set, then NAT will be disabled and only
|
||||
* transparent proxying is performed.
|
||||
*/
|
||||
#define PKT_ALIAS_PROXY_ONLY 0x40
|
||||
|
||||
extern int
|
||||
PacketAliasOut(char *, int);
|
||||
/*
|
||||
* If PKT_ALIAS_REVERSE is set, the actions of PacketAliasIn() and
|
||||
* PacketAliasOut() are reversed.
|
||||
*/
|
||||
#define PKT_ALIAS_REVERSE 0x80
|
||||
|
||||
extern int
|
||||
PacketUnaliasOut(char *, int);
|
||||
/* Function return codes. */
|
||||
#define PKT_ALIAS_ERROR -1
|
||||
#define PKT_ALIAS_OK 1
|
||||
#define PKT_ALIAS_IGNORED 2
|
||||
#define PKT_ALIAS_UNRESOLVED_FRAGMENT 3
|
||||
#define PKT_ALIAS_FOUND_HEADER_FRAGMENT 4
|
||||
|
||||
/* Port and Address Redirection */
|
||||
extern struct alias_link *
|
||||
PacketAliasRedirectPort(struct in_addr, u_short,
|
||||
struct in_addr, u_short,
|
||||
struct in_addr, u_short,
|
||||
u_char);
|
||||
#endif /* !_ALIAS_H_ */
|
||||
|
||||
extern int
|
||||
PacketAliasAddServer(struct alias_link *, struct in_addr, u_short);
|
||||
|
||||
extern struct alias_link *
|
||||
PacketAliasRedirectProto(struct in_addr,
|
||||
struct in_addr,
|
||||
struct in_addr,
|
||||
u_char);
|
||||
|
||||
extern struct alias_link *
|
||||
PacketAliasRedirectAddr(struct in_addr,
|
||||
struct in_addr);
|
||||
|
||||
extern void
|
||||
PacketAliasRedirectDelete(struct alias_link *);
|
||||
|
||||
/* Fragment Handling */
|
||||
extern int
|
||||
PacketAliasSaveFragment(char *);
|
||||
|
||||
extern char *
|
||||
PacketAliasGetFragment(char *);
|
||||
|
||||
extern void
|
||||
PacketAliasFragmentIn(char *, char *);
|
||||
|
||||
/* Miscellaneous Functions */
|
||||
extern void
|
||||
PacketAliasSetTarget(struct in_addr);
|
||||
|
||||
extern int
|
||||
PacketAliasCheckNewLink(void);
|
||||
|
||||
extern u_short
|
||||
PacketAliasInternetChecksum(u_short *, int);
|
||||
|
||||
/* Transparent Proxying */
|
||||
extern int
|
||||
PacketAliasProxyRule(const char *);
|
||||
|
||||
|
||||
/********************** Mode flags ********************/
|
||||
/* Set these flags using PacketAliasSetMode() */
|
||||
|
||||
/* If PKT_ALIAS_LOG is set, a message will be printed to
|
||||
/var/log/alias.log every time a link is created or deleted. This
|
||||
is useful for debugging */
|
||||
#define PKT_ALIAS_LOG 0x01
|
||||
|
||||
/* If PKT_ALIAS_DENY_INCOMING is set, then incoming connections (e.g.
|
||||
to ftp, telnet or web servers will be prevented by the aliasing
|
||||
mechanism. */
|
||||
#define PKT_ALIAS_DENY_INCOMING 0x02
|
||||
|
||||
/* If PKT_ALIAS_SAME_PORTS is set, packets will be attempted sent from
|
||||
the same port as they originated on. This allows e.g. rsh to work
|
||||
*99% of the time*, but _not_ 100%. (It will be slightly flakey
|
||||
instead of not working at all.) This mode bit is set by
|
||||
PacketAliasInit(), so it is a default mode of operation. */
|
||||
#define PKT_ALIAS_SAME_PORTS 0x04
|
||||
|
||||
/* If PKT_ALIAS_USE_SOCKETS is set, then when partially specified
|
||||
links (e.g. destination port and/or address is zero), the packet
|
||||
aliasing engine will attempt to allocate a socket for the aliasing
|
||||
port it chooses. This will avoid interference with the host
|
||||
machine. Fully specified links do not require this. This bit
|
||||
is set after a call to PacketAliasInit(), so it is a default
|
||||
mode of operation. */
|
||||
#define PKT_ALIAS_USE_SOCKETS 0x08
|
||||
|
||||
/* If PKT_ALIAS_UNREGISTERED_ONLY is set, then only packets with
|
||||
unregistered source addresses will be aliased. Private
|
||||
addresses are those in the following ranges:
|
||||
10.0.0.0 -> 10.255.255.255
|
||||
172.16.0.0 -> 172.31.255.255
|
||||
192.168.0.0 -> 192.168.255.255 */
|
||||
#define PKT_ALIAS_UNREGISTERED_ONLY 0x10
|
||||
|
||||
/* If PKT_ALIAS_RESET_ON_ADDR_CHANGE is set, then the table of dynamic
|
||||
aliasing links will be reset whenever PacketAliasSetAddress()
|
||||
changes the default aliasing address. If the default aliasing
|
||||
address is left unchanged by this function call, then the
|
||||
table of dynamic aliasing links will be left intact. This
|
||||
bit is set after a call to PacketAliasInit(). */
|
||||
#define PKT_ALIAS_RESET_ON_ADDR_CHANGE 0x20
|
||||
|
||||
#ifndef NO_FW_PUNCH
|
||||
/* If PKT_ALIAS_PUNCH_FW is set, active FTP and IRC DCC connections
|
||||
will create a 'hole' in the firewall to allow the transfers to
|
||||
work. Where (IPFW "line-numbers") the hole is created is
|
||||
controlled by PacketAliasSetFWBase(base, size). The hole will be
|
||||
attached to that particular alias_link, so when the link goes away
|
||||
so do the hole. */
|
||||
#define PKT_ALIAS_PUNCH_FW 0x100
|
||||
#endif
|
||||
|
||||
/* If PKT_ALIAS_PROXY_ONLY is set, then NAT will be disabled and only
|
||||
transparent proxying performed */
|
||||
#define PKT_ALIAS_PROXY_ONLY 0x40
|
||||
|
||||
/* If PKT_ALIAS_REVERSE is set, the actions of PacketAliasIn()
|
||||
and PacketAliasOut() are reversed */
|
||||
#define PKT_ALIAS_REVERSE 0x80
|
||||
|
||||
/* Return Codes */
|
||||
#define PKT_ALIAS_ERROR -1
|
||||
#define PKT_ALIAS_OK 1
|
||||
#define PKT_ALIAS_IGNORED 2
|
||||
#define PKT_ALIAS_UNRESOLVED_FRAGMENT 3
|
||||
#define PKT_ALIAS_FOUND_HEADER_FRAGMENT 4
|
||||
|
||||
#endif
|
||||
/*lint -restore */
|
||||
/* lint -restore */
|
||||
|
@ -2634,12 +2634,6 @@ do { \
|
||||
} /*lint -save -e717 */ while(0) /*lint -restore */
|
||||
#define fw_tstfield(field, num) ((field)[(num) - fireWallBaseNum])
|
||||
|
||||
void
|
||||
PacketAliasSetFWBase(unsigned int base, unsigned int num) {
|
||||
fireWallBaseNum = base;
|
||||
fireWallNumNums = num;
|
||||
}
|
||||
|
||||
static void
|
||||
InitPunchFW(void) {
|
||||
fireWallField = malloc(fireWallNumNums);
|
||||
@ -2784,3 +2778,11 @@ ClearAllFWHoles(void) {
|
||||
memset(fireWallField, 0, fireWallNumNums);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
PacketAliasSetFWBase(unsigned int base, unsigned int num) {
|
||||
#ifndef NO_FW_PUNCH
|
||||
fireWallBaseNum = base;
|
||||
fireWallNumNums = num;
|
||||
#endif
|
||||
}
|
||||
|
@ -1,211 +1,203 @@
|
||||
/* -*- mode: c; tab-width: 3; c-basic-offset: 3; -*-
|
||||
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.
|
||||
|
||||
Initial version: August, 1996 (cjm)
|
||||
|
||||
<updated several times by original author and Eivind Eklund>
|
||||
|
||||
$FreeBSD$
|
||||
*/
|
||||
#ifndef ALIAS_LOCAL_H
|
||||
#define ALIAS_LOCAL_H
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
Macros
|
||||
* 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.
|
||||
*
|
||||
* Initial version: August, 1996 (cjm)
|
||||
*
|
||||
* <updated several times by original author and Eivind Eklund>
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
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) { \
|
||||
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; \
|
||||
} \
|
||||
}
|
||||
#ifndef _ALIAS_LOCAL_H_
|
||||
#define _ALIAS_LOCAL_H_
|
||||
|
||||
/* Macros */
|
||||
|
||||
/*
|
||||
Globals
|
||||
*/
|
||||
* 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 */
|
||||
|
||||
extern int packetAliasMode;
|
||||
|
||||
|
||||
/*
|
||||
Structs
|
||||
*/
|
||||
|
||||
struct alias_link; /* Incomplete structure */
|
||||
|
||||
|
||||
/*
|
||||
Prototypes
|
||||
*/
|
||||
/* Prototypes */
|
||||
|
||||
/* General utilities */
|
||||
u_short IpChecksum(struct ip *);
|
||||
u_short TcpChecksum(struct ip *);
|
||||
void DifferentialChecksum(u_short *, u_short *, u_short *, int);
|
||||
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);
|
||||
|
||||
/* Internal data access */
|
||||
struct alias_link *
|
||||
FindIcmpIn(struct in_addr, struct in_addr, u_short, int);
|
||||
|
||||
FindIcmpIn(struct in_addr _dst_addr, struct in_addr _alias_addr,
|
||||
u_short _id_alias, int _create);
|
||||
struct alias_link *
|
||||
FindIcmpOut(struct in_addr, struct in_addr, u_short, int);
|
||||
|
||||
FindIcmpOut(struct in_addr _src_addr, struct in_addr _dst_addr,
|
||||
u_short _id, int _create);
|
||||
struct alias_link *
|
||||
FindFragmentIn1(struct in_addr, struct in_addr, u_short);
|
||||
|
||||
FindFragmentIn1(struct in_addr _dst_addr, struct in_addr _alias_addr,
|
||||
u_short _ip_id);
|
||||
struct alias_link *
|
||||
FindFragmentIn2(struct in_addr, struct in_addr, u_short);
|
||||
|
||||
FindFragmentIn2(struct in_addr _dst_addr, struct in_addr _alias_addr,
|
||||
u_short _ip_id);
|
||||
struct alias_link *
|
||||
AddFragmentPtrLink(struct in_addr, u_short);
|
||||
|
||||
AddFragmentPtrLink(struct in_addr _dst_addr, u_short _ip_id);
|
||||
struct alias_link *
|
||||
FindFragmentPtr(struct in_addr, u_short);
|
||||
|
||||
FindFragmentPtr(struct in_addr _dst_addr, u_short _ip_id);
|
||||
struct alias_link *
|
||||
FindProtoIn(struct in_addr, struct in_addr, u_char);
|
||||
|
||||
FindProtoIn(struct in_addr _dst_addr, struct in_addr _alias_addr,
|
||||
u_char _proto);
|
||||
struct alias_link *
|
||||
FindProtoOut(struct in_addr, struct in_addr, u_char);
|
||||
|
||||
FindProtoOut(struct in_addr _src_addr, struct in_addr _dst_addr,
|
||||
u_char _proto);
|
||||
struct alias_link *
|
||||
FindUdpTcpIn (struct in_addr, struct in_addr, u_short, u_short, u_char, int);
|
||||
|
||||
FindUdpTcpIn(struct in_addr _dst_addr, struct in_addr _alias_addr,
|
||||
u_short _dst_port, u_short _alias_port, u_char _proto, int _create);
|
||||
struct alias_link *
|
||||
FindUdpTcpOut(struct in_addr, struct in_addr, u_short, u_short, u_char, int);
|
||||
|
||||
FindUdpTcpOut(struct in_addr _src_addr, struct in_addr _dst_addr,
|
||||
u_short _src_port, u_short _dst_port, u_char _proto, int _create);
|
||||
struct alias_link *
|
||||
AddPptp(struct in_addr, struct in_addr, struct in_addr, u_int16_t);
|
||||
|
||||
AddPptp(struct in_addr _src_addr, struct in_addr _dst_addr,
|
||||
struct in_addr _alias_addr, u_int16_t _src_call_id);
|
||||
struct alias_link *
|
||||
FindPptpOutByCallId(struct in_addr, struct in_addr, u_int16_t);
|
||||
|
||||
FindPptpOutByCallId(struct in_addr _src_addr,
|
||||
struct in_addr _dst_addr, u_int16_t _src_call_id);
|
||||
struct alias_link *
|
||||
FindPptpInByCallId(struct in_addr, struct in_addr, u_int16_t);
|
||||
|
||||
FindPptpInByCallId(struct in_addr _dst_addr,
|
||||
struct in_addr _alias_addr, u_int16_t _dst_call_id);
|
||||
struct alias_link *
|
||||
FindPptpOutByPeerCallId(struct in_addr, struct in_addr, u_int16_t);
|
||||
|
||||
FindPptpOutByPeerCallId(struct in_addr _src_addr,
|
||||
struct in_addr _dst_addr, u_int16_t _dst_call_id);
|
||||
struct alias_link *
|
||||
FindPptpInByPeerCallId(struct in_addr, struct in_addr, u_int16_t);
|
||||
|
||||
FindPptpInByPeerCallId(struct in_addr _dst_addr,
|
||||
struct in_addr _alias_addr, u_int16_t _alias_call_id);
|
||||
struct alias_link *
|
||||
FindRtspOut(struct in_addr, struct in_addr, u_short, u_short, u_char);
|
||||
|
||||
FindRtspOut(struct in_addr _src_addr, struct in_addr _dst_addr,
|
||||
u_short _src_port, u_short _alias_port, u_char _proto);
|
||||
struct in_addr
|
||||
FindOriginalAddress(struct in_addr);
|
||||
|
||||
FindOriginalAddress(struct in_addr _alias_addr);
|
||||
struct in_addr
|
||||
FindAliasAddress(struct in_addr);
|
||||
FindAliasAddress(struct in_addr _original_addr);
|
||||
|
||||
/* External data access/modification */
|
||||
int FindNewPortGroup(struct in_addr, struct in_addr,
|
||||
u_short, u_short, u_short, u_char, u_char);
|
||||
void GetFragmentAddr(struct alias_link *, struct in_addr *);
|
||||
void SetFragmentAddr(struct alias_link *, struct in_addr);
|
||||
void GetFragmentPtr(struct alias_link *, char **);
|
||||
void SetFragmentPtr(struct alias_link *, char *);
|
||||
void SetStateIn(struct alias_link *, int);
|
||||
void SetStateOut(struct alias_link *, int);
|
||||
int GetStateIn(struct alias_link *);
|
||||
int GetStateOut(struct alias_link *);
|
||||
struct in_addr GetOriginalAddress(struct alias_link *);
|
||||
struct in_addr GetDestAddress(struct alias_link *);
|
||||
struct in_addr GetAliasAddress(struct alias_link *);
|
||||
struct in_addr GetDefaultAliasAddress(void);
|
||||
void SetDefaultAliasAddress(struct in_addr);
|
||||
u_short GetOriginalPort(struct alias_link *);
|
||||
u_short GetAliasPort(struct alias_link *);
|
||||
struct in_addr GetProxyAddress(struct alias_link *);
|
||||
void SetProxyAddress(struct alias_link *, struct in_addr);
|
||||
u_short GetProxyPort(struct alias_link *);
|
||||
void SetProxyPort(struct alias_link *, u_short);
|
||||
void SetAckModified(struct alias_link *);
|
||||
int GetAckModified(struct alias_link *);
|
||||
int GetDeltaAckIn(struct ip *, struct alias_link *);
|
||||
int GetDeltaSeqOut(struct ip *, struct alias_link *);
|
||||
void AddSeq(struct ip *, struct alias_link *, int);
|
||||
void SetExpire(struct alias_link *, int);
|
||||
void ClearCheckNewLink(void);
|
||||
void SetLastLineCrlfTermed(struct alias_link *, int);
|
||||
int GetLastLineCrlfTermed(struct alias_link *);
|
||||
void SetDestCallId(struct alias_link *, u_int16_t);
|
||||
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);
|
||||
void SetLastLineCrlfTermed(struct alias_link *_link, int _yes);
|
||||
int GetLastLineCrlfTermed(struct alias_link *_link);
|
||||
void SetDestCallId(struct alias_link *_link, u_int16_t _cid);
|
||||
#ifndef NO_FW_PUNCH
|
||||
void PunchFWHole(struct alias_link *);
|
||||
void PunchFWHole(struct alias_link *_link);
|
||||
#endif
|
||||
|
||||
|
||||
/* Housekeeping function */
|
||||
void HouseKeeping(void);
|
||||
void HouseKeeping(void);
|
||||
|
||||
/* Tcp specfic routines */
|
||||
/*lint -save -library Suppress flexelint warnings */
|
||||
/* lint -save -library Suppress flexelint warnings */
|
||||
|
||||
/* FTP routines */
|
||||
void AliasHandleFtpOut(struct ip *, struct alias_link *, int);
|
||||
void AliasHandleFtpOut(struct ip *_pip, struct alias_link *_link,
|
||||
int _maxpacketsize);
|
||||
|
||||
/* IRC routines */
|
||||
void AliasHandleIrcOut(struct ip *, struct alias_link *, int);
|
||||
void AliasHandleIrcOut(struct ip *_pip, struct alias_link *_link,
|
||||
int _maxsize);
|
||||
|
||||
/* RTSP routines */
|
||||
void AliasHandleRtspOut(struct ip *, struct alias_link *, int);
|
||||
void AliasHandleRtspOut(struct ip *_pip, struct alias_link *_link,
|
||||
int _maxpacketsize);
|
||||
|
||||
/* PPTP routines */
|
||||
void AliasHandlePptpOut(struct ip *, struct alias_link *);
|
||||
void AliasHandlePptpIn(struct ip *, struct alias_link *);
|
||||
int AliasHandlePptpGreOut(struct ip *);
|
||||
int AliasHandlePptpGreIn(struct ip *);
|
||||
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);
|
||||
|
||||
/* NetBIOS routines */
|
||||
int AliasHandleUdpNbt(struct ip *, struct alias_link *, struct in_addr *, u_short);
|
||||
int AliasHandleUdpNbtNS(struct ip *, struct alias_link *, struct in_addr *, u_short *, struct in_addr *, u_short *);
|
||||
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);
|
||||
|
||||
/* CUSeeMe routines */
|
||||
void AliasHandleCUSeeMeOut(struct ip *, struct alias_link *);
|
||||
void AliasHandleCUSeeMeIn(struct ip *, struct in_addr);
|
||||
void AliasHandleCUSeeMeOut(struct ip *_pip, struct alias_link *_link);
|
||||
void AliasHandleCUSeeMeIn(struct ip *_pip, struct in_addr _original_addr);
|
||||
|
||||
/* Transparent proxy routines */
|
||||
int ProxyCheck(struct ip *, struct in_addr *, u_short *);
|
||||
void ProxyModify(struct alias_link *, struct ip *, int, int);
|
||||
|
||||
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);
|
||||
|
||||
enum alias_tcp_state {
|
||||
ALIAS_TCP_STATE_NOT_CONNECTED,
|
||||
ALIAS_TCP_STATE_CONNECTED,
|
||||
ALIAS_TCP_STATE_DISCONNECTED
|
||||
ALIAS_TCP_STATE_NOT_CONNECTED,
|
||||
ALIAS_TCP_STATE_CONNECTED,
|
||||
ALIAS_TCP_STATE_DISCONNECTED
|
||||
};
|
||||
|
||||
/*lint -restore */
|
||||
#endif /* defined(ALIAS_LOCAL_H) */
|
||||
|
||||
#endif /* !_ALIAS_LOCAL_H_ */
|
||||
|
@ -241,7 +241,7 @@ int AliasHandleUdpNbt(
|
||||
sptr = (u_short *) alias_address;
|
||||
acc -= *sptr++;
|
||||
acc -= *sptr;
|
||||
ADJUST_CHECKSUM(acc, uh->uh_sum)
|
||||
ADJUST_CHECKSUM(acc, uh->uh_sum);
|
||||
}
|
||||
ndh->source_ip = *alias_address;
|
||||
ndh->source_port = alias_port;
|
||||
@ -358,7 +358,7 @@ AliasHandleResourceNB(
|
||||
sptr = (u_short *) &(nbtarg->newaddr);
|
||||
acc -= *sptr++;
|
||||
acc -= *sptr;
|
||||
ADJUST_CHECKSUM(acc, *nbtarg->uh_sum)
|
||||
ADJUST_CHECKSUM(acc, *nbtarg->uh_sum);
|
||||
}
|
||||
|
||||
nb->addr = nbtarg->newaddr;
|
||||
@ -426,7 +426,7 @@ AliasHandleResourceA(
|
||||
sptr = (u_short *) &nbtarg->newaddr; /* New */
|
||||
acc -= *sptr++;
|
||||
acc -= *sptr;
|
||||
ADJUST_CHECKSUM(acc, *nbtarg->uh_sum)
|
||||
ADJUST_CHECKSUM(acc, *nbtarg->uh_sum);
|
||||
}
|
||||
|
||||
a->addr = nbtarg->newaddr;
|
||||
|
@ -71,6 +71,8 @@
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/tcp.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "alias_local.h"
|
||||
|
||||
/*
|
||||
|
@ -97,6 +97,8 @@
|
||||
#include <netinet/tcp.h>
|
||||
#include <netinet/udp.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "alias_local.h"
|
||||
#include "alias.h"
|
||||
|
||||
@ -261,7 +263,7 @@ IcmpAliasIn1(struct ip *pip)
|
||||
/* Adjust ICMP checksum */
|
||||
accumulate = ic->icmp_id;
|
||||
accumulate -= original_id;
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum)
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum);
|
||||
|
||||
/* Put original sequence number back in */
|
||||
ic->icmp_id = original_id;
|
||||
@ -340,7 +342,7 @@ IcmpAliasIn2(struct ip *pip)
|
||||
accumulate -= *sptr;
|
||||
accumulate += ud->uh_sport;
|
||||
accumulate -= original_port;
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum)
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum);
|
||||
|
||||
/* Un-alias address in IP header */
|
||||
DifferentialChecksum(&pip->ip_sum,
|
||||
@ -373,7 +375,7 @@ fragment contained in ICMP data section */
|
||||
accumulate -= *sptr;
|
||||
accumulate += ic2->icmp_id;
|
||||
accumulate -= original_id;
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum)
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum);
|
||||
|
||||
/* Un-alias address in IP header */
|
||||
DifferentialChecksum(&pip->ip_sum,
|
||||
@ -454,7 +456,7 @@ IcmpAliasOut1(struct ip *pip)
|
||||
/* Since data field is being modified, adjust ICMP checksum */
|
||||
accumulate = ic->icmp_id;
|
||||
accumulate -= alias_id;
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum)
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum);
|
||||
|
||||
/* Alias sequence number */
|
||||
ic->icmp_id = alias_id;
|
||||
@ -534,7 +536,7 @@ IcmpAliasOut2(struct ip *pip)
|
||||
accumulate -= *sptr;
|
||||
accumulate += ud->uh_dport;
|
||||
accumulate -= alias_port;
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum)
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum);
|
||||
|
||||
/*
|
||||
* Alias address in IP header if it comes from the host
|
||||
@ -572,7 +574,7 @@ fragment contained in ICMP data section */
|
||||
accumulate -= *sptr;
|
||||
accumulate += ic2->icmp_id;
|
||||
accumulate -= alias_id;
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum)
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum);
|
||||
|
||||
/*
|
||||
* Alias address in IP header if it comes from the host
|
||||
@ -756,7 +758,7 @@ UdpAliasIn(struct ip *pip)
|
||||
sptr = (u_short *) &original_address;
|
||||
accumulate -= *sptr++;
|
||||
accumulate -= *sptr;
|
||||
ADJUST_CHECKSUM(accumulate, ud->uh_sum)
|
||||
ADJUST_CHECKSUM(accumulate, ud->uh_sum);
|
||||
}
|
||||
|
||||
/* Restore original IP address */
|
||||
@ -827,7 +829,7 @@ UdpAliasOut(struct ip *pip)
|
||||
sptr = (u_short *) &alias_address;
|
||||
accumulate -= *sptr++;
|
||||
accumulate -= *sptr;
|
||||
ADJUST_CHECKSUM(accumulate, ud->uh_sum)
|
||||
ADJUST_CHECKSUM(accumulate, ud->uh_sum);
|
||||
}
|
||||
|
||||
/* Put alias port in UDP header */
|
||||
@ -1084,7 +1086,7 @@ TcpAliasOut(struct ip *pip, int maxpacketsize)
|
||||
}
|
||||
}
|
||||
|
||||
ADJUST_CHECKSUM(accumulate, tc->th_sum)
|
||||
ADJUST_CHECKSUM(accumulate, tc->th_sum);
|
||||
|
||||
/* Change source address */
|
||||
sptr = (u_short *) &(pip->ip_src);
|
||||
@ -1095,7 +1097,7 @@ TcpAliasOut(struct ip *pip, int maxpacketsize)
|
||||
accumulate -= *sptr++;
|
||||
accumulate -= *sptr;
|
||||
|
||||
ADJUST_CHECKSUM(accumulate, pip->ip_sum)
|
||||
ADJUST_CHECKSUM(accumulate, pip->ip_sum);
|
||||
|
||||
return(PKT_ALIAS_OK);
|
||||
}
|
||||
@ -1475,11 +1477,11 @@ PacketUnaliasOut(char *ptr, /* valid IP packet */
|
||||
if (pip->ip_p == IPPROTO_UDP) {
|
||||
accumulate += ud->uh_sport;
|
||||
accumulate -= original_port;
|
||||
ADJUST_CHECKSUM(accumulate, ud->uh_sum)
|
||||
ADJUST_CHECKSUM(accumulate, ud->uh_sum);
|
||||
} else {
|
||||
accumulate += tc->th_sport;
|
||||
accumulate -= original_port;
|
||||
ADJUST_CHECKSUM(accumulate, tc->th_sum)
|
||||
ADJUST_CHECKSUM(accumulate, tc->th_sum);
|
||||
}
|
||||
|
||||
/* Adjust IP checksum */
|
||||
@ -1516,7 +1518,7 @@ PacketUnaliasOut(char *ptr, /* valid IP packet */
|
||||
accumulate -= *sptr;
|
||||
accumulate += ic->icmp_id;
|
||||
accumulate -= original_id;
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum)
|
||||
ADJUST_CHECKSUM(accumulate, ic->icmp_cksum);
|
||||
|
||||
/* Adjust IP checksum */
|
||||
DifferentialChecksum(&pip->ip_sum,
|
||||
|
@ -1,169 +1,156 @@
|
||||
/*lint -save -library Flexelint comment for external headers */
|
||||
|
||||
/*
|
||||
Alias.h defines the outside world interfaces for the packet
|
||||
aliasing software.
|
||||
|
||||
This software is placed into the public domain with no restrictions
|
||||
on its distribution.
|
||||
|
||||
$FreeBSD$
|
||||
*/
|
||||
/* lint -save -library Flexelint comment for external headers */
|
||||
|
||||
/*-
|
||||
* Alias.h defines the outside world interfaces for the packet aliasing
|
||||
* software.
|
||||
*
|
||||
* This software is placed into the public domain with no restrictions on its
|
||||
* distribution.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _ALIAS_H_
|
||||
#define _ALIAS_H_
|
||||
#define _ALIAS_H_
|
||||
|
||||
/* Alias link representative (incomplete struct) */
|
||||
struct alias_link;
|
||||
/* The external interface to libalias, the packet aliasing engine. */
|
||||
|
||||
/* External interfaces (API) to packet aliasing engine */
|
||||
/* Initialization and control functions. */
|
||||
void PacketAliasInit(void);
|
||||
void PacketAliasSetAddress(struct in_addr _addr);
|
||||
void PacketAliasSetFWBase(unsigned int _base, unsigned int _num);
|
||||
unsigned int
|
||||
PacketAliasSetMode(unsigned int _flags, unsigned int _mask);
|
||||
void PacketAliasUninit(void);
|
||||
|
||||
/* Initialization and Control */
|
||||
extern void
|
||||
PacketAliasInit(void);
|
||||
/* Packet Handling functions. */
|
||||
int PacketAliasIn(char *_ptr, int _maxpacketsize);
|
||||
int PacketAliasOut(char *_ptr, int _maxpacketsize);
|
||||
int PacketUnaliasOut(char *_ptr, int _maxpacketsize);
|
||||
|
||||
extern void
|
||||
PacketAliasUninit(void);
|
||||
/* Port and address redirection functions. */
|
||||
|
||||
extern void
|
||||
PacketAliasSetAddress(struct in_addr);
|
||||
/*
|
||||
* An anonymous structure, a pointer to which is returned from
|
||||
* PacketAliasRedirectAddr(), PacketAliasRedirectPort() or
|
||||
* PacketAliasRedirectProto(), passed to PacketAliasAddServer(),
|
||||
* and freed by PacketAliasRedirectDelete().
|
||||
*/
|
||||
struct alias_link;
|
||||
|
||||
extern unsigned int
|
||||
PacketAliasSetMode(unsigned int, unsigned int);
|
||||
int PacketAliasAddServer(struct alias_link *_link,
|
||||
struct in_addr _addr, unsigned short _port);
|
||||
struct alias_link *
|
||||
PacketAliasRedirectAddr(struct in_addr _src_addr,
|
||||
struct in_addr _alias_addr);
|
||||
void PacketAliasRedirectDelete(struct alias_link *_link);
|
||||
struct alias_link *
|
||||
PacketAliasRedirectPort(struct in_addr _src_addr,
|
||||
unsigned short _src_port, struct in_addr _dst_addr,
|
||||
unsigned short _dst_port, struct in_addr _alias_addr,
|
||||
unsigned short _alias_port, unsigned char _proto);
|
||||
struct alias_link *
|
||||
PacketAliasRedirectProto(struct in_addr _src_addr,
|
||||
struct in_addr _dst_addr, struct in_addr _alias_addr,
|
||||
unsigned char _proto);
|
||||
|
||||
/* Fragment Handling functions. */
|
||||
void PacketAliasFragmentIn(char *_ptr, char *_ptr_fragment);
|
||||
char *PacketAliasGetFragment(char *_ptr);
|
||||
int PacketAliasSaveFragment(char *_ptr);
|
||||
|
||||
/* Miscellaneous functions. */
|
||||
int PacketAliasCheckNewLink(void);
|
||||
unsigned short
|
||||
PacketAliasInternetChecksum(unsigned short *_ptr, int _nbytes);
|
||||
void PacketAliasSetTarget(struct in_addr _target_addr);
|
||||
|
||||
/* Transparent proxying routines. */
|
||||
int PacketAliasProxyRule(const char *_cmd);
|
||||
|
||||
/* Mode flags, set using PacketAliasSetMode() */
|
||||
|
||||
/*
|
||||
* If PKT_ALIAS_LOG is set, a message will be printed to /var/log/alias.log
|
||||
* every time a link is created or deleted. This is useful for debugging.
|
||||
*/
|
||||
#define PKT_ALIAS_LOG 0x01
|
||||
|
||||
/*
|
||||
* If PKT_ALIAS_DENY_INCOMING is set, then incoming connections (e.g. to ftp,
|
||||
* telnet or web servers will be prevented by the aliasing mechanism.
|
||||
*/
|
||||
#define PKT_ALIAS_DENY_INCOMING 0x02
|
||||
|
||||
/*
|
||||
* If PKT_ALIAS_SAME_PORTS is set, packets will be attempted sent from the
|
||||
* same port as they originated on. This allows e.g. rsh to work *99% of the
|
||||
* time*, but _not_ 100% (it will be slightly flakey instead of not working
|
||||
* at all). This mode bit is set by PacketAliasInit(), so it is a default
|
||||
* mode of operation.
|
||||
*/
|
||||
#define PKT_ALIAS_SAME_PORTS 0x04
|
||||
|
||||
/*
|
||||
* If PKT_ALIAS_USE_SOCKETS is set, then when partially specified links (e.g.
|
||||
* destination port and/or address is zero), the packet aliasing engine will
|
||||
* attempt to allocate a socket for the aliasing port it chooses. This will
|
||||
* avoid interference with the host machine. Fully specified links do not
|
||||
* require this. This bit is set after a call to PacketAliasInit(), so it is
|
||||
* a default mode of operation.
|
||||
*/
|
||||
#define PKT_ALIAS_USE_SOCKETS 0x08
|
||||
|
||||
/*-
|
||||
* If PKT_ALIAS_UNREGISTERED_ONLY is set, then only packets with
|
||||
* unregistered source addresses will be aliased. Private
|
||||
* addresses are those in the following ranges:
|
||||
*
|
||||
* 10.0.0.0 -> 10.255.255.255
|
||||
* 172.16.0.0 -> 172.31.255.255
|
||||
* 192.168.0.0 -> 192.168.255.255
|
||||
*/
|
||||
#define PKT_ALIAS_UNREGISTERED_ONLY 0x10
|
||||
|
||||
/*
|
||||
* If PKT_ALIAS_RESET_ON_ADDR_CHANGE is set, then the table of dynamic
|
||||
* aliasing links will be reset whenever PacketAliasSetAddress() changes the
|
||||
* default aliasing address. If the default aliasing address is left
|
||||
* unchanged by this function call, then the table of dynamic aliasing links
|
||||
* will be left intact. This bit is set after a call to PacketAliasInit().
|
||||
*/
|
||||
#define PKT_ALIAS_RESET_ON_ADDR_CHANGE 0x20
|
||||
|
||||
#ifndef NO_FW_PUNCH
|
||||
extern void
|
||||
PacketAliasSetFWBase(unsigned int, unsigned int);
|
||||
/*
|
||||
* If PKT_ALIAS_PUNCH_FW is set, active FTP and IRC DCC connections will
|
||||
* create a 'hole' in the firewall to allow the transfers to work. The
|
||||
* ipfw rule number that the hole is created with is controlled by
|
||||
* PacketAliasSetFWBase(). The hole will be attached to that
|
||||
* particular alias_link, so when the link goes away the hole is deleted.
|
||||
*/
|
||||
#define PKT_ALIAS_PUNCH_FW 0x100
|
||||
#endif
|
||||
|
||||
/* Packet Handling */
|
||||
extern int
|
||||
PacketAliasIn(char *, int);
|
||||
/*
|
||||
* If PKT_ALIAS_PROXY_ONLY is set, then NAT will be disabled and only
|
||||
* transparent proxying is performed.
|
||||
*/
|
||||
#define PKT_ALIAS_PROXY_ONLY 0x40
|
||||
|
||||
extern int
|
||||
PacketAliasOut(char *, int);
|
||||
/*
|
||||
* If PKT_ALIAS_REVERSE is set, the actions of PacketAliasIn() and
|
||||
* PacketAliasOut() are reversed.
|
||||
*/
|
||||
#define PKT_ALIAS_REVERSE 0x80
|
||||
|
||||
extern int
|
||||
PacketUnaliasOut(char *, int);
|
||||
/* Function return codes. */
|
||||
#define PKT_ALIAS_ERROR -1
|
||||
#define PKT_ALIAS_OK 1
|
||||
#define PKT_ALIAS_IGNORED 2
|
||||
#define PKT_ALIAS_UNRESOLVED_FRAGMENT 3
|
||||
#define PKT_ALIAS_FOUND_HEADER_FRAGMENT 4
|
||||
|
||||
/* Port and Address Redirection */
|
||||
extern struct alias_link *
|
||||
PacketAliasRedirectPort(struct in_addr, u_short,
|
||||
struct in_addr, u_short,
|
||||
struct in_addr, u_short,
|
||||
u_char);
|
||||
#endif /* !_ALIAS_H_ */
|
||||
|
||||
extern int
|
||||
PacketAliasAddServer(struct alias_link *, struct in_addr, u_short);
|
||||
|
||||
extern struct alias_link *
|
||||
PacketAliasRedirectProto(struct in_addr,
|
||||
struct in_addr,
|
||||
struct in_addr,
|
||||
u_char);
|
||||
|
||||
extern struct alias_link *
|
||||
PacketAliasRedirectAddr(struct in_addr,
|
||||
struct in_addr);
|
||||
|
||||
extern void
|
||||
PacketAliasRedirectDelete(struct alias_link *);
|
||||
|
||||
/* Fragment Handling */
|
||||
extern int
|
||||
PacketAliasSaveFragment(char *);
|
||||
|
||||
extern char *
|
||||
PacketAliasGetFragment(char *);
|
||||
|
||||
extern void
|
||||
PacketAliasFragmentIn(char *, char *);
|
||||
|
||||
/* Miscellaneous Functions */
|
||||
extern void
|
||||
PacketAliasSetTarget(struct in_addr);
|
||||
|
||||
extern int
|
||||
PacketAliasCheckNewLink(void);
|
||||
|
||||
extern u_short
|
||||
PacketAliasInternetChecksum(u_short *, int);
|
||||
|
||||
/* Transparent Proxying */
|
||||
extern int
|
||||
PacketAliasProxyRule(const char *);
|
||||
|
||||
|
||||
/********************** Mode flags ********************/
|
||||
/* Set these flags using PacketAliasSetMode() */
|
||||
|
||||
/* If PKT_ALIAS_LOG is set, a message will be printed to
|
||||
/var/log/alias.log every time a link is created or deleted. This
|
||||
is useful for debugging */
|
||||
#define PKT_ALIAS_LOG 0x01
|
||||
|
||||
/* If PKT_ALIAS_DENY_INCOMING is set, then incoming connections (e.g.
|
||||
to ftp, telnet or web servers will be prevented by the aliasing
|
||||
mechanism. */
|
||||
#define PKT_ALIAS_DENY_INCOMING 0x02
|
||||
|
||||
/* If PKT_ALIAS_SAME_PORTS is set, packets will be attempted sent from
|
||||
the same port as they originated on. This allows e.g. rsh to work
|
||||
*99% of the time*, but _not_ 100%. (It will be slightly flakey
|
||||
instead of not working at all.) This mode bit is set by
|
||||
PacketAliasInit(), so it is a default mode of operation. */
|
||||
#define PKT_ALIAS_SAME_PORTS 0x04
|
||||
|
||||
/* If PKT_ALIAS_USE_SOCKETS is set, then when partially specified
|
||||
links (e.g. destination port and/or address is zero), the packet
|
||||
aliasing engine will attempt to allocate a socket for the aliasing
|
||||
port it chooses. This will avoid interference with the host
|
||||
machine. Fully specified links do not require this. This bit
|
||||
is set after a call to PacketAliasInit(), so it is a default
|
||||
mode of operation. */
|
||||
#define PKT_ALIAS_USE_SOCKETS 0x08
|
||||
|
||||
/* If PKT_ALIAS_UNREGISTERED_ONLY is set, then only packets with
|
||||
unregistered source addresses will be aliased. Private
|
||||
addresses are those in the following ranges:
|
||||
10.0.0.0 -> 10.255.255.255
|
||||
172.16.0.0 -> 172.31.255.255
|
||||
192.168.0.0 -> 192.168.255.255 */
|
||||
#define PKT_ALIAS_UNREGISTERED_ONLY 0x10
|
||||
|
||||
/* If PKT_ALIAS_RESET_ON_ADDR_CHANGE is set, then the table of dynamic
|
||||
aliasing links will be reset whenever PacketAliasSetAddress()
|
||||
changes the default aliasing address. If the default aliasing
|
||||
address is left unchanged by this function call, then the
|
||||
table of dynamic aliasing links will be left intact. This
|
||||
bit is set after a call to PacketAliasInit(). */
|
||||
#define PKT_ALIAS_RESET_ON_ADDR_CHANGE 0x20
|
||||
|
||||
#ifndef NO_FW_PUNCH
|
||||
/* If PKT_ALIAS_PUNCH_FW is set, active FTP and IRC DCC connections
|
||||
will create a 'hole' in the firewall to allow the transfers to
|
||||
work. Where (IPFW "line-numbers") the hole is created is
|
||||
controlled by PacketAliasSetFWBase(base, size). The hole will be
|
||||
attached to that particular alias_link, so when the link goes away
|
||||
so do the hole. */
|
||||
#define PKT_ALIAS_PUNCH_FW 0x100
|
||||
#endif
|
||||
|
||||
/* If PKT_ALIAS_PROXY_ONLY is set, then NAT will be disabled and only
|
||||
transparent proxying performed */
|
||||
#define PKT_ALIAS_PROXY_ONLY 0x40
|
||||
|
||||
/* If PKT_ALIAS_REVERSE is set, the actions of PacketAliasIn()
|
||||
and PacketAliasOut() are reversed */
|
||||
#define PKT_ALIAS_REVERSE 0x80
|
||||
|
||||
/* Return Codes */
|
||||
#define PKT_ALIAS_ERROR -1
|
||||
#define PKT_ALIAS_OK 1
|
||||
#define PKT_ALIAS_IGNORED 2
|
||||
#define PKT_ALIAS_UNRESOLVED_FRAGMENT 3
|
||||
#define PKT_ALIAS_FOUND_HEADER_FRAGMENT 4
|
||||
|
||||
#endif
|
||||
/*lint -restore */
|
||||
/* lint -restore */
|
||||
|
@ -2634,12 +2634,6 @@ do { \
|
||||
} /*lint -save -e717 */ while(0) /*lint -restore */
|
||||
#define fw_tstfield(field, num) ((field)[(num) - fireWallBaseNum])
|
||||
|
||||
void
|
||||
PacketAliasSetFWBase(unsigned int base, unsigned int num) {
|
||||
fireWallBaseNum = base;
|
||||
fireWallNumNums = num;
|
||||
}
|
||||
|
||||
static void
|
||||
InitPunchFW(void) {
|
||||
fireWallField = malloc(fireWallNumNums);
|
||||
@ -2784,3 +2778,11 @@ ClearAllFWHoles(void) {
|
||||
memset(fireWallField, 0, fireWallNumNums);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
PacketAliasSetFWBase(unsigned int base, unsigned int num) {
|
||||
#ifndef NO_FW_PUNCH
|
||||
fireWallBaseNum = base;
|
||||
fireWallNumNums = num;
|
||||
#endif
|
||||
}
|
||||
|
@ -1,211 +1,203 @@
|
||||
/* -*- mode: c; tab-width: 3; c-basic-offset: 3; -*-
|
||||
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.
|
||||
|
||||
Initial version: August, 1996 (cjm)
|
||||
|
||||
<updated several times by original author and Eivind Eklund>
|
||||
|
||||
$FreeBSD$
|
||||
*/
|
||||
#ifndef ALIAS_LOCAL_H
|
||||
#define ALIAS_LOCAL_H
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
Macros
|
||||
* 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.
|
||||
*
|
||||
* Initial version: August, 1996 (cjm)
|
||||
*
|
||||
* <updated several times by original author and Eivind Eklund>
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
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) { \
|
||||
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; \
|
||||
} \
|
||||
}
|
||||
#ifndef _ALIAS_LOCAL_H_
|
||||
#define _ALIAS_LOCAL_H_
|
||||
|
||||
/* Macros */
|
||||
|
||||
/*
|
||||
Globals
|
||||
*/
|
||||
* 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 */
|
||||
|
||||
extern int packetAliasMode;
|
||||
|
||||
|
||||
/*
|
||||
Structs
|
||||
*/
|
||||
|
||||
struct alias_link; /* Incomplete structure */
|
||||
|
||||
|
||||
/*
|
||||
Prototypes
|
||||
*/
|
||||
/* Prototypes */
|
||||
|
||||
/* General utilities */
|
||||
u_short IpChecksum(struct ip *);
|
||||
u_short TcpChecksum(struct ip *);
|
||||
void DifferentialChecksum(u_short *, u_short *, u_short *, int);
|
||||
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);
|
||||
|
||||
/* Internal data access */
|
||||
struct alias_link *
|
||||
FindIcmpIn(struct in_addr, struct in_addr, u_short, int);
|
||||
|
||||
FindIcmpIn(struct in_addr _dst_addr, struct in_addr _alias_addr,
|
||||
u_short _id_alias, int _create);
|
||||
struct alias_link *
|
||||
FindIcmpOut(struct in_addr, struct in_addr, u_short, int);
|
||||
|
||||
FindIcmpOut(struct in_addr _src_addr, struct in_addr _dst_addr,
|
||||
u_short _id, int _create);
|
||||
struct alias_link *
|
||||
FindFragmentIn1(struct in_addr, struct in_addr, u_short);
|
||||
|
||||
FindFragmentIn1(struct in_addr _dst_addr, struct in_addr _alias_addr,
|
||||
u_short _ip_id);
|
||||
struct alias_link *
|
||||
FindFragmentIn2(struct in_addr, struct in_addr, u_short);
|
||||
|
||||
FindFragmentIn2(struct in_addr _dst_addr, struct in_addr _alias_addr,
|
||||
u_short _ip_id);
|
||||
struct alias_link *
|
||||
AddFragmentPtrLink(struct in_addr, u_short);
|
||||
|
||||
AddFragmentPtrLink(struct in_addr _dst_addr, u_short _ip_id);
|
||||
struct alias_link *
|
||||
FindFragmentPtr(struct in_addr, u_short);
|
||||
|
||||
FindFragmentPtr(struct in_addr _dst_addr, u_short _ip_id);
|
||||
struct alias_link *
|
||||
FindProtoIn(struct in_addr, struct in_addr, u_char);
|
||||
|
||||
FindProtoIn(struct in_addr _dst_addr, struct in_addr _alias_addr,
|
||||
u_char _proto);
|
||||
struct alias_link *
|
||||
FindProtoOut(struct in_addr, struct in_addr, u_char);
|
||||
|
||||
FindProtoOut(struct in_addr _src_addr, struct in_addr _dst_addr,
|
||||
u_char _proto);
|
||||
struct alias_link *
|
||||
FindUdpTcpIn (struct in_addr, struct in_addr, u_short, u_short, u_char, int);
|
||||
|
||||
FindUdpTcpIn(struct in_addr _dst_addr, struct in_addr _alias_addr,
|
||||
u_short _dst_port, u_short _alias_port, u_char _proto, int _create);
|
||||
struct alias_link *
|
||||
FindUdpTcpOut(struct in_addr, struct in_addr, u_short, u_short, u_char, int);
|
||||
|
||||
FindUdpTcpOut(struct in_addr _src_addr, struct in_addr _dst_addr,
|
||||
u_short _src_port, u_short _dst_port, u_char _proto, int _create);
|
||||
struct alias_link *
|
||||
AddPptp(struct in_addr, struct in_addr, struct in_addr, u_int16_t);
|
||||
|
||||
AddPptp(struct in_addr _src_addr, struct in_addr _dst_addr,
|
||||
struct in_addr _alias_addr, u_int16_t _src_call_id);
|
||||
struct alias_link *
|
||||
FindPptpOutByCallId(struct in_addr, struct in_addr, u_int16_t);
|
||||
|
||||
FindPptpOutByCallId(struct in_addr _src_addr,
|
||||
struct in_addr _dst_addr, u_int16_t _src_call_id);
|
||||
struct alias_link *
|
||||
FindPptpInByCallId(struct in_addr, struct in_addr, u_int16_t);
|
||||
|
||||
FindPptpInByCallId(struct in_addr _dst_addr,
|
||||
struct in_addr _alias_addr, u_int16_t _dst_call_id);
|
||||
struct alias_link *
|
||||
FindPptpOutByPeerCallId(struct in_addr, struct in_addr, u_int16_t);
|
||||
|
||||
FindPptpOutByPeerCallId(struct in_addr _src_addr,
|
||||
struct in_addr _dst_addr, u_int16_t _dst_call_id);
|
||||
struct alias_link *
|
||||
FindPptpInByPeerCallId(struct in_addr, struct in_addr, u_int16_t);
|
||||
|
||||
FindPptpInByPeerCallId(struct in_addr _dst_addr,
|
||||
struct in_addr _alias_addr, u_int16_t _alias_call_id);
|
||||
struct alias_link *
|
||||
FindRtspOut(struct in_addr, struct in_addr, u_short, u_short, u_char);
|
||||
|
||||
FindRtspOut(struct in_addr _src_addr, struct in_addr _dst_addr,
|
||||
u_short _src_port, u_short _alias_port, u_char _proto);
|
||||
struct in_addr
|
||||
FindOriginalAddress(struct in_addr);
|
||||
|
||||
FindOriginalAddress(struct in_addr _alias_addr);
|
||||
struct in_addr
|
||||
FindAliasAddress(struct in_addr);
|
||||
FindAliasAddress(struct in_addr _original_addr);
|
||||
|
||||
/* External data access/modification */
|
||||
int FindNewPortGroup(struct in_addr, struct in_addr,
|
||||
u_short, u_short, u_short, u_char, u_char);
|
||||
void GetFragmentAddr(struct alias_link *, struct in_addr *);
|
||||
void SetFragmentAddr(struct alias_link *, struct in_addr);
|
||||
void GetFragmentPtr(struct alias_link *, char **);
|
||||
void SetFragmentPtr(struct alias_link *, char *);
|
||||
void SetStateIn(struct alias_link *, int);
|
||||
void SetStateOut(struct alias_link *, int);
|
||||
int GetStateIn(struct alias_link *);
|
||||
int GetStateOut(struct alias_link *);
|
||||
struct in_addr GetOriginalAddress(struct alias_link *);
|
||||
struct in_addr GetDestAddress(struct alias_link *);
|
||||
struct in_addr GetAliasAddress(struct alias_link *);
|
||||
struct in_addr GetDefaultAliasAddress(void);
|
||||
void SetDefaultAliasAddress(struct in_addr);
|
||||
u_short GetOriginalPort(struct alias_link *);
|
||||
u_short GetAliasPort(struct alias_link *);
|
||||
struct in_addr GetProxyAddress(struct alias_link *);
|
||||
void SetProxyAddress(struct alias_link *, struct in_addr);
|
||||
u_short GetProxyPort(struct alias_link *);
|
||||
void SetProxyPort(struct alias_link *, u_short);
|
||||
void SetAckModified(struct alias_link *);
|
||||
int GetAckModified(struct alias_link *);
|
||||
int GetDeltaAckIn(struct ip *, struct alias_link *);
|
||||
int GetDeltaSeqOut(struct ip *, struct alias_link *);
|
||||
void AddSeq(struct ip *, struct alias_link *, int);
|
||||
void SetExpire(struct alias_link *, int);
|
||||
void ClearCheckNewLink(void);
|
||||
void SetLastLineCrlfTermed(struct alias_link *, int);
|
||||
int GetLastLineCrlfTermed(struct alias_link *);
|
||||
void SetDestCallId(struct alias_link *, u_int16_t);
|
||||
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);
|
||||
void SetLastLineCrlfTermed(struct alias_link *_link, int _yes);
|
||||
int GetLastLineCrlfTermed(struct alias_link *_link);
|
||||
void SetDestCallId(struct alias_link *_link, u_int16_t _cid);
|
||||
#ifndef NO_FW_PUNCH
|
||||
void PunchFWHole(struct alias_link *);
|
||||
void PunchFWHole(struct alias_link *_link);
|
||||
#endif
|
||||
|
||||
|
||||
/* Housekeeping function */
|
||||
void HouseKeeping(void);
|
||||
void HouseKeeping(void);
|
||||
|
||||
/* Tcp specfic routines */
|
||||
/*lint -save -library Suppress flexelint warnings */
|
||||
/* lint -save -library Suppress flexelint warnings */
|
||||
|
||||
/* FTP routines */
|
||||
void AliasHandleFtpOut(struct ip *, struct alias_link *, int);
|
||||
void AliasHandleFtpOut(struct ip *_pip, struct alias_link *_link,
|
||||
int _maxpacketsize);
|
||||
|
||||
/* IRC routines */
|
||||
void AliasHandleIrcOut(struct ip *, struct alias_link *, int);
|
||||
void AliasHandleIrcOut(struct ip *_pip, struct alias_link *_link,
|
||||
int _maxsize);
|
||||
|
||||
/* RTSP routines */
|
||||
void AliasHandleRtspOut(struct ip *, struct alias_link *, int);
|
||||
void AliasHandleRtspOut(struct ip *_pip, struct alias_link *_link,
|
||||
int _maxpacketsize);
|
||||
|
||||
/* PPTP routines */
|
||||
void AliasHandlePptpOut(struct ip *, struct alias_link *);
|
||||
void AliasHandlePptpIn(struct ip *, struct alias_link *);
|
||||
int AliasHandlePptpGreOut(struct ip *);
|
||||
int AliasHandlePptpGreIn(struct ip *);
|
||||
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);
|
||||
|
||||
/* NetBIOS routines */
|
||||
int AliasHandleUdpNbt(struct ip *, struct alias_link *, struct in_addr *, u_short);
|
||||
int AliasHandleUdpNbtNS(struct ip *, struct alias_link *, struct in_addr *, u_short *, struct in_addr *, u_short *);
|
||||
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);
|
||||
|
||||
/* CUSeeMe routines */
|
||||
void AliasHandleCUSeeMeOut(struct ip *, struct alias_link *);
|
||||
void AliasHandleCUSeeMeIn(struct ip *, struct in_addr);
|
||||
void AliasHandleCUSeeMeOut(struct ip *_pip, struct alias_link *_link);
|
||||
void AliasHandleCUSeeMeIn(struct ip *_pip, struct in_addr _original_addr);
|
||||
|
||||
/* Transparent proxy routines */
|
||||
int ProxyCheck(struct ip *, struct in_addr *, u_short *);
|
||||
void ProxyModify(struct alias_link *, struct ip *, int, int);
|
||||
|
||||
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);
|
||||
|
||||
enum alias_tcp_state {
|
||||
ALIAS_TCP_STATE_NOT_CONNECTED,
|
||||
ALIAS_TCP_STATE_CONNECTED,
|
||||
ALIAS_TCP_STATE_DISCONNECTED
|
||||
ALIAS_TCP_STATE_NOT_CONNECTED,
|
||||
ALIAS_TCP_STATE_CONNECTED,
|
||||
ALIAS_TCP_STATE_DISCONNECTED
|
||||
};
|
||||
|
||||
/*lint -restore */
|
||||
#endif /* defined(ALIAS_LOCAL_H) */
|
||||
|
||||
#endif /* !_ALIAS_LOCAL_H_ */
|
||||
|
@ -241,7 +241,7 @@ int AliasHandleUdpNbt(
|
||||
sptr = (u_short *) alias_address;
|
||||
acc -= *sptr++;
|
||||
acc -= *sptr;
|
||||
ADJUST_CHECKSUM(acc, uh->uh_sum)
|
||||
ADJUST_CHECKSUM(acc, uh->uh_sum);
|
||||
}
|
||||
ndh->source_ip = *alias_address;
|
||||
ndh->source_port = alias_port;
|
||||
@ -358,7 +358,7 @@ AliasHandleResourceNB(
|
||||
sptr = (u_short *) &(nbtarg->newaddr);
|
||||
acc -= *sptr++;
|
||||
acc -= *sptr;
|
||||
ADJUST_CHECKSUM(acc, *nbtarg->uh_sum)
|
||||
ADJUST_CHECKSUM(acc, *nbtarg->uh_sum);
|
||||
}
|
||||
|
||||
nb->addr = nbtarg->newaddr;
|
||||
@ -426,7 +426,7 @@ AliasHandleResourceA(
|
||||
sptr = (u_short *) &nbtarg->newaddr; /* New */
|
||||
acc -= *sptr++;
|
||||
acc -= *sptr;
|
||||
ADJUST_CHECKSUM(acc, *nbtarg->uh_sum)
|
||||
ADJUST_CHECKSUM(acc, *nbtarg->uh_sum);
|
||||
}
|
||||
|
||||
a->addr = nbtarg->newaddr;
|
||||
|
@ -71,6 +71,8 @@
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/tcp.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "alias_local.h"
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user