FreeBSD kernel IPv4 code
alias_proxy.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/ctype.h>
#include <sys/libkern.h>
#include <sys/limits.h>
#include <netinet/tcp.h>
#include <netinet/libalias/alias.h>
#include <netinet/libalias/alias_local.h>
#include <netinet/libalias/alias_mod.h>
Include dependency graph for alias_proxy.c:

Go to the source code of this file.

Data Structures

struct  proxy_entry
 

Macros

#define PROXY_TYPE_ENCODE_NONE   1
 
#define PROXY_TYPE_ENCODE_TCPSTREAM   2
 
#define PROXY_TYPE_ENCODE_IPHDR   3
 
#define OPTION_LEN_BYTES   8
 
#define OPTION_LEN_INT16   4
 
#define OPTION_LEN_INT32   2
 
#define STATE_READ_KEYWORD   0
 
#define STATE_READ_TYPE   1
 
#define STATE_READ_PORT   2
 
#define STATE_READ_SERVER   3
 
#define STATE_READ_RULE   4
 
#define STATE_READ_DELETE   5
 
#define STATE_READ_PROTO   6
 
#define STATE_READ_SRC   7
 
#define STATE_READ_DST   8
 

Functions

 __FBSDID ("$FreeBSD$")
 
static int IpMask (int, struct in_addr *)
 
static int IpAddr (char *, struct in_addr *)
 
static int IpPort (char *, int, int *)
 
static void RuleAdd (struct libalias *la, struct proxy_entry *)
 
static void RuleDelete (struct proxy_entry *)
 
static int RuleNumberDelete (struct libalias *la, int)
 
static void ProxyEncodeTcpStream (struct alias_link *, struct ip *, int)
 
static void ProxyEncodeIpHeader (struct ip *, int)
 
int 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)
 
void ProxyModify (struct libalias *la, struct alias_link *lnk, struct ip *pip, int maxpacketsize, int proxy_type)
 
int LibAliasProxyRule (struct libalias *la, const char *cmd)
 

Macro Definition Documentation

◆ OPTION_LEN_BYTES

#define OPTION_LEN_BYTES   8

◆ OPTION_LEN_INT16

#define OPTION_LEN_INT16   4

◆ OPTION_LEN_INT32

#define OPTION_LEN_INT32   2

◆ PROXY_TYPE_ENCODE_IPHDR

#define PROXY_TYPE_ENCODE_IPHDR   3

Definition at line 96 of file alias_proxy.c.

◆ PROXY_TYPE_ENCODE_NONE

#define PROXY_TYPE_ENCODE_NONE   1

Definition at line 94 of file alias_proxy.c.

◆ PROXY_TYPE_ENCODE_TCPSTREAM

#define PROXY_TYPE_ENCODE_TCPSTREAM   2

Definition at line 95 of file alias_proxy.c.

◆ STATE_READ_DELETE

#define STATE_READ_DELETE   5

◆ STATE_READ_DST

#define STATE_READ_DST   8

◆ STATE_READ_KEYWORD

#define STATE_READ_KEYWORD   0

◆ STATE_READ_PORT

#define STATE_READ_PORT   2

◆ STATE_READ_PROTO

#define STATE_READ_PROTO   6

◆ STATE_READ_RULE

#define STATE_READ_RULE   4

◆ STATE_READ_SERVER

#define STATE_READ_SERVER   3

◆ STATE_READ_SRC

#define STATE_READ_SRC   7

◆ STATE_READ_TYPE

#define STATE_READ_TYPE   1

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ IpAddr()

static int IpAddr ( char *  s,
struct in_addr addr 
)
static

Definition at line 164 of file alias_proxy.c.

References inet_aton().

Referenced by LibAliasProxyRule().

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

◆ IpMask()

static int IpMask ( int  nbits,
struct in_addr mask 
)
static

Definition at line 147 of file alias_proxy.c.

References in_addr::s_addr.

Referenced by LibAliasProxyRule().

Here is the caller graph for this function:

◆ IpPort()

static int IpPort ( char *  s,
int  proto,
int *  port 
)
static

Definition at line 173 of file alias_proxy.c.

References IPPROTO_TCP, and IPPROTO_UDP.

Referenced by LibAliasProxyRule().

Here is the caller graph for this function:

◆ LibAliasProxyRule()

◆ ProxyCheck()

int 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 
)

◆ ProxyEncodeIpHeader()

static void ProxyEncodeIpHeader ( struct ip pip,
int  maxpacketsize 
)
static

Definition at line 378 of file alias_proxy.c.

References ADJUST_CHECKSUM, ip::ip_dst, ip::ip_hl, ip::ip_len, ip::ip_sum, OPTION_LEN_BYTES, OPTION_LEN_INT16, and OPTION_LEN_INT32.

Referenced by ProxyModify().

Here is the caller graph for this function:

◆ ProxyEncodeTcpStream()

static void ProxyEncodeTcpStream ( struct alias_link lnk,
struct ip pip,
int  maxpacketsize 
)
static

Definition at line 287 of file alias_proxy.c.

References AddSeq(), ADJUST_CHECKSUM, GetAckModified(), GetDeltaSeqOut(), GetProxyAddress(), GetProxyPort(), INET_NTOA_BUF, inet_ntoa_r(), ip::ip_hl, ip::ip_len, ip::ip_sum, and SetAckModified().

Referenced by ProxyModify().

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

◆ ProxyModify()

void ProxyModify ( struct libalias la,
struct alias_link lnk,
struct ip pip,
int  maxpacketsize,
int  proxy_type 
)

Definition at line 494 of file alias_proxy.c.

References LIBALIAS_LOCK_ASSERT, PROXY_TYPE_ENCODE_IPHDR, PROXY_TYPE_ENCODE_TCPSTREAM, ProxyEncodeIpHeader(), and ProxyEncodeTcpStream().

Referenced by TcpAliasOut(), and UdpAliasOut().

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

◆ RuleAdd()

void RuleAdd ( struct libalias la,
struct proxy_entry entry 
)
static

Definition at line 202 of file alias_proxy.c.

References proxy_entry::la, proxy_entry::last, LIBALIAS_LOCK_ASSERT, proxy_entry::next, libalias::proxyList, and proxy_entry::rule_index.

Referenced by LibAliasProxyRule().

Here is the caller graph for this function:

◆ RuleDelete()

static void RuleDelete ( struct proxy_entry entry)
static

Definition at line 246 of file alias_proxy.c.

References proxy_entry::la, proxy_entry::last, LIBALIAS_LOCK_ASSERT, proxy_entry::next, and libalias::proxyList.

Referenced by RuleNumberDelete().

Here is the caller graph for this function:

◆ RuleNumberDelete()

static int RuleNumberDelete ( struct libalias la,
int  rule_index 
)
static

Definition at line 264 of file alias_proxy.c.

References proxy_entry::la, LIBALIAS_LOCK_ASSERT, proxy_entry::next, libalias::proxyList, proxy_entry::rule_index, and RuleDelete().

Referenced by LibAliasProxyRule().

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