Lines Matching full:hook

45  * This node type accepts any number of hook connections.  With each hook
46 * is associated a bpf(4) filter program, and two hook names (each possibly
48 * matching packets are delivered out the first named hook (or dropped if
50 * named hook (or dropped if the empty string).
52 * Each hook also keeps statistics about how many packets have matched, etc.
84 /* Per hook private info */
86 hook_p hook; member
109 static int ng_bpf_setprog(hook_p hook, const struct ng_bpf_hookprog *hp);
216 /* Default BPF program for a hook that matches nothing */
218 { '\0' }, /* to be filled in at hook creation time */
242 ng_bpf_addrefs(hook_p hook, void* arg) in ng_bpf_addrefs() argument
244 hinfo_p hip = NG_HOOK_PRIVATE(hook); in ng_bpf_addrefs()
255 ng_bpf_remrefs(hook_p hook, void* arg) in ng_bpf_remrefs() argument
257 hinfo_p hip = NG_HOOK_PRIVATE(hook); in ng_bpf_remrefs()
268 * Add a hook
271 ng_bpf_newhook(node_p node, hook_p hook, const char *name) in ng_bpf_newhook() argument
276 /* Create hook private structure */ in ng_bpf_newhook()
280 hip->hook = hook; in ng_bpf_newhook()
281 NG_HOOK_SET_PRIVATE(hook, hip); in ng_bpf_newhook()
284 NG_NODE_FOREACH_HOOK(node, ng_bpf_addrefs, hook); in ng_bpf_newhook()
287 if ((error = ng_bpf_setprog(hook, &ng_bpf_default_prog)) != 0) { in ng_bpf_newhook()
289 NG_HOOK_SET_PRIVATE(hook, NULL); in ng_bpf_newhook()
293 /* Set hook name */ in ng_bpf_newhook()
316 hook_p hook; in ng_bpf_rcvmsg() local
324 /* Find hook */ in ng_bpf_rcvmsg()
325 if ((hook = ng_findhook(node, hp->thisHook)) == NULL) in ng_bpf_rcvmsg()
329 if ((error = ng_bpf_setprog(hook, hp)) != 0) in ng_bpf_rcvmsg()
337 hook_p hook; in ng_bpf_rcvmsg() local
344 /* Find hook */ in ng_bpf_rcvmsg()
345 if ((hook = ng_findhook(node, msg->data)) == NULL) in ng_bpf_rcvmsg()
349 hp = ((hinfo_p)NG_HOOK_PRIVATE(hook))->prog; in ng_bpf_rcvmsg()
364 hook_p hook; in ng_bpf_rcvmsg() local
371 /* Find hook */ in ng_bpf_rcvmsg()
372 if ((hook = ng_findhook(node, msg->data)) == NULL) in ng_bpf_rcvmsg()
374 stats = &((hinfo_p)NG_HOOK_PRIVATE(hook))->stats; in ng_bpf_rcvmsg()
407 * Receive data on a hook
412 ng_bpf_rcvdata(hook_p hook, item_p item) in ng_bpf_rcvdata() argument
414 const hinfo_p hip = NG_HOOK_PRIVATE(hook); in ng_bpf_rcvdata()
425 /* Update stats on incoming hook. XXX Can we do 64 bits atomically? */ in ng_bpf_rcvdata()
477 /* See if we got a match and find destination hook */ in ng_bpf_rcvdata()
498 /* Deliver frame out destination hook */ in ng_bpf_rcvdata()
517 * Hook disconnection
520 ng_bpf_disconnect(hook_p hook) in ng_bpf_disconnect() argument
522 const node_p node = NG_HOOK_NODE(hook); in ng_bpf_disconnect()
523 const hinfo_p hip = NG_HOOK_PRIVATE(hook); in ng_bpf_disconnect()
528 NG_NODE_FOREACH_HOOK(node, ng_bpf_remrefs, hook); in ng_bpf_disconnect()
548 * Set the BPF program associated with a hook
551 ng_bpf_setprog(hook_p hook, const struct ng_bpf_hookprog *hp0) in ng_bpf_setprog() argument
553 const hinfo_p hip = NG_HOOK_PRIVATE(hook); in ng_bpf_setprog()
586 hip->match = ng_findhook(NG_HOOK_NODE(hook), hip->prog->ifMatch); in ng_bpf_setprog()
587 hip->nomatch = ng_findhook(NG_HOOK_NODE(hook), hip->prog->ifNotMatch); in ng_bpf_setprog()