FreeBSD kernel netgraph code
ng_patch.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/endian.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <net/bpf.h>
#include <net/ethernet.h>
#include <netgraph/ng_message.h>
#include <netgraph/ng_parse.h>
#include <netgraph/netgraph.h>
#include <netgraph/ng_patch.h>
Include dependency graph for ng_patch.c:

Go to the source code of this file.

Data Structures

struct  ng_patch_priv
 

Macros

#define ERROUT(x)   { error = (x); goto done; }
 
#define PULLUP_CHECK(mbuf, length)
 

Typedefs

typedef struct ng_patch_privpriv_p
 

Functions

 __FBSDID ("$FreeBSD$")
 
static int ng_patch_config_getlen (const struct ng_parse_type *type, const u_char *start, const u_char *buf)
 
 NETGRAPH_INIT (patch, &typestruct)
 
static int ng_patch_constructor (node_p node)
 
static int ng_patch_newhook (node_p node, hook_p hook, const char *name)
 
static int ng_patch_rcvmsg (node_p node, item_p item, hook_p lasthook)
 
static void do_patch (priv_p privp, struct mbuf *m, int global_offset)
 
static int ng_patch_rcvdata (hook_p hook, item_p item)
 
static int ng_patch_shutdown (node_p node)
 
static int ng_patch_disconnect (hook_p hook)
 

Variables

static ng_constructor_t ng_patch_constructor
 
static ng_rcvmsg_t ng_patch_rcvmsg
 
static ng_shutdown_t ng_patch_shutdown
 
static ng_newhook_t ng_patch_newhook
 
static ng_rcvdata_t ng_patch_rcvdata
 
static ng_disconnect_t ng_patch_disconnect
 
static const struct ng_parse_struct_field ng_patch_op_type_fields [] = NG_PATCH_OP_TYPE
 
static const struct ng_parse_type ng_patch_op_type
 
static const struct ng_parse_array_info ng_patch_ops_array_info
 
static const struct ng_parse_type ng_patch_ops_array_type
 
static const struct ng_parse_struct_field ng_patch_config_type_fields [] = NG_PATCH_CONFIG_TYPE
 
static const struct ng_parse_type ng_patch_config_type
 
static const struct ng_parse_struct_field ng_patch_stats_fields [] = NG_PATCH_STATS_TYPE
 
static const struct ng_parse_type ng_patch_stats_type
 
static const struct ng_cmdlist ng_patch_cmdlist []
 
static struct ng_type typestruct
 

Macro Definition Documentation

◆ ERROUT

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

Definition at line 68 of file ng_patch.c.

◆ PULLUP_CHECK

#define PULLUP_CHECK (   mbuf,
  length 
)
Value:
do { \
pullup_len += length; \
if (((mbuf)->m_pkthdr.len < pullup_len) || \
(pullup_len > MHLEN)) { \
error = EINVAL; \
goto bypass; \
} \
if ((mbuf)->m_len < pullup_len && \
(((mbuf) = m_pullup((mbuf), pullup_len)) == NULL)) { \
error = ENOBUFS; \
goto drop; \
} \
} while (0)
uint8_t length
Definition: ng_ubt_var.h:1

Typedef Documentation

◆ priv_p

typedef struct ng_patch_priv* priv_p

Definition at line 59 of file ng_patch.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ do_patch()

static void do_patch ( priv_p  privp,
struct mbuf *  m,
int  global_offset 
)
static

◆ NETGRAPH_INIT()

NETGRAPH_INIT ( patch  ,
typestruct 
)

◆ ng_patch_config_getlen()

static int ng_patch_config_getlen ( const struct ng_parse_type type,
const u_char *  start,
const u_char *  buf 
)
static

Definition at line 71 of file ng_patch.c.

References ng_patch_config::count, and ng_patch_config::ops.

◆ ng_patch_constructor()

static int ng_patch_constructor ( node_p  node)
static

Definition at line 180 of file ng_patch.c.

References NG_NODE_SET_PRIVATE.

◆ ng_patch_disconnect()

static int ng_patch_disconnect ( hook_p  hook)
static

Definition at line 676 of file ng_patch.c.

References NG_HOOK_NODE, NG_NODE_IS_VALID, NG_NODE_NUMHOOKS, NG_NODE_PRIVATE, and ng_rmnode_self().

Here is the call graph for this function:

◆ ng_patch_newhook()

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

Definition at line 193 of file ng_patch.c.

References name, NG_NODE_PRIVATE, NG_PATCH_HOOK_IN, and NG_PATCH_HOOK_OUT.

◆ ng_patch_rcvdata()

static int ng_patch_rcvdata ( hook_p  hook,
item_p  item 
)
static

Definition at line 552 of file ng_patch.c.

References do_patch(), ERROUT, ng_patch_vlan_header::etype, NG_FREE_ITEM, NG_FREE_M, NG_FWD_NEW_DATA, NG_HOOK_NODE, NG_NODE_PRIVATE, NGI_GET_M, PULLUP_CHECK, and priv::stats.

