add man page for sockopt(9)
This commit is contained in:
parent
fd7356a917
commit
e922dcbb71
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: mi,v 1.1173 2008/08/05 14:42:03 pooka Exp $
|
||||
# $NetBSD: mi,v 1.1174 2008/08/06 15:08:08 plunky Exp $
|
||||
#
|
||||
# Note: don't delete entries from here - mark them as "obsolete" instead.
|
||||
#
|
||||
|
@ -8577,6 +8577,13 @@
|
|||
./usr/share/man/cat9/simple_unlock.0 comp-sys-catman .cat
|
||||
./usr/share/man/cat9/sleep.0 comp-obsolete obsolete
|
||||
./usr/share/man/cat9/snprintf.0 comp-sys-catman .cat
|
||||
./usr/share/man/cat9/sockopt.0 comp-sys-catman .cat
|
||||
./usr/share/man/cat9/sockopt_init.0 comp-sys-catman .cat
|
||||
./usr/share/man/cat9/sockopt_destroy.0 comp-sys-catman .cat
|
||||
./usr/share/man/cat9/sockopt_get.0 comp-sys-catman .cat
|
||||
./usr/share/man/cat9/sockopt_getint.0 comp-sys-catman .cat
|
||||
./usr/share/man/cat9/sockopt_set.0 comp-sys-catman .cat
|
||||
./usr/share/man/cat9/sockopt_setint.0 comp-sys-catman .cat
|
||||
./usr/share/man/cat9/softint.0 comp-sys-catman .cat
|
||||
./usr/share/man/cat9/softint_disestablish.0 comp-sys-catman .cat
|
||||
./usr/share/man/cat9/softint_establish.0 comp-sys-catman .cat
|
||||
|
@ -13938,6 +13945,13 @@
|
|||
./usr/share/man/man9/simple_unlock.9 comp-sys-man .man
|
||||
./usr/share/man/man9/sleep.9 comp-obsolete obsolete
|
||||
./usr/share/man/man9/snprintf.9 comp-sys-man .man
|
||||
./usr/share/man/man9/sockopt.9 comp-sys-man .man
|
||||
./usr/share/man/man9/sockopt_init.9 comp-sys-man .man
|
||||
./usr/share/man/man9/sockopt_destroy.9 comp-sys-man .man
|
||||
./usr/share/man/man9/sockopt_get.9 comp-sys-man .man
|
||||
./usr/share/man/man9/sockopt_getint.9 comp-sys-man .man
|
||||
./usr/share/man/man9/sockopt_set.9 comp-sys-man .man
|
||||
./usr/share/man/man9/sockopt_setint.9 comp-sys-man .man
|
||||
./usr/share/man/man9/softint.9 comp-sys-man .man
|
||||
./usr/share/man/man9/softint_disestablish.9 comp-sys-man .man
|
||||
./usr/share/man/man9/softint_establish.9 comp-sys-man .man
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.264 2008/05/06 11:32:46 yamt Exp $
|
||||
# $NetBSD: Makefile,v 1.265 2008/08/06 15:08:08 plunky Exp $
|
||||
|
||||
# Makefile for section 9 (kernel function and variable) manual pages.
|
||||
|
||||
|
@ -46,7 +46,8 @@ MAN= altq.9 arc4random.9 arp.9 audio.9 autoconf.9 \
|
|||
sched_4bsd.9 scsipi.9 \
|
||||
secmodel.9 secmodel_bsd44.9 secmodel_overlay.9 secmodel_securelevel.9 \
|
||||
setjmp.9 shutdownhook_establish.9 \
|
||||
signal.9 softintr.9 spl.9 splraiseipl.9 store.9 suspendsched.9 \
|
||||
signal.9 sockopt.9 softintr.9 spl.9 splraiseipl.9 \
|
||||
store.9 suspendsched.9 \
|
||||
sysctl.9 sysmon_envsys.9 tc.9 tcp_congctl.9 timecounter.9 time_second.9 \
|
||||
todr.9 uiomove.9 ucom.9 userret.9 \
|
||||
vattr.9 veriexec.9 vcons.9 vfs.9 vfs_hooks.9 vfsops.9 vfssubr.9 vme.9 \
|
||||
|
@ -536,6 +537,12 @@ MLINKS+=signal.9 siginit.9 \
|
|||
signal.9 sendsig.9 \
|
||||
signal.9 sigcode.9 \
|
||||
signal.9 sigtramp.9
|
||||
MLINKS+=sockopt.9 sockopt_init.9 \
|
||||
sockopt.9 sockopt_destroy.9 \
|
||||
sockopt.9 sockopt_get.9 \
|
||||
sockopt.9 sockopt_getint.9 \
|
||||
sockopt.9 sockopt_set.9 \
|
||||
sockopt.9 sockopt_setint.9 \
|
||||
MLINKS+=softintr.9 softintr_establish.9 softintr.9 softintr_disestablish.9 \
|
||||
softintr.9 softintr_schedule.9 softintr.9 softint.9 \
|
||||
softintr.9 softint_establish.9 softintr.9 softint_disestablish.9 \
|
||||
|
|
|
@ -0,0 +1,131 @@
|
|||
.\" $NetBSD: sockopt.9,v 1.1 2008/08/06 15:08:08 plunky Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2008 Iain Hibbert
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd August 6, 2008
|
||||
.Dt SOCKOPT 9
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm sockopt_init ,
|
||||
.Nm sockopt_destroy ,
|
||||
.Nm sockopt_get ,
|
||||
.Nm sockopt_getint
|
||||
.Nm sockopt_set ,
|
||||
.Nm sockopt_setint ,
|
||||
.Nd socket options handling
|
||||
.Sh SYNOPSIS
|
||||
.In sys/socketvar.h
|
||||
.Ft void
|
||||
.Fn sockopt_init "struct sockopt *sopt" "int level" "int name" "size_t size"
|
||||
.Ft void
|
||||
.Fn sockopt_destroy "struct sockopt *sopt"
|
||||
.Ft int
|
||||
.Fn sockopt_get "struct sockopt *sopt" "void *value" "size_t size"
|
||||
.Ft int
|
||||
.Fn sockopt_getint "struct sockopt *sopt" "int *value"
|
||||
.Ft int
|
||||
.Fn sockopt_set "struct sockopt *sopt" "const void *value" "size_t size"
|
||||
.Ft int
|
||||
.Fn sockopt_setint "struct sockopt *sopt" "int value"
|
||||
.Sh DESCRIPTION
|
||||
The sockopt structure is used to pass a socket option and associated
|
||||
value:
|
||||
.Bd -literal -offset indent
|
||||
struct sockopt {
|
||||
int sopt_level; /* option level */
|
||||
int sopt_name; /* option name */
|
||||
size_t sopt_size; /* data length */
|
||||
void * sopt_data; /* data pointer */
|
||||
uint8_t sopt_buf[sizeof(int)]; /* internal storage */
|
||||
};
|
||||
.Ed
|
||||
.Pp
|
||||
The internal storage is used for the common case of values up to integer
|
||||
size so that memory allocation is not required and sopt_data will point
|
||||
to this in that case.
|
||||
.Pp
|
||||
Note: a sockopt structure may only be used for a single level/name/size
|
||||
combination.
|
||||
If the structure is to be re-used, it must be destroyed and re-initialized
|
||||
with the new values.
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width xxxx
|
||||
.It Cd "options DIAGNOSTIC"
|
||||
Kernels compiled with the
|
||||
.Dv DIAGNOSTIC
|
||||
option will perform basic sanity checks on socket options operations.
|
||||
.El
|
||||
.Sh FUNCTIONS
|
||||
.Bl -tag -width xxxx
|
||||
.It Fn sockopt_init "sopt" "level" "name" "size"
|
||||
Initialise sockopt storage.
|
||||
If
|
||||
.Ar size
|
||||
is given,
|
||||
.Fn sockopt_init
|
||||
will arrange for sopt_data to point to a buffer of
|
||||
.Ar size
|
||||
bytes for the sockopt value.
|
||||
.It Fn sockopt_destroy "sopt"
|
||||
Destroy sockopt storage, releasing any allocated memory.
|
||||
.It Fn sockopt_get "sopt" "value" "size"
|
||||
Copy out sockopt value.
|
||||
Will return
|
||||
.Dv EINVAL
|
||||
if an incorrect data size is given.
|
||||
.It Fn sockopt_getint "sopt" "value"
|
||||
Common case of get sockopt integer value.
|
||||
Will return
|
||||
.Dv EINVAL
|
||||
if sockopt does not contain an integer sized value.
|
||||
.It Fn sockopt_set "sopt" "value" "size"
|
||||
Copy in sockopt value.
|
||||
The sockopt structure must contain a data field of
|
||||
.Ar size
|
||||
bytes or be previously unset, in which case a data buffer may be
|
||||
allocated using
|
||||
.Dv M_WAITOK .
|
||||
.It Fn sockopt_setint "sopt" "value"
|
||||
Common case of set sockopt integer value.
|
||||
The sockpt structure must contain an int sized data field or be previously
|
||||
unset, in which case the data pointer will be set to the internal storage.
|
||||
.El
|
||||
.Sh CODE REFERENCES
|
||||
This section describes places within the
|
||||
.Nx
|
||||
source tree where code implementing socket options can be found.
|
||||
All pathnames are relative to
|
||||
.Pa /usr/src .
|
||||
.Pp
|
||||
The function prototypes and sockopt structure are defined in the
|
||||
.Pa sys/sys/socketvar.h
|
||||
header file, and the socket options implementation is in
|
||||
.Pa sys/kern/uipc_socket.c .
|
||||
.Sh SEE ALSO
|
||||
.Xr errno 2 ,
|
||||
.Xr malloc 9
|
||||
.Sh HISTORY
|
||||
The socket options KPI was inspired by a similar KPI in FreeBSD and
|
||||
first appeared in
|
||||
.Nx 5.0 .
|
Loading…
Reference in New Issue