Lines Matching refs:hook

36  * This node type accepts an arbitrary number of hooks. Each hook can be
37 * configured for an mbuf_tags(9) definition and two hook names: a hook
38 * for matched packets, and a hook for packets, that didn't match. Incoming
40 * out via first hook, and not matched out via second. If corresponding hook
43 * A hook can also have an outgoing tag definition configured, so that
44 * all packets leaving the hook will be unconditionally appended with newly
49 * are unconditionally forwarded to non-matching hook on input. There is
54 * If compiled with NG_TAG_DEBUG, each hook also keeps statistics about
80 * Per hook private info.
95 hook_p hi_match; /* matching hook pointer */
96 hook_p hi_nonmatch; /* non-matching hook pointer */
123 static int ng_tag_setdata_in(hook_p hook, const struct ng_tag_hookin *hp);
124 static int ng_tag_setdata_out(hook_p hook, const struct ng_tag_hookout *hp);
262 * this default structures and initialize thisHook once at hook creation
266 /* Default tag values for a hook that matches nothing. */
268 { '\0' }, /* to be filled in at hook creation time */
277 /* Default tag values for a hook that adds nothing */
279 { '\0' }, /* to be filled in at hook creation time */
288 * We don't keep any per-node private data - we do it on per-hook basis.
297 * Add a hook.
300 ng_tag_newhook(node_p node, hook_p hook, const char *name)
305 /* Create hook private structure. */
309 NG_HOOK_SET_PRIVATE(hook, hip);
312 * After M_ZERO both in and out hook pointers are set to NULL,
319 if ((error = ng_tag_setdata_in(hook, &ng_tag_default_in)) != 0) {
325 if ((error = ng_tag_setdata_out(hook, &ng_tag_default_out)) != 0) {
331 * Set hook name. This is done only once at hook creation time
332 * since hook name can't change, rather than to do it on every
361 hook_p hook;
368 /* Find hook. */
369 if ((hook = ng_findhook(node, hp->thisHook)) == NULL)
373 if ((error = ng_tag_setdata_in(hook, hp)) != 0)
382 hook_p hook;
389 /* Find hook. */
390 if ((hook = ng_findhook(node, hp->thisHook)) == NULL)
394 if ((error = ng_tag_setdata_out(hook, hp)) != 0)
402 hook_p hook;
409 /* Find hook. */
410 if ((hook = ng_findhook(node, msg->data)) == NULL)
414 hp = ((hinfo_p)NG_HOOK_PRIVATE(hook))->in;
426 hook_p hook;
433 /* Find hook. */
434 if ((hook = ng_findhook(node, msg->data)) == NULL)
438 hp = ((hinfo_p)NG_HOOK_PRIVATE(hook))->out;
453 hook_p hook;
460 /* Find hook. */
461 if ((hook = ng_findhook(node, msg->data)) == NULL)
463 stats = &((hinfo_p)NG_HOOK_PRIVATE(hook))->stats;
496 * Receive data on a hook.
501 ng_tag_rcvdata(hook_p hook, item_p item)
505 const hinfo_p hip = NG_HOOK_PRIVATE(hook);
532 * to find such tag (for example, these are zeroes after hook
547 /* See if we got a match and find destination hook. */
563 /* Deliver frame out destination hook. */
608 ng_tag_disconnect(hook_p hook)
610 const hinfo_p hip = NG_HOOK_PRIVATE(hook);
611 node_p node = NG_HOOK_NODE(hook);
619 if (priv->hi_match == hook)
621 if (priv->hi_nonmatch == hook)
628 NG_HOOK_SET_PRIVATE(hook, NULL); /* for good measure */
629 if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0) &&
630 (NG_NODE_IS_VALID(NG_HOOK_NODE(hook)))) {
631 ng_rmnode_self(NG_HOOK_NODE(hook));
641 * Set the IN tag values associated with a hook.
644 ng_tag_setdata_in(hook_p hook, const struct ng_tag_hookin *hp0)
646 const hinfo_p hip = NG_HOOK_PRIVATE(hook);
662 * Resolve hook names to pointers.
668 * XXX The drawback is that user can configure a hook to use
671 * if the hook already exists, causing node to drop packets and
673 * every hook creation with pointers correction, but that involves
678 hip->hi_match = ng_findhook(NG_HOOK_NODE(hook), hip->in->ifMatch);
679 hip->hi_nonmatch = ng_findhook(NG_HOOK_NODE(hook), hip->in->ifNotMatch);
691 * Set the OUT tag values associated with a hook.
694 ng_tag_setdata_out(hook_p hook, const struct ng_tag_hookout *hp0)
696 const hinfo_p hip = NG_HOOK_PRIVATE(hook);