1 .\" Copyright (c) 1996-1999 Whistle Communications, Inc.
2 .\" All rights reserved.
4 .\" Subject to the following obligations and disclaimer of warranty, use and
5 .\" redistribution of this software, in source or object code forms, with or
6 .\" without modifications are expressly permitted by Whistle Communications;
7 .\" provided, however, that:
8 .\" 1. Any and all reproductions of the source or object code must include the
9 .\" copyright notice above and the following disclaimer of warranties; and
10 .\" 2. No rights are granted, in any manner or form, to use Whistle
11 .\" Communications, Inc. trademarks, including the mark "WHISTLE
12 .\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
13 .\" such appears in the above copyright notice or in the software.
15 .\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
16 .\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
17 .\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
18 .\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
19 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
20 .\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
21 .\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
22 .\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
23 .\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
24 .\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
25 .\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26 .\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
27 .\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
28 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 .\" THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
33 .\" Author: Archie Cobbs <archie@whistle.com>
36 .\" $Whistle: netgraph.3,v 1.7 1999/01/25 07:14:06 archie Exp $
50 .Nd Netgraph user library
52 .Fd #include <netgraph.h>
54 .Fn NgMkSockNode "const char *name" "int *csp" "int *dsp"
56 .Fn NgNameNode "int cs" "const char *path" "const char *fmt" "..."
58 .Fn NgSendMsg "int cs" "const char *path" "int cookie" "int cmd" "const void *arg" "size_t arglen"
60 .Fn NgSendMsgReply "int cs" "const char *path" "struct ng_mesg *msg" "const void *arg" "size_t arglen"
62 .Fn NgRecvMsg "int cs" "struct ng_mesg *rep" "size_t replen" "char *path"
64 .Fn NgSendData "int ds" "const char *hook" "const u_char *buf" "size_t len"
66 .Fn NgRecvData "int ds" "u_char *buf" "size_t len" "char *hook"
68 .Fn NgSetDebug "int level"
70 .Fn NgSetErrLog "void (*log)(const char *fmt, ...)" "void (*logx)(const char *fmt, ...)"
72 These functions facilitate user-mode program participation in the kernel
74 graph-based networking system, by utilizing the netgraph
80 should be called first, to create a new
82 type netgraph node with associated control and data sockets. If
84 is non-NULL, the node will have that global name assigned to it.
88 will be set to the newly opened control and data sockets
89 associated with the node; either
93 may be NULL if only one socket is desired.
96 assigns a global name to the node addressed by
100 sends a control message from the socket node associated with control socket
102 to the node addressed by
106 indicates how to interpret
108 which indicates a specific command.
109 Extra argument data (if any) is specified by
116 and argument data are defined by the header file corresponding
117 to the type of the node being addressed.
121 to send reply to a previously received control message.
122 The original message header should be pointed to by
126 reads the next control message received by the node associated with
129 The message and any extra argument data must fit in
134 is non-NULL, it must point to a buffer of at least
136 bytes, which will be filled in (and NUL terminated) with the path to
137 the node from which the message was received.
140 writes a data packet out on the specified hook of the node corresponding
143 The node must already be connected to some other node via that hook.
146 reads the next data packet (of up to
148 bytes) received by the node corresponding to data socket
152 which must be large enough to hold the entire packet. If
154 is non-NULL, it must point to a buffer of at least
156 bytes, which will be filled in (and NUL terminated) with the name of
157 the hook on which the data was received.
162 are used for debugging.
164 sets the debug level (if non-negative), and returns the old setting.
165 Higher debug levels result in more verbosity. The default is zero.
166 All debug and error messages are logged via the functions
167 specified in the most recent call to
169 The default logging functions are
176 can be used on the data and the control sockets to detect the presence of
177 incoming data and control messages, respectively.
178 Data and control packets are always written and read atomically, i.e.,
181 User mode programs must be linked with the
183 flag to link in this library.
185 Netgraph is not part of the standard FreeBSD kernel. To enable it,
186 either your kernel must be compiled with ``options NETGRAPH''
187 in the kernel configuration file, or else the
191 KLD modules must have been loaded via
198 return -1 if there was an error and set errno accordingly.
208 system was designed and first implemented at Whistle Communications, Inc.
209 in a version FreeBSD 2.2 customized for the Whistle InterJet.
211 .An Archie Cobbs <archie@whistle.com>