* Send ng_item_fn2 function call to the specified node. * * If an optional pitem parameter is supplied, its apply * callback will be copied to the new item. If also NG_REUSE_ITEM * flag is set, no new item will be allocated, but pitem will * be used. */
| 3731 | * be used. |
| 3732 | */ |
| 3733 | int |
| 3734 | ng_send_fn2(node_p node, hook_p hook, item_p pitem, ng_item_fn2 *fn, void *arg1, |
| 3735 | int arg2, int flags) |
| 3736 | { |
| 3737 | item_p item; |
| 3738 | |
| 3739 | KASSERT((pitem != NULL || (flags & NG_REUSE_ITEM) == 0), |
| 3740 | ("%s: NG_REUSE_ITEM but no pitem", __func__)); |
| 3741 | |
| 3742 | /* |
| 3743 | * Allocate a new item if no supplied or |
| 3744 | * if we can't use supplied one. |
| 3745 | */ |
| 3746 | if (pitem == NULL || (flags & NG_REUSE_ITEM) == 0) { |
| 3747 | if ((item = ng_alloc_item(NGQF_FN2, flags)) == NULL) |
| 3748 | return (ENOMEM); |
| 3749 | if (pitem != NULL) |
| 3750 | item->apply = pitem->apply; |
| 3751 | } else { |
| 3752 | if ((item = ng_realloc_item(pitem, NGQF_FN2, flags)) == NULL) |
| 3753 | return (ENOMEM); |
| 3754 | } |
| 3755 | |
| 3756 | item->el_flags = (item->el_flags & ~NGQF_RW) | NGQF_WRITER; |
| 3757 | NG_NODE_REF(node); /* and one for the item */ |
| 3758 | NGI_SET_NODE(item, node); |
| 3759 | if (hook) { |
| 3760 | NG_HOOK_REF(hook); |
| 3761 | NGI_SET_HOOK(item, hook); |
| 3762 | } |
| 3763 | NGI_FN2(item) = fn; |
| 3764 | NGI_ARG1(item) = arg1; |
| 3765 | NGI_ARG2(item) = arg2; |
| 3766 | return(ng_snd_item(item, flags)); |
| 3767 | } |
| 3768 | |
| 3769 | /* |
| 3770 | * Official timeout routines for Netgraph nodes. |
no test coverage detected