FreeBSD kernel IPv4 code
alias_db.c File Reference
#include <sys/cdefs.h>
#include <machine/stdarg.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/lock.h>
#include <sys/module.h>
#include <sys/rwlock.h>
#include <sys/syslog.h>
#include <sys/socket.h>
#include <netinet/tcp.h>
#include <netinet/libalias/alias.h>
#include <netinet/libalias/alias_local.h>
#include <netinet/libalias/alias_mod.h>
#include <net/if.h>
#include "alias_db.h"
#include <netinet/ip_fw.h>
#include <string.h>
#include <err.h>
Include dependency graph for alias_db.c:

Go to the source code of this file.

Functions

 __FBSDID ("$FreeBSD$")
 
static LIST_HEAD (MODULE_VERSION(libalias)
 
 DECLARE_MODULE (alias, alias_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND)
 
 SPLAY_GENERATE (splay_out, alias_link, all.out, cmp_out)
 
 SPLAY_GENERATE (splay_in, group_in, in, cmp_in)
 
static struct group_inStartPointIn (struct libalias *la, struct in_addr alias_addr, u_short alias_port, int link_type, int create)
 
static int SeqDiff (u_long x, u_long y)
 
static void AliasLog (char *str, const char *format,...)
 
static void ShowAliasStats (struct libalias *la)
 
void SctpShowAliasStats (struct libalias *la)
 Log current statistics for the libalias instance. More...
 
static u_short _RandomPort (struct libalias *la)
 
static int GetNewPort (struct libalias *la, struct alias_link *lnk, int alias_port_param)
 
static u_short GetSocket (struct libalias *la, u_short port_net, int *sockfd, int link_type)
 
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)
 
static void CleanupAliasData (struct libalias *la, int deletePermanent)
 
static void CleanupLink (struct libalias *la, struct alias_link **lnk, int deletePermanent)
 
static struct alias_linkUseLink (struct libalias *la, struct alias_link *lnk)
 
static void DeleteLink (struct alias_link **plnk, int deletePermanent)
 
struct alias_linkAddLink (struct libalias *la, struct in_addr src_addr, struct in_addr dst_addr, struct in_addr alias_addr, u_short src_port, u_short dst_port, int alias_port_param, int link_type)
 
static struct alias_linkReLink (struct alias_link *old_lnk, struct in_addr src_addr, struct in_addr dst_addr, struct in_addr alias_addr, u_short src_port, u_short dst_port, int alias_port_param, int link_type, int deletePermanent)
 
static struct alias_link_SearchLinkOut (struct libalias *la, struct in_addr src_addr, struct in_addr dst_addr, u_short src_port, u_short dst_port, int link_type)
 
static struct alias_link_FindLinkOut (struct libalias *la, struct in_addr src_addr, struct in_addr dst_addr, u_short src_port, u_short dst_port, int link_type, int replace_partial_links)
 
static struct alias_linkFindLinkOut (struct libalias *la, struct in_addr src_addr, struct in_addr dst_addr, u_short src_port, u_short dst_port, int link_type, int replace_partial_links)
 
static struct alias_link_FindLinkIn (struct libalias *la, struct in_addr dst_addr, struct in_addr alias_addr, u_short dst_port, u_short alias_port, int link_type, int replace_partial_links)
 
static struct alias_linkFindLinkIn (struct libalias *la, struct in_addr dst_addr, struct in_addr alias_addr, u_short dst_port, u_short alias_port, int link_type, int replace_partial_links)
 
struct alias_linkFindIcmpIn (struct libalias *la, struct in_addr dst_addr, struct in_addr alias_addr, u_short id_alias, int create)
 
struct alias_linkFindIcmpOut (struct libalias *la, struct in_addr src_addr, struct in_addr dst_addr, u_short id, int create)
 
struct alias_linkFindFragmentIn1 (struct libalias *la, struct in_addr dst_addr, struct in_addr alias_addr, u_short ip_id)
 
struct alias_linkFindFragmentIn2 (struct libalias *la, struct in_addr dst_addr, struct in_addr alias_addr, u_short ip_id)
 
struct alias_linkAddFragmentPtrLink (struct libalias *la, struct in_addr dst_addr, u_short ip_id)
 
struct alias_linkFindFragmentPtr (struct libalias *la, struct in_addr dst_addr, u_short ip_id)
 
struct alias_linkFindProtoIn (struct libalias *la, struct in_addr dst_addr, struct in_addr alias_addr, u_char proto)
 
struct alias_linkFindProtoOut (struct libalias *la, struct in_addr src_addr, struct in_addr dst_addr, u_char proto)
 
struct alias_linkFindUdpTcpIn (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)
 
struct alias_linkFindUdpTcpOut (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)
 
struct alias_linkAddPptp (struct libalias *la, struct in_addr src_addr, struct in_addr dst_addr, struct in_addr alias_addr, u_int16_t src_call_id)
 
struct alias_linkFindPptpOutByCallId (struct libalias *la, struct in_addr src_addr, struct in_addr dst_addr, u_int16_t src_call_id)
 
struct alias_linkFindPptpOutByPeerCallId (struct libalias *la, struct in_addr src_addr, struct in_addr dst_addr, u_int16_t dst_call_id)
 
struct alias_linkFindPptpInByCallId (struct libalias *la, struct in_addr dst_addr, struct in_addr alias_addr, u_int16_t dst_call_id)
 
struct alias_linkFindPptpInByPeerCallId (struct libalias *la, struct in_addr dst_addr, struct in_addr alias_addr, u_int16_t alias_call_id)
 
