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

SYNOPSIS

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

DESCRIPTION

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

Routines

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

AVAILABILITY

160     These functions are part of libtirpc.
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