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

4.104.114.84.95
Last change on this file since ebb35264 was cd9564e, checked in by Ralf Corsepius <ralf.corsepius@…>, on 05/10/07 at 07:29:14

Include <rtems/bsd/sys/cdefs.h> instead of <sys/cdefs.h>.

  • Property mode set to 100644
File size: 9.4 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.35 88/12/17 SMI
30 *      from: @(#)svc.h      1.27    94/04/25 SMI
31 * $FreeBSD: src/include/rpc/svc.h,v 1.24 2003/06/15 10:32:01 mbr Exp $
32 */
33
34/*
35 * svc.h, Server-side remote procedure call interface.
36 *
37 * Copyright (C) 1986-1993 by Sun Microsystems, Inc.
38 */
39
40#ifndef _RPC_SVC_H
41#define _RPC_SVC_H
42#include <rtems/bsd/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 *, struct rpc_msg *);
83            /* get transport status */
84            enum xprt_stat (*xp_stat)(struct __rpc_svcxprt *);
85            /* get arguments */
86            bool_t      (*xp_getargs)(struct __rpc_svcxprt *, xdrproc_t,
87                                void *);
88            /* send reply */
89            bool_t      (*xp_reply)(struct __rpc_svcxprt *, struct rpc_msg *);
90            /* free mem allocated for args */
91            bool_t      (*xp_freeargs)(struct __rpc_svcxprt *, xdrproc_t,
92                                void *);
93            /* destroy this struct */
94            void        (*xp_destroy)(struct __rpc_svcxprt *);
95        } *xp_ops;
96        socklen_t       xp_addrlen;      /* length of remote address */
97        struct sockaddr_in xp_raddr;     /* remote addr. (backward ABI compat) */
98        struct opaque_auth xp_verf;      /* raw response verifier */
99        void            *xp_p1;          /* private: for use by svc ops */
100        void            *xp_p2;          /* private: for use by svc ops */
101} SVCXPRT;
102
103/*
104 * Service request
105 */
106struct svc_req {
107        u_int32_t       rq_prog;        /* service program number */
108        u_int32_t       rq_vers;        /* service protocol version */
109        u_int32_t       rq_proc;        /* the desired procedure */
110        struct opaque_auth rq_cred;     /* raw creds from the wire */
111        caddr_t         rq_clntcred;    /* read only cooked cred */
112        SVCXPRT         *rq_xprt;       /* associated transport */
113};
114
115
116/*
117 * Operations defined on an SVCXPRT handle
118 *
119 * SVCXPRT              *xprt;
120 * struct rpc_msg       *msg;
121 * xdrproc_t             xargs;
122 * caddr_t               argsp;
123 */
124#define SVC_RECV(xprt, msg)                             \
125        (*(xprt)->xp_ops->xp_recv)((xprt), (msg))
126#define svc_recv(xprt, msg)                             \
127        (*(xprt)->xp_ops->xp_recv)((xprt), (msg))
128
129#define SVC_STAT(xprt)                                  \
130        (*(xprt)->xp_ops->xp_stat)(xprt)
131#define svc_stat(xprt)                                  \
132        (*(xprt)->xp_ops->xp_stat)(xprt)
133
134#define SVC_GETARGS(xprt, xargs, argsp)                 \
135        (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
136#define svc_getargs(xprt, xargs, argsp)                 \
137        (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
138
139#define SVC_REPLY(xprt, msg)                            \
140        (*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
141#define svc_reply(xprt, msg)                            \
142        (*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
143
144#define SVC_FREEARGS(xprt, xargs, argsp)                \
145        (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
146#define svc_freeargs(xprt, xargs, argsp)                \
147        (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
148
149#define SVC_DESTROY(xprt)                               \
150        (*(xprt)->xp_ops->xp_destroy)(xprt)
151#define svc_destroy(xprt)                               \
152        (*(xprt)->xp_ops->xp_destroy)(xprt)
153
154/*
155 * Transport registration.
156 *
157 * xprt_register(xprt)
158 *      SVCXPRT *xprt;
159 */
160__BEGIN_DECLS
161extern void     xprt_register(SVCXPRT *);
162__END_DECLS
163
164/*
165 * Transport un-register
166 *
167 * xprt_unregister(xprt)
168 *      SVCXPRT *xprt;
169 */
170__BEGIN_DECLS
171extern void     xprt_unregister(SVCXPRT *);
172__END_DECLS
173
174
175/*
176 * When the service routine is called, it must first check to see if it
177 * knows about the procedure;  if not, it should call svcerr_noproc
178 * and return.  If so, it should deserialize its arguments via
179 * SVC_GETARGS (defined above).  If the deserialization does not work,
180 * svcerr_decode should be called followed by a return.  Successful
181 * decoding of the arguments should be followed the execution of the
182 * procedure's code and a call to svc_sendreply.
183 *
184 * Also, if the service refuses to execute the procedure due to too-
185 * weak authentication parameters, svcerr_weakauth should be called.
186 * Note: do not confuse access-control failure with weak authentication!
187 *
188 * NB: In pure implementations of rpc, the caller always waits for a reply
189 * msg.  This message is sent when svc_sendreply is called.
190 * Therefore pure service implementations should always call
191 * svc_sendreply even if the function logically returns void;  use
192 * xdr.h - xdr_void for the xdr routine.  HOWEVER, tcp based rpc allows
193 * for the abuse of pure rpc via batched calling or pipelining.  In the
194 * case of a batched call, svc_sendreply should NOT be called since
195 * this would send a return message, which is what batching tries to avoid.
196 * It is the service/protocol writer's responsibility to know which calls are
197 * batched and which are not.  Warning: responding to batch calls may
198 * deadlock the caller and server processes!
199 */
200
201__BEGIN_DECLS
202extern bool_t   svc_sendreply(SVCXPRT *, xdrproc_t, void *);
203extern void     svcerr_decode(SVCXPRT *);
204extern void     svcerr_weakauth(SVCXPRT *);
205extern void     svcerr_noproc(SVCXPRT *);
206extern void     svcerr_progvers(SVCXPRT *, rpcvers_t, rpcvers_t);
207extern void     svcerr_auth(SVCXPRT *, enum auth_stat);
208extern void     svcerr_noprog(SVCXPRT *);
209extern void     svcerr_systemerr(SVCXPRT *);
210__END_DECLS
211
212/*
213 * Lowest level dispatching -OR- who owns this process anyway.
214 * Somebody has to wait for incoming requests and then call the correct
215 * service routine.  The routine svc_run does infinite waiting; i.e.,
216 * svc_run never returns.
217 * Since another (co-existant) package may wish to selectively wait for
218 * incoming calls or other events outside of the rpc architecture, the
219 * routine svc_getreq is provided.  It must be passed readfds, the
220 * "in-place" results of a select system call (see select, section 2).
221 */
222
223/*
224 * Global keeper of rpc service descriptors in use
225 * dynamic; must be inspected before each call to select
226 */
227extern int svc_maxfd;
228extern fd_set svc_fdset;
229#define svc_fds svc_fdset.fds_bits[0]   /* compatibility */
230
231#ifndef _KERNEL
232/*
233 * a small program implemented by the svc_rpc implementation itself;
234 * also see clnt.h for protocol numbers.
235 */
236__BEGIN_DECLS
237extern void rpctest_service(void);
238__END_DECLS
239#endif
240
241__BEGIN_DECLS
242extern void     svc_getreq(int);
243extern void     svc_getreqset(fd_set *);
244extern void     svc_getreqset2(fd_set *, int); /* XXX: nonstd, undoc */
245extern void     svc_run(void);
246__END_DECLS
247
248/*
249 * Socket to use on svcxxx_create call to get default socket
250 */
251#define RPC_ANYSOCK     -1
252#define RPC_ANYFD       RPC_ANYSOCK
253
254/*
255 * These are the existing service side transport implementations
256 */
257
258__BEGIN_DECLS
259/*
260 * Transport independent svc_create routine.
261 */
262
263/*
264 * Connectionless and connectionful create routines
265 */
266
267extern SVCXPRT *svc_vc_create(const int, const u_int, const u_int);
268/*
269 *      const int fd;                           -- open connection end point
270 *      const u_int sendsize;                   -- max send size
271 *      const u_int recvsize;                   -- max recv size
272 */
273
274/*
275 * Added for compatibility to old rpc 4.0. Obsoleted by svc_vc_create().
276 */
277extern SVCXPRT *svcunix_create(int, u_int, u_int, char *);
278
279/*
280 * Added for compatibility to old rpc 4.0. Obsoleted by svc_fd_create().
281 */
282extern SVCXPRT *svcunixfd_create(int, u_int, u_int);
283__END_DECLS
284
285
286/* for backward compatibility */
287#include <rpc/svc_soc.h>
288
289#endif /* !_RPC_SVC_H */
Note: See TracBrowser for help on using the repository browser.