struct alias_linkFindRtspOut (struct libalias *la, 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 libalias *la, struct in_addr alias_addr)
 
struct in_addr FindAliasAddress (struct libalias *la, struct in_addr original_addr)
 
void SetFragmentAddr (struct alias_link *lnk, struct in_addr src_addr)
 
void GetFragmentAddr (struct alias_link *lnk, struct in_addr *src_addr)
 
void SetFragmentPtr (struct alias_link *lnk, void *fptr)
 
void GetFragmentPtr (struct alias_link *lnk, void **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)
 
struct in_addr GetOriginalAddress (struct alias_link *lnk)
 
struct in_addr GetDestAddress (struct alias_link *lnk)
 
struct in_addr GetAliasAddress (struct alias_link *lnk)
 
struct in_addr GetDefaultAliasAddress (struct libalias *la)
 
void SetDefaultAliasAddress (struct libalias *la, struct in_addr alias_addr)
 
u_short GetOriginalPort (struct alias_link *lnk)
 
u_short GetAliasPort (struct alias_link *lnk)
 
static u_short GetDestPort (struct alias_link *lnk)
 
void SetAckModified (struct alias_link *lnk)
 
struct in_addr 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)
 
int GetAckModified (struct alias_link *lnk)
 
int GetDeltaAckIn (u_long ack, struct alias_link *lnk)
 
int GetDeltaSeqOut (u_long seq, 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)
 
void SetExpire (struct alias_link *lnk, int expire)
 
void SetProtocolFlags (struct alias_link *lnk, int pflags)
 
int GetProtocolFlags (struct alias_link *lnk)
 
void SetDestCallId (struct alias_link *lnk, u_int16_t cid)
 
void HouseKeeping (struct libalias *la)
 
static int InitPacketAliasLog (struct libalias *la)
 
static void UninitPacketAliasLog (struct libalias *la)
 
struct alias_linkLibAliasRedirectPort (struct libalias *la, struct in_addr src_addr, u_short src_port, struct in_addr dst_addr, u_short dst_port, struct in_addr alias_addr, u_short alias_port, u_char proto)
 
int LibAliasAddServer (struct libalias *la, struct alias_link *lnk, struct in_addr addr, u_short port)
 
struct alias_linkLibAliasRedirectProto (struct libalias *la, struct in_addr src_addr, struct in_addr dst_addr, struct in_addr alias_addr, u_char proto)
 
struct alias_linkLibAliasRedirectAddr (struct libalias *la, struct in_addr src_addr, struct in_addr alias_addr)
 
int LibAliasRedirectDynamic (struct libalias *la, struct alias_link *lnk)
 
void LibAliasRedirectDelete (struct libalias *la, struct alias_link *lnk)
 
void LibAliasSetAddress (struct libalias *la, struct in_addr addr)
 
void LibAliasSetAliasPortRange (struct libalias *la, u_short port_low, u_short port_high)
 
void LibAliasSetTarget (struct libalias *la, struct in_addr target_addr)
 
static void finishoff (void)
 
struct libaliasLibAliasInit (struct libalias *la)
 
void LibAliasUninit (struct libalias *la)
 
unsigned int LibAliasSetMode (struct libalias *la, unsigned int flags, unsigned int mask)
 
static ipfw_insnnext_cmd (ipfw_insn *cmd)
 
static ipfw_insnfill_cmd (ipfw_insn *cmd, enum ipfw_opcodes opcode, int size, int flags, u_int16_t arg)
 
static ipfw_insnfill_ip (ipfw_insn *cmd1, enum ipfw_opcodes opcode, u_int32_t addr)
 
static ipfw_insnfill_one_port (ipfw_insn *cmd1, enum ipfw_opcodes opcode, u_int16_t port)
 
static int fill_rule (void *buf, int bufsize, int rulenum, enum ipfw_opcodes action, int proto, struct in_addr sa, u_int16_t sp, struct in_addr da, u_int16_t dp)
 
static void InitPunchFW (struct libalias *la)
 
static void UninitPunchFW (struct libalias *la)
 
void PunchFWHole (struct alias_link *lnk)
 
static void ClearFWHole (struct alias_link *lnk)
 
static void ClearAllFWHoles (struct libalias *la)
 
void LibAliasSetFWBase (struct libalias *la, unsigned int base, unsigned int num)
 
void LibAliasSetSkinnyPort (struct libalias *la, unsigned int port)
 
struct in_addr FindSctpRedirectAddress (struct libalias *la, struct sctp_nat_msg *sm)
 

Variables

static moduledata_t alias_mod
 

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ _FindLinkIn()

static struct alias_link * _FindLinkIn ( struct libalias la,
struct in_addr  dst_addr,
struct in_addr  alias_addr,
u_short  dst_port,
u_short  alias_port,
int  link_type,
int  replace_partial_links 
)
static

◆ _FindLinkOut()

static struct alias_link * _FindLinkOut ( struct libalias la,
struct in_addr  src_addr,
struct in_addr  dst_addr,
u_short  src_port,
u_short  dst_port,
int  link_type,
int  replace_partial_links 
)
static

Definition at line 767 of file alias_db.c.

References _SearchLinkOut(), alias_link::alias_addr, alias_link::alias_port, ANY_ADDR, alias_link::dst_addr, alias_link::dst_port, INADDR_ANY, alias_link::la, LIBALIAS_LOCK_ASSERT, alias_link::link_type, ReLink(), in_addr::s_addr, alias_link::src_addr, and alias_link::src_port.

Referenced by FindLinkOut().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _RandomPort()

static u_short _RandomPort ( struct libalias la)
static

Definition at line 192 of file alias_db.c.

