FreeBSD kernel netgraph code
ng_tcpmss.c File Reference
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/endian.h>
#include <sys/errno.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <netgraph/ng_message.h>
#include <netgraph/netgraph.h>
#include <netgraph/ng_parse.h>
#include <netgraph/ng_tcpmss.h>
Include dependency graph for ng_tcpmss.c:

Go to the source code of this file.

Data Structures

struct  hpriv_p
 

Macros

#define ERROUT(x)   { error = (x); goto done; }
 
#define M_CHECK(length)
 
#define TCPMSS_ADJUST_CHECKSUM(acc, cksum)
 

Functions

static int correct_mss (struct tcphdr *, int, uint16_t, int)
 
 NETGRAPH_INIT (tcpmss, &ng_tcpmss_typestruct)
 
static int ng_tcpmss_constructor (node_p node)
 
static int ng_tcpmss_newhook (node_p node, hook_p hook, const char *name)
 
static int ng_tcpmss_rcvmsg (node_p node, item_p item, hook_p lasthook)
 
static int ng_tcpmss_rcvdata (hook_p hook, item_p item)
 
static int ng_tcpmss_disconnect (hook_p hook)
 

Variables

static ng_constructor_t ng_tcpmss_constructor
 
static ng_rcvmsg_t ng_tcpmss_rcvmsg
 
static ng_newhook_t ng_tcpmss_newhook
 
static ng_rcvdata_t ng_tcpmss_rcvdata
 
static ng_disconnect_t ng_tcpmss_disconnect
 
static const struct ng_parse_struct_field ng_tcpmss_hookstat_type_fields [] = NG_TCPMSS_HOOKSTAT_INFO
 
static const struct ng_parse_type ng_tcpmss_hookstat_type
 
static const struct ng_parse_struct_field ng_tcpmss_config_type_fields [] = NG_TCPMSS_CONFIG_INFO
 
static const struct ng_parse_type ng_tcpmss_config_type
 
static const struct ng_cmdlist ng_tcpmss_cmds []
 
static struct ng_type ng_tcpmss_typestruct
 

Macro Definition Documentation

◆ ERROUT

#define ERROUT (   x)    { error = (x); goto done; }

Definition at line 145 of file ng_tcpmss.c.

◆ M_CHECK

#define M_CHECK (   length)
Value:
do { \
pullup_len += length; \
if ((m)->m_pkthdr.len < pullup_len) \
goto send; \
if ((m)->m_len < pullup_len && \
(((m) = m_pullup((m), pullup_len)) == NULL)) \
ERROUT(ENOBUFS); \
} while (0)
uint8_t length
Definition: ng_ubt_var.h:1

◆ TCPMSS_ADJUST_CHECKSUM

#define TCPMSS_ADJUST_CHECKSUM (   acc,
  cksum 
)
Value:
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);

Definition at line 396 of file ng_tcpmss.c.

Function Documentation

◆ correct_mss()

static int correct_mss ( struct tcphdr *  tc,
int  hlen,
uint16_t  maxmss,
int  flags 
)
static

Definition at line 411 of file ng_tcpmss.c.

References flags, and TCPMSS_ADJUST_CHECKSUM.

Referenced by ng_tcpmss_rcvdata().

Here is the caller graph for this function:

◆ NETGRAPH_INIT()

NETGRAPH_INIT ( tcpmss  ,
ng_tcpmss_typestruct 
)

◆ ng_tcpmss_constructor()

static int ng_tcpmss_constructor ( node_p  node)
static

Definition at line 151 of file ng_tcpmss.c.

◆ ng_tcpmss_disconnect()

static int ng_tcpmss_disconnect ( hook_p  hook)
static

Definition at line 364 of file ng_tcpmss.c.

References NG_HOOK_NODE, NG_HOOK_PRIVATE, NG_NODE_NUMHOOKS, and ng_rmnode_self().

Here is the call graph for this function:

◆ ng_tcpmss_newhook()

static int ng_tcpmss_newhook ( node_p  node,
hook_p  hook,
const char *  name 
)
static

Definition at line 160 of file ng_tcpmss.c.

