* 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. */
| 3761 | * be used. |
| 3762 | */ |
| 3763 | int |
| 3764 | ng_send_fn2(node_p node, hook_p hook, item_p pitem, ng_item_fn2 *fn, void *arg1, |
| 3765 | int arg2, int flags) |
| 3766 | { |
| 3767 | item_p item; |
| 3768 | |
| 3769 | KASSERT((pitem != NULL || (flags & NG_REUSE_ITEM) == 0), |
| 3770 | ("%s: NG_REUSE_ITEM but no pitem", __func__)); |
| 3771 | |
| 3772 | /* |
| 3773 | * Allocate a new item if no supplied or |
| 3774 | * if we can't use supplied one. |
| 3775 | */ |
| 3776 | if (pitem == NULL || (flags & NG_REUSE_ITEM) == 0) { |
| 3777 | if ((item = ng_alloc_item(NGQF_FN2, flags)) == NULL) |
| 3778 | return (ENOMEM); |
| 3779 | if (pitem != NULL) |
| 3780 | item->apply = pitem->apply; |
| 3781 | } else { |
| 3782 | if ((item = ng_realloc_item(pitem, NGQF_FN2, flags)) == NULL) |
| 3783 | return (ENOMEM); |
| 3784 | } |
| 3785 | |
| 3786 | item->el_flags = (item->el_flags & ~NGQF_RW) | NGQF_WRITER; |
| 3787 | NG_NODE_REF(node); /* and one for the item */ |
| 3788 | NGI_SET_NODE(item, node); |
| 3789 | if (hook) { |
| 3790 | NG_HOOK_REF(hook); |
| 3791 | NGI_SET_HOOK(item, hook); |
| 3792 | } |
| 3793 | NGI_FN2(item) = fn; |
| 3794 | NGI_ARG1(item) = arg1; |
| 3795 | NGI_ARG2(item) = arg2; |
| 3796 | return(ng_snd_item(item, flags)); |
| 3797 | } |
| 3798 | |
| 3799 | /* |
| 3800 | * Official timeout routines for Netgraph nodes. |
no test coverage detected