1999-11-16 23:27:10 +00:00
|
|
|
.\" Copyright (c) 1999 Whistle Communications, Inc.
|
|
|
|
.\" All rights reserved.
|
2001-07-14 19:41:16 +00:00
|
|
|
.\"
|
1999-11-16 23:27:10 +00:00
|
|
|
.\" Subject to the following obligations and disclaimer of warranty, use and
|
|
|
|
.\" redistribution of this software, in source or object code forms, with or
|
|
|
|
.\" without modifications are expressly permitted by Whistle Communications;
|
|
|
|
.\" provided, however, that:
|
|
|
|
.\" 1. Any and all reproductions of the source or object code must include the
|
|
|
|
.\" copyright notice above and the following disclaimer of warranties; and
|
|
|
|
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
|
|
|
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
|
|
|
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
|
|
|
.\" such appears in the above copyright notice or in the software.
|
2001-07-14 19:41:16 +00:00
|
|
|
.\"
|
1999-11-16 23:27:10 +00:00
|
|
|
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
|
|
|
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
|
|
|
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
|
|
|
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
|
|
|
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
|
|
|
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
|
|
|
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
|
|
|
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
|
|
|
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
|
|
|
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
|
|
|
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
|
|
|
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
|
|
|
|
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
.\" THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
|
|
|
.\" OF SUCH DAMAGE.
|
2001-07-14 19:41:16 +00:00
|
|
|
.\"
|
2000-10-26 15:30:44 +00:00
|
|
|
.\" Author: Archie Cobbs <archie@FreeBSD.org>
|
1999-11-16 23:27:10 +00:00
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
2004-06-25 19:22:05 +00:00
|
|
|
.Dd June 8, 2004
|
2000-05-04 17:54:37 +00:00
|
|
|
.Dt NG_KSOCKET 4
|
2001-07-10 15:31:11 +00:00
|
|
|
.Os
|
1999-11-16 23:27:10 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm ng_ksocket
|
|
|
|
.Nd kernel socket netgraph node type
|
|
|
|
.Sh SYNOPSIS
|
2001-10-01 16:09:29 +00:00
|
|
|
.In netgraph/ng_ksocket.h
|
1999-11-16 23:27:10 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
A
|
|
|
|
.Nm ksocket
|
2001-08-14 10:01:54 +00:00
|
|
|
node is both a netgraph node and a
|
|
|
|
.Bx
|
2003-06-28 23:53:39 +00:00
|
|
|
socket.
|
|
|
|
The
|
1999-12-21 01:25:21 +00:00
|
|
|
.Nm
|
1999-11-16 23:27:10 +00:00
|
|
|
node type allows one to open a socket inside the kernel and have
|
2003-06-28 23:53:39 +00:00
|
|
|
it appear as a Netgraph node.
|
|
|
|
The
|
1999-12-21 01:25:21 +00:00
|
|
|
.Nm
|
1999-11-16 23:27:10 +00:00
|
|
|
node type is the reverse of the socket node type (see
|
2000-05-04 17:54:37 +00:00
|
|
|
.Xr ng_socket 4 ) :
|
1999-11-16 23:27:10 +00:00
|
|
|
whereas the socket node type enables the user-level manipulation (via
|
1999-11-30 07:24:05 +00:00
|
|
|
a socket) of what is normally a kernel-level entity (the associated
|
|
|
|
Netgraph node), the
|
1999-12-21 01:25:21 +00:00
|
|
|
.Nm
|
1999-11-16 23:27:10 +00:00
|
|
|
node type enables the kernel-level manipulation (via a Netgraph node) of
|
1999-11-30 07:24:05 +00:00
|
|
|
what is normally a user-level entity (the associated socket).
|
1999-11-16 23:27:10 +00:00
|
|
|
.Pp
|
|
|
|
A
|
1999-12-21 01:25:21 +00:00
|
|
|
.Nm
|
2003-06-28 23:53:39 +00:00
|
|
|
node allows at most one hook connection.
|
|
|
|
Connecting to the node is
|
|
|
|
equivalent to opening the associated socket.
|
|
|
|
The name given to the hook
|
1999-11-30 07:24:05 +00:00
|
|
|
determines what kind of socket the node will open (see below).
|
1999-11-16 23:27:10 +00:00
|
|
|
When the hook is disconnected and/or the node is shutdown, the
|
|
|
|
associated socket is closed.
|
|
|
|
.Sh HOOKS
|
|
|
|
This node type supports a single hook connection at a time.
|
|
|
|
The name of the hook must be of the form
|
2001-02-28 17:38:53 +00:00
|
|
|
.Em <family>/<type>/<proto> ,
|
1999-11-16 23:27:10 +00:00
|
|
|
where the
|
2001-02-28 17:38:53 +00:00
|
|
|
.Em family ,
|
|
|
|
.Em type ,
|
1999-11-16 23:27:10 +00:00
|
|
|
and
|
2001-02-28 17:38:53 +00:00
|
|
|
.Em proto
|
1999-11-16 23:27:10 +00:00
|
|
|
are the decimal equivalent of the same arguments to
|
|
|
|
.Xr socket 2 .
|
|
|
|
Alternately, aliases for the commonly used values are accepted as
|
2004-07-03 18:29:24 +00:00
|
|
|
well.
|
|
|
|
For example
|
1999-11-16 23:27:10 +00:00
|
|
|
.Dv inet/dgram/udp
|
2001-07-14 19:41:16 +00:00
|
|
|
is a more readable but equivalent version of
|
1999-11-16 23:27:10 +00:00
|
|
|
.Dv 2/2/17 .
|
2004-06-25 19:22:05 +00:00
|
|
|
.Pp
|
|
|
|
Data received into socket is sent out via hook.
|
|
|
|
Data received on hook is sent out from socket, if the latter is
|
|
|
|
connected (an
|
|
|
|
.Dv NGM_KSOCKET_CONNECT
|
|
|
|
was sent to node before).
|
|
|
|
If socket is not connected, destination
|
2004-07-03 18:29:24 +00:00
|
|
|
.Vt "struct sockaddr"
|
2004-06-25 19:22:05 +00:00
|
|
|
must be supplied in an mbuf tag with cookie
|
|
|
|
.Dv NGM_KSOCKET_COOKIE
|
|
|
|
and type
|
|
|
|
.Dv NG_KSOCKET_TAG_SOCKADDR
|
|
|
|
attached to data.
|
|
|
|
Otherwise
|
|
|
|
.Nm
|
|
|
|
will return
|
2004-07-03 18:29:24 +00:00
|
|
|
.Er ENOTCONN
|
2004-06-25 19:22:05 +00:00
|
|
|
to sender.
|
1999-11-16 23:27:10 +00:00
|
|
|
.Sh CONTROL MESSAGES
|
|
|
|
This node type supports the generic control messages, plus the following:
|
|
|
|
.Bl -tag -width foo
|
|
|
|
.It Dv NGM_KSOCKET_BIND
|
|
|
|
This functions exactly like the
|
|
|
|
.Xr bind 2
|
2003-06-28 23:53:39 +00:00
|
|
|
system call.
|
|
|
|
The
|
2004-07-03 18:29:24 +00:00
|
|
|
.Vt "struct sockaddr"
|
1999-11-16 23:27:10 +00:00
|
|
|
socket address parameter should be supplied as an argument.
|
|
|
|
.It Dv NGM_KSOCKET_LISTEN
|
|
|
|
This functions exactly like the
|
|
|
|
.Xr listen 2
|
2003-06-28 23:53:39 +00:00
|
|
|
system call.
|
|
|
|
The backlog parameter (a single 32 bit
|
1999-11-16 23:27:10 +00:00
|
|
|
.Dv int )
|
|
|
|
should be supplied as an argument.
|
|
|
|
.It Dv NGM_KSOCKET_CONNECT
|
|
|
|
This functions exactly like the
|
|
|
|
.Xr connect 2
|
2003-06-28 23:53:39 +00:00
|
|
|
system call.
|
|
|
|
The
|
2004-07-03 18:29:24 +00:00
|
|
|
.Vt "struct sockaddr"
|
1999-11-30 07:24:05 +00:00
|
|
|
destination address parameter should be supplied as an argument.
|
1999-11-16 23:27:10 +00:00
|
|
|
.It Dv NGM_KSOCKET_ACCEPT
|
|
|
|
Currently unimplemented.
|
|
|
|
.It Dv NGM_KSOCKET_GETNAME
|
1999-11-30 07:24:05 +00:00
|
|
|
Equivalent to the
|
2001-06-10 12:06:54 +00:00
|
|
|
.Xr getsockname 2
|
2003-06-28 23:53:39 +00:00
|
|
|
system call.
|
|
|
|
The name is returned as a
|
2004-07-03 18:29:24 +00:00
|
|
|
.Vt "struct sockaddr"
|
1999-11-30 07:24:05 +00:00
|
|
|
in the arguments field of the reply.
|
1999-11-16 23:27:10 +00:00
|
|
|
.It Dv NGM_KSOCKET_GETPEERNAME
|
1999-11-30 07:24:05 +00:00
|
|
|
Equivalent to the
|
|
|
|
.Xr getpeername 2
|
2003-06-28 23:53:39 +00:00
|
|
|
system call.
|
|
|
|
The name is returned as a
|
2004-07-03 18:29:24 +00:00
|
|
|
.Vt "struct sockaddr"
|
1999-11-30 07:24:05 +00:00
|
|
|
in the arguments field of the reply.
|
1999-11-16 23:27:10 +00:00
|
|
|
.It Dv NGM_KSOCKET_SETOPT
|
1999-11-30 07:24:05 +00:00
|
|
|
Equivalent to the
|
|
|
|
.Xr setsockopt 2
|
|
|
|
system call, except that the option name, level, and value are passed in a
|
2004-07-03 18:29:24 +00:00
|
|
|
.Vt "struct ng_ksocket_sockopt" .
|
1999-11-16 23:27:10 +00:00
|
|
|
.It Dv NGM_KSOCKET_GETOPT
|
1999-11-30 07:24:05 +00:00
|
|
|
Equivalent to the
|
|
|
|
.Xr getsockopt 2
|
|
|
|
system call, except that the option is passed in a
|
2004-07-03 18:29:24 +00:00
|
|
|
.Vt "struct ng_ksocket_sockopt" .
|
1999-11-30 07:24:05 +00:00
|
|
|
When sending this command, the
|
|
|
|
.Dv value
|
|
|
|
field should be empty; upon return, it will contain the
|
|
|
|
retrieved value.
|
|
|
|
.El
|
|
|
|
.Sh ASCII FORM CONTROL MESSAGES
|
|
|
|
For control messages that pass a
|
2004-07-03 18:29:24 +00:00
|
|
|
.Vt "struct sockaddr"
|
1999-12-21 01:25:21 +00:00
|
|
|
in the argument field, the normal
|
|
|
|
.Tn ASCII
|
|
|
|
equivalent of the C structure
|
2003-06-28 23:53:39 +00:00
|
|
|
is an acceptable form.
|
|
|
|
For the
|
1999-11-30 07:24:05 +00:00
|
|
|
.Dv PF_INET
|
|
|
|
and
|
|
|
|
.Dv PF_LOCAL
|
|
|
|
address families, a more convenient form is also used, which is
|
|
|
|
the protocol family name, followed by a slash, followed by the actual
|
2003-06-28 23:53:39 +00:00
|
|
|
address.
|
|
|
|
For
|
1999-11-30 07:24:05 +00:00
|
|
|
.Dv PF_INET ,
|
|
|
|
the address is an IP address followed by an optional colon and port number.
|
|
|
|
For
|
|
|
|
.Dv PF_LOCAL ,
|
|
|
|
the address is the pathname as a doubly quoted string.
|
|
|
|
.Pp
|
|
|
|
Examples:
|
|
|
|
.Bl -tag -width XXXXXXXXXX
|
|
|
|
.It Dv PF_LOCAL
|
|
|
|
local/"/tmp/foo.socket"
|
2000-03-13 18:29:58 +00:00
|
|
|
.It Dv PF_INET
|
|
|
|
inet/192.168.1.1:1234
|
1999-11-30 07:24:05 +00:00
|
|
|
.It Other
|
2000-03-13 18:29:58 +00:00
|
|
|
.Dv "\&{ family=16 len=16 data=[0x70 0x00 0x01 0x23] \&}"
|
1999-11-16 23:27:10 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
1999-11-30 07:24:05 +00:00
|
|
|
For control messages that pass a
|
2004-07-03 18:29:24 +00:00
|
|
|
.Vt "struct ng_ksocket_sockopt" ,
|
1999-12-21 01:25:21 +00:00
|
|
|
the normal
|
|
|
|
.Tn ASCII
|
2003-06-28 23:53:39 +00:00
|
|
|
form for that structure is used.
|
|
|
|
In the future, more
|
1999-11-30 07:24:05 +00:00
|
|
|
convenient encoding of the more common socket options may be supported.
|
1999-11-16 23:27:10 +00:00
|
|
|
.Sh SHUTDOWN
|
|
|
|
This node shuts down upon receipt of a
|
|
|
|
.Dv NGM_SHUTDOWN
|
|
|
|
control message, or when the hook is disconnected.
|
|
|
|
Shutdown of the node closes the associated socket.
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr socket 2 ,
|
|
|
|
.Xr netgraph 4 ,
|
2000-05-04 17:54:37 +00:00
|
|
|
.Xr ng_socket 4 ,
|
2004-06-25 19:22:05 +00:00
|
|
|
.Xr ngctl 8 ,
|
|
|
|
.Xr mbuf_tags 9
|
1999-12-21 01:25:21 +00:00
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
node type was implemented in
|
|
|
|
.Fx 4.0 .
|
|
|
|
.Sh AUTHORS
|
2000-10-26 15:30:44 +00:00
|
|
|
.An Archie Cobbs Aq archie@FreeBSD.org
|