References NG_HOOK_SET_PRIVATE.

◆ ng_tcpmss_rcvdata()

static int ng_tcpmss_rcvdata ( hook_p  hook,
item_p  item 
)
static

Definition at line 267 of file ng_tcpmss.c.

References correct_mss(), ERROUT, M_CHECK, NG_FREE_ITEM, NG_FREE_M, NG_FWD_NEW_DATA, NG_HOOK_PRIVATE, NGI_GET_M, and priv::stats.

Here is the call graph for this function:

◆ ng_tcpmss_rcvmsg()

Variable Documentation

◆ ng_tcpmss_cmds

const struct ng_cmdlist ng_tcpmss_cmds[]
static

Definition at line 100 of file ng_tcpmss.c.

◆ ng_tcpmss_config_type

const struct ng_parse_type ng_tcpmss_config_type
static
Initial value:
= {
}
const struct ng_parse_type ng_parse_struct_type
Definition: ng_parse.c:222
static const struct ng_parse_struct_field ng_tcpmss_config_type_fields[]
Definition: ng_tcpmss.c:93

Definition at line 94 of file ng_tcpmss.c.

◆ ng_tcpmss_config_type_fields

const struct ng_parse_struct_field ng_tcpmss_config_type_fields[] = NG_TCPMSS_CONFIG_INFO
static

Definition at line 92 of file ng_tcpmss.c.

◆ ng_tcpmss_constructor

ng_constructor_t ng_tcpmss_constructor
static

Definition at line 75 of file ng_tcpmss.c.

◆ ng_tcpmss_disconnect

ng_disconnect_t ng_tcpmss_disconnect
static

Definition at line 79 of file ng_tcpmss.c.

◆ ng_tcpmss_hookstat_type

const struct ng_parse_type ng_tcpmss_hookstat_type
static
Initial value:
= {
}
static const struct ng_parse_struct_field ng_tcpmss_hookstat_type_fields[]
Definition: ng_tcpmss.c:85

Definition at line 86 of file ng_tcpmss.c.

◆ ng_tcpmss_hookstat_type_fields

const struct ng_parse_struct_field ng_tcpmss_hookstat_type_fields[] = NG_TCPMSS_HOOKSTAT_INFO
static

Definition at line 84 of file ng_tcpmss.c.

◆ ng_tcpmss_newhook

ng_newhook_t ng_tcpmss_newhook
static

Definition at line 77 of file ng_tcpmss.c.

◆ ng_tcpmss_rcvdata

ng_rcvdata_t ng_tcpmss_rcvdata
static

Definition at line 78 of file ng_tcpmss.c.

◆ ng_tcpmss_rcvmsg

ng_rcvmsg_t ng_tcpmss_rcvmsg
static

Definition at line 76 of file ng_tcpmss.c.

◆ ng_tcpmss_typestruct

struct ng_type ng_tcpmss_typestruct
static
Initial value:
= {
.version = NG_ABI_VERSION,
.constructor = ng_tcpmss_constructor,
.rcvmsg = ng_tcpmss_rcvmsg,
.newhook = ng_tcpmss_newhook,
.rcvdata = ng_tcpmss_rcvdata,
.disconnect = ng_tcpmss_disconnect,
.cmdlist = ng_tcpmss_cmds,
}
#define NG_ABI_VERSION
Definition: netgraph.h:77
static ng_newhook_t ng_tcpmss_newhook
Definition: ng_tcpmss.c:77
static ng_constructor_t ng_tcpmss_constructor
Definition: ng_tcpmss.c:75
static ng_rcvmsg_t ng_tcpmss_rcvmsg
Definition: ng_tcpmss.c:76
static ng_disconnect_t ng_tcpmss_disconnect
Definition: ng_tcpmss.c:79
static ng_rcvdata_t ng_tcpmss_rcvdata
Definition: ng_tcpmss.c:78
static const struct ng_cmdlist ng_tcpmss_cmds[]
Definition: ng_tcpmss.c:100
#define NG_TCPMSS_NODE_TYPE
Definition: ng_tcpmss.h:38

Definition at line 133 of file ng_tcpmss.c.