References libalias::aliasPortLength, and libalias::aliasPortLower.

Referenced by FindNewPortGroup(), and GetNewPort().

Here is the caller graph for this function:

◆ _SearchLinkOut()

static struct alias_link * _SearchLinkOut ( struct libalias la,
struct in_addr  src_addr,
struct in_addr  dst_addr,
u_short  src_port,
u_short  dst_port,
int  link_type 
)
static

Definition at line 748 of file alias_db.c.

References alias_link::dst_addr, alias_link::dst_port, alias_link::la, alias_link::link_type, alias_link::src_addr, alias_link::src_port, and UseLink().

Referenced by _FindLinkOut().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddFragmentPtrLink()

struct alias_link * AddFragmentPtrLink ( struct libalias la,
struct in_addr  dst_addr,
u_short  ip_id 
)

Definition at line 1069 of file alias_db.c.

References AddLink(), ANY_ADDR, alias_link::dst_addr, ip_id, alias_link::la, LIBALIAS_LOCK_ASSERT, LINK_FRAGMENT_PTR, NO_DEST_PORT, and NO_SRC_PORT.

Referenced by LibAliasSaveFragment().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddLink()

struct alias_link * AddLink ( struct libalias la,
struct in_addr  src_addr,
struct in_addr  dst_addr,
struct in_addr  alias_addr,
u_short  src_port,
u_short  dst_port,
int  alias_port_param,
int  link_type 
)

Definition at line 564 of file alias_db.c.

References tcp_dat::ack, tcp_state::ack_modified, ack_data_record::active, alias_link::alias_addr, group_in::alias_addr, alias_link::alias_port, ALIAS_TCP_STATE_NOT_CONNECTED, alias_link::data, alias_link::dst_addr, alias_link::dst_port, expire, alias_link::expire, alias_link::flags, FRAGMENT_ID_EXPIRE_TIME, FRAGMENT_PTR_EXPIRE_TIME, libalias::fragmentIdLinkCount, libalias::fragmentPtrLinkCount, tcp_dat::fwhole, GetNewPort(), ICMP_EXPIRE_TIME, libalias::icmpLinkCount, tcp_state::in, INADDR_ANY, tcp_state::index, alias_link::la, LIBALIAS_LOCK_ASSERT, LibAliasTime, LINK_ADDR, LINK_FRAGMENT_ID, LINK_FRAGMENT_PTR, LINK_ICMP, LINK_PARTIALLY_SPECIFIED, LINK_PPTP, LINK_TCP, alias_link::link_type, group_in::link_type, LINK_UDP, LINK_UNKNOWN_DEST_ADDR, LINK_UNKNOWN_DEST_PORT, N_LINK_TCP_DATA, tcp_state::out, libalias::packetAliasMode, group_in::partial, alias_link::pflags, PKT_ALIAS_LOG, libalias::pptpLinkCount, PROTO_EXPIRE_TIME, libalias::protoLinkCount, alias_link::proxy_addr, alias_link::proxy_port, in_addr::s_addr, alias_link::server, ShowAliasStats(), alias_link::sockfd, alias_link::src_addr, alias_link::src_port, StartPointIn(), tcp_dat::state, alias_link::tcp, TCP_EXPIRE_INITIAL, libalias::tcpLinkCount, alias_link::time, alias_link::timestamp, UDP_EXPIRE_TIME, and libalias::udpLinkCount.

Referenced by AddFragmentPtrLink(), AddPptp(), AliasHandleFtpIn(), FindFragmentIn1(), FindIcmpIn(), FindIcmpOut(), FindProtoIn(), FindProtoOut(), FindRtspOut(), FindUdpTcpIn(), FindUdpTcpOut(), LibAliasRedirectAddr(), LibAliasRedirectPort(), LibAliasRedirectProto(), NewFtpMessage(), and ReLink().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddPptp()

struct alias_link * 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 
)

Definition at line 1211 of file alias_db.c.

References AddLink(), alias_link::alias_addr, alias_link::dst_addr, GET_ALIAS_PORT, alias_link::la, LIBALIAS_LOCK_ASSERT, LINK_PPTP, and alias_link::src_addr.

Referenced by AliasHandlePptpOut().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddSeq()

void AddSeq ( struct alias_link lnk,
int  delta,
u_int  ip_hl,
u_short  ip_len,
u_long  th_seq,
u_int  th_off 
)

◆ AliasLog()

static void AliasLog ( char *  str,
const char *  format,
  ... 
)
static

Definition at line 135 of file alias_db.c.

References LIBALIAS_BUF_SIZE.

Referenced by ShowAliasStats().

Here is the caller graph for this function:

◆ CleanupAliasData()

static void CleanupAliasData ( struct libalias la,
int  deletePermanent 
)
static

Definition at line 423 of file alias_db.c.

References DeleteLink(), expire, alias_link::la, and LIBALIAS_LOCK_ASSERT.

Referenced by LibAliasInit(), LibAliasSetAddress(), and LibAliasUninit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CleanupLink()

static void CleanupLink ( struct libalias la,
struct alias_link **  lnk,
int  deletePermanent 
)
static

Definition at line 434 of file alias_db.c.

References DeleteLink(), expire, alias_link::la, LIBALIAS_LOCK_ASSERT, and LibAliasTime.

Referenced by HouseKeeping(), and UseLink().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearAllFWHoles()

static void ClearAllFWHoles ( struct libalias la)
static

Definition at line 2416 of file alias_db.c.

References libalias::fireWallBaseNum, libalias::fireWallFD, libalias::fireWallField, libalias::fireWallNumNums, IPPROTO_IP, and rule.

