#include "opt_bpf.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <net/bpf.h>
#include <netgraph/ng_message.h>
#include <netgraph/netgraph.h>
#include <netgraph/ng_parse.h>
#include <netgraph/ng_bpf.h>
Go to the source code of this file.
|
#define | M_NETGRAPH_BPF M_NETGRAPH |
|
#define | OFFSETOF(s, e) ((char *)&((s *)0)->e - (char *)((s *)0)) |
|
#define | ERROUT(x) do { error = (x); goto done; } while (0) |
|
|
static int | ng_bpf_setprog (hook_p hook, const struct ng_bpf_hookprog *hp) |
|
static int | ng_bpf_hookprogary_getLength (const struct ng_parse_type *type, const u_char *start, const u_char *buf) |
|
| NETGRAPH_INIT (bpf, &typestruct) |
|
static int | ng_bpf_constructor (node_p node) |
|
static int | ng_bpf_addrefs (hook_p hook, void *arg) |
|
static int | ng_bpf_remrefs (hook_p hook, void *arg) |
|
static int | ng_bpf_newhook (node_p node, hook_p hook, const char *name) |
|
static int | ng_bpf_rcvmsg (node_p node, item_p item, hook_p lasthook) |
|
static int | ng_bpf_rcvdata (hook_p hook, item_p item) |
|
static int | ng_bpf_shutdown (node_p node) |
|
static int | ng_bpf_disconnect (hook_p hook) |
|
◆ ERROUT
#define ERROUT |
( |
|
x | ) |
do { error = (x); goto done; } while (0) |
◆ M_NETGRAPH_BPF
#define M_NETGRAPH_BPF M_NETGRAPH |
◆ OFFSETOF
#define OFFSETOF |
( |
|
s, |
|
|
|
e |
|
) |
| ((char *)&((s *)0)->e - (char *)((s *)0)) |
◆ hinfo_p
◆ NETGRAPH_INIT()
NETGRAPH_INIT |
( |
bpf |
, |
|
|
& |
typestruct |
|
) |
| |
◆ ng_bpf_addrefs()
static int ng_bpf_addrefs |
( |
hook_p |
hook, |
|
|
void * |
arg |
|
) |
| |
|
static |
◆ ng_bpf_constructor()
static int ng_bpf_constructor |
( |
node_p |
node | ) |
|
|
static |
◆ ng_bpf_disconnect()
static int ng_bpf_disconnect |
( |
hook_p |
hook | ) |
|
|
static |
◆ ng_bpf_hookprogary_getLength()
static int ng_bpf_hookprogary_getLength |
( |
const struct ng_parse_type * |
type, |
|
|
const u_char * |
start, |
|
|
const u_char * |
buf |
|
) |
| |
|
static |
◆ ng_bpf_newhook()
static int ng_bpf_newhook |
( |
node_p |
node, |
|
|
hook_p |
hook, |
|
|
const char * |
name |
|
) |
| |
|
static |
◆ ng_bpf_rcvdata()
Definition at line 415 of file ng_bpf.c.
References ng_bpf_hookprog::bpf_prog, data, M_NETGRAPH_BPF, ng_bpf_hookinfo::match, NG_FREE_ITEM, NG_FWD_ITEM_HOOK, NG_HOOK_PRIVATE, NGI_M, ng_bpf_hookinfo::nomatch, ng_bpf_hookinfo::prog, ng_bpf_hookstat::recvFrames, ng_bpf_hookstat::recvMatchFrames, ng_bpf_hookstat::recvMatchOctets, ng_bpf_hookstat::recvOctets, ng_bpf_hookinfo::stats, ng_bpf_hookstat::xmitFrames, and ng_bpf_hookstat::xmitOctets.
◆ ng_bpf_rcvmsg()
Definition at line 305 of file ng_bpf.c.
References ng_mesg::ng_msghdr::arglen, ng_bpf_hookprog::bpf_prog_len, ng_mesg::ng_msghdr::cmd, ng_mesg::data, ERROUT, ng_mesg::header, NG_BPF_HOOKPROG_SIZE, ng_bpf_setprog(), ng_findhook(), NG_FREE_MSG, NG_HOOK_PRIVATE, NG_MKRESPONSE, NG_RESPOND_MSG, NGI_GET_MSG, NGM_BPF_CLR_STATS, NGM_BPF_COOKIE, NGM_BPF_GET_PROGRAM, NGM_BPF_GET_STATS, NGM_BPF_GETCLR_STATS, NGM_BPF_SET_PROGRAM, ng_bpf_hookprog::thisHook, and ng_mesg::ng_msghdr::typecookie.
◆ ng_bpf_remrefs()
static int ng_bpf_remrefs |
( |
hook_p |
hook, |
|
|
void * |
arg |
|
) |
| |
|
static |
◆ ng_bpf_setprog()
Definition at line 555 of file ng_bpf.c.
References bpf_maxinsns, ng_bpf_hookprog::bpf_prog, ng_bpf_hookprog::bpf_prog_len, ng_bpf_hookprog::ifMatch, ng_bpf_hookprog::ifNotMatch, M_NETGRAPH_BPF, ng_bpf_hookinfo::match, NG_BPF_HOOKPROG_SIZE, ng_findhook(), NG_HOOK_NODE, NG_HOOK_PRIVATE, ng_bpf_hookinfo::nomatch, and ng_bpf_hookinfo::prog.
Referenced by ng_bpf_newhook(), and ng_bpf_rcvmsg().
◆ ng_bpf_shutdown()
static int ng_bpf_shutdown |
( |
node_p |
node | ) |
|
|
static |
◆ bpf_maxinsns
◆ ng_bpf_cmdlist
◆ ng_bpf_constructor
◆ ng_bpf_default_prog
Initial value:= {
{ '\0' },
{ '\0' },
{ '\0' },
1,
{ BPF_STMT(BPF_RET+BPF_K, 0) }
}
Definition at line 219 of file ng_bpf.c.
Referenced by ng_bpf_newhook().
◆ ng_bpf_disconnect
◆ ng_bpf_hookprog_type
Initial value:= {
}
static const struct ng_parse_struct_field ng_bpf_hookprog_type_fields[]
const struct ng_parse_type ng_parse_struct_type
Definition at line 151 of file ng_bpf.c.
◆ ng_bpf_hookprog_type_fields
◆ ng_bpf_hookprogary_info
Initial value:= {
NULL
}
static int ng_bpf_hookprogary_getLength(const struct ng_parse_type *type, const u_char *start, const u_char *buf)
static const struct ng_parse_type ng_bpf_insn_type
Definition at line 138 of file ng_bpf.c.
◆ ng_bpf_hookprogary_type
Initial value:= {
}
static const struct ng_parse_array_info ng_bpf_hookprogary_info
const struct ng_parse_type ng_parse_array_type
Definition at line 143 of file ng_bpf.c.
◆ ng_bpf_hookstat_type
Initial value:= {
}
static const struct ng_parse_struct_field ng_bpf_hookstat_type_fields[]
Definition at line 159 of file ng_bpf.c.
◆ ng_bpf_hookstat_type_fields
◆ ng_bpf_insn_type
Initial value:= {
}
static const struct ng_parse_struct_field ng_bpf_insn_type_fields[]
Definition at line 121 of file ng_bpf.c.
◆ ng_bpf_insn_type_fields
Initial value:= {
{ NULL }
}
const struct ng_parse_type ng_parse_uint32_type
const struct ng_parse_type ng_parse_uint8_type
const struct ng_parse_type ng_parse_hint16_type
Definition at line 114 of file ng_bpf.c.
◆ ng_bpf_newhook
◆ ng_bpf_rcvdata
◆ ng_bpf_rcvmsg
◆ ng_bpf_shutdown
◆ typestruct
Initial value:= {
}
static ng_shutdown_t ng_bpf_shutdown
static ng_newhook_t ng_bpf_newhook
static ng_disconnect_t ng_bpf_disconnect
static ng_constructor_t ng_bpf_constructor
static const struct ng_cmdlist ng_bpf_cmdlist[]
static ng_rcvmsg_t ng_bpf_rcvmsg
static ng_rcvdata_t ng_bpf_rcvdata
Definition at line 205 of file ng_bpf.c.