add mention of SO_ACCEPTFILTERS, language largely from FreeBSD manpage

This commit is contained in:
plunky 2009-06-29 06:22:13 +00:00
parent 8f62518cea
commit fc992f3309

View File

@ -1,4 +1,4 @@
.\" $NetBSD: getsockopt.2,v 1.32 2009/05/18 14:51:55 wiz Exp $ .\" $NetBSD: getsockopt.2,v 1.33 2009/06/29 06:22:13 plunky Exp $
.\" .\"
.\" Copyright (c) 1983, 1991, 1993 .\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@ -29,7 +29,7 @@
.\" .\"
.\" @(#)getsockopt.2 8.4 (Berkeley) 5/2/95 .\" @(#)getsockopt.2 8.4 (Berkeley) 5/2/95
.\" .\"
.Dd December 16, 2007 .Dd June 28, 2009
.Dt GETSOCKOPT 2 .Dt GETSOCKOPT 2
.Os .Os
.Sh NAME .Sh NAME
@ -149,7 +149,7 @@ Except as noted, each may be examined with
.Fn getsockopt .Fn getsockopt
and set with and set with
.Fn setsockopt . .Fn setsockopt .
.Bl -column SO_OOBINLINE data -offset indent .Bl -column SO_ACCEPTFILTER data -offset indent
.It Dv SO_DEBUG Ta "enables recording of debugging information" .It Dv SO_DEBUG Ta "enables recording of debugging information"
.It Dv SO_REUSEADDR Ta "enables local address reuse" .It Dv SO_REUSEADDR Ta "enables local address reuse"
.It Dv SO_REUSEPORT Ta "enables duplicate address and port bindings" .It Dv SO_REUSEPORT Ta "enables duplicate address and port bindings"
@ -165,6 +165,7 @@ and set with
.It Dv SO_SNDTIMEO Ta "set timeout value for output" .It Dv SO_SNDTIMEO Ta "set timeout value for output"
.It Dv SO_RCVTIMEO Ta "set timeout value for input" .It Dv SO_RCVTIMEO Ta "set timeout value for input"
.It Dv SO_TIMESTAMP Ta "enables reception of a timestamp with datagrams" .It Dv SO_TIMESTAMP Ta "enables reception of a timestamp with datagrams"
.It Dv SO_ACCEPTFILTER Ta "set accept filter on listening socket"
.It Dv SO_TYPE Ta "get the type of the socket (get only)" .It Dv SO_TYPE Ta "get the type of the socket (get only)"
.It Dv SO_ERROR Ta "get and clear error on the socket (get only)" .It Dv SO_ERROR Ta "get and clear error on the socket (get only)"
.El .El
@ -327,6 +328,45 @@ cmsg_level = SOL_SOCKET
cmsg_type = SCM_TIMESTAMP cmsg_type = SCM_TIMESTAMP
.Ed .Ed
.Pp .Pp
.Dv SO_ACCEPTFILTER
places an
.Xr accept_filter 9
on the socket, which will filter incoming connections on a listening
socket before being presented for
.Xr accept 2 .
The
.Fn setsockopt
system call will fail if the socket already has a filter set, and
.Xr listen 2
must be called on the socket before trying to install a filter.
The
.Fa optval
argument
should point to a
.Fa struct accept_filter_arg
that will select and configure the
.Xr accept_filter 9 ,
defined as follows:
.Bd -literal
struct accept_filter_arg {
char af_name[16];
char af_arg[256-16];
};
.Ed
.Lp
The
.Fa af_name
argument should be filled with the name of the accept filter
that the application wishes to place on the listening socket.
The optional argument
.Fa af_arg
can be passed to the accept filter specified by
.Fa af_name
to provide additional configuration options at attach time.
Passing in an
.Fa optval
of NULL will remove the filter.
.Pp
Finally, Finally,
.Dv SO_TYPE .Dv SO_TYPE
and and
@ -360,6 +400,11 @@ For
this error may also be returned if this error may also be returned if
.Fa optlen .Fa optlen
is not in a valid part of the process address space. is not in a valid part of the process address space.
.It Bq Er EINVAL
The socket
.Fa s
was not suitable for installing an
.Xr accept_filter 9 .
.It Bq Er ENOPROTOOPT .It Bq Er ENOPROTOOPT
The option is unknown at the level indicated. The option is unknown at the level indicated.
.It Bq Er ENOTSOCK .It Bq Er ENOTSOCK
@ -385,7 +430,8 @@ is a file, not a socket.
.Xr tcp 4 , .Xr tcp 4 ,
.Xr tp 4 , .Xr tp 4 ,
.Xr unix 4 , .Xr unix 4 ,
.Xr protocols 5 .Xr protocols 5 ,
.Xr accept_filter 9
.Sh HISTORY .Sh HISTORY
The The
.Fn getsockopt .Fn getsockopt