Referenced by InitPunchFW(), and UninitPunchFW().

Here is the caller graph for this function:

◆ ClearFWHole()

static void ClearFWHole ( struct alias_link lnk)
static

Definition at line 2394 of file alias_db.c.

References alias_link::data, libalias::fireWallFD, libalias::fireWallField, fw_clrfield, tcp_dat::fwhole, IPPROTO_IP, alias_link::la, LINK_TCP, alias_link::link_type, rule, and alias_link::tcp.

Referenced by DeleteLink().

Here is the caller graph for this function:

◆ DECLARE_MODULE()

DECLARE_MODULE ( alias  ,
alias_mod  ,
SI_SUB_DRIVERS  ,
SI_ORDER_SECOND   
)

◆ DeleteLink()

◆ fill_cmd()

static ipfw_insn * fill_cmd ( ipfw_insn cmd,
enum ipfw_opcodes  opcode,
int  size,
int  flags,
u_int16_t  arg 
)
static

Definition at line 2237 of file alias_db.c.

References _ipfw_insn::arg1, F_LEN_MASK, F_NOT, F_OR, _ipfw_insn::len, and next_cmd().

Referenced by fill_ip(), fill_one_port(), and fill_rule().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fill_ip()

static ipfw_insn * fill_ip ( ipfw_insn cmd1,
enum ipfw_opcodes  opcode,
u_int32_t  addr 
)
static

Definition at line 2247 of file alias_db.c.

References _ipfw_insn_ip::addr, F_INSN_SIZE, fill_cmd(), and in_addr::s_addr.

Referenced by fill_rule().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fill_one_port()

static ipfw_insn * fill_one_port ( ipfw_insn cmd1,
enum ipfw_opcodes  opcode,
u_int16_t  port 
)
static

Definition at line 2256 of file alias_db.c.

References F_INSN_SIZE, fill_cmd(), and _ipfw_insn_u16::ports.

Referenced by fill_rule().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fill_rule()

static int fill_rule ( void *  buf,
int  bufsize,
int  rulenum,
enum ipfw_opcodes  action,
int  proto,
struct in_addr  sa,
u_int16_t  sp,
struct in_addr  da,
u_int16_t  dp 
)
static

Definition at line 2265 of file alias_db.c.

References F_INSN_SIZE, fill_cmd(), fill_ip(), fill_one_port(), O_IP_DST, O_IP_DSTPORT, O_IP_SRC, O_IP_SRCPORT, O_PROTO, rule, and in_addr::s_addr.

Referenced by PunchFWHole().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindAliasAddress()

struct in_addr FindAliasAddress ( struct libalias la,
struct in_addr  original_addr 
)

Definition at line 1363 of file alias_db.c.

References alias_link::alias_addr, libalias::aliasAddress, ANY_ADDR, FindLinkOut(), INADDR_ANY, alias_link::la, LIBALIAS_LOCK_ASSERT, LINK_ADDR, and in_addr::s_addr.

Referenced by alias_rtsp_out(), FindIcmpOut(), FindProtoOut(), FindRtspOut(), FindUdpTcpOut(), and FragmentOut().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindFragmentIn1()

struct alias_link * FindFragmentIn1 ( struct libalias la,
struct in_addr  dst_addr,
struct in_addr  alias_addr,
u_short  ip_id 
)

Definition at line 1038 of file alias_db.c.

References AddLink(), alias_link::alias_addr, ANY_ADDR, alias_link::dst_addr, FindLinkIn(), ip_id, alias_link::la, LIBALIAS_LOCK_ASSERT, LINK_FRAGMENT_ID, NO_DEST_PORT, and NO_SRC_PORT.

Referenced by LibAliasInLocked().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindFragmentIn2()

struct alias_link * FindFragmentIn2 ( struct libalias la,
struct in_addr  dst_addr,
struct in_addr  alias_addr,
u_short  ip_id 
)

Definition at line 1059 of file alias_db.c.

References alias_link::alias_addr, alias_link::dst_addr, FindLinkIn(), ip_id, alias_link::la, LIBALIAS_LOCK_ASSERT, LINK_FRAGMENT_ID, and NO_DEST_PORT.

Referenced by FragmentIn().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindFragmentPtr()

struct alias_link * FindFragmentPtr ( struct libalias la,
struct in_addr  dst_addr,
u_short  ip_id 
)

Definition at line 1079 of file alias_db.c.

References ANY_ADDR, alias_link::dst_addr, FindLinkIn(), ip_id, alias_link::la, LIBALIAS_LOCK_ASSERT, LINK_FRAGMENT_PTR, and NO_DEST_PORT.

Referenced by LibAliasGetFragment().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindIcmpIn()

struct alias_link * FindIcmpIn ( struct libalias la,
struct in_addr  dst_addr,
struct in_addr  alias_addr,
u_short  id_alias,
int  create 
)

Definition at line 992 of file alias_db.c.

References AddLink(), alias_link::alias_addr, alias_link::dst_addr, FindLinkIn(), FindOriginalAddress(), alias_link::la, LIBALIAS_LOCK_ASSERT, LINK_ICMP, NO_DEST_PORT, libalias::packetAliasMode, and PKT_ALIAS_DENY_INCOMING.

Referenced by IcmpAliasIn1(), IcmpAliasIn2(), and LibAliasUnaliasOut().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindIcmpOut()

struct alias_link * FindIcmpOut ( struct libalias la,
struct in_addr  src_addr,
struct in_addr  dst_addr,
u_short  id,
int  create 
)

Definition at line 1015 of file alias_db.c.

