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@FreeBSD.org>
34 .\" $Whistle: ng_socket.8,v 1.5 1999/01/25 23:46:27 archie Exp $
41 .Nd netgraph socket node type
44 .In netgraph/ng_socket.h
50 socket and a netgraph node.
53 node type allows user-mode processes to participate in the kernel
55 networking subsystem using the
59 root privileges to be able to create netgraph sockets however once created,
60 any process that has one may use it.
64 node is created by creating a new socket of type
66 in the protocol family
71 Any control messages received by the node
72 and not having a cookie value of
74 are received by the process, using
76 the socket address argument is a
77 .Dv "struct sockaddr_ng"
78 containing the sender's netgraph address.
79 Conversely, control messages can be sent to any node by calling
81 supplying the recipient's address in a
82 .Dv "struct sockaddr_ng" .
85 system call may be used to assign a global netgraph name to the node.
87 To transmit and receive netgraph data packets, a
89 socket must also be created using
95 sockets do not automatically
96 have nodes associated with them; they are bound to a specific node via the
99 The address argument is the netgraph address of the
101 node already created.
102 Once a data socket is associated with a node,
103 any data packets received by the node are read using
105 and any packets to be sent out from the node are written using
107 In the case of data sockets, the
108 .Dv "struct sockaddr_ng"
109 contains the name of the
111 on which the data was received or should be sent.
113 As a special case, to allow netgraph data sockets to be used as stdin or stdout
116 with a NULL sockaddr pointer, a
120 will succeed in the case where there is exactly ONE hook attached to
121 the socket node, (and thus the path is unambiguous).
123 There is a user library that simplifies using netgraph sockets; see
126 This node type supports hooks with arbitrary names (as long as
127 they are unique) and always accepts hook connection requests.
129 This node type supports the generic control messages, plus the following:
131 .It Dv NGM_SOCK_CMD_NOLINGER
132 When the last hook is removed from this node, it will shut down as
136 Attempts to access the sockets associated will return
138 .It Dv NGM_SOCK_CMD_LINGER
139 This is the default mode.
140 When the last hook is removed, the node will
141 continue to exist, ready to accept new hooks until it
142 is explicitly shut down.
147 .Dv NGM_SOCKET_COOKIE
149 .Dv NGM_GENERIC_COOKIE
150 will be passed unaltered up the
154 This node type shuts down and disappears when both the associated
158 sockets have been closed, or a
160 control message is received.
161 In the latter case, attempts to write
162 to the still-open sockets will return
165 .Dv NGM_SOCK_CMD_NOLINGER
166 message has been received, closure of the last hook will also initiate
167 a shutdown of the node.
177 node type was implemented in
180 .An Julian Elischer Aq Mt julian@FreeBSD.org
182 It is not possible to reject the connection of a hook, though any
183 data received on that hook can certainly be ignored.
185 The controlling process is not notified of all events that an in-kernel node
186 would be notified of, e.g.\& a new hook, or hook removal.
187 Some node-initiated messages should be defined for this purpose (to be
188 sent up the control socket).