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
|
|
|
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/sysctl.h>
|
2005-05-05 21:05:38 +00:00
|
|
|
|
|
|
|
#ifdef _KERNEL
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
#include <sys/malloc.h>
|
2006-12-15 12:50:06 +00:00
|
|
|
#include <sys/param.h>
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
#include <sys/lock.h>
|
2006-12-15 12:50:06 +00:00
|
|
|
#include <sys/mutex.h>
|
|
|
|
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
/* XXX: LibAliasSetTarget() uses this constant. */
|
2005-05-05 21:05:38 +00:00
|
|
|
#define INADDR_NONE 0xffffffff
|
2009-02-07 18:49:42 +00:00
|
|
|
|
|
|
|
#include <netinet/libalias/alias_sctp.h>
|
|
|
|
#else
|
|
|
|
#include "alias_sctp.h"
|
2005-05-05 21:05:38 +00:00
|
|
|
#endif
|
|
|
|
|
2004-01-17 10:52:21 +00:00
|
|
|
/* Sizes of input and output link tables */
|
2008-06-01 18:34:58 +00:00
|
|
|
#define LINK_TABLE_OUT_SIZE 4001
|
2004-01-17 10:52:21 +00:00
|
|
|
#define LINK_TABLE_IN_SIZE 4001
|
|
|
|
|
|
|
|
struct proxy_entry;
|
|
|
|
|
|
|
|
struct libalias {
|
2004-03-16 21:30:41 +00:00
|
|
|
LIST_ENTRY(libalias) instancelist;
|
2004-01-17 10:52:21 +00:00
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
int packetAliasMode; /* Mode flags */
|
|
|
|
/* - documented in alias.h */
|
2004-01-17 10:52:21 +00:00
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
struct in_addr aliasAddress; /* Address written onto source */
|
|
|
|
/* field of IP packet. */
|
2004-01-17 10:52:21 +00:00
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
struct in_addr targetAddress; /* IP address incoming packets */
|
|
|
|
/* are sent to if no aliasing */
|
|
|
|
/* link already exists */
|
2004-01-17 10:52:21 +00:00
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
struct in_addr nullAddress; /* Used as a dummy parameter for */
|
|
|
|
/* some function calls */
|
2004-01-17 10:52:21 +00:00
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
LIST_HEAD (, alias_link) linkTableOut[LINK_TABLE_OUT_SIZE];
|
|
|
|
/* Lookup table of pointers to */
|
|
|
|
/* chains of link records. Each */
|
2004-01-17 10:52:21 +00:00
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
LIST_HEAD (, alias_link) linkTableIn[LINK_TABLE_IN_SIZE];
|
|
|
|
/* link record is doubly indexed */
|
|
|
|
/* into input and output lookup */
|
|
|
|
/* tables. */
|
2004-01-17 10:52:21 +00:00
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
/* Link statistics */
|
|
|
|
int icmpLinkCount;
|
|
|
|
int udpLinkCount;
|
|
|
|
int tcpLinkCount;
|
|
|
|
int pptpLinkCount;
|
|
|
|
int protoLinkCount;
|
|
|
|
int fragmentIdLinkCount;
|
|
|
|
int fragmentPtrLinkCount;
|
|
|
|
int sockCount;
|
2004-01-17 10:52:21 +00:00
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
int cleanupIndex; /* Index to chain of link table */
|
|
|
|
/* being inspected for old links */
|
2004-01-17 10:52:21 +00:00
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
int timeStamp; /* System time in seconds for */
|
|
|
|
/* current packet */
|
2004-01-17 10:52:21 +00:00
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
int lastCleanupTime; /* Last time
|
|
|
|
* IncrementalCleanup() */
|
|
|
|
/* was called */
|
2004-01-17 10:52:21 +00:00
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
int deleteAllLinks; /* If equal to zero, DeleteLink() */
|
|
|
|
/* will not remove permanent links */
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
|
|
|
|
/* log descriptor */
|
|
|
|
#ifdef _KERNEL
|
|
|
|
char *logDesc;
|
|
|
|
#else
|
|
|
|
FILE *logDesc;
|
2005-05-05 20:22:09 +00:00
|
|
|
#endif
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
/* statistics monitoring */
|
2004-01-17 10:52:21 +00:00
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
int newDefaultLink; /* Indicates if a new aliasing */
|
|
|
|
/* link has been created after a */
|
|
|
|
/* call to PacketAliasIn/Out(). */
|
2004-01-17 10:52:21 +00:00
|
|
|
|
|
|
|
#ifndef NO_FW_PUNCH
|
2004-03-16 21:30:41 +00:00
|
|
|
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 */
|
2004-01-17 10:52:21 +00:00
|
|
|
#endif
|
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
unsigned int skinnyPort; /* TCP port used by the Skinny */
|
|
|
|
/* protocol. */
|
2004-01-17 10:52:21 +00:00
|
|
|
|
|
|
|
struct proxy_entry *proxyList;
|
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
struct in_addr true_addr; /* in network byte order. */
|
|
|
|
u_short true_port; /* in host byte order. */
|
2009-02-07 18:49:42 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* sctp code support
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* counts associations that have progressed to UP and not yet removed */
|
|
|
|
int sctpLinkCount;
|
2006-12-15 12:50:06 +00:00
|
|
|
#ifdef _KERNEL
|
2009-02-07 18:49:42 +00:00
|
|
|
/* timing queue for keeping track of association timeouts */
|
|
|
|
struct sctp_nat_timer sctpNatTimer;
|
|
|
|
|
|
|
|
/* size of hash table used in this instance */
|
|
|
|
u_int sctpNatTableSize;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* local look up table sorted by l_vtag/l_port
|
|
|
|
*/
|
|
|
|
LIST_HEAD(sctpNatTableL, sctp_nat_assoc) *sctpTableLocal;
|
|
|
|
/*
|
|
|
|
* global look up table sorted by g_vtag/g_port
|
|
|
|
*/
|
|
|
|
LIST_HEAD(sctpNatTableG, sctp_nat_assoc) *sctpTableGlobal;
|
|
|
|
|
2006-12-15 12:50:06 +00:00
|
|
|
/*
|
|
|
|
* avoid races in libalias: every public function has to use it.
|
|
|
|
*/
|
|
|
|
struct mtx mutex;
|
|
|
|
#endif
|
2004-01-17 10:52:21 +00:00
|
|
|
};
|
|
|
|
|
2001-03-25 12:05:10 +00:00
|
|
|
/* Macros */
|
1999-02-27 02:16:01 +00:00
|
|
|
|
2006-12-15 12:50:06 +00:00
|
|
|
#ifdef _KERNEL
|
|
|
|
#define LIBALIAS_LOCK_INIT(l) \
|
|
|
|
mtx_init(&l->mutex, "per-instance libalias mutex", NULL, MTX_DEF)
|
|
|
|
#define LIBALIAS_LOCK_ASSERT(l) mtx_assert(&l->mutex, MA_OWNED)
|
|
|
|
#define LIBALIAS_LOCK(l) mtx_lock(&l->mutex)
|
|
|
|
#define LIBALIAS_UNLOCK(l) mtx_unlock(&l->mutex)
|
|
|
|
#define LIBALIAS_LOCK_DESTROY(l) mtx_destroy(&l->mutex)
|
|
|
|
#else
|
|
|
|
#define LIBALIAS_LOCK_INIT(l)
|
|
|
|
#define LIBALIAS_LOCK_ASSERT(l)
|
|
|
|
#define LIBALIAS_LOCK(l)
|
|
|
|
#define LIBALIAS_UNLOCK(l)
|
|
|
|
#define LIBALIAS_LOCK_DESTROY(l)
|
|
|
|
#endif
|
|
|
|
|
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)
|
|
|
|
|
1997-05-23 04:41:31 +00:00
|
|
|
|
2001-03-25 12:05:10 +00:00
|
|
|
/* Prototypes */
|
1997-05-23 04:41:31 +00:00
|
|
|
|
2009-02-07 18:49:42 +00:00
|
|
|
/*
|
|
|
|
* SctpFunction prototypes
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void AliasSctpInit(struct libalias *la);
|
|
|
|
void AliasSctpTerm(struct libalias *la);
|
|
|
|
int SctpAlias(struct libalias *la, struct ip *ip, int direction);
|
|
|
|
|
2005-06-27 07:36:02 +00:00
|
|
|
/*
|
|
|
|
* 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
|
2004-03-16 21:30:41 +00:00
|
|
|
u_short IpChecksum(struct ip *_pip);
|
|
|
|
u_short TcpChecksum(struct ip *_pip);
|
2005-06-27 07:36:02 +00:00
|
|
|
#endif
|
2004-03-16 21:30:41 +00:00
|
|
|
void
|
2004-03-31 21:32:58 +00:00
|
|
|
DifferentialChecksum(u_short * _cksum, void * _new, void * _old, int _n);
|
1997-05-23 04:41:31 +00:00
|
|
|
|
|
|
|
/* Internal data access */
|
|
|
|
struct alias_link *
|
2004-03-16 21:30:41 +00:00
|
|
|
FindIcmpIn(struct libalias *la, 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 *
|
2004-03-16 21:30:41 +00:00
|
|
|
FindIcmpOut(struct libalias *la, 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 *
|
2004-03-16 21:30:41 +00:00
|
|
|
FindFragmentIn1(struct libalias *la, 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 *
|
2004-03-16 21:30:41 +00:00
|
|
|
FindFragmentIn2(struct libalias *la, 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 *
|
2004-03-16 21:30:41 +00:00
|
|
|
AddFragmentPtrLink(struct libalias *la, struct in_addr _dst_addr, u_short _ip_id);
|
1997-05-23 04:41:31 +00:00
|
|
|
struct alias_link *
|
2004-03-16 21:30:41 +00:00
|
|
|
FindFragmentPtr(struct libalias *la, struct in_addr _dst_addr, u_short _ip_id);
|
2000-04-18 10:18:21 +00:00
|
|
|
struct alias_link *
|
2004-03-16 21:30:41 +00:00
|
|
|
FindProtoIn(struct libalias *la, struct in_addr _dst_addr, struct in_addr _alias_addr,
|
|
|
|
u_char _proto);
|
2000-04-18 10:18:21 +00:00
|
|
|
struct alias_link *
|
2004-03-16 21:30:41 +00:00
|
|
|
FindProtoOut(struct libalias *la, struct in_addr _src_addr, struct in_addr _dst_addr,
|
|
|
|
u_char _proto);
|
1997-05-23 04:41:31 +00:00
|
|
|
struct alias_link *
|
2004-03-16 21:30:41 +00:00
|
|
|
FindUdpTcpIn(struct libalias *la, 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 *
|
2004-03-16 21:30:41 +00:00
|
|
|
FindUdpTcpOut(struct libalias *la, 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 *
|
2004-03-16 21:30:41 +00:00
|
|
|
AddPptp(struct libalias *la, 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 *
|
2004-03-16 21:30:41 +00:00
|
|
|
FindPptpOutByCallId(struct libalias *la, 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 *
|
2004-03-16 21:30:41 +00:00
|
|
|
FindPptpInByCallId(struct libalias *la, 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 *
|
2004-03-16 21:30:41 +00:00
|
|
|
FindPptpOutByPeerCallId(struct libalias *la, 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 *
|
2004-03-16 21:30:41 +00:00
|
|
|
FindPptpInByPeerCallId(struct libalias *la, 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 *
|
2004-03-16 21:30:41 +00:00
|
|
|
FindRtspOut(struct libalias *la, 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
|
2004-03-16 21:30:41 +00:00
|
|
|
FindOriginalAddress(struct libalias *la, struct in_addr _alias_addr);
|
1997-05-23 04:41:31 +00:00
|
|
|
struct in_addr
|
2004-03-16 21:30:41 +00:00
|
|
|
FindAliasAddress(struct libalias *la, struct in_addr _original_addr);
|
2009-02-07 18:49:42 +00:00
|
|
|
struct in_addr
|
|
|
|
FindSctpRedirectAddress(struct libalias *la, struct sctp_nat_msg *sm);
|
1997-05-23 04:41:31 +00:00
|
|
|
|
|
|
|
/* External data access/modification */
|
2004-03-16 21:30:41 +00:00
|
|
|
int
|
|
|
|
FindNewPortGroup(struct libalias *la, 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);
|
2004-07-05 11:10:57 +00:00
|
|
|
void GetFragmentAddr(struct alias_link *_lnk, struct in_addr *_src_addr);
|
|
|
|
void SetFragmentAddr(struct alias_link *_lnk, struct in_addr _src_addr);
|
|
|
|
void GetFragmentPtr(struct alias_link *_lnk, char **_fptr);
|
|
|
|
void SetFragmentPtr(struct alias_link *_lnk, char *fptr);
|
|
|
|
void SetStateIn(struct alias_link *_lnk, int _state);
|
|
|
|
void SetStateOut(struct alias_link *_lnk, int _state);
|
|
|
|
int GetStateIn (struct alias_link *_lnk);
|
|
|
|
int GetStateOut(struct alias_link *_lnk);
|
2001-03-25 12:05:10 +00:00
|
|
|
struct in_addr
|
2004-07-05 11:10:57 +00:00
|
|
|
GetOriginalAddress(struct alias_link *_lnk);
|
2001-03-25 12:05:10 +00:00
|
|
|
struct in_addr
|
2004-07-05 11:10:57 +00:00
|
|
|
GetDestAddress(struct alias_link *_lnk);
|
2001-03-25 12:05:10 +00:00
|
|
|
struct in_addr
|
2004-07-05 11:10:57 +00:00
|
|
|
GetAliasAddress(struct alias_link *_lnk);
|
2001-03-25 12:05:10 +00:00
|
|
|
struct in_addr
|
2004-03-16 21:30:41 +00:00
|
|
|
GetDefaultAliasAddress(struct libalias *la);
|
|
|
|
void SetDefaultAliasAddress(struct libalias *la, struct in_addr _alias_addr);
|
2004-07-05 11:10:57 +00:00
|
|
|
u_short GetOriginalPort(struct alias_link *_lnk);
|
|
|
|
u_short GetAliasPort(struct alias_link *_lnk);
|
2001-03-25 12:05:10 +00:00
|
|
|
struct in_addr
|
2004-07-05 11:10:57 +00:00
|
|
|
GetProxyAddress(struct alias_link *_lnk);
|
|
|
|
void SetProxyAddress(struct alias_link *_lnk, struct in_addr _addr);
|
|
|
|
u_short GetProxyPort(struct alias_link *_lnk);
|
|
|
|
void SetProxyPort(struct alias_link *_lnk, u_short _port);
|
|
|
|
void SetAckModified(struct alias_link *_lnk);
|
|
|
|
int GetAckModified(struct alias_link *_lnk);
|
2008-03-06 21:50:41 +00:00
|
|
|
int GetDeltaAckIn(u_long, struct alias_link *_lnk);
|
|
|
|
int GetDeltaSeqOut(u_long, struct alias_link *lnk);
|
|
|
|
void AddSeq(struct alias_link *lnk, int delta, u_int ip_hl,
|
|
|
|
u_short ip_len, u_long th_seq, u_int th_off);
|
2004-07-05 11:10:57 +00:00
|
|
|
void SetExpire (struct alias_link *_lnk, int _expire);
|
2004-03-16 21:30:41 +00:00
|
|
|
void ClearCheckNewLink(struct libalias *la);
|
2004-07-05 11:10:57 +00:00
|
|
|
void SetProtocolFlags(struct alias_link *_lnk, int _pflags);
|
|
|
|
int GetProtocolFlags(struct alias_link *_lnk);
|
|
|
|
void SetDestCallId(struct alias_link *_lnk, u_int16_t _cid);
|
2004-03-16 21:30:41 +00:00
|
|
|
|
1998-06-06 21:52:37 +00:00
|
|
|
#ifndef NO_FW_PUNCH
|
2004-07-05 11:10:57 +00:00
|
|
|
void PunchFWHole(struct alias_link *_lnk);
|
2004-03-16 21:30:41 +00:00
|
|
|
|
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 */
|
2004-03-16 21:30:41 +00:00
|
|
|
void HouseKeeping(struct libalias *);
|
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
|
|
|
|
|
|
|
/* Transparent proxy routines */
|
2004-03-16 21:30:41 +00:00
|
|
|
int
|
2008-03-06 21:50:41 +00:00
|
|
|
ProxyCheck(struct libalias *la, struct in_addr *proxy_server_addr,
|
|
|
|
u_short * proxy_server_port, struct in_addr src_addr,
|
|
|
|
struct in_addr dst_addr, u_short dst_port, u_char ip_p);
|
2004-03-16 21:30:41 +00:00
|
|
|
void
|
2004-07-05 11:10:57 +00:00
|
|
|
ProxyModify(struct libalias *la, struct alias_link *_lnk, struct ip *_pip,
|
2004-03-16 21:30:41 +00:00
|
|
|
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
|
|
|
|
2004-07-06 12:13:28 +00:00
|
|
|
#if defined(_NETINET_IP_H_)
|
|
|
|
static __inline void *
|
|
|
|
ip_next(struct ip *iphdr)
|
|
|
|
{
|
|
|
|
char *p = (char *)iphdr;
|
|
|
|
return (&p[iphdr->ip_hl * 4]);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(_NETINET_TCP_H_)
|
|
|
|
static __inline void *
|
|
|
|
tcp_next(struct tcphdr *tcphdr)
|
|
|
|
{
|
|
|
|
char *p = (char *)tcphdr;
|
|
|
|
return (&p[tcphdr->th_off * 4]);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(_NETINET_UDP_H_)
|
|
|
|
static __inline void *
|
|
|
|
udp_next(struct udphdr *udphdr)
|
|
|
|
{
|
|
|
|
return ((void *)(udphdr + 1));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
#endif /* !_ALIAS_LOCAL_H_ */
|