124ea1dbfSLutz Donnerhacke /* 224ea1dbfSLutz Donnerhacke * SPDX-License-Identifier: BSD-3-Clause 324ea1dbfSLutz Donnerhacke * 424ea1dbfSLutz Donnerhacke * Copyright 2021 Lutz Donnerhacke 524ea1dbfSLutz Donnerhacke * 624ea1dbfSLutz Donnerhacke * Redistribution and use in source and binary forms, with or without 724ea1dbfSLutz Donnerhacke * modification, are permitted provided that the following conditions 824ea1dbfSLutz Donnerhacke * are met: 924ea1dbfSLutz Donnerhacke * 1024ea1dbfSLutz Donnerhacke * 1. Redistributions of source code must retain the above copyright 1124ea1dbfSLutz Donnerhacke * notice, this list of conditions and the following disclaimer. 1224ea1dbfSLutz Donnerhacke * 2. Redistributions in binary form must reproduce the above 1324ea1dbfSLutz Donnerhacke * copyright notice, this list of conditions and the following 1424ea1dbfSLutz Donnerhacke * disclaimer in the documentation and/or other materials provided 1524ea1dbfSLutz Donnerhacke * with the distribution. 1624ea1dbfSLutz Donnerhacke * 3. Neither the name of the copyright holder nor the names of its 1724ea1dbfSLutz Donnerhacke * contributors may be used to endorse or promote products derived 1824ea1dbfSLutz Donnerhacke * from this software without specific prior written permission. 1924ea1dbfSLutz Donnerhacke * 2024ea1dbfSLutz Donnerhacke * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 2124ea1dbfSLutz Donnerhacke * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 2224ea1dbfSLutz Donnerhacke * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 2324ea1dbfSLutz Donnerhacke * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 2424ea1dbfSLutz Donnerhacke * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 2524ea1dbfSLutz Donnerhacke * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 2624ea1dbfSLutz Donnerhacke * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 2724ea1dbfSLutz Donnerhacke * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2824ea1dbfSLutz Donnerhacke * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 2924ea1dbfSLutz Donnerhacke * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 3024ea1dbfSLutz Donnerhacke * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 3124ea1dbfSLutz Donnerhacke * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3224ea1dbfSLutz Donnerhacke * SUCH DAMAGE. 3324ea1dbfSLutz Donnerhacke */ 3424ea1dbfSLutz Donnerhacke 3524ea1dbfSLutz Donnerhacke #include <netgraph.h> 3624ea1dbfSLutz Donnerhacke 3724ea1dbfSLutz Donnerhacke void ng_connect (char const *path1, char const *hook1, 3824ea1dbfSLutz Donnerhacke char const *path2, char const *hook2); 3924ea1dbfSLutz Donnerhacke void ng_mkpeer (char const *path1, char const *hook1, 4024ea1dbfSLutz Donnerhacke char const *type, char const *hook2); 4124ea1dbfSLutz Donnerhacke void ng_shutdown(char const *path); 4224ea1dbfSLutz Donnerhacke void ng_rmhook (char const *path, char const *hook); 4324ea1dbfSLutz Donnerhacke void ng_name (char const *path, char const *name); 4424ea1dbfSLutz Donnerhacke 4524ea1dbfSLutz Donnerhacke typedef void (*ng_data_handler_t)(void *, size_t, void *ctx); 4624ea1dbfSLutz Donnerhacke void ng_register_data(char const *hook, ng_data_handler_t proc); 4724ea1dbfSLutz Donnerhacke void ng_send_data(char const *hook, void const *, size_t); 4824ea1dbfSLutz Donnerhacke 49*09307dbfSLutz Donnerhacke typedef void (*ng_msg_handler_t)(char const *, struct ng_mesg *, void *); 50*09307dbfSLutz Donnerhacke void ng_register_msg(ng_msg_handler_t proc); 5124ea1dbfSLutz Donnerhacke int ng_send_msg(char const *path, char const *msg); 5224ea1dbfSLutz Donnerhacke 5324ea1dbfSLutz Donnerhacke int ng_handle_event (unsigned int ms, void *ctx); 5424ea1dbfSLutz Donnerhacke void ng_handle_events(unsigned int ms, void *ctx); 5524ea1dbfSLutz Donnerhacke 5624ea1dbfSLutz Donnerhacke typedef enum { FAIL, PASS } ng_error_t; 5724ea1dbfSLutz Donnerhacke ng_error_t ng_errors(ng_error_t); 5824ea1dbfSLutz Donnerhacke 5924ea1dbfSLutz Donnerhacke void ng_init(void); 60