alias_local.h revision 4dd5020158b69719fd7942ff7b996df2d4535bb4
/*-
* Copyright (c) 2001 Charles Mott <cm@linktel.net>
* 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
*
* 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: src/sys/netinet/libalias/alias_local.h,v 1.34.2.1.4.1 2009/04/15 03:14:26 kensmith Exp $
*/
/*
* 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>
*/
#ifndef _ALIAS_LOCAL_H_
#define _ALIAS_LOCAL_H_
#ifndef VBOX
#ifdef _KERNEL
/* XXX: LibAliasSetTarget() uses this constant. */
#define INADDR_NONE 0xffffffff
#endif
#else /* VBOX */
# include <slirp.h>
#endif /* VBOX */
/* Sizes of input and output link tables */
#define LINK_TABLE_OUT_SIZE 4001
#define LINK_TABLE_IN_SIZE 4001
struct proxy_entry;
struct libalias {
int packetAliasMode; /* Mode flags */
/* - documented in alias.h */
/* field of IP packet. */
/* are sent to if no aliasing */
/* link already exists */
/* some function calls */
/* Lookup table of pointers to */
/* chains of link records. Each */
/* link record is doubly indexed */
/* into input and output lookup */
/* tables. */
/* Link statistics */
int icmpLinkCount;
int udpLinkCount;
int tcpLinkCount;
int pptpLinkCount;
int protoLinkCount;
int fragmentIdLinkCount;
int fragmentPtrLinkCount;
int sockCount;
int cleanupIndex; /* Index to chain of link table */
/* being inspected for old links */
#ifndef VBOX
int timeStamp; /* System time in seconds for */
/* current packet */
int lastCleanupTime; /* Last time
* IncrementalCleanup() */
#else
unsigned int timeStamp; /* System time in seconds for */
unsigned int lastCleanupTime; /* Last time */
#endif
/* was called */
int deleteAllLinks; /* If equal to zero, DeleteLink() */
/* will not remove permanent links */
/* log descriptor */
#ifdef _KERNEL
char *logDesc;
#else
#endif
/* statistics monitoring */
int newDefaultLink; /* Indicates if a new aliasing */
/* link has been created after a */
/* call to PacketAliasIn/Out(). */
#ifndef NO_FW_PUNCH
int fireWallFD; /* File descriptor to be able to */
/* control firewall. Opened by */
/* PacketAliasSetMode on first */
/* setting the PKT_ALIAS_PUNCH_FW */
/* flag. */
int fireWallBaseNum; /* The first firewall entry
* free for our use */
int fireWallNumNums; /* How many entries can we
* use? */
int fireWallActiveNum; /* Which entry did we last
* use? */
char *fireWallField; /* bool array for entries */
#endif
unsigned int skinnyPort; /* TCP port used by the Skinny */
/* protocol. */
struct proxy_entry *proxyList;
/*
* avoid races in libalias: every public function has to use it.
*/
#endif
#ifdef VBOX
#endif
};
/* Macros */
#define LIBALIAS_LOCK_INIT(l) \
#else
#define LIBALIAS_LOCK_INIT(l)
#define LIBALIAS_LOCK_ASSERT(l)
#define LIBALIAS_LOCK(l) NOREF((l));
#define LIBALIAS_UNLOCK(l) NOREF((l))
#define LIBALIAS_LOCK_DESTROY(l)
#endif
/*
* 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.
*/
do { \
if (acc < 0) { \
} else { \
} \
} while (0)
/* Prototypes */
/*
* We do not calculate TCP checksums when libalias is a kernel
* module, since it has no idea about checksum offloading.
* If TCP data has changed, then we just set checksum to zero,
* and caller must recalculate it himself.
* In case if libalias will edit UDP data, the same approach
* should be used.
*/
#ifndef _KERNEL
#endif
void
/* Internal data access */
struct alias_link *
struct alias_link *
struct alias_link *
struct alias_link *
struct alias_link *
struct alias_link *
struct alias_link *
struct alias_link *
struct alias_link *
struct alias_link *
struct alias_link *
struct alias_link *
struct alias_link *
struct alias_link *
struct alias_link *
struct alias_link *
struct in_addr
struct in_addr
/* External data access/modification */
int
struct in_addr
struct in_addr
struct in_addr
struct in_addr
struct in_addr
#ifndef NO_FW_PUNCH
#endif
/* Housekeeping function */
void HouseKeeping(struct libalias *);
/* Tcp specfic routines */
/* lint -save -library Suppress flexelint warnings */
/* Transparent proxy routines */
int
void
int _maxpacketsize, int _proxy_type);
enum alias_tcp_state {
};
#if defined(_NETINET_IP_H_)
static __inline void *
{
char *p = (char *)iphdr;
}
#endif
#if defined(_NETINET_TCP_H_)
static __inline void *
{
char *p = (char *)tcphdr;
}
#endif
#if defined(_NETINET_UDP_H_)
static __inline void *
{
return ((void *)(udphdr + 1));
}
#endif
#endif /* !_ALIAS_LOCAL_H_ */