1 .\" Copyright (c) 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>
42 .Nd kernel socket netgraph node type
45 .In netgraph/ng_ksocket.h
49 node is both a netgraph node and a
54 node type allows one to open a socket inside the kernel and have
55 it appear as a Netgraph node.
58 node type is the reverse of the socket node type (see
60 whereas the socket node type enables the user-level manipulation (via
61 a socket) of what is normally a kernel-level entity (the associated
64 node type enables the kernel-level manipulation (via a Netgraph node) of
65 what is normally a user-level entity (the associated socket).
69 node allows at most one hook connection.
70 Connecting to the node is
71 equivalent to opening the associated socket.
72 The name given to the hook
73 determines what kind of socket the node will open (see below).
74 When the hook is disconnected and/or the node is shutdown, the
75 associated socket is closed.
77 This node type supports a single hook connection at a time.
78 The name of the hook must be of the form
79 .Em <family>/<type>/<proto> ,
85 are the decimal equivalent of the same arguments to
87 Alternately, aliases for the commonly used values are accepted as
91 is a more readable but equivalent version of
94 Data received into socket is sent out via hook.
95 Data received on hook is sent out from socket, if the latter is
97 .Dv NGM_KSOCKET_CONNECT
98 was sent to node before).
99 If socket is not connected, destination
100 .Vt "struct sockaddr"
101 must be supplied in an mbuf tag with cookie
102 .Dv NGM_KSOCKET_COOKIE
104 .Dv NG_KSOCKET_TAG_SOCKADDR
112 This node type supports the generic control messages, plus the following:
114 .It Dv NGM_KSOCKET_BIND
115 This functions exactly like the
119 .Vt "struct sockaddr"
120 socket address parameter should be supplied as an argument.
121 .It Dv NGM_KSOCKET_LISTEN
122 This functions exactly like the
125 The backlog parameter (a single 32 bit
127 should be supplied as an argument.
128 .It Dv NGM_KSOCKET_CONNECT
129 This functions exactly like the
133 .Vt "struct sockaddr"
134 destination address parameter should be supplied as an argument.
135 .It Dv NGM_KSOCKET_ACCEPT
138 system call on a non-blocking socket.
139 If there is a pending connection on the queue,
140 a new socket and a corresponding cloned node are created.
141 Returned are the cloned node's ID and a peer name (as
142 .Vt "struct sockaddr" ) .
143 If there are no pending connections,
144 this control message returns nothing,
145 and a connected node will receive the above message asynchronously,
146 when a connection is established.
148 A cloned node supports a single hook with an arbitrary name.
149 If not connected, a node disappears when its parent node is destroyed.
150 Once connected, it becomes an independent node.
151 .It Dv NGM_KSOCKET_GETNAME
155 The name is returned as a
156 .Vt "struct sockaddr"
157 in the arguments field of the reply.
158 .It Dv NGM_KSOCKET_GETPEERNAME
162 The name is returned as a
163 .Vt "struct sockaddr"
164 in the arguments field of the reply.
165 .It Dv NGM_KSOCKET_SETOPT
168 system call, except that the option name, level, and value are passed in a
169 .Vt "struct ng_ksocket_sockopt" .
170 .It Dv NGM_KSOCKET_GETOPT
173 system call, except that the option is passed in a
174 .Vt "struct ng_ksocket_sockopt" .
175 When sending this command, the
177 field should be empty; upon return, it will contain the
180 .Sh ASCII FORM CONTROL MESSAGES
181 For control messages that pass a
182 .Vt "struct sockaddr"
183 in the argument field, the normal
185 equivalent of the C structure
186 is an acceptable form.
191 address families, a more convenient form is also used, which is
192 the protocol family name, followed by a slash, followed by the actual
196 the address is an IP address followed by an optional colon and port number.
199 the address is the pathname as a doubly quoted string.
202 .Bl -tag -width XXXXXXXXXX
204 local/"/tmp/foo.socket"
206 inet/192.168.1.1:1234
208 .Dv "\&{ family=16 len=16 data=[0x70 0x00 0x01 0x23] \&}"
211 For control messages that pass a
212 .Vt "struct ng_ksocket_sockopt" ,
215 form for that structure is used.
217 convenient encoding of the more common socket options may be supported.
219 This node shuts down upon receipt of a
221 control message, or when the hook is disconnected.
222 Shutdown of the node closes the associated socket.
233 node type was implemented in
236 .An Archie Cobbs Aq archie@FreeBSD.org