source: rtems/cpukit/librpc/include/rpc/svc.h @ 8faf4bd

4.104.114.84.95
Last change on this file since 8faf4bd was 8faf4bd, checked in by Ralf Corsepius <ralf.corsepius@…>, on 01/07/05 at 07:46:15

2005-01-07 Ralf Corsepius <ralf.corsepius@…>

  • librpc/include/rpc/svc.h, librpc/include/rpc/xdr.h: Remove P(xx).
  • Property mode set to 100644
File size: 9.7 KB
Line 
1/*
2 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
3 * unrestricted use provided that this legend is included on all tape
4 * media and as a part of the software program in whole or part.  Users
5 * may copy or modify Sun RPC without charge, but are not authorized
6 * to license or distribute it to anyone else except as part of a product or
7 * program developed by the user.
8 *
9 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
10 * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
11 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
12 *
13 * Sun RPC is provided with no support and without any obligation on the
14 * part of Sun Microsystems, Inc. to assist in its use, correction,
15 * modification or enhancement.
16 *
17 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
18 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
19 * OR ANY PART THEREOF.
20 *
21 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
22 * or profits or other special, indirect and consequential damages, even if
23 * Sun has been advised of the possibility of such damages.
24 *
25 * Sun Microsystems, Inc.
26 * 2550 Garcia Avenue
27 * Mountain View, California  94043
28 *
29 *      from: @(#)svc.h 1.20 88/02/08 SMI
30 *      from: @(#)svc.h 2.2 88/07/29 4.0 RPCSRC
31 * $FreeBSD: src/include/rpc/svc.h,v 1.16 1999/12/29 05:00:43 peter Exp $
32 */
33
34/*
35 * svc.h, Server-side remote procedure call interface.
36 *
37 * Copyright (C) 1984, Sun Microsystems, Inc.
38 */
39
40#ifndef _RPC_SVC_H
41#define _RPC_SVC_H
42#include <sys/cdefs.h>
43
44/*
45 * This interface must manage two items concerning remote procedure calling:
46 *
47 * 1) An arbitrary number of transport connections upon which rpc requests
48 * are received.  The two most notable transports are TCP and UDP;  they are
49 * created and registered by routines in svc_tcp.c and svc_udp.c, respectively;
50 * they in turn call xprt_register and xprt_unregister.
51 *
52 * 2) An arbitrary number of locally registered services.  Services are
53 * described by the following four data: program number, version number,
54 * "service dispatch" function, a transport handle, and a boolean that
55 * indicates whether or not the exported program should be registered with a
56 * local binder service;  if true the program's number and version and the
57 * port number from the transport handle are registered with the binder.
58 * These data are registered with the rpc svc system via svc_register.
59 *
60 * A service's dispatch function is called whenever an rpc request comes in
61 * on a transport.  The request's program and version numbers must match
62 * those of the registered service.  The dispatch function is passed two
63 * parameters, struct svc_req * and SVCXPRT *, defined below.
64 */
65
66enum xprt_stat {
67        XPRT_DIED,
68        XPRT_MOREREQS,
69        XPRT_IDLE
70};
71
72struct rpc_msg;
73
74/*
75 * Server side transport handle
76 */
77typedef struct __rpc_svcxprt {
78        int             xp_sock;
79        u_short         xp_port;         /* associated port number */
80        struct xp_ops {
81            /* receive incoming requests */
82            bool_t      (*xp_recv) (struct __rpc_svcxprt *,
83                                struct rpc_msg *);
84            /* get transport status */
85            enum xprt_stat (*xp_stat) (struct __rpc_svcxprt *);
86            /* get arguments */
87            bool_t      (*xp_getargs) (struct __rpc_svcxprt *, xdrproc_t,
88                                caddr_t);
89            /* send reply */
90            bool_t      (*xp_reply) (struct __rpc_svcxprt *,
91                                struct rpc_msg *);
92            /* free mem allocated for args */
93            bool_t      (*xp_freeargs) (struct __rpc_svcxprt *, xdrproc_t,
94                                caddr_t);
95            /* destroy this struct */
96            void        (*xp_destroy) (struct __rpc_svcxprt *);
97        } *xp_ops;
98        int             xp_addrlen;      /* length of remote address */
99        struct sockaddr_in xp_raddr;     /* remote address */
100        struct opaque_auth xp_verf;      /* raw response verifier */
101        caddr_t         xp_p1;           /* private */
102        caddr_t         xp_p2;           /* private */
103} SVCXPRT;
104
105/*
106 *  Approved way of getting address of caller
107 */
108#define svc_getcaller(x) (&(x)->xp_raddr)
109
110/*
111 * Operations defined on an SVCXPRT handle
112 *
113 * SVCXPRT              *xprt;
114 * struct rpc_msg       *msg;
115 * xdrproc_t             xargs;
116 * caddr_t               argsp;
117 */
118#define SVC_RECV(xprt, msg)                             \
119        (*(xprt)->xp_ops->xp_recv)((xprt), (msg))
120#define svc_recv(xprt, msg)                             \
121        (*(xprt)->xp_ops->xp_recv)((xprt), (msg))
122
123#define SVC_STAT(xprt)                                  \
124        (*(xprt)->xp_ops->xp_stat)(xprt)
125#define svc_stat(xprt)                                  \
126        (*(xprt)->xp_ops->xp_stat)(xprt)
127
128#define SVC_GETARGS(xprt, xargs, argsp)                 \
129        (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
130#define svc_getargs(xprt, xargs, argsp)                 \
131        (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
132
133#define SVC_REPLY(xprt, msg)                            \
134        (*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
135#define svc_reply(xprt, msg)                            \
136        (*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
137
138#define SVC_FREEARGS(xprt, xargs, argsp)                \
139        (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
140#define svc_freeargs(xprt, xargs, argsp)                \
141        (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
142
143#define SVC_DESTROY(xprt)                               \
144        (*(xprt)->xp_ops->xp_destroy)(xprt)
145#define svc_destroy(xprt)                               \
146        (*(xprt)->xp_ops->xp_destroy)(xprt)
147
148
149/*
150 * Service request
151 */
152struct svc_req {
153        u_int32_t       rq_prog;        /* service program number */
154        u_int32_t       rq_vers;        /* service protocol version */
155        u_int32_t       rq_proc;        /* the desired procedure */
156        struct opaque_auth rq_cred;     /* raw creds from the wire */
157        caddr_t         rq_clntcred;    /* read only cooked cred */
158        SVCXPRT *rq_xprt;               /* associated transport */
159};
160
161
162/*
163 * Service registration
164 *
165 * svc_register(xprt, prog, vers, dispatch, protocol)
166 *      SVCXPRT *xprt;
167 *      u_long prog;
168 *      u_long vers;
169 *      void (*dispatch)();
170 *      int protocol;        (like TCP or UDP, zero means do not register)
171 */
172__BEGIN_DECLS
173extern bool_t   svc_register (SVCXPRT *, u_long, u_long,
174                        void (*) (struct svc_req *, SVCXPRT *), int);
175__END_DECLS
176
177/*
178 * Service un-registration
179 *
180 * svc_unregister(prog, vers)
181 *      u_long prog;
182 *      u_long vers;
183 */
184__BEGIN_DECLS
185extern void     svc_unregister (u_long, u_long);
186__END_DECLS
187
188/*
189 * Transport registration.
190 *
191 * xprt_register(xprt)
192 *      SVCXPRT *xprt;
193 */
194__BEGIN_DECLS
195extern void     xprt_register   (SVCXPRT *);
196__END_DECLS
197
198/*
199 * Transport un-register
200 *
201 * xprt_unregister(xprt)
202 *      SVCXPRT *xprt;
203 */
204__BEGIN_DECLS
205extern void     xprt_unregister (SVCXPRT *);
206__END_DECLS
207
208
209
210
211/*
212 * When the service routine is called, it must first check to see if it
213 * knows about the procedure;  if not, it should call svcerr_noproc
214 * and return.  If so, it should deserialize its arguments via
215 * SVC_GETARGS (defined above).  If the deserialization does not work,
216 * svcerr_decode should be called followed by a return.  Successful
217 * decoding of the arguments should be followed the execution of the
218 * procedure's code and a call to svc_sendreply.
219 *
220 * Also, if the service refuses to execute the procedure due to too-
221 * weak authentication parameters, svcerr_weakauth should be called.
222 * Note: do not confuse access-control failure with weak authentication!
223 *
224 * NB: In pure implementations of rpc, the caller always waits for a reply
225 * msg.  This message is sent when svc_sendreply is called.
226 * Therefore pure service implementations should always call
227 * svc_sendreply even if the function logically returns void;  use
228 * xdr.h - xdr_void for the xdr routine.  HOWEVER, tcp based rpc allows
229 * for the abuse of pure rpc via batched calling or pipelining.  In the
230 * case of a batched call, svc_sendreply should NOT be called since
231 * this would send a return message, which is what batching tries to avoid.
232 * It is the service/protocol writer's responsibility to know which calls are
233 * batched and which are not.  Warning: responding to batch calls may
234 * deadlock the caller and server processes!
235 */
236
237__BEGIN_DECLS
238extern bool_t   svc_sendreply   (SVCXPRT *, xdrproc_t, char *);
239extern void     svcerr_decode   (SVCXPRT *);
240extern void     svcerr_weakauth (SVCXPRT *);
241extern void     svcerr_noproc   (SVCXPRT *);
242extern void     svcerr_progvers (SVCXPRT *, u_long, u_long);
243extern void     svcerr_auth     (SVCXPRT *, enum auth_stat);
244extern void     svcerr_noprog   (SVCXPRT *);
245extern void     svcerr_systemerr (SVCXPRT *);
246__END_DECLS
247
248/*
249 * Lowest level dispatching -OR- who owns this process anyway.
250 * Somebody has to wait for incoming requests and then call the correct
251 * service routine.  The routine svc_run does infinite waiting; i.e.,
252 * svc_run never returns.
253 * Since another (co-existant) package may wish to selectively wait for
254 * incoming calls or other events outside of the rpc architecture, the
255 * routine svc_getreq is provided.  It must be passed readfds, the
256 * "in-place" results of a select system call (see select, section 2).
257 */
258
259/*
260 * Global keeper of rpc service descriptors in use
261 * dynamic; must be inspected before each call to select
262 */
263extern int svc_maxfd;
264extern fd_set svc_fdset;
265#define svc_fds svc_fdset.fds_bits[0]   /* compatibility */
266
267#ifndef _KERNEL
268/*
269 * a small program implemented by the svc_rpc implementation itself;
270 * also see clnt.h for protocol numbers.
271 */
272extern void rpctest_service();
273#endif
274
275__BEGIN_DECLS
276extern void     svc_getreq      (int);
277extern void     svc_getreqset   (fd_set *);
278extern void     svc_getreqset2  (fd_set *, int); /* XXX: nonstd, undoc */
279extern void     svc_run         (void);
280__END_DECLS
281
282/*
283 * Socket to use on svcxxx_create call to get default socket
284 */
285#define RPC_ANYSOCK     -1
286
287/*
288 * These are the existing service side transport implementations
289 */
290
291/*
292 * Memory based rpc for testing and timing.
293 */
294__BEGIN_DECLS
295extern SVCXPRT *svcraw_create (void);
296__END_DECLS
297
298
299/*
300 * Udp based rpc.
301 */
302__BEGIN_DECLS
303extern SVCXPRT *svcudp_create (int);
304extern SVCXPRT *svcudp_bufcreate (int, u_int, u_int);
305__END_DECLS
306
307
308/*
309 * Tcp based rpc.
310 */
311__BEGIN_DECLS
312extern SVCXPRT *svctcp_create (int, u_int, u_int);
313extern SVCXPRT *svcfd_create (int, u_int, u_int);
314__END_DECLS
315
316/*
317 * AF_UNIX socket based rpc.
318 */
319__BEGIN_DECLS
320extern SVCXPRT *svcunix_create (int, u_int, u_int, char *);
321extern SVCXPRT *svcunixfd_create (int, u_int, u_int);
322__END_DECLS
323
324#endif /* !_RPC_SVC_H */
Note: See TracBrowser for help on using the repository browser.