63#include <sys/kernel.h>
64#include <sys/malloc.h>
66#include <sys/stddef.h>
73#ifdef NG_SEPARATE_MALLOC
76#define M_NETGRAPH_TAG M_NETGRAPH
79#define ERROUT(x) do { error = (x); goto done; } while (0)
111 struct ng_tag_hookstat
stats;
131 const u_char *start,
const u_char *buf)
142 const u_char *start,
const u_char *buf)
180 = NG_TAG_HOOKSTAT_TYPE_INFO;
183 &ng_tag_hookstat_type_fields
223 &ng_tag_hookstat_type
234 NGM_TAG_GETCLR_STATS,
237 &ng_tag_hookstat_type
338 strncpy(hip->in->thisHook,
name,
sizeof(hip->in->thisHook) - 1);
339 hip->in->thisHook[
sizeof(hip->in->thisHook) - 1] =
'\0';
340 strncpy(hip->out->thisHook,
name,
sizeof(hip->out->thisHook) - 1);
341 hip->out->thisHook[
sizeof(hip->out->thisHook) - 1] =
'\0';
420 bcopy(hp, resp->
data,
444 bcopy(hp, resp->
data,
450 case NGM_TAG_GET_STATS:
451 case NGM_TAG_CLR_STATS:
452 case NGM_TAG_GETCLR_STATS:
454 struct ng_tag_hookstat *
stats;
468 if (msg->
header.
cmd != NGM_TAG_CLR_STATS) {
470 msg,
sizeof(*
stats), M_WAITOK);
476 if (msg->
header.
cmd != NGM_TAG_GET_STATS)
506 struct m_tag *tag = NULL;
508 uint16_t
type, tag_len;
513 int found = 0, error = 0;
516 totlen = m->m_pkthdr.len;
524 cookie = hip->in_tag_cookie;
525 type = hip->in_tag_id;
526 tag_len = hip->in_tag_len;
535 if ((cookie != 0) || (
type != 0)) {
536 tag = m_tag_locate(m, cookie,
type, NULL);
537 while (tag != NULL) {
538 if (memcmp((
void *)(tag + 1),
539 hip->in_tag_data, tag_len) == 0) {
543 tag = m_tag_locate(m, cookie,
type, tag);
554 m_tag_delete(m, tag);
555 dest = hip->hi_match;
557 dest = hip->hi_nonmatch;
571 cookie = dhip->out_tag_cookie;
572 type = dhip->out_tag_id;
573 tag_len = dhip->out_tag_len;
575 if ((cookie != 0) || (
type != 0)) {
576 tag = m_tag_alloc(cookie,
type, tag_len, M_NOWAIT);
581 memcpy((
void *)(tag + 1),
582 dhip->out_tag_data, tag_len);
584 m_tag_prepend(m, tag);
614 KASSERT(hip != NULL, (
"%s: null info", __func__));
616 LIST_FOREACH(hook2, &node->nd_hooks, hk_hooks) {
619 if (
priv->hi_match == hook)
620 priv->hi_match = NULL;
621 if (
priv->hi_nonmatch == hook)
622 priv->hi_nonmatch = NULL;
654 bcopy(hp0, hp, size);
682 hip->in_tag_cookie = hip->in->tag_cookie;
683 hip->in_tag_id = hip->in->tag_id;
684 hip->in_tag_len = hip->in->tag_len;
685 hip->strip = hip->in->strip;
686 hip->in_tag_data = (
void*)(hip->in->tag_data);
704 bcopy(hp0, hp, size);
707 if (hip->out != NULL)
712 hip->out_tag_cookie = hip->out->tag_cookie;
713 hip->out_tag_id = hip->out->tag_id;
714 hip->out_tag_len = hip->out->tag_len;
715 hip->out_tag_data = (
void*)(hip->out->tag_data);
#define NG_HOOK_NODE(hook)
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_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_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)
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_bytearray_type
const struct ng_parse_type ng_parse_struct_type
const struct ng_parse_type ng_parse_hookbuf_type
static int ng_tag_setdata_out(hook_p hook, const struct ng_tag_hookout *hp)
static int ng_tag_hookinary_getLength(const struct ng_parse_type *type, const u_char *start, const u_char *buf)
static ng_newhook_t ng_tag_newhook
static const struct ng_tag_hookout ng_tag_default_out
static const struct ng_parse_struct_field ng_tag_hookout_type_fields[]
static const struct ng_cmdlist ng_tag_cmdlist[]
static ng_shutdown_t ng_tag_shutdown
static ng_rcvdata_t ng_tag_rcvdata
struct ng_tag_hookinfo * hinfo_p
static int ng_tag_setdata_in(hook_p hook, const struct ng_tag_hookin *hp)
static const struct ng_parse_struct_field ng_tag_hookin_type_fields[]
static ng_disconnect_t ng_tag_disconnect
static ng_constructor_t ng_tag_constructor
static struct ng_type typestruct
static const struct ng_parse_type ng_tag_hookout_type
static int ng_tag_hookoutary_getLength(const struct ng_parse_type *type, const u_char *start, const u_char *buf)
static const struct ng_tag_hookin ng_tag_default_in
static ng_rcvmsg_t ng_tag_rcvmsg
NETGRAPH_INIT(tag, &typestruct)
static const struct ng_parse_type ng_tag_hookin_type
static const struct ng_parse_type ng_tag_hookinary_type
static const struct ng_parse_type ng_tag_hookoutary_type
#define NG_TAG_HOOKOUT_SIZE(taglen)
#define NG_TAG_HOOKIN_TYPE_INFO(tdtype)
#define NG_TAG_HOOKOUT_TYPE_INFO(tdtype)
#define NG_TAG_HOOKIN_SIZE(taglen)
struct ng_bpf_hookstat stats
u_int64_t recvMatchFrames
u_int64_t recvMatchOctets
struct ng_mesg::ng_msghdr header
char thisHook[NG_HOOKSIZ]
struct ng_tag_hookout * out
struct ng_tag_hookin * in
char thisHook[NG_HOOKSIZ]