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>
35 .\" $FreeBSD: src/lib/libnetgraph/netgraph.3,v 1.4.2.10 2002/12/29 16:35:36 schweikh Exp $
36 .\" $DragonFly: src/lib/libnetgraph/netgraph.3,v 1.2 2003/06/17 04:26:50 dillon Exp $
37 .\" $Whistle: netgraph.3,v 1.7 1999/01/25 07:14:06 archie Exp $
51 .Nd netgraph user library
57 .Fn NgMkSockNode "const char *name" "int *csp" "int *dsp"
59 .Fn NgNameNode "int cs" "const char *path" "const char *fmt" "..."
61 .Fn NgSendMsg "int cs" "const char *path" "int cookie" "int cmd" "const void *arg" "size_t arglen"
63 .Fn NgSendAsciiMsg "int cs" "const char *path" "const char *fmt" "..."
65 .Fn NgSendMsgReply "int cs" "const char *path" "struct ng_mesg *msg" "const void *arg" "size_t arglen"
67 .Fn NgRecvMsg "int cs" "struct ng_mesg *rep" "size_t replen" "char *path"
69 .Fn NgRecvAsciiMsg "int cs" "struct ng_mesg *rep" "size_t replen" "char *path"
71 .Fn NgSendData "int ds" "const char *hook" "const u_char *buf" "size_t len"
73 .Fn NgRecvData "int ds" "u_char *buf" "size_t len" "char *hook"
75 .Fn NgSetDebug "int level"
77 .Fn NgSetErrLog "void (*log)(const char *fmt, ...)" "void (*logx)(const char *fmt, ...)"
79 These functions facilitate user-mode program participation in the kernel
81 graph-based networking system, by utilizing the netgraph
87 should be called first, to create a new
89 type netgraph node with associated control and data sockets. If
91 is non-NULL, the node will have that global name assigned to it.
95 will be set to the newly opened control and data sockets
96 associated with the node; either
100 may be NULL if only one socket is desired.
102 loads the socket node type KLD if it's not already loaded.
105 assigns a global name to the node addressed by
109 sends a binary control message from the socket node associated
112 to the node addressed by
116 indicates how to interpret
118 which indicates a specific command.
119 Extra argument data (if any) is specified by
126 and argument data are defined by the header file corresponding
127 to the type of the node being addressed.
128 The unique, non-negative token value chosen for use in the message
129 header is returned. This value is typically used to associate replies.
133 to send reply to a previously received control message.
134 The original message header should be pointed to by
138 performs the same function as
142 encoding of control messages.
144 formats its input a la
146 and then sends the resulting
148 string to the node in a
150 control message. The node returns a binary version of the
151 message, which is then sent back to the node just as with
155 the message token value is returned.
158 conversion may not be supported by all node types.
161 reads the next control message received by the node associated with
164 The message and any extra argument data must fit in
169 is non-NULL, it must point to a buffer of at least
171 bytes, which will be filled in (and NUL terminated) with the path to
172 the node from which the message was received.
174 The length of the control message is returned.
175 A return value of zero indicates that the socket was closed.
180 except that after the message is received, any binary arguments
185 request back to the originating node. The result is the same as
187 with the exception that the reply arguments field will contain
190 version of the arguments (and the reply
191 header argument length field will be adjusted).
194 writes a data packet out on the specified hook of the node corresponding
197 The node must already be connected to some other node via that hook.
200 reads the next data packet (of up to
202 bytes) received by the node corresponding to data socket
206 which must be large enough to hold the entire packet. If
208 is non-NULL, it must point to a buffer of at least
210 bytes, which will be filled in (and NUL terminated) with the name of
211 the hook on which the data was received.
213 The length of the packet is returned.
214 A return value of zero indicates that the socket was closed.
219 are used for debugging.
221 sets the debug level (if non-negative), and returns the old setting.
222 Higher debug levels result in more verbosity. The default is zero.
223 All debug and error messages are logged via the functions
224 specified in the most recent call to
226 The default logging functions are
231 At debug level 3, the library attempts to display control message arguments
234 format; however, this results in additional messages being
235 sent which may interfere with debugging. At even higher levels,
236 even these additional messages will be displayed, etc.
240 can be used on the data and the control sockets to detect the presence of
241 incoming data and control messages, respectively.
242 Data and control packets are always written and read atomically, i.e.,
245 User mode programs must be linked with the
247 flag to link in this library.
249 To enable Netgraph in your kernel, either your kernel must be
252 in the kernel configuration
257 KLD modules must have been loaded via
261 returns the previous debug setting.
264 All other functions return \-1 if there was an error and set
267 A return value of zero from
271 indicates that the netgraph socket has been closed.
277 the following additional errors are possible:
280 The node type does not know how to encode or decode the control message.
282 The encoded or decoded arguments were too long for the supplied buffer.
284 An unknown structure field was seen in an
288 The same structure field was specified twice in an
293 control message parse error or illegal value.
295 ASCII control message array or fixed width string buffer overflow.
307 system was designed and first implemented at Whistle Communications, Inc. in
310 customized for the Whistle InterJet.
312 .An Archie Cobbs Aq archie@whistle.com