xref: /freebsd/lib/libc/rpc/rpc_svc_calls.3 (revision dc36d6f9)
18360efbdSAlfred Perlstein.\" Copyright 1989 AT&T
28360efbdSAlfred Perlstein.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
38360efbdSAlfred Perlstein.\"	$NetBSD: rpc_svc_calls.3,v 1.1 2000/06/02 23:11:13 fvdl Exp $
48360efbdSAlfred Perlstein.Dd May 3, 1993
58360efbdSAlfred Perlstein.Dt RPC_SVC_CALLS 3
68360efbdSAlfred Perlstein.Os
78360efbdSAlfred Perlstein.Sh NAME
88360efbdSAlfred Perlstein.Nm svc_dg_enablecache ,
98360efbdSAlfred Perlstein.Nm svc_exit ,
108360efbdSAlfred Perlstein.Nm svc_fdset ,
118360efbdSAlfred Perlstein.Nm svc_freeargs ,
128360efbdSAlfred Perlstein.Nm svc_getargs ,
138360efbdSAlfred Perlstein.Nm svc_getreq_common ,
148360efbdSAlfred Perlstein.Nm svc_getreq_poll ,
158360efbdSAlfred Perlstein.Nm svc_getreqset ,
168360efbdSAlfred Perlstein.Nm svc_getrpccaller ,
178360efbdSAlfred Perlstein.Nm svc_pollset ,
188360efbdSAlfred Perlstein.Nm svc_run ,
198360efbdSAlfred Perlstein.Nm svc_sendreply
208360efbdSAlfred Perlstein.Nd library routines for RPC servers
218360efbdSAlfred Perlstein.Sh LIBRARY
228360efbdSAlfred Perlstein.Lb libc
238360efbdSAlfred Perlstein.Sh SYNOPSIS
2432eef9aeSRuslan Ermilov.In rpc/rpc.h
258360efbdSAlfred Perlstein.Ft int
268360efbdSAlfred Perlstein.Fn svc_dg_enablecache "SVCXPRT *xprt" "const unsigned cache_size"
278360efbdSAlfred Perlstein.Ft void
288360efbdSAlfred Perlstein.Fn svc_exit "void"
298360efbdSAlfred Perlstein.Ft bool_t
308360efbdSAlfred Perlstein.Fn svc_freeargs "const SVCXPRT *xprt" "const xdrproc_t inproc" "caddr_t in"
318360efbdSAlfred Perlstein.Ft bool_t
328360efbdSAlfred Perlstein.Fn svc_getargs "const SVCXPRT *xprt" "const xdrproc_t inproc" "caddr_t in"
338360efbdSAlfred Perlstein.Ft void
348360efbdSAlfred Perlstein.Fn svc_getreq_common "const int fd"
358360efbdSAlfred Perlstein.Ft void
368360efbdSAlfred Perlstein.Fn svc_getreq_poll "struct pollfd *pfdp" "const int pollretval"
378360efbdSAlfred Perlstein.Ft void
388360efbdSAlfred Perlstein.Fn svc_getreqset "fd_set * rdfds"
398360efbdSAlfred Perlstein.Ft "struct netbuf *"
408360efbdSAlfred Perlstein.Fn svc_getrpccaller "const SVCXPRT *xprt"
418360efbdSAlfred Perlstein.Ft "struct cmsgcred *"
428360efbdSAlfred Perlstein.Fn __svc_getcallercreds "const SVCXPRT *xprt"
438360efbdSAlfred Perlstein.Vt struct pollfd svc_pollset[FD_SETSIZE];
448360efbdSAlfred Perlstein.Ft void
458360efbdSAlfred Perlstein.Fn svc_run "void"
468360efbdSAlfred Perlstein.Ft bool_t
4779be508cSRuslan Ermilov.Fn svc_sendreply "SVCXPRT *xprt" "xdrproc_t outproc" "void *out"
488360efbdSAlfred Perlstein.Sh DESCRIPTION
498360efbdSAlfred PerlsteinThese routines are part of the
508360efbdSAlfred PerlsteinRPC
518360efbdSAlfred Perlsteinlibrary which allows C language programs to make procedure
528360efbdSAlfred Perlsteincalls on other machines across the network.
538360efbdSAlfred Perlstein.Pp
548360efbdSAlfred PerlsteinThese routines are associated with the server side of the
558360efbdSAlfred PerlsteinRPC mechanism.
568360efbdSAlfred PerlsteinSome of them are called by the server side dispatch function,
578360efbdSAlfred Perlsteinwhile others
588360efbdSAlfred Perlstein(such as
598360efbdSAlfred Perlstein.Fn svc_run )
608360efbdSAlfred Perlsteinare called when the server is initiated.
618360efbdSAlfred Perlstein.\" .Pp
628360efbdSAlfred Perlstein.\" In the current implementation, the service transport handle,
638360efbdSAlfred Perlstein.\" .Dv SVCXPRT ,
648360efbdSAlfred Perlstein.\" contains a single data area for decoding arguments and encoding results.
658360efbdSAlfred Perlstein.\" Therefore, this structure cannot be freely shared between threads that call
668360efbdSAlfred Perlstein.\" functions that do this.
678360efbdSAlfred Perlstein.\" Routines on this page that are affected by this
688360efbdSAlfred Perlstein.\" restriction are marked as unsafe for MT applications.
698360efbdSAlfred Perlstein.Sh Routines
708360efbdSAlfred PerlsteinSee
718360efbdSAlfred Perlstein.Xr rpc 3
728360efbdSAlfred Perlsteinfor the definition of the
738360efbdSAlfred Perlstein.Vt SVCXPRT
748360efbdSAlfred Perlsteindata structure.
758360efbdSAlfred Perlstein.Bl -tag -width __svc_getcallercreds()
768360efbdSAlfred Perlstein.It Fn svc_dg_enablecache
778360efbdSAlfred PerlsteinThis function allocates a duplicate request cache for the
788360efbdSAlfred Perlsteinservice endpoint
798360efbdSAlfred Perlstein.Fa xprt ,
808360efbdSAlfred Perlsteinlarge enough to hold
818360efbdSAlfred Perlstein.Fa cache_size
828360efbdSAlfred Perlsteinentries.
838360efbdSAlfred PerlsteinOnce enabled, there is no way to disable caching.
848360efbdSAlfred PerlsteinThis routine returns 0 if space necessary for a cache of the given size
858360efbdSAlfred Perlsteinwas successfully allocated, and 1 otherwise.
868360efbdSAlfred Perlstein.It Fn svc_exit
878360efbdSAlfred PerlsteinThis function, when called by any of the RPC server procedure or
888360efbdSAlfred Perlsteinotherwise, causes
898360efbdSAlfred Perlstein.Fn svc_run
908360efbdSAlfred Perlsteinto return.
918360efbdSAlfred Perlstein.Pp
928360efbdSAlfred PerlsteinAs currently implemented,
938360efbdSAlfred Perlstein.Fn svc_exit
948360efbdSAlfred Perlsteinzeroes the
958360efbdSAlfred Perlstein.Va svc_fdset
968360efbdSAlfred Perlsteinglobal variable.
978360efbdSAlfred PerlsteinIf RPC server activity is to be resumed,
988360efbdSAlfred Perlsteinservices must be reregistered with the RPC library
998360efbdSAlfred Perlsteineither through one of the
10011d84435SRuslan Ermilov.Xr rpc_svc_create 3
1018360efbdSAlfred Perlsteinfunctions, or using
1028360efbdSAlfred Perlstein.Fn xprt_register .
1031fae73b1SRuslan ErmilovThe
1048360efbdSAlfred Perlstein.Fn svc_exit
1051fae73b1SRuslan Ermilovfunction
1068360efbdSAlfred Perlsteinhas global scope and ends all RPC server activity.
1078360efbdSAlfred Perlstein.It Xo
1088360efbdSAlfred Perlstein.Vt fd_set Va svc_fdset
1098360efbdSAlfred Perlstein.Xc
1108360efbdSAlfred PerlsteinA global variable reflecting the
1119d5abbddSJens SchweikhardtRPC server's read file descriptor bit mask; it is suitable as an argument
1128360efbdSAlfred Perlsteinto the
1138360efbdSAlfred Perlstein.Xr select 2
1148360efbdSAlfred Perlsteinsystem call.
1158360efbdSAlfred PerlsteinThis is only of interest
1168360efbdSAlfred Perlsteinif service implementors do not call
1178360efbdSAlfred Perlstein.Fn svc_run ,
1188360efbdSAlfred Perlsteinbut rather do their own asynchronous event processing.
1198360efbdSAlfred PerlsteinThis variable is read-only (do not pass its address to
1208360efbdSAlfred Perlstein.Xr select 2 ! ) ,
1218360efbdSAlfred Perlsteinyet it may change after calls to
1228360efbdSAlfred Perlstein.Fn svc_getreqset
1238360efbdSAlfred Perlsteinor any creation routines.
1248360efbdSAlfred Perlstein.It Fn svc_freeargs
1258360efbdSAlfred PerlsteinA function macro that frees any data allocated by the
1268360efbdSAlfred PerlsteinRPC/XDR system when it decoded the arguments to a service procedure
1278360efbdSAlfred Perlsteinusing
1288360efbdSAlfred Perlstein.Fn svc_getargs .
1298360efbdSAlfred PerlsteinThis routine returns
1308360efbdSAlfred Perlstein.Dv TRUE
1318360efbdSAlfred Perlsteinif the results were successfully
1328360efbdSAlfred Perlsteinfreed, and
1338360efbdSAlfred Perlstein.Dv FALSE
1348360efbdSAlfred Perlsteinotherwise.
1358360efbdSAlfred Perlstein.It Fn svc_getargs
1368360efbdSAlfred PerlsteinA function macro that decodes the arguments of an
1378360efbdSAlfred PerlsteinRPC request associated with the RPC
1388360efbdSAlfred Perlsteinservice transport handle
1398360efbdSAlfred Perlstein.Fa xprt .
1402efeeba5SRuslan ErmilovThe
1418360efbdSAlfred Perlstein.Fa in
1422efeeba5SRuslan Ermilovargument
1438360efbdSAlfred Perlsteinis the address where the arguments will be placed;
1448360efbdSAlfred Perlstein.Fa inproc
1458360efbdSAlfred Perlsteinis the XDR
1468360efbdSAlfred Perlsteinroutine used to decode the arguments.
1478360efbdSAlfred PerlsteinThis routine returns
1488360efbdSAlfred Perlstein.Dv TRUE
1498360efbdSAlfred Perlsteinif decoding succeeds, and
1508360efbdSAlfred Perlstein.Dv FALSE
1518360efbdSAlfred Perlsteinotherwise.
1528360efbdSAlfred Perlstein.It Fn svc_getreq_common
1538360efbdSAlfred PerlsteinThis routine is called to handle a request on the given
1548360efbdSAlfred Perlsteinfile descriptor.
1558360efbdSAlfred Perlstein.It Fn svc_getreq_poll
1568360efbdSAlfred PerlsteinThis routine is only of interest if a service implementor
1578360efbdSAlfred Perlsteindoes not call
1588360efbdSAlfred Perlstein.Fn svc_run ,
1598360efbdSAlfred Perlsteinbut instead implements custom asynchronous event processing.
1608360efbdSAlfred PerlsteinIt is called when
1618360efbdSAlfred Perlstein.Xr poll 2
1628360efbdSAlfred Perlsteinhas determined that an RPC request has arrived on some RPC
1638360efbdSAlfred Perlsteinfile descriptors;
1648360efbdSAlfred Perlstein.Fa pollretval
1658360efbdSAlfred Perlsteinis the return value from
1668360efbdSAlfred Perlstein.Xr poll 2
1678360efbdSAlfred Perlsteinand
1688360efbdSAlfred Perlstein.Fa pfdp
1698360efbdSAlfred Perlsteinis the array of
1708360efbdSAlfred Perlstein.Vt pollfd
1718360efbdSAlfred Perlsteinstructures on which the
1728360efbdSAlfred Perlstein.Xr poll 2
1738360efbdSAlfred Perlsteinwas done.
1748360efbdSAlfred PerlsteinIt is assumed to be an array large enough to
1758360efbdSAlfred Perlsteincontain the maximal number of descriptors allowed.
1768360efbdSAlfred Perlstein.It Fn svc_getreqset
1778360efbdSAlfred PerlsteinThis routine is only of interest if a service implementor
1788360efbdSAlfred Perlsteindoes not call
1798360efbdSAlfred Perlstein.Fn svc_run ,
1808360efbdSAlfred Perlsteinbut instead implements custom asynchronous event processing.
1818360efbdSAlfred PerlsteinIt is called when
1828360efbdSAlfred Perlstein.Xr poll 2
1838360efbdSAlfred Perlsteinhas determined that an RPC
1848360efbdSAlfred Perlsteinrequest has arrived on some RPC file descriptors;
1858360efbdSAlfred Perlstein.Fa rdfds
1868360efbdSAlfred Perlsteinis the resultant read file descriptor bit mask.
1878360efbdSAlfred PerlsteinThe routine returns when all file descriptors
1888360efbdSAlfred Perlsteinassociated with the value of
1898360efbdSAlfred Perlstein.Fa rdfds
1908360efbdSAlfred Perlsteinhave been serviced.
1918360efbdSAlfred Perlstein.It Fn svc_getrpccaller
1928360efbdSAlfred PerlsteinThe approved way of getting the network address of the caller
1938360efbdSAlfred Perlsteinof a procedure associated with the
1948360efbdSAlfred PerlsteinRPC service transport handle
1958360efbdSAlfred Perlstein.Fa xprt .
1968360efbdSAlfred Perlstein.It Fn __svc_getcallercreds
1978360efbdSAlfred Perlstein.Em Warning :
1988360efbdSAlfred Perlsteinthis macro is specific to
1998360efbdSAlfred Perlstein.Fx
2008360efbdSAlfred Perlsteinand thus not portable.
2018360efbdSAlfred PerlsteinThis macro returns a pointer to a
2028360efbdSAlfred Perlstein.Vt cmsgcred
2038360efbdSAlfred Perlsteinstructure, defined in
204fe08efe6SRuslan Ermilov.In sys/socket.h ,
2058360efbdSAlfred Perlsteinidentifying the calling client.
2068360efbdSAlfred PerlsteinThis only works if the client is
2078360efbdSAlfred Perlsteincalling the server over an
2088360efbdSAlfred Perlstein.Dv AF_LOCAL
2098360efbdSAlfred Perlsteinsocket.
2108360efbdSAlfred Perlstein.It Xo
2118360efbdSAlfred Perlstein.Vt struct pollfd Va svc_pollset[FD_SETSIZE] ;
2128360efbdSAlfred Perlstein.Xc
2138360efbdSAlfred Perlstein.Va svc_pollset
2148360efbdSAlfred Perlsteinis an array of
2158360efbdSAlfred Perlstein.Vt pollfd
2168360efbdSAlfred Perlsteinstructures derived from
2178360efbdSAlfred Perlstein.Va svc_fdset[] .
2182efeeba5SRuslan ErmilovIt is suitable as an argument to the
2198360efbdSAlfred Perlstein.Xr poll 2
2208360efbdSAlfred Perlsteinsystem call.
2218360efbdSAlfred PerlsteinThe derivation of
2228360efbdSAlfred Perlstein.Va svc_pollset
2238360efbdSAlfred Perlsteinfrom
2248360efbdSAlfred Perlstein.Va svc_fdset
2258360efbdSAlfred Perlsteinis made in the current implementation in
2268360efbdSAlfred Perlstein.Fn svc_run .
2278360efbdSAlfred PerlsteinService implementors who do not call
2288360efbdSAlfred Perlstein.Fn svc_run
2298360efbdSAlfred Perlsteinand who wish to use this array must perform this derivation themselves.
2308360efbdSAlfred Perlstein.It Fn svc_run
2318360efbdSAlfred PerlsteinThis routine never returns.
2328360efbdSAlfred PerlsteinIt waits for RPC
2338360efbdSAlfred Perlsteinrequests to arrive, and calls the appropriate service
2348360efbdSAlfred Perlsteinprocedure using
2358360efbdSAlfred Perlstein.Fn svc_getreq_poll
2368360efbdSAlfred Perlsteinwhen one arrives.
2378360efbdSAlfred PerlsteinThis procedure is usually waiting for the
2388360efbdSAlfred Perlstein.Xr poll 2
2398360efbdSAlfred Perlsteinsystem call to return.
2408360efbdSAlfred Perlstein.It Fn svc_sendreply
2418360efbdSAlfred PerlsteinCalled by an RPC service's dispatch routine to send the results of a
2428360efbdSAlfred Perlsteinremote procedure call.
2432efeeba5SRuslan ErmilovThe
2448360efbdSAlfred Perlstein.Fa xprt
2452efeeba5SRuslan Ermilovargument
2468360efbdSAlfred Perlsteinis the request's associated transport handle;
2478360efbdSAlfred Perlstein.Fa outproc
2488360efbdSAlfred Perlsteinis the XDR
2498360efbdSAlfred Perlsteinroutine which is used to encode the results; and
2508360efbdSAlfred Perlstein.Fa out
2518360efbdSAlfred Perlsteinis the address of the results.
2528360efbdSAlfred PerlsteinThis routine returns
2538360efbdSAlfred Perlstein.Dv TRUE
2548360efbdSAlfred Perlsteinif it succeeds,
2558360efbdSAlfred Perlstein.Dv FALSE
2568360efbdSAlfred Perlsteinotherwise.
2578360efbdSAlfred Perlstein.El
2588360efbdSAlfred Perlstein.Sh SEE ALSO
2598360efbdSAlfred Perlstein.Xr poll 2 ,
2608360efbdSAlfred Perlstein.Xr select 2 ,
2618360efbdSAlfred Perlstein.Xr rpc 3 ,
2628360efbdSAlfred Perlstein.Xr rpc_svc_create 3 ,
2638360efbdSAlfred Perlstein.Xr rpc_svc_err 3 ,
2648360efbdSAlfred Perlstein.Xr rpc_svc_reg 3
265