References AddLink(), alias_link::dst_addr, FindAliasAddress(), FindLinkOut(), GET_ALIAS_ID, alias_link::la, LIBALIAS_LOCK_ASSERT, LINK_ICMP, NO_DEST_PORT, and alias_link::src_addr.

Referenced by IcmpAliasOut1(), and IcmpAliasOut2().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindLinkIn()

static struct alias_link * FindLinkIn ( struct libalias la,
struct in_addr  dst_addr,
struct in_addr  alias_addr,
u_short  dst_port,
u_short  alias_port,
int  link_type,
int  replace_partial_links 
)
static

◆ FindLinkOut()

static struct alias_link * FindLinkOut ( struct libalias la,
struct in_addr  src_addr,
struct in_addr  dst_addr,
u_short  src_port,
u_short  dst_port,
int  link_type,
int  replace_partial_links 
)
static

◆ FindNewPortGroup()

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 
)

◆ FindOriginalAddress()

struct in_addr FindOriginalAddress ( struct libalias la,
struct in_addr  alias_addr 
)

◆ FindPptpInByCallId()

struct alias_link * FindPptpInByCallId ( struct libalias la,
struct in_addr  dst_addr,
struct in_addr  alias_addr,
u_int16_t  dst_call_id 
)

Definition at line 1261 of file alias_db.c.

References alias_link::alias_addr, alias_link::dst_addr, alias_link::dst_port, alias_link::la, LIBALIAS_LOCK_ASSERT, alias_link::pptp, in_addr::s_addr, and UseLink().

Referenced by AliasHandlePptpIn().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindPptpInByPeerCallId()

struct alias_link * FindPptpInByPeerCallId ( struct libalias la,
struct in_addr  dst_addr,
struct in_addr  alias_addr,
u_int16_t  alias_call_id 
)

Definition at line 1279 of file alias_db.c.

References alias_link::alias_addr, alias_link::alias_port, alias_link::dst_addr, alias_link::la, LIBALIAS_LOCK_ASSERT, alias_link::pptp, and in_addr::s_addr.

Referenced by AliasHandlePptpGreIn(), and AliasHandlePptpIn().

Here is the caller graph for this function:

◆ FindPptpOutByCallId()

struct alias_link * FindPptpOutByCallId ( struct libalias la,
struct in_addr  src_addr,
struct in_addr  dst_addr,
u_int16_t  src_call_id 
)

Definition at line 1227 of file alias_db.c.

References alias_link::dst_addr, alias_link::la, LIBALIAS_LOCK_ASSERT, alias_link::pptp, in_addr::s_addr, alias_link::src_addr, alias_link::src_port, and UseLink().

Referenced by AliasHandlePptpOut().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindPptpOutByPeerCallId()

struct alias_link * FindPptpOutByPeerCallId ( struct libalias la,
struct in_addr  src_addr,
struct in_addr  dst_addr,
u_int16_t  dst_call_id 
)

Definition at line 1244 of file alias_db.c.

References alias_link::dst_addr, alias_link::dst_port, alias_link::la, LIBALIAS_LOCK_ASSERT, alias_link::pptp, in_addr::s_addr, alias_link::src_addr, and UseLink().

Referenced by AliasHandlePptpGreOut().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindProtoIn()

struct alias_link * FindProtoIn ( struct libalias la,
struct in_addr  dst_addr,
struct in_addr  alias_addr,
u_char  proto 
)

Definition at line 1089 of file alias_db.c.

References AddLink(), alias_link::alias_addr, alias_link::dst_addr, FindLinkIn(), FindOriginalAddress(), alias_link::la, LIBALIAS_LOCK_ASSERT, NO_DEST_PORT, NO_SRC_PORT, libalias::packetAliasMode, and PKT_ALIAS_DENY_INCOMING.

Referenced by ProtoAliasIn().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindProtoOut()

struct alias_link * FindProtoOut ( struct libalias la,
struct in_addr  src_addr,
struct in_addr  dst_addr,
u_char  proto 
)

Definition at line 1112 of file alias_db.c.

References AddLink(), alias_link::dst_addr, FindAliasAddress(), FindLinkOut(), alias_link::la, LIBALIAS_LOCK_ASSERT, NO_DEST_PORT, NO_SRC_PORT, and alias_link::src_addr.

Referenced by ProtoAliasOut().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindRtspOut()

struct alias_link * 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 
)

Definition at line 1296 of file alias_db.c.

References AddLink(), alias_link::dst_addr, FindAliasAddress(), FindLinkOut(), IPPROTO_TCP, IPPROTO_UDP, alias_link::la, LIBALIAS_LOCK_ASSERT, LINK_TCP, alias_link::link_type, LINK_UDP, alias_link::src_addr, and alias_link::src_port.

Referenced by alias_rtsp_out(), and protohandler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindSctpRedirectAddress()

struct in_addr FindSctpRedirectAddress ( struct libalias la,
struct sctp_nat_msg sm 
)

Definition at line 2459 of file alias_db.c.

References FindLinkIn(), FindOriginalAddress(), LIBALIAS_LOCK_ASSERT, LINK_SCTP, NO_DEST_PORT, in_addr::s_addr, and alias_link::src_addr.

Here is the call graph for this function:

◆ FindUdpTcpIn()

struct alias_link * 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 
)

◆ FindUdpTcpOut()

struct alias_link * 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 
)

◆ finishoff()

static void finishoff ( void  )
static

Definition at line 2071 of file alias_db.c.

References LibAliasUninit().

Referenced by LibAliasInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAckModified()

int GetAckModified ( struct alias_link lnk)

Definition at line 1576 of file alias_db.c.

References tcp_state::ack_modified, alias_link::data, tcp_dat::state, and alias_link::tcp.

