1RPC_SVC_CALLS(3)         BSD Library Functions Manual         RPC_SVC_CALLS(3)
2

NAME

4     svc_dg_enablecache, svc_exit, svc_fdset, svc_freeargs, svc_getargs,
5     svc_getreq_common, svc_getreq_poll, svc_getreqset, svc_getrpccaller,
6     svc_pollset, svc_run, svc_sendreply — library routines for RPC servers
7

LIBRARY

9     Standard C Library (libc, -lc)
10

SYNOPSIS

12     #include <rpc/rpc.h>
13
14     int
15     svc_dg_enablecache(SVCXPRT *xprt, const unsigned cache_size);
16
17     void
18     svc_exit(void);
19
20     bool_t
21     svc_freeargs(const SVCXPRT *xprt, const xdrproc_t inproc, caddr_t in);
22
23     bool_t
24     svc_getargs(const SVCXPRT *xprt, const xdrproc_t inproc, caddr_t in);
25
26     void
27     svc_getreq_common(const int fd);
28
29     void
30     svc_getreq_poll(struct pollfd *pfdp, const int pollretval);
31
32     void
33     svc_getreqset(fd_set * rdfds);
34
35     struct netbuf *
36     svc_getrpccaller(const SVCXPRT *xprt);
37
38     struct cmsgcred *
39     __svc_getcallercreds(const SVCXPRT *xprt);
40
41     struct pollfd svc_pollset[FD_SETSIZE];
42
43     void
44     svc_run(void);
45
46     bool_t
47     svc_sendreply(SVCXPRT *xprt, xdrproc_t outproc, char *out);
48

DESCRIPTION

50     These routines are part of the RPC library which allows C language pro‐
51     grams to make procedure calls on other machines across the network.
52
53     These routines are associated with the server side of the RPC mechanism.
54     Some of them are called by the server side dispatch function, while oth‐
55     ers (such as svc_run()) are called when the server is initiated.
56

Routines

58     See rpc(3) for the definition of the SVCXPRT data structure.
59
60     svc_dg_enablecache()    This function allocates a duplicate request cache
61                             for the service endpoint xprt, large enough to
62                             hold cache_size entries.  Once enabled, there is
63                             no way to disable caching.  This routine returns
64                             0 if space necessary for a cache of the given
65                             size was successfully allocated, and 1 otherwise.
66
67     svc_exit()              This function, when called by any of the RPC
68                             server procedure or otherwise, causes svc_run()
69                             to return.
70
71                             As currently implemented, svc_exit() zeroes the
72                             svc_fdset global variable.  If RPC server activ‐
73                             ity is to be resumed, services must be reregis‐
74                             tered with the RPC library either through one of
75                             the rpc_svc_create(3) functions, or using
76                             xprt_register().  The svc_exit() function has
77                             global scope and ends all RPC server activity.
78
79     fd_set svc_fdset        A global variable reflecting the RPC server's
80                             read file descriptor bit mask; it is suitable as
81                             an argument to the select(2) system call.  This
82                             is only of interest if service implementors do
83                             not call svc_run(), but rather do their own asyn‐
84                             chronous event processing.  This variable is
85                             read-only (do not pass its address to
86                             select(2)!), yet it may change after calls to
87                             svc_getreqset() or any creation routines.
88
89     svc_freeargs()          A function macro that frees any data allocated by
90                             the RPC/XDR system when it decoded the arguments
91                             to a service procedure using svc_getargs().  This
92                             routine returns TRUE if the results were success‐
93                             fully freed, and FALSE otherwise.
94
95     svc_getargs()           A function macro that decodes the arguments of an
96                             RPC request associated with the RPC service
97                             transport handle xprt.  The in argument is the
98                             address where the arguments will be placed;
99                             inproc is the XDR routine used to decode the
100                             arguments.  This routine returns TRUE if decoding
101                             succeeds, and FALSE otherwise.
102
103     svc_getreq_common()     This routine is called to handle a request on the
104                             given file descriptor.
105
106     svc_getreq_poll()       This routine is only of interest if a service
107                             implementor does not call svc_run(), but instead
108                             implements custom asynchronous event processing.
109                             It is called when poll(2) has determined that an
110                             RPC request has arrived on some RPC file descrip‐
111                             tors; pollretval is the return value from poll(2)
112                             and pfdp is the array of pollfd structures on
113                             which the poll(2) was done.  It is assumed to be
114                             an array large enough to contain the maximal num‐
115                             ber of descriptors allowed.
116
117     svc_getreqset()         This routine is only of interest if a service
118                             implementor does not call svc_run(), but instead
119                             implements custom asynchronous event processing.
120                             It is called when poll(2) has determined that an
121                             RPC request has arrived on some RPC file descrip‐
122                             tors; rdfds is the resultant read file descriptor
123                             bit mask.  The routine returns when all file
124                             descriptors associated with the value of rdfds
125                             have been serviced.
126
127     svc_getrpccaller()      The approved way of getting the network address
128                             of the caller of a procedure associated with the
129                             RPC service transport handle xprt.
130
131     __svc_getcallercreds()  Warning: this macro is specific to FreeBSD and
132                             thus not portable.  This macro returns a pointer
133                             to a cmsgcred structure, defined in
134                             <sys/socket.h>, identifying the calling client.
135                             This only works if the client is calling the
136                             server over an AF_LOCAL socket.
137
138     struct pollfd svc_pollset[FD_SETSIZE];
139                             svc_pollset is an array of pollfd structures
140                             derived from svc_fdset[].  It is suitable as an
141                             argument to the poll(2) system call.  The deriva‐
142                             tion of svc_pollset from svc_fdset is made in the
143                             current implementation in svc_run().  Service
144                             implementors who do not call svc_run() and who
145                             wish to use this array must perform this deriva‐
146                             tion themselves.
147
148     svc_run()               This routine never returns.  It waits for RPC
149                             requests to arrive, and calls the appropriate
150                             service procedure using svc_getreq_poll() when
151                             one arrives.  This procedure is usually waiting
152                             for the poll(2) system call to return.
153
154     svc_sendreply()         Called by an RPC service's dispatch routine to
155                             send the results of a remote procedure call.  The
156                             xprt argument is the request's associated trans‐
157                             port handle; outproc is the XDR routine which is
158                             used to encode the results; and out is the
159                             address of the results.  This routine returns
160                             TRUE if it succeeds, FALSE otherwise.
161

SEE ALSO

163     poll(2), select(2), rpc(3), rpc_svc_create(3), rpc_svc_err(3),
164     rpc_svc_reg(3)
165
166BSD                               May 3, 1993                              BSD
Impressum