[BACK]Return to rpc_svc_create.3 CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libc / rpc

File: [cvs.NetBSD.org] / src / lib / libc / rpc / rpc_svc_create.3 (download)

Revision 1.11, Mon Mar 22 19:30:54 2010 UTC (14 years ago) by joerg
Branch: MAIN
CVS Tags: yamt-pagecache-tag8, yamt-pagecache-base9, yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, yamt-pagecache-base5, yamt-pagecache-base4, yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, yamt-pagecache, tls-maxphys-base, tls-maxphys, tls-earlyentropy-base, tls-earlyentropy, riastradh-xf86-video-intel-2-7-1-pre-2-21-15, riastradh-drm2-base3, riastradh-drm2-base2, riastradh-drm2-base1, riastradh-drm2-base, riastradh-drm2, prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, phil-wifi-base, phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, phil-wifi-20191119, phil-wifi-20190609, phil-wifi, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, pgoyette-compat-merge-20190127, pgoyette-compat-base, pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, pgoyette-compat, perseant-stdc-iso10646-base, perseant-stdc-iso10646, netbsd-9-base, netbsd-9-3-RELEASE, netbsd-9-2-RELEASE, netbsd-9-1-RELEASE, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1, netbsd-9, netbsd-8-base, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-base, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-1, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0, netbsd-7, netbsd-6-base, netbsd-6-1-RELEASE, netbsd-6-1-RC4, netbsd-6-1-RC3, netbsd-6-1-RC2, netbsd-6-1-RC1, netbsd-6-1-5-RELEASE, netbsd-6-1-4-RELEASE, netbsd-6-1-3-RELEASE, netbsd-6-1-2-RELEASE, netbsd-6-1-1-RELEASE, netbsd-6-1, netbsd-6-0-RELEASE, netbsd-6-0-RC2, netbsd-6-0-RC1, netbsd-6-0-6-RELEASE, netbsd-6-0-5-RELEASE, netbsd-6-0-4-RELEASE, netbsd-6-0-3-RELEASE, netbsd-6-0-2-RELEASE, netbsd-6-0-1-RELEASE, netbsd-6-0, netbsd-6, netbsd-10-base, netbsd-10-0-RC6, netbsd-10-0-RC5, netbsd-10-0-RC4, netbsd-10-0-RC3, netbsd-10-0-RC2, netbsd-10-0-RC1, netbsd-10, matt-nb8-mediatek-base, matt-nb8-mediatek, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus, matt-mips64-premerge-20101231, localcount-20160914, is-mlppp-base, is-mlppp, cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x, cherry-xenmp-base, cherry-xenmp, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan, bouyer-quota2-nbase, bouyer-quota2-base, bouyer-quota2, agc-symver-base, agc-symver, HEAD
Changes since 1.10: +2 -2 lines

Use .In for header files instead of .Ar Pa and variations.

