62#include <sys/kernel.h>
63#include <sys/malloc.h>
68#include <net/bpf_jitter.h>
76#ifdef NG_SEPARATE_MALLOC
79#define M_NETGRAPH_BPF M_NETGRAPH
82#define OFFSETOF(s, e) ((char *)&((s *)0)->e - (char *)((s *)0))
84#define ERROUT(x) do { error = (x); goto done; } while (0)
93 bpf_jit_filter *jit_prog;
129 const u_char *start,
const u_char *buf)
224 { BPF_STMT(BPF_RET+BPF_K, 0) }
357 bcopy(hp, resp->
data,
382 msg,
sizeof(*
stats), M_NOWAIT);
419 int needfree = 0, error = 0, usejit = 0;
427 totlen = m->m_pkthdr.len;
441 if (bpf_jitter_enable != 0 && hip->jit_prog != NULL)
446 if (m->m_next != NULL && totlen > MHLEN) {
454 m_copydata(m, 0, totlen, (caddr_t)
data);
457 if (m->m_next != NULL) {
458 NGI_M(item) = m = m_pullup(m, totlen);
464 data = mtod(m, u_char *);
470 len = (*(hip->jit_prog->func))(
data, totlen, totlen);
476 len = bpf_filter(hip->
prog->
bpf_prog, (u_char *)m, totlen, 0);
490 m_adj(m, -(totlen - len));
529 KASSERT(hip != NULL, (
"%s: null info", __func__));
536 if (hip->jit_prog != NULL)
537 bpf_destroy_jit_filter(hip->jit_prog);
560 bpf_jit_filter *jit_prog;
574 bcopy(hp0, hp, size);
580 if (hip->
prog != NULL)
584 if (hip->jit_prog != NULL)
585 bpf_destroy_jit_filter(hip->jit_prog);
586 hip->jit_prog = jit_prog;
#define NG_HOOK_NODE(hook)
#define NG_NODE_FOREACH_HOOK(node, fn, arg, rethook)
int ng_rcvmsg_t(node_p node, item_p item, hook_p lasthook)
#define NG_FWD_ITEM_HOOK(error, item, hook)
int ng_disconnect_t(hook_p hook)
#define NG_NODE_SET_PRIVATE(node, val)
#define NG_RESPOND_MSG(error, here, item, resp)
#define NG_NODE_IS_VALID(node)
#define NG_NODE_UNREF(node)
#define NG_HOOK_SET_PRIVATE(hook, val)
int ng_rmnode_self(node_p here)
int ng_rcvdata_t(hook_p hook, item_p item)
int ng_shutdown_t(node_p node)
#define NG_HOOK_NAME(hook)
#define NG_FREE_ITEM(item)
int ng_constructor_t(node_p node)
#define NG_NODE_NUMHOOKS(node)
#define NGI_GET_MSG(i, m)
int ng_newhook_t(node_p node, hook_p hook, const char *name)
hook_p ng_findhook(node_p node, const char *name)
#define NG_HOOK_PRIVATE(hook)
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_struct_field ng_bpf_hookstat_type_fields[]
static ng_shutdown_t ng_bpf_shutdown
static int ng_bpf_remrefs(hook_p hook, void *arg)
static const struct ng_parse_array_info ng_bpf_hookprogary_info
static ng_newhook_t ng_bpf_newhook
static struct ng_type typestruct
static int ng_bpf_addrefs(hook_p hook, void *arg)
static const struct ng_parse_type ng_bpf_insn_type
NETGRAPH_INIT(bpf, &typestruct)
static int ng_bpf_setprog(hook_p hook, const struct ng_bpf_hookprog *hp)
static const struct ng_parse_type ng_bpf_hookstat_type
static const struct ng_parse_type ng_bpf_hookprogary_type
static const struct ng_bpf_hookprog ng_bpf_default_prog
static const struct ng_parse_struct_field ng_bpf_insn_type_fields[]
struct ng_bpf_hookinfo * hinfo_p
static const struct ng_parse_type ng_bpf_hookprog_type
static ng_disconnect_t ng_bpf_disconnect
static ng_constructor_t ng_bpf_constructor
static const struct ng_parse_struct_field ng_bpf_hookprog_type_fields[]
static const struct ng_cmdlist ng_bpf_cmdlist[]
static ng_rcvmsg_t ng_bpf_rcvmsg
static ng_rcvdata_t ng_bpf_rcvdata
#define NG_BPF_HOOKSTAT_TYPE_INFO
#define NG_BPF_HOOKPROG_TYPE_INFO(bptype)
#define NG_BPF_HOOKPROG_SIZE(numInsn)
MALLOC_DEFINE(M_NG_CCATM, "ng_ccatm", "netgraph uni api node")
#define NG_MKRESPONSE(rsp, msg, len, how)
const struct ng_parse_type ng_parse_array_type
const struct ng_parse_type ng_parse_struct_type
const struct ng_parse_type ng_parse_uint32_type
const struct ng_parse_type ng_parse_hookbuf_type
const struct ng_parse_type ng_parse_uint8_type
const struct ng_parse_type ng_parse_hint16_type
struct ng_bpf_hookstat stats
struct ng_bpf_hookprog * prog
char ifNotMatch[NG_HOOKSIZ]
char thisHook[NG_HOOKSIZ]
struct bpf_insn bpf_prog[]
u_int64_t recvMatchFrames
u_int64_t recvMatchOctets
struct ng_mesg::ng_msghdr header