186d7f5d3SJohn Marino.\" @(#)rpc_svc_calls.3n 1.28 93/05/10 SMI; from SVr4 286d7f5d3SJohn Marino.\" Copyright 1989 AT&T 386d7f5d3SJohn Marino.\" @(#)rpc_svc_calls 1.5 89/07/25 SMI; 486d7f5d3SJohn Marino.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved. 586d7f5d3SJohn Marino.\" $NetBSD: rpc_svc_calls.3,v 1.1 2000/06/02 23:11:13 fvdl Exp $ 686d7f5d3SJohn Marino.\" $FreeBSD: src/lib/libc/rpc/rpc_svc_calls.3,v 1.10 2005/11/23 16:44:23 ru Exp $ 786d7f5d3SJohn Marino.Dd January 31, 2009 886d7f5d3SJohn Marino.Dt RPC_SVC_CALLS 3 986d7f5d3SJohn Marino.Os 1086d7f5d3SJohn Marino.Sh NAME 1186d7f5d3SJohn Marino.Nm svc_dg_enablecache , 1286d7f5d3SJohn Marino.Nm svc_exit , 1386d7f5d3SJohn Marino.Nm svc_fdset , 1486d7f5d3SJohn Marino.Nm svc_freeargs , 1586d7f5d3SJohn Marino.Nm svc_getargs , 1686d7f5d3SJohn Marino.Nm svc_getreq_common , 1786d7f5d3SJohn Marino.Nm svc_getreq_poll , 1886d7f5d3SJohn Marino.Nm svc_getreqset , 1986d7f5d3SJohn Marino.Nm svc_getrpccaller , 2086d7f5d3SJohn Marino.Nm svc_pollset , 2186d7f5d3SJohn Marino.Nm svc_run , 2286d7f5d3SJohn Marino.Nm svc_sendreply 2386d7f5d3SJohn Marino.Nd library routines for RPC servers 2486d7f5d3SJohn Marino.Sh LIBRARY 2586d7f5d3SJohn Marino.Lb libc 2686d7f5d3SJohn Marino.Sh SYNOPSIS 2786d7f5d3SJohn Marino.In rpc/rpc.h 2886d7f5d3SJohn Marino.Ft int 2986d7f5d3SJohn Marino.Fn svc_dg_enablecache "SVCXPRT *xprt" "const unsigned cache_size" 3086d7f5d3SJohn Marino.Ft void 3186d7f5d3SJohn Marino.Fn svc_exit "void" 3286d7f5d3SJohn Marino.Ft bool_t 3386d7f5d3SJohn Marino.Fn svc_freeargs "const SVCXPRT *xprt" "const xdrproc_t inproc" "caddr_t in" 3486d7f5d3SJohn Marino.Ft bool_t 3586d7f5d3SJohn Marino.Fn svc_getargs "const SVCXPRT *xprt" "const xdrproc_t inproc" "caddr_t in" 3686d7f5d3SJohn Marino.Ft void 3786d7f5d3SJohn Marino.Fn svc_getreq_common "const int fd" 3886d7f5d3SJohn Marino.Ft void 3986d7f5d3SJohn Marino.Fn svc_getreq_poll "struct pollfd *pfdp" "const int pollretval" 4086d7f5d3SJohn Marino.Ft void 4186d7f5d3SJohn Marino.Fn svc_getreqset "fd_set * rdfds" 4286d7f5d3SJohn Marino.Ft "struct netbuf *" 4386d7f5d3SJohn Marino.Fn svc_getrpccaller "const SVCXPRT *xprt" 4486d7f5d3SJohn Marino.Vt struct pollfd svc_pollset[FD_SETSIZE]; 4586d7f5d3SJohn Marino.Ft void 4686d7f5d3SJohn Marino.Fn svc_run "void" 4786d7f5d3SJohn Marino.Ft bool_t 4886d7f5d3SJohn Marino.Fn svc_sendreply "SVCXPRT *xprt" "xdrproc_t outproc" "void *out" 4986d7f5d3SJohn Marino.Sh DESCRIPTION 5086d7f5d3SJohn MarinoThese routines are part of the 5186d7f5d3SJohn MarinoRPC 5286d7f5d3SJohn Marinolibrary which allows C language programs to make procedure 5386d7f5d3SJohn Marinocalls on other machines across the network. 5486d7f5d3SJohn Marino.Pp 5586d7f5d3SJohn MarinoThese routines are associated with the server side of the 5686d7f5d3SJohn MarinoRPC mechanism. 5786d7f5d3SJohn MarinoSome of them are called by the server side dispatch function, 5886d7f5d3SJohn Marinowhile others 5986d7f5d3SJohn Marino(such as 6086d7f5d3SJohn Marino.Fn svc_run ) 6186d7f5d3SJohn Marinoare called when the server is initiated. 6286d7f5d3SJohn Marino.\" .Pp 6386d7f5d3SJohn Marino.\" In the current implementation, the service transport handle, 6486d7f5d3SJohn Marino.\" .Dv SVCXPRT , 6586d7f5d3SJohn Marino.\" contains a single data area for decoding arguments and encoding results. 6686d7f5d3SJohn Marino.\" Therefore, this structure cannot be freely shared between threads that call 6786d7f5d3SJohn Marino.\" functions that do this. 6886d7f5d3SJohn Marino.\" Routines on this page that are affected by this 6986d7f5d3SJohn Marino.\" restriction are marked as unsafe for MT applications. 7086d7f5d3SJohn Marino.Sh Routines 7186d7f5d3SJohn MarinoSee 7286d7f5d3SJohn Marino.Xr rpc 3 7386d7f5d3SJohn Marinofor the definition of the 7486d7f5d3SJohn Marino.Vt SVCXPRT 7586d7f5d3SJohn Marinodata structure. 7686d7f5d3SJohn Marino.Bl -tag -width ".Fn svc_dg_enablecache" 7786d7f5d3SJohn Marino.It Fn svc_dg_enablecache 7886d7f5d3SJohn MarinoThis function allocates a duplicate request cache for the 7986d7f5d3SJohn Marinoservice endpoint 8086d7f5d3SJohn Marino.Fa xprt , 8186d7f5d3SJohn Marinolarge enough to hold 8286d7f5d3SJohn Marino.Fa cache_size 8386d7f5d3SJohn Marinoentries. 8486d7f5d3SJohn MarinoOnce enabled, there is no way to disable caching. 8586d7f5d3SJohn MarinoThis routine returns 0 if space necessary for a cache of the given size 8686d7f5d3SJohn Marinowas successfully allocated, and 1 otherwise. 8786d7f5d3SJohn Marino.It Fn svc_exit 8886d7f5d3SJohn MarinoThis function, when called by any of the RPC server procedure or 8986d7f5d3SJohn Marinootherwise, causes 9086d7f5d3SJohn Marino.Fn svc_run 9186d7f5d3SJohn Marinoto return. 9286d7f5d3SJohn Marino.Pp 9386d7f5d3SJohn MarinoAs currently implemented, 9486d7f5d3SJohn Marino.Fn svc_exit 9586d7f5d3SJohn Marinozeroes the 9686d7f5d3SJohn Marino.Va svc_fdset 9786d7f5d3SJohn Marinoglobal variable. 9886d7f5d3SJohn MarinoIf RPC server activity is to be resumed, 9986d7f5d3SJohn Marinoservices must be reregistered with the RPC library 10086d7f5d3SJohn Marinoeither through one of the 10186d7f5d3SJohn Marino.Xr rpc_svc_create 3 10286d7f5d3SJohn Marinofunctions, or using 10386d7f5d3SJohn Marino.Fn xprt_register . 10486d7f5d3SJohn MarinoThe 10586d7f5d3SJohn Marino.Fn svc_exit 10686d7f5d3SJohn Marinofunction 10786d7f5d3SJohn Marinohas global scope and ends all RPC server activity. 10886d7f5d3SJohn Marino.It Xo 10986d7f5d3SJohn Marino.Vt fd_set Va svc_fdset 11086d7f5d3SJohn Marino.Xc 11186d7f5d3SJohn MarinoA global variable reflecting the 11286d7f5d3SJohn MarinoRPC server's read file descriptor bit mask; it is suitable as an argument 11386d7f5d3SJohn Marinoto the 11486d7f5d3SJohn Marino.Xr select 2 11586d7f5d3SJohn Marinosystem call. 11686d7f5d3SJohn MarinoThis is only of interest 11786d7f5d3SJohn Marinoif service implementors do not call 11886d7f5d3SJohn Marino.Fn svc_run , 11986d7f5d3SJohn Marinobut rather do their own asynchronous event processing. 12086d7f5d3SJohn MarinoThis variable is read-only (do not pass its address to 12186d7f5d3SJohn Marino.Xr select 2 ! ) , 12286d7f5d3SJohn Marinoyet it may change after calls to 12386d7f5d3SJohn Marino.Fn svc_getreqset 12486d7f5d3SJohn Marinoor any creation routines. 12586d7f5d3SJohn Marino.It Fn svc_freeargs 12686d7f5d3SJohn MarinoA function macro that frees any data allocated by the 12786d7f5d3SJohn MarinoRPC/XDR system when it decoded the arguments to a service procedure 12886d7f5d3SJohn Marinousing 12986d7f5d3SJohn Marino.Fn svc_getargs . 13086d7f5d3SJohn MarinoThis routine returns 13186d7f5d3SJohn Marino.Dv TRUE 13286d7f5d3SJohn Marinoif the results were successfully 13386d7f5d3SJohn Marinofreed, and 13486d7f5d3SJohn Marino.Dv FALSE 13586d7f5d3SJohn Marinootherwise. 13686d7f5d3SJohn Marino.It Fn svc_getargs 13786d7f5d3SJohn MarinoA function macro that decodes the arguments of an 13886d7f5d3SJohn MarinoRPC request associated with the RPC 13986d7f5d3SJohn Marinoservice transport handle 14086d7f5d3SJohn Marino.Fa xprt . 14186d7f5d3SJohn MarinoThe 14286d7f5d3SJohn Marino.Fa in 14386d7f5d3SJohn Marinoargument 14486d7f5d3SJohn Marinois the address where the arguments will be placed; 14586d7f5d3SJohn Marino.Fa inproc 14686d7f5d3SJohn Marinois the XDR 14786d7f5d3SJohn Marinoroutine used to decode the arguments. 14886d7f5d3SJohn MarinoThis routine returns 14986d7f5d3SJohn Marino.Dv TRUE 15086d7f5d3SJohn Marinoif decoding succeeds, and 15186d7f5d3SJohn Marino.Dv FALSE 15286d7f5d3SJohn Marinootherwise. 15386d7f5d3SJohn Marino.It Fn svc_getreq_common 15486d7f5d3SJohn MarinoThis routine is called to handle a request on the given 15586d7f5d3SJohn Marinofile descriptor. 15686d7f5d3SJohn Marino.It Fn svc_getreq_poll 15786d7f5d3SJohn MarinoThis routine is only of interest if a service implementor 15886d7f5d3SJohn Marinodoes not call 15986d7f5d3SJohn Marino.Fn svc_run , 16086d7f5d3SJohn Marinobut instead implements custom asynchronous event processing. 16186d7f5d3SJohn MarinoIt is called when 16286d7f5d3SJohn Marino.Xr poll 2 16386d7f5d3SJohn Marinohas determined that an RPC request has arrived on some RPC 16486d7f5d3SJohn Marinofile descriptors; 16586d7f5d3SJohn Marino.Fa pollretval 16686d7f5d3SJohn Marinois the return value from 16786d7f5d3SJohn Marino.Xr poll 2 16886d7f5d3SJohn Marinoand 16986d7f5d3SJohn Marino.Fa pfdp 17086d7f5d3SJohn Marinois the array of 17186d7f5d3SJohn Marino.Vt pollfd 17286d7f5d3SJohn Marinostructures on which the 17386d7f5d3SJohn Marino.Xr poll 2 17486d7f5d3SJohn Marinowas done. 17586d7f5d3SJohn MarinoIt is assumed to be an array large enough to 17686d7f5d3SJohn Marinocontain the maximal number of descriptors allowed. 17786d7f5d3SJohn Marino.It Fn svc_getreqset 17886d7f5d3SJohn MarinoThis routine is only of interest if a service implementor 17986d7f5d3SJohn Marinodoes not call 18086d7f5d3SJohn Marino.Fn svc_run , 18186d7f5d3SJohn Marinobut instead implements custom asynchronous event processing. 18286d7f5d3SJohn MarinoIt is called when 18386d7f5d3SJohn Marino.Xr poll 2 18486d7f5d3SJohn Marinohas determined that an RPC 18586d7f5d3SJohn Marinorequest has arrived on some RPC file descriptors; 18686d7f5d3SJohn Marino.Fa rdfds 18786d7f5d3SJohn Marinois the resultant read file descriptor bit mask. 18886d7f5d3SJohn MarinoThe routine returns when all file descriptors 18986d7f5d3SJohn Marinoassociated with the value of 19086d7f5d3SJohn Marino.Fa rdfds 19186d7f5d3SJohn Marinohave been serviced. 19286d7f5d3SJohn Marino.It Fn svc_getrpccaller 19386d7f5d3SJohn MarinoThe approved way of getting the network address of the caller 19486d7f5d3SJohn Marinoof a procedure associated with the 19586d7f5d3SJohn MarinoRPC service transport handle 19686d7f5d3SJohn Marino.Fa xprt . 19786d7f5d3SJohn Marino.It Xo 19886d7f5d3SJohn Marino.Vt struct pollfd Va svc_pollset[FD_SETSIZE] ; 19986d7f5d3SJohn Marino.Xc 20086d7f5d3SJohn Marino.Va svc_pollset 20186d7f5d3SJohn Marinois an array of 20286d7f5d3SJohn Marino.Vt pollfd 20386d7f5d3SJohn Marinostructures derived from 20486d7f5d3SJohn Marino.Va svc_fdset[] . 20586d7f5d3SJohn MarinoIt is suitable as an argument to the 20686d7f5d3SJohn Marino.Xr poll 2 20786d7f5d3SJohn Marinosystem call. 20886d7f5d3SJohn MarinoThe derivation of 20986d7f5d3SJohn Marino.Va svc_pollset 21086d7f5d3SJohn Marinofrom 21186d7f5d3SJohn Marino.Va svc_fdset 21286d7f5d3SJohn Marinois made in the current implementation in 21386d7f5d3SJohn Marino.Fn svc_run . 21486d7f5d3SJohn MarinoService implementors who do not call 21586d7f5d3SJohn Marino.Fn svc_run 21686d7f5d3SJohn Marinoand who wish to use this array must perform this derivation themselves. 21786d7f5d3SJohn Marino.It Fn svc_run 21886d7f5d3SJohn MarinoThis routine never returns. 21986d7f5d3SJohn MarinoIt waits for RPC 22086d7f5d3SJohn Marinorequests to arrive, and calls the appropriate service 22186d7f5d3SJohn Marinoprocedure using 22286d7f5d3SJohn Marino.Fn svc_getreq_poll 22386d7f5d3SJohn Marinowhen one arrives. 22486d7f5d3SJohn MarinoThis procedure is usually waiting for the 22586d7f5d3SJohn Marino.Xr poll 2 22686d7f5d3SJohn Marinosystem call to return. 22786d7f5d3SJohn Marino.It Fn svc_sendreply 22886d7f5d3SJohn MarinoCalled by an RPC service's dispatch routine to send the results of a 22986d7f5d3SJohn Marinoremote procedure call. 23086d7f5d3SJohn MarinoThe 23186d7f5d3SJohn Marino.Fa xprt 23286d7f5d3SJohn Marinoargument 23386d7f5d3SJohn Marinois the request's associated transport handle; 23486d7f5d3SJohn Marino.Fa outproc 23586d7f5d3SJohn Marinois the XDR 23686d7f5d3SJohn Marinoroutine which is used to encode the results; and 23786d7f5d3SJohn Marino.Fa out 23886d7f5d3SJohn Marinois the address of the results. 23986d7f5d3SJohn MarinoThis routine returns 24086d7f5d3SJohn Marino.Dv TRUE 24186d7f5d3SJohn Marinoif it succeeds, 24286d7f5d3SJohn Marino.Dv FALSE 24386d7f5d3SJohn Marinootherwise. 24486d7f5d3SJohn Marino.El 24586d7f5d3SJohn Marino.Sh SEE ALSO 24686d7f5d3SJohn Marino.Xr poll 2 , 24786d7f5d3SJohn Marino.Xr select 2 , 24886d7f5d3SJohn Marino.Xr rpc 3 , 24986d7f5d3SJohn Marino.Xr rpc_svc_create 3 , 25086d7f5d3SJohn Marino.Xr rpc_svc_err 3 , 25186d7f5d3SJohn Marino.Xr rpc_svc_reg 3 252