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