.\" @(#)rpc_svc_create.3n 1.26 93/08/26 SMI; from SVr4
.\" Copyright 1989 AT&T
.\" @(#)rpc_svc_create 1.3 89/06/28 SMI;
.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
.\" $NetBSD: rpc_svc_create.3,v 1.11 2010/03/22 19:30:54 joerg Exp $
.Dd May 3, 1993
.Dt RPC_SVC_CREATE 3
.Os
.Sh NAME
.Nm rpc_svc_create ,
.Nm svc_control ,
.Nm svc_create ,
.Nm svc_destroy ,
.Nm svc_dg_create ,
.Nm svc_fd_create ,
.Nm svc_raw_create ,
.Nm svc_tli_create ,
.Nm svc_tp_create ,
.Nm svc_vc_create
.Nd library routines for the creation of server handles
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In rpc/rpc.h
.Ft bool_t
.Fn svc_control "SVCXPRT *svc" "const u_int req" "void *info"
.Ft int
.Fn svc_create "const void (*dispatch)(struct svc_req *, SVCXPRT *)" "const rpcprog_t prognum" "const rpcvers_t versnum" "const char *nettype"
.Ft SVCXPRT *"
.Fn svc_dg_create "const int fildes" "const u_int sendsz" "const u_int recvsz"
.Ft void
.Fn svc_destroy "SVCXPRT *xprt"
.Ft "SVCXPRT *"
.Fn svc_fd_create "const int fildes" "const u_int sendsz" "const u_int recvsz"
.Ft "SVCXPRT *"
.Fn svc_raw_create "void"
.Ft "SVCXPRT *"
.Fn svc_tli_create "const int fildes" "const struct netconfig *netconf" "const struct t_bind *bindaddr" "const u_int sendsz" "const u_int recvsz"
.Ft "SVCXPRT *"
.Fn svc_tp_create "const void (*dispatch)(const struct svc_reg *, const SVCXPRT  *)" "const rpcprog_t prognum" "const rpcvers_t versnum" "const struct netconfig *netconf"
.Ft "SVCXPRT *"
.Fn svc_vc_create "const int fildes" "const u_int sendsz" "const u_int recvsz"
.Sh DESCRIPTION
These routines are part of the RPC
library which allows C language programs to make procedure
calls on servers across the network.
These routines deal with the creation of service handles.
Once the handle is created, the server can be invoked by calling
.Fn svc_run .
.Sh ROUTINES
See
.Xr rpc 3
for the definition of the
.Dv SVCXPRT
data structure.
.Pp
.Bl -tag -width XXXXX
.It Fn svc_control
A function to change or retrieve various information
about a service object.
.Fa req
indicates the type of operation and
.Fa info
is a pointer to the information.
The supported values of
.Fa req ,
their argument types, and what they do are:
.Bl -tag -width SVCGET_XID
.It Dv SVCGET_VERSQUIET
If a request is received for a program number
served by this server but the version number
is outside the range registered with the server,
an
.Dv RPC_PROGVERSMISMATCH
error will normally
be returned.
.Fa info
should be a pointer to an integer.
Upon successful completion of the
.Dv SVCGET_VERSQUIET
request,
.Fa *info
contains an
integer which describes the server's current
behavior:  0 indicates normal server behavior
(that is, an
.Dv RPC_PROGVERSMISMATCH
error
will be returned); 1 indicates that the out of
range request will be silently ignored.
.Pp
.It Dv SVCSET_VERSQUIET
If a request is received for a program number
served by this server but the version number
is outside the range registered with the server,
an
.Dv RPC_PROGVERSMISMATCH
error will normally be returned.
It is sometimes desirable to change this behavior.
.Fa info
should be a
pointer to an integer which is either 0
(indicating normal server behavior - an
.Dv RPC_PROGVERSMISMATCH
error will be returned),
or 1 (indicating that the out of range request
should be silently ignored).
.El
.Pp
.It Fn svc_create
.Fn svc_create
creates server handles for all the transports
belonging to the class
.Fa nettype .
.Fa nettype
defines a class of transports which can be used
for a particular application.
The transports are tried in left to right order in
.Ev NETPATH
variable or in top to bottom order in the netconfig database.
If
.Fa nettype
is
.Dv NULL ,
it defaults to
.Dv netpath .
.Pp
.Fn svc_create
registers itself with the rpcbind
service (see
.Xr rpcbind 8 ) .
.Fa dispatch
is called when there is a remote procedure call for the given
.Fa prognum
and
.Fa versnum ;
this requires calling
.Fn svc_run
(see
.Fn svc_run
in
.Xr rpc_svc_reg 3 ) .
If
.Fn svc_create
succeeds, it returns the number of server
handles it created,
otherwise it returns 0 and an error message is logged.
.Pp
.It Fn svc_destroy
A function macro that destroys the RPC
service handle
.Fa xprt .
Destruction usually involves deallocation
of private data structures,
including
.Fa xprt
itself.
Use of
.Fa xprt
is undefined after calling this routine.
.Pp
.It Fn svc_dg_create
This routine creates a connectionless RPC
service handle, and returns a pointer to it.
This routine returns
.Dv NULL
if it fails, and an error message is logged.
.Fa sendsz
and
.Fa recvsz
are parameters used to specify the size of the buffers.
If they are 0, suitable defaults are chosen.
The file descriptor
.Fa fildes
should be open and bound.
The server is not registered with
.Xr rpcbind 8 .
.Em Warning :
since connectionless-based RPC
messages can only hold limited amount of encoded data,
this transport cannot be used for procedures
that take large arguments or return huge results.
.Pp
.It Fn svc_fd_create
This routine creates a service on top of an open and bound file descriptor,
and returns the handle to it.
Typically, this descriptor is a connected file descriptor for a
connection-oriented transport.
.Fa sendsz
and
.Fa recvsz
indicate sizes for the send and receive buffers.
If they are 0, reasonable defaults are chosen.
This routine returns
.Dv NULL
if it fails, and an error message is logged.
.Pp
.It Fn svc_raw_create
This routine creates an RPC
service handle and returns a pointer to it.
The transport is really a buffer within the process's
address space, so the corresponding RPC
client should live in the same address space;
(see
.Fn clnt_raw_create
in
.Xr rpc_clnt_create 3 ) .
This routine allows simulation of RPC and acquisition of
RPC overheads (such as round trip times),
without any kernel and networking interference.
This routine returns
.Dv NULL
if it fails, and an error message is logged.
.Em Note :
.Fn svc_run
should not be called when the raw interface is being used.
.Pp
.It Fn svc_tli_create
This routine creates an RPC
server handle, and returns a pointer to it.
.Fa fildes
is the file descriptor on which the service is listening.
If
.Fa fildes
is
.Dv RPC_ANYFD ,
it opens a file descriptor on the transport specified by
.Fa netconf .
If the file descriptor is unbound and
.Fa bindaddr
is non-null
.Fa fildes
is bound to the address specified by
.Fa bindaddr ,
otherwise
.Fa fildes
is bound to a default address chosen by the transport.
.Pp
Note: the
.Vt t_bind
structure comes from the TLI/XTI SysV interface, which
.Nx
does not use.
The structure is defined in
.In rpc/types.h
for compatibility as:
.Bd -literal
struct t_bind {
    struct netbuf addr;	/* network address, see rpc(3) */
    unsigned int  qlen;	/* queue length (for listen(2)) */
};
.Ed
.Pp
In the case where the default address is chosen,
the number of outstanding connect requests is set to 8
for connection-oriented transports.
The user may specify the size of the send and receive buffers
with the parameters
.Fa sendsz
and
.Fa recvsz ;
values of 0 choose suitable defaults.
This routine returns
.Dv NULL
if it fails,
and an error message is logged.
The server is not registered with the
.Xr rpcbind 8
service.
.Pp
.It Fn svc_tp_create
.Fn svc_tp_create
creates a server handle for the network
specified by
.Fa netconf ,
and registers itself with the rpcbind service.
.Fa dispatch
is called when there is a remote procedure call
for the given
.Fa prognum
and
.Fa versnum ;
this requires calling
.Fn svc_run .
.Fn svc_tp_create
returns the service handle if it succeeds,
otherwise a
.Dv NULL
is returned and an error message is logged.
.Pp
.It Fn svc_vc_create
This routine creates a connection-oriented RPC
service and returns a pointer to it.
This routine returns
.Dv NULL
if it fails, and an error message is logged.
The users may specify the size of the send and receive buffers
with the parameters
.Fa sendsz
and
.Fa recvsz ;
values of 0 choose suitable defaults.
The file descriptor
.Fa fildes
should be open and bound.
The server is not registered with the
.Xr rpcbind 8
service.
.El
.Sh SEE ALSO
.Xr rpc 3 ,
.Xr rpc_svc_calls 3 ,
.Xr rpc_svc_err 3 ,
.Xr rpc_svc_reg 3 ,
.Xr rpcbind 8