]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man4/ng_ksocket.4
This commit was generated by cvs2svn to compensate for changes in r151497,
[FreeBSD/FreeBSD.git] / share / man / man4 / ng_ksocket.4
1 .\" Copyright (c) 1999 Whistle Communications, Inc.
2 .\" All rights reserved.
3 .\"
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.
14 .\"
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
31 .\" OF SUCH DAMAGE.
32 .\"
33 .\" Author: Archie Cobbs <archie@FreeBSD.org>
34 .\"
35 .\" $FreeBSD$
36 .\"
37 .Dd June 8, 2004
38 .Dt NG_KSOCKET 4
39 .Os
40 .Sh NAME
41 .Nm ng_ksocket
42 .Nd kernel socket netgraph node type
43 .Sh SYNOPSIS
44 .In sys/types.h
45 .In netgraph/ng_ksocket.h
46 .Sh DESCRIPTION
47 A
48 .Nm ksocket
49 node is both a netgraph node and a
50 .Bx
51 socket.
52 The
53 .Nm
54 node type allows one to open a socket inside the kernel and have
55 it appear as a Netgraph node.
56 The
57 .Nm
58 node type is the reverse of the socket node type (see
59 .Xr ng_socket 4 ) :
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
62 Netgraph node), the
63 .Nm
64 node type enables the kernel-level manipulation (via a Netgraph node) of
65 what is normally a user-level entity (the associated socket).
66 .Pp
67 A
68 .Nm
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.
76 .Sh HOOKS
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> ,
80 where the
81 .Em family ,
82 .Em type ,
83 and
84 .Em proto
85 are the decimal equivalent of the same arguments to
86 .Xr socket 2 .
87 Alternately, aliases for the commonly used values are accepted as
88 well.
89 For example
90 .Dv inet/dgram/udp
91 is a more readable but equivalent version of
92 .Dv 2/2/17 .
93 .Pp
94 Data received into socket is sent out via hook.
95 Data received on hook is sent out from socket, if the latter is
96 connected (an
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
103 and type
104 .Dv NG_KSOCKET_TAG_SOCKADDR
105 attached to data.
106 Otherwise
107 .Nm
108 will return
109 .Er ENOTCONN
110 to sender.
111 .Sh CONTROL MESSAGES
112 This node type supports the generic control messages, plus the following:
113 .Bl -tag -width foo
114 .It Dv NGM_KSOCKET_BIND
115 This functions exactly like the
116 .Xr bind 2
117 system call.
118 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
123 .Xr listen 2
124 system call.
125 The backlog parameter (a single 32 bit
126 .Dv int )
127 should be supplied as an argument.
128 .It Dv NGM_KSOCKET_CONNECT
129 This functions exactly like the
130 .Xr connect 2
131 system call.
132 The
133 .Vt "struct sockaddr"
134 destination address parameter should be supplied as an argument.
135 .It Dv NGM_KSOCKET_ACCEPT
136 Currently unimplemented.
137 .It Dv NGM_KSOCKET_GETNAME
138 Equivalent to the
139 .Xr getsockname 2
140 system call.
141 The name is returned as a
142 .Vt "struct sockaddr"
143 in the arguments field of the reply.
144 .It Dv NGM_KSOCKET_GETPEERNAME
145 Equivalent to the
146 .Xr getpeername 2
147 system call.
148 The name is returned as a
149 .Vt "struct sockaddr"
150 in the arguments field of the reply.
151 .It Dv NGM_KSOCKET_SETOPT
152 Equivalent to the
153 .Xr setsockopt 2
154 system call, except that the option name, level, and value are passed in a
155 .Vt "struct ng_ksocket_sockopt" .
156 .It Dv NGM_KSOCKET_GETOPT
157 Equivalent to the
158 .Xr getsockopt 2
159 system call, except that the option is passed in a
160 .Vt "struct ng_ksocket_sockopt" .
161 When sending this command, the
162 .Dv value
163 field should be empty; upon return, it will contain the
164 retrieved value.
165 .El
166 .Sh ASCII FORM CONTROL MESSAGES
167 For control messages that pass a
168 .Vt "struct sockaddr"
169 in the argument field, the normal
170 .Tn ASCII
171 equivalent of the C structure
172 is an acceptable form.
173 For the
174 .Dv PF_INET
175 and
176 .Dv PF_LOCAL
177 address families, a more convenient form is also used, which is
178 the protocol family name, followed by a slash, followed by the actual
179 address.
180 For
181 .Dv PF_INET ,
182 the address is an IP address followed by an optional colon and port number.
183 For
184 .Dv PF_LOCAL ,
185 the address is the pathname as a doubly quoted string.
186 .Pp
187 Examples:
188 .Bl -tag -width XXXXXXXXXX
189 .It Dv PF_LOCAL
190 local/"/tmp/foo.socket"
191 .It Dv PF_INET
192 inet/192.168.1.1:1234
193 .It Other
194 .Dv "\&{ family=16 len=16 data=[0x70 0x00 0x01 0x23] \&}"
195 .El
196 .Pp
197 For control messages that pass a
198 .Vt "struct ng_ksocket_sockopt" ,
199 the normal
200 .Tn ASCII
201 form for that structure is used.
202 In the future, more
203 convenient encoding of the more common socket options may be supported.
204 .Sh SHUTDOWN
205 This node shuts down upon receipt of a
206 .Dv NGM_SHUTDOWN
207 control message, or when the hook is disconnected.
208 Shutdown of the node closes the associated socket.
209 .Sh SEE ALSO
210 .Xr socket 2 ,
211 .Xr netgraph 4 ,
212 .Xr ng_socket 4 ,
213 .Xr ngctl 8 ,
214 .Xr mbuf_tags 9
215 .Sh HISTORY
216 The
217 .Nm
218 node type was implemented in
219 .Fx 4.0 .
220 .Sh AUTHORS
221 .An Archie Cobbs Aq archie@FreeBSD.org