Referenced by ProxyEncodeTcpStream(), TcpAliasIn(), and TcpAliasOut().

Here is the caller graph for this function:

◆ GetAliasAddress()

◆ GetAliasPort()

u_short GetAliasPort ( struct alias_link lnk)

◆ GetDefaultAliasAddress()

struct in_addr GetDefaultAliasAddress ( struct libalias la)

Definition at line 1509 of file alias_db.c.

References LIBALIAS_LOCK_ASSERT.

Referenced by LibAliasOutLocked().

Here is the caller graph for this function:

◆ GetDeltaAckIn()

int GetDeltaAckIn ( u_long  ack,
struct alias_link lnk 
)

Definition at line 1588 of file alias_db.c.

References tcp_dat::ack, ack_data_record::ack_new, ack_data_record::active, alias_link::data, ack_data_record::delta, tcp_state::index, N_LINK_TCP_DATA, SeqDiff(), tcp_dat::state, and alias_link::tcp.

Referenced by TcpAliasIn().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDeltaSeqOut()

int GetDeltaSeqOut ( u_long  seq,
struct alias_link lnk 
)

Definition at line 1630 of file alias_db.c.

References tcp_dat::ack, ack_data_record::ack_old, ack_data_record::active, alias_link::data, ack_data_record::delta, tcp_state::index, N_LINK_TCP_DATA, SeqDiff(), tcp_dat::state, and alias_link::tcp.

Referenced by alias_rtsp_out(), AliasHandleIrcOut(), NewFtpMessage(), ProxyEncodeTcpStream(), and TcpAliasOut().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDestAddress()

struct in_addr GetDestAddress ( struct alias_link lnk)

Definition at line 1494 of file alias_db.c.

Referenced by alias_pna_out(), AliasHandlePptpIn(), AliasHandlePptpOut(), NewFtpMessage(), and PunchFWHole().

Here is the caller graph for this function:

◆ GetDestPort()

static u_short GetDestPort ( struct alias_link lnk)
static

Definition at line 1536 of file alias_db.c.

References alias_link::dst_port.

Referenced by PunchFWHole().

Here is the caller graph for this function:

◆ GetFragmentAddr()

void GetFragmentAddr ( struct alias_link lnk,
struct in_addr src_addr 
)

Definition at line 1403 of file alias_db.c.

References alias_link::data, alias_link::frag_addr, and alias_link::src_addr.

Referenced by FragmentIn().

Here is the caller graph for this function:

◆ GetFragmentPtr()

void GetFragmentPtr ( struct alias_link lnk,
void **  fptr 
)

Definition at line 1415 of file alias_db.c.

References alias_link::data, and alias_link::frag_ptr.

Referenced by LibAliasGetFragment().

Here is the caller graph for this function:

◆ GetNewPort()

◆ GetOriginalAddress()

struct in_addr GetOriginalAddress ( struct alias_link lnk)

◆ GetOriginalPort()

u_short GetOriginalPort ( struct alias_link lnk)

Definition at line 1523 of file alias_db.c.

References alias_link::src_port.

Referenced by AliasHandlePptpGreIn(), AliasHandlePptpIn(), IcmpAliasIn1(), IcmpAliasIn2(), LibAliasUnaliasOut(), PunchFWHole(), TcpAliasIn(), and UdpAliasIn().

Here is the caller graph for this function:

◆ GetProtocolFlags()

int GetProtocolFlags ( struct alias_link lnk)

Definition at line 1723 of file alias_db.c.

References alias_link::pflags.

Referenced by AliasHandleFtpIn(), and AliasHandleFtpOut().

Here is the caller graph for this function:

◆ GetProxyAddress()

struct in_addr GetProxyAddress ( struct alias_link lnk)

Definition at line 1551 of file alias_db.c.

Referenced by ProxyEncodeTcpStream(), TcpAliasIn(), and UdpAliasIn().

Here is the caller graph for this function:

◆ GetProxyPort()

u_short GetProxyPort ( struct alias_link lnk)

Definition at line 1563 of file alias_db.c.

References alias_link::proxy_port.

Referenced by ProxyEncodeTcpStream(), TcpAliasIn(), and UdpAliasIn().

Here is the caller graph for this function:

◆ GetSocket()

static u_short GetSocket ( struct libalias la,
u_short  port_net,
int *  sockfd,
int  link_type 
)
static

Definition at line 293 of file alias_db.c.

References INADDR_ANY, LIBALIAS_LOCK_ASSERT, LINK_TCP, LINK_UDP, in_addr::s_addr, sockaddr_in::sin_addr, sockaddr_in::sin_family, sockaddr_in::sin_port, and libalias::sockCount.

Referenced by GetNewPort().

Here is the caller graph for this function:

◆ GetStateIn()

int GetStateIn ( struct alias_link lnk)

Definition at line 1471 of file alias_db.c.

References alias_link::data, tcp_state::in, tcp_dat::state, and alias_link::tcp.

Referenced by TcpMonitorIn().

Here is the caller graph for this function:

◆ GetStateOut()

int GetStateOut ( struct alias_link lnk)

Definition at line 1478 of file alias_db.c.

References alias_link::data, tcp_state::out, tcp_dat::state, and alias_link::tcp.

Referenced by TcpMonitorOut().

Here is the caller graph for this function:

◆ HouseKeeping()

void HouseKeeping ( struct libalias la)

Definition at line 1753 of file alias_db.c.

References CleanupLink(), alias_link::la, LIBALIAS_LOCK_ASSERT, LibAliasTime, libalias::tcpLinkCount, and libalias::udpLinkCount.

