source: rtems/cpukit/libnetworking/rpc/svc.h @ 16f4661f

5
Last change on this file since 16f4661f was 16f4661f, checked in by Sebastian Huber <sebastian.huber@…>, on 03/09/18 at 07:38:18

network: Optionally install network headers

Install the network headers only if --enable-networking is specified.

Update #3254.

  • Property mode set to 100644
File size: 9.6 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
43#include <sys/cdefs.h>
44#include <rpc/types.h>
45#include <rpc/xdr.h> /* xdrproc_t */
46#include <sys/select.h> /* fd_set */
47#include <sys/socket.h> /* socklen_t */
48#include <netinet/in.h> /* struct sockaddr_in */
49#include <rpc/auth.h> /* auth_stat */
50
51/*
52 * This interface must manage two items concerning remote procedure calling:
53 *
54 * 1) An arbitrary number of transport connections upon which rpc requests
55 * are received.  The two most notable transports are TCP and UDP;  they are
56 * created and registered by routines in svc_tcp.c and svc_udp.c, respectively;
57 * they in turn call xprt_register and xprt_unregister.
58 *
59 * 2) An arbitrary number of locally registered services.  Services are
60 * described by the following four data: program number, version number,
61 * "service dispatch" function, a transport handle, and a boolean that
62 * indicates whether or not the exported program should be registered with a
63 * local binder service;  if true the program's number and version and the
64 * port number from the transport handle are registered with the binder.
65 * These data are registered with the rpc svc system via svc_register.
66 *
67 * A service's dispatch function is called whenever an rpc request comes in
68 * on a transport.  The request's program and version numbers must match
69 * those of the registered service.  The dispatch function is passed two
70 * parameters, struct svc_req * and SVCXPRT *, defined below.
71 */
72
73enum xprt_stat {
74        XPRT_DIED,
75        XPRT_MOREREQS,
76        XPRT_IDLE,
77        _XPRT_STAT = 0xffffffff
78};
79
80struct rpc_msg;
81
82/*
83 * Server side transport handle
84 */
85typedef struct __rpc_svcxprt {
86        int             xp_sock;
87        u_short         xp_port;         /* associated port number */
88        struct xp_ops {
89            /* receive incoming requests */
90            bool_t      (*xp_recv)(struct __rpc_svcxprt *, struct rpc_msg *);
91            /* get transport status */
92            enum xprt_stat (*xp_stat)(struct __rpc_svcxprt *);
93            /* get arguments */
94            bool_t      (*xp_getargs)(struct __rpc_svcxprt *, xdrproc_t,
95                                caddr_t args_ptr);
96            /* send reply */
97            bool_t      (*xp_reply)(struct __rpc_svcxprt *, struct rpc_msg *);
98            /* free mem allocated for args */
99            bool_t      (*xp_freeargs)(struct __rpc_svcxprt *, xdrproc_t,
100                                caddr_t args_ptr);
101            /* destroy this struct */
102            void        (*xp_destroy)(struct __rpc_svcxprt *);
103        } *xp_ops;
104        socklen_t       xp_addrlen;      /* length of remote address */
105        struct sockaddr_in xp_raddr;     /* remote addr. (backward ABI compat) */
106        struct opaque_auth xp_verf;      /* raw response verifier */
107        void            *xp_p1;          /* private: for use by svc ops */
108        void            *xp_p2;          /* private: for use by svc ops */
109} SVCXPRT;
110
111/*
112 * Service request
113 */
114struct svc_req {
115        u_int32_t       rq_prog;        /* service program number */
116        u_int32_t       rq_vers;        /* service protocol version */
117        u_int32_t       rq_proc;        /* the desired procedure */
118        struct opaque_auth rq_cred;     /* raw creds from the wire */
119        caddr_t         rq_clntcred;    /* read only cooked cred */
120        SVCXPRT         *rq_xprt;       /* associated transport */
121};
122
123
124/*
125 * Operations defined on an SVCXPRT handle
126 *
127 * SVCXPRT              *xprt;
128 * struct rpc_msg       *msg;
129 * xdrproc_t             xargs;
130 * caddr_t               argsp;
131 */
132#define SVC_RECV(xprt, msg)                             \
133        (*(xprt)->xp_ops->xp_recv)((xprt), (msg))
134#define svc_recv(xprt, msg)                             \
135        (*(xprt)->xp_ops->xp_recv)((xprt), (msg))
136
137#define SVC_STAT(xprt)                                  \
138        (*(xprt)->xp_ops->xp_stat)(xprt)
139#define svc_stat(xprt)                                  \
140        (*(xprt)->xp_ops->xp_stat)(xprt)
141
142#define SVC_GETARGS(xprt, xargs, argsp)                 \
143        (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
144#define svc_getargs(xprt, xargs, argsp)                 \
145        (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
146
147#define SVC_REPLY(xprt, msg)                            \
148        (*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
149#define svc_reply(xprt, msg)                            \
150        (*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
151
152#define SVC_FREEARGS(xprt, xargs, argsp)                \
153        (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
154#define svc_freeargs(xprt, xargs, argsp)                \
155        (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
156
157#define SVC_DESTROY(xprt)                               \
158        (*(xprt)->xp_ops->xp_destroy)(xprt)
159#define svc_destroy(xprt)                               \
160        (*(xprt)->xp_ops->xp_destroy)(xprt)
161
162/*
163 * Transport registration.
164 *
165 * xprt_register(xprt)
166 *      SVCXPRT *xprt;
167 */
168__BEGIN_DECLS
169extern void     xprt_register(SVCXPRT *);
170__END_DECLS
171
172/*
173 * Transport un-register
174 *
175 * xprt_unregister(xprt)
176 *      SVCXPRT *xprt;
177 */
178__BEGIN_DECLS
179extern void     xprt_unregister(SVCXPRT *);
180__END_DECLS
181
182
183/*
184 * When the service routine is called, it must first check to see if it
185 * knows about the procedure;  if not, it should call svcerr_noproc
186 * and return.  If so, it should deserialize its arguments via
187 * SVC_GETARGS (defined above).  If the deserialization does not work,
188 * svcerr_decode should be called followed by a return.  Successful
189 * decoding of the arguments should be followed the execution of the
190 * procedure's code and a call to svc_sendreply.
191 *
192 * Also, if the service refuses to execute the procedure due to too-
193 * weak authentication parameters, svcerr_weakauth should be called.
194 * Note: do not confuse access-control failure with weak authentication!
195 *
196 * NB: In pure implementations of rpc, the caller always waits for a reply
197 * msg.  This message is sent when svc_sendreply is called.
198 * Therefore pure service implementations should always call
199 * svc_sendreply even if the function logically returns void;  use
200 * xdr.h - xdr_void for the xdr routine.  HOWEVER, tcp based rpc allows
201 * for the abuse of pure rpc via batched calling or pipelining.  In the
202 * case of a batched call, svc_sendreply should NOT be called since
203 * this would send a return message, which is what batching tries to avoid.
204 * It is the service/protocol writer's responsibility to know which calls are
205 * batched and which are not.  Warning: responding to batch calls may
206 * deadlock the caller and server processes!
207 */
208
209__BEGIN_DECLS
210extern bool_t   svc_sendreply(SVCXPRT *, xdrproc_t, void *);
211extern void     svcerr_decode(SVCXPRT *);
212extern void     svcerr_weakauth(SVCXPRT *);
213extern void     svcerr_noproc(SVCXPRT *);
214extern void     svcerr_progvers(SVCXPRT *, rpcvers_t, rpcvers_t);
215extern void     svcerr_auth(SVCXPRT *, enum auth_stat);
216extern void     svcerr_noprog(SVCXPRT *);
217extern void     svcerr_systemerr(SVCXPRT *);
218__END_DECLS
219
220/*
221 * Lowest level dispatching -OR- who owns this process anyway.
222 * Somebody has to wait for incoming requests and then call the correct
223 * service routine.  The routine svc_run does infinite waiting; i.e.,
224 * svc_run never returns.
225 * Since another (co-existant) package may wish to selectively wait for
226 * incoming calls or other events outside of the rpc architecture, the
227 * routine svc_getreq is provided.  It must be passed readfds, the
228 * "in-place" results of a select system call (see select, section 2).
229 */
230
231/*
232 * Global keeper of rpc service descriptors in use
233 * dynamic; must be inspected before each call to select
234 */
235extern int svc_maxfd;
236extern fd_set svc_fdset;
237#define svc_fds svc_fdset.fds_bits[0]   /* compatibility */
238
239#ifndef _KERNEL
240/*
241 * a small program implemented by the svc_rpc implementation itself;
242 * also see clnt.h for protocol numbers.
243 */
244__BEGIN_DECLS
245extern void rpctest_service(void);
246__END_DECLS
247#endif
248
249__BEGIN_DECLS
250extern void     svc_getreq(int);
251extern void     svc_getreqset(fd_set *);
252extern void     svc_getreqset2(fd_set *, int); /* XXX: nonstd, undoc */
253extern void     svc_run(void);
254__END_DECLS
255
256/*
257 * Socket to use on svcxxx_create call to get default socket
258 */
259#define RPC_ANYSOCK     -1
260#define RPC_ANYFD       RPC_ANYSOCK
261
262/*
263 * These are the existing service side transport implementations
264 */
265
266__BEGIN_DECLS
267/*
268 * Transport independent svc_create routine.
269 */
270
271/*
272 * Connectionless and connectionful create routines
273 */
274
275extern SVCXPRT *svc_vc_create(const int, const u_int, const u_int);
276/*
277 *      const int fd;                           -- open connection end point
278 *      const u_int sendsize;                   -- max send size
279 *      const u_int recvsize;                   -- max recv size
280 */
281
282/*
283 * Added for compatibility to old rpc 4.0. Obsoleted by svc_vc_create().
284 */
285extern SVCXPRT *svcunix_create(int, u_int, u_int, char *);
286
287/*
288 * Added for compatibility to old rpc 4.0. Obsoleted by svc_fd_create().
289 */
290extern SVCXPRT *svcunixfd_create(int, u_int, u_int);
291__END_DECLS
292
293
294/* for backward compatibility */
295#include <rpc/svc_soc.h>
296
297#endif /* !_RPC_SVC_H */
Note: See TracBrowser for help on using the repository browser.