Here is the call graph for this function:

◆ ng_patch_rcvmsg()

◆ ng_patch_shutdown()

static int ng_patch_shutdown ( node_p  node)
static

Definition at line 660 of file ng_patch.c.

References NG_NODE_PRIVATE, NG_NODE_SET_PRIVATE, and NG_NODE_UNREF.

Variable Documentation

◆ ng_patch_cmdlist

const struct ng_cmdlist ng_patch_cmdlist[]
static

Definition at line 112 of file ng_patch.c.

◆ ng_patch_config_type

const struct ng_parse_type ng_patch_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_patch_config_type_fields[]
Definition: ng_patch.c:99

Definition at line 100 of file ng_patch.c.

◆ ng_patch_config_type_fields

const struct ng_parse_struct_field ng_patch_config_type_fields[] = NG_PATCH_CONFIG_TYPE
static

Definition at line 98 of file ng_patch.c.

◆ ng_patch_constructor

ng_constructor_t ng_patch_constructor
static

Definition at line 62 of file ng_patch.c.

◆ ng_patch_disconnect

ng_disconnect_t ng_patch_disconnect
static

Definition at line 67 of file ng_patch.c.

◆ ng_patch_newhook

ng_newhook_t ng_patch_newhook
static

Definition at line 65 of file ng_patch.c.

◆ ng_patch_op_type

const struct ng_parse_type ng_patch_op_type
static
Initial value:
= {
}
static const struct ng_parse_struct_field ng_patch_op_type_fields[]
Definition: ng_patch.c:83

Definition at line 84 of file ng_patch.c.

◆ ng_patch_op_type_fields

const struct ng_parse_struct_field ng_patch_op_type_fields[] = NG_PATCH_OP_TYPE
static

Definition at line 82 of file ng_patch.c.

◆ ng_patch_ops_array_info

const struct ng_parse_array_info ng_patch_ops_array_info
static
Initial value:
= {
}
static int ng_patch_config_getlen(const struct ng_parse_type *type, const u_char *start, const u_char *buf)
Definition: ng_patch.c:71
static const struct ng_parse_type ng_patch_op_type
Definition: ng_patch.c:84

Definition at line 89 of file ng_patch.c.

◆ ng_patch_ops_array_type

const struct ng_parse_type ng_patch_ops_array_type
static
Initial value:
= {
}
const struct ng_parse_type ng_parse_array_type
Definition: ng_parse.c:318
static const struct ng_parse_array_info ng_patch_ops_array_info
Definition: ng_patch.c:89

Definition at line 93 of file ng_patch.c.

◆ ng_patch_rcvdata

ng_rcvdata_t ng_patch_rcvdata
static

Definition at line 66 of file ng_patch.c.

◆ ng_patch_rcvmsg

ng_rcvmsg_t ng_patch_rcvmsg
static

Definition at line 63 of file ng_patch.c.

◆ ng_patch_shutdown

ng_shutdown_t ng_patch_shutdown
static

Definition at line 64 of file ng_patch.c.

◆ ng_patch_stats_fields

const struct ng_parse_struct_field ng_patch_stats_fields[] = NG_PATCH_STATS_TYPE
static

Definition at line 105 of file ng_patch.c.

◆ ng_patch_stats_type

const struct ng_parse_type ng_patch_stats_type
static
Initial value:
= {
}
static const struct ng_parse_struct_field ng_patch_stats_fields[]
Definition: ng_patch.c:106

Definition at line 107 of file ng_patch.c.

◆ typestruct

struct ng_type typestruct
static
Initial value:
= {
.version = NG_ABI_VERSION,
.constructor = ng_patch_constructor,
.rcvmsg = ng_patch_rcvmsg,
.shutdown = ng_patch_shutdown,
.newhook = ng_patch_newhook,
.rcvdata = ng_patch_rcvdata,
.disconnect = ng_patch_disconnect,
.cmdlist = ng_patch_cmdlist,
}
#define NG_ABI_VERSION
Definition: netgraph.h:77
static ng_newhook_t ng_patch_newhook
Definition: ng_patch.c:65
static ng_rcvdata_t ng_patch_rcvdata
Definition: ng_patch.c:66
static ng_shutdown_t ng_patch_shutdown
Definition: ng_patch.c:64
static ng_constructor_t ng_patch_constructor
Definition: ng_patch.c:62
static ng_disconnect_t ng_patch_disconnect
Definition: ng_patch.c:67
static const struct ng_cmdlist ng_patch_cmdlist[]
Definition: ng_patch.c:112
static ng_rcvmsg_t ng_patch_rcvmsg
Definition: ng_patch.c:63
#define NG_PATCH_NODE_TYPE
Definition: ng_patch.h:36

Definition at line 165 of file ng_patch.c.