Referenced by LibAliasInLocked(), and LibAliasOutLocked().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitPacketAliasLog()

static int InitPacketAliasLog ( struct libalias la)
static

Definition at line 1798 of file alias_db.c.

References alias_link::la, LIBALIAS_BUF_SIZE, LIBALIAS_LOCK_ASSERT, libalias::logDesc, libalias::packetAliasMode, and PKT_ALIAS_LOG.

Referenced by LibAliasSetMode().

Here is the caller graph for this function:

◆ InitPunchFW()

static void InitPunchFW ( struct libalias la)
static

Definition at line 2290 of file alias_db.c.

References ClearAllFWHoles(), libalias::fireWallActiveNum, libalias::fireWallBaseNum, libalias::fireWallFD, libalias::fireWallField, and libalias::fireWallNumNums.

Referenced by LibAliasSetMode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LibAliasAddServer()

int LibAliasAddServer ( struct libalias la,
struct alias_link lnk,
struct in_addr  addr,
u_short  port 
)

◆ LibAliasInit()

◆ LibAliasRedirectAddr()

struct alias_link * LibAliasRedirectAddr ( struct libalias la,
struct in_addr  src_addr,
struct in_addr  alias_addr 
)

Definition at line 1979 of file alias_db.c.

References AddLink(), alias_link::alias_addr, ANY_ADDR, alias_link::flags, alias_link::la, LIBALIAS_LOCK, LIBALIAS_UNLOCK, LINK_ADDR, LINK_PERMANENT, and alias_link::src_addr.

Here is the call graph for this function:

◆ LibAliasRedirectDelete()

void LibAliasRedirectDelete ( struct libalias la,
struct alias_link lnk 
)

Definition at line 2025 of file alias_db.c.

References DeleteLink(), alias_link::la, LIBALIAS_LOCK, and LIBALIAS_UNLOCK.

Here is the call graph for this function:

◆ LibAliasRedirectDynamic()

int LibAliasRedirectDynamic ( struct libalias la,
struct alias_link lnk 
)

◆ LibAliasRedirectPort()

struct alias_link * LibAliasRedirectPort ( struct libalias la,
struct in_addr  src_addr,
u_short  src_port,
struct in_addr  dst_addr,
u_short  dst_port,
struct in_addr  alias_addr,
u_short  alias_port,
u_char  proto 
)

◆ LibAliasRedirectProto()

struct alias_link * LibAliasRedirectProto ( struct libalias la,
struct in_addr  src_addr,
struct in_addr  dst_addr,
struct in_addr  alias_addr,
u_char  proto 
)

◆ LibAliasSetAddress()

void LibAliasSetAddress ( struct libalias la,
struct in_addr  addr 
)

◆ LibAliasSetAliasPortRange()

void LibAliasSetAliasPortRange ( struct libalias la,
u_short  port_low,
u_short  port_high 
)

◆ LibAliasSetFWBase()

void LibAliasSetFWBase ( struct libalias la,
unsigned int  base,
unsigned int  num 
)

◆ LibAliasSetMode()

unsigned int LibAliasSetMode ( struct libalias la,
unsigned int  flags,
unsigned int  mask 
)

Definition at line 2171 of file alias_db.c.

References InitPacketAliasLog(), InitPunchFW(), LIBALIAS_LOCK, LIBALIAS_UNLOCK, libalias::packetAliasMode, PKT_ALIAS_LOG, UninitPacketAliasLog(), and UninitPunchFW().

Here is the call graph for this function:

◆ LibAliasSetSkinnyPort()

void LibAliasSetSkinnyPort ( struct libalias la,
unsigned int  port 
)

Definition at line 2448 of file alias_db.c.

References LIBALIAS_LOCK, LIBALIAS_UNLOCK, and libalias::skinnyPort.

◆ LibAliasSetTarget()

void LibAliasSetTarget ( struct libalias la,
struct in_addr  target_addr 
)

Definition at line 2063 of file alias_db.c.

References alias_link::la, LIBALIAS_LOCK, LIBALIAS_UNLOCK, and libalias::targetAddress.

◆ LibAliasUninit()

void LibAliasUninit ( struct libalias la)

Definition at line 2152 of file alias_db.c.

References AliasSctpTerm(), CleanupAliasData(), LIBALIAS_LOCK, LIBALIAS_LOCK_DESTROY, LIBALIAS_UNLOCK, UninitPacketAliasLog(), and UninitPunchFW().

Referenced by finishoff().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LIST_HEAD()

static LIST_HEAD ( MODULE_VERSION libalias)
static

Definition at line 66 of file alias_db.c.

◆ next_cmd()

static ipfw_insn * next_cmd ( ipfw_insn cmd)
static

Definition at line 2225 of file alias_db.c.

References F_LEN.

Referenced by fill_cmd().

Here is the caller graph for this function:

◆ PunchFWHole()

◆ ReLink()

static struct alias_link * ReLink ( struct alias_link old_lnk,
struct in_addr  src_addr,
struct in_addr  dst_addr,
struct in_addr  alias_addr,
u_short  src_port,
u_short  dst_port,
int  alias_port_param,
int  link_type,
int  deletePermanent 
)
static

Definition at line 719 of file alias_db.c.

References AddLink(), alias_link::data, DeleteLink(), tcp_dat::fwhole, alias_link::la, LIBALIAS_LOCK_ASSERT, LINK_TCP, alias_link::link_type, PunchFWHole(), and alias_link::tcp.

Referenced by _FindLinkIn(), _FindLinkOut(), and SetDestCallId().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SeqDiff()

static int SeqDiff ( u_long  x,
u_long  y 
)
static

Definition at line 124 of file alias_db.c.

Referenced by GetDeltaAckIn(), and GetDeltaSeqOut().

Here is the caller graph for this function:

◆ SetAckModified()

void SetAckModified ( struct alias_link lnk)

Definition at line 1545 of file alias_db.c.

References tcp_state::ack_modified, alias_link::data, tcp_dat::state, and alias_link::tcp.

Referenced by alias_rtsp_out(), AliasHandleIrcOut(), NewFtpMessage(), and ProxyEncodeTcpStream().

Here is the caller graph for this function:

◆ SetDefaultAliasAddress()

void SetDefaultAliasAddress ( struct libalias la,
struct in_addr  alias_addr 
)

Definition at line 1516 of file alias_db.c.

References libalias::aliasAddress, and LIBALIAS_LOCK_ASSERT.

Referenced by LibAliasOutLocked().

Here is the caller graph for this function:

◆ SetDestCallId()

void SetDestCallId ( struct alias_link lnk,
u_int16_t  cid 
)

Definition at line 1729 of file alias_db.c.

References alias_link::alias_addr, alias_link::alias_port, alias_link::dst_addr, alias_link::la, LIBALIAS_LOCK_ASSERT, alias_link::link_type, ReLink(), alias_link::src_addr, and alias_link::src_port.

Referenced by AliasHandlePptpIn(), and AliasHandlePptpOut().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetExpire()

void SetExpire ( struct alias_link lnk,
int  expire 
)

Definition at line 1699 of file alias_db.c.

References DeleteLink(), expire, alias_link::expire, alias_link::flags, LINK_PERMANENT, and alias_link::time.

Referenced by AliasHandlePptpIn(), AliasHandlePptpOut(), and LibAliasGetFragment().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetFragmentAddr()

void SetFragmentAddr ( struct alias_link lnk,
struct in_addr  src_addr 
)

Definition at line 1397 of file alias_db.c.

References alias_link::data, alias_link::frag_addr, and alias_link::src_addr.

Referenced by LibAliasInLocked().

Here is the caller graph for this function:

◆ SetFragmentPtr()

void SetFragmentPtr ( struct alias_link lnk,
void *  fptr 
)

Definition at line 1409 of file alias_db.c.

References alias_link::data, and alias_link::frag_ptr.

Referenced by LibAliasGetFragment(), and LibAliasSaveFragment().

Here is the caller graph for this function:

◆ SetProtocolFlags()

void SetProtocolFlags ( struct alias_link lnk,
int  pflags 
)

Definition at line 1717 of file alias_db.c.

References alias_link::pflags.

Referenced by AliasHandleFtpIn(), and AliasHandleFtpOut().

Here is the caller graph for this function:

◆ SetProxyAddress()

void SetProxyAddress ( struct alias_link lnk,
struct in_addr  addr 
)

Definition at line 1557 of file alias_db.c.

References alias_link::proxy_addr.

Referenced by TcpAliasOut(), and UdpAliasOut().

Here is the caller graph for this function:

◆ SetProxyPort()

void SetProxyPort ( struct alias_link lnk,
u_short  port 
)

Definition at line 1569 of file alias_db.c.

References alias_link::proxy_port.

Referenced by TcpAliasOut(), and UdpAliasOut().

Here is the caller graph for this function:

◆ SetStateIn()

void SetStateIn ( struct alias_link lnk,
int  state 
)

◆ SetStateOut()

void SetStateOut ( struct alias_link lnk,
int  state 
)

◆ ShowAliasStats()

static void ShowAliasStats ( struct libalias la)
static

◆ SPLAY_GENERATE() [1/2]

SPLAY_GENERATE ( splay_in  ,
group_in  ,
in  ,
cmp_in   
)

◆ SPLAY_GENERATE() [2/2]

SPLAY_GENERATE ( splay_out  ,
alias_link  ,
all.  out,
cmp_out   
)

◆ StartPointIn()

static struct group_in * StartPointIn ( struct libalias la,
struct in_addr  alias_addr,
u_short  alias_port,
int  link_type,
int  create 
)
static

Definition at line 100 of file alias_db.c.

References group_in::alias_addr, group_in::alias_port, group_in::link_type, and group_in::partial.

Referenced by _FindLinkIn(), AddLink(), DeleteLink(), and GetNewPort().

Here is the caller graph for this function:

◆ UninitPacketAliasLog()

static void UninitPacketAliasLog ( struct libalias la)
static

Definition at line 1819 of file alias_db.c.

References alias_link::la, LIBALIAS_LOCK_ASSERT, libalias::logDesc, and libalias::packetAliasMode.

Referenced by LibAliasSetMode(), and LibAliasUninit().

Here is the caller graph for this function:

◆ UninitPunchFW()

static void UninitPunchFW ( struct libalias la)
static

Definition at line 2304 of file alias_db.c.

References ClearAllFWHoles(), libalias::fireWallFD, libalias::fireWallField, and libalias::packetAliasMode.

Referenced by LibAliasSetMode(), and LibAliasUninit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UseLink()

static struct alias_link * UseLink ( struct libalias la,
struct alias_link lnk 
)
static

Definition at line 453 of file alias_db.c.

References CleanupLink(), alias_link::la, LibAliasTime, and alias_link::timestamp.

Referenced by _FindLinkIn(), _SearchLinkOut(), FindPptpInByCallId(), FindPptpOutByCallId(), and FindPptpOutByPeerCallId().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ alias_mod

moduledata_t alias_mod
static
Initial value:
= {
"alias", alias_mod_handler, NULL
}

Definition at line 89 of file alias_db.c.