RTEMS: cpukit/libfs/src/nfsclient/src/rpcio.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
rpcio.h
Go to the documentation of this file.
1
9/*
10 * Author: Till Straumann, <strauman@slac.stanford.edu>, 2002
11 *
12 * Authorship
13 * ----------
14 * This software (NFS-2 client implementation for RTEMS) was created by
15 * Till Straumann <strauman@slac.stanford.edu>, 2002-2007,
16 * Stanford Linear Accelerator Center, Stanford University.
17 *
18 * Acknowledgement of sponsorship
19 * ------------------------------
20 * The NFS-2 client implementation for RTEMS was produced by
21 * the Stanford Linear Accelerator Center, Stanford University,
22 * under Contract DE-AC03-76SFO0515 with the Department of Energy.
23 *
24 * Government disclaimer of liability
25 * ----------------------------------
26 * Neither the United States nor the United States Department of Energy,
27 * nor any of their employees, makes any warranty, express or implied, or
28 * assumes any legal liability or responsibility for the accuracy,
29 * completeness, or usefulness of any data, apparatus, product, or process
30 * disclosed, or represents that its use would not infringe privately owned
31 * rights.
32 *
33 * Stanford disclaimer of liability
34 * --------------------------------
35 * Stanford University makes no representations or warranties, express or
36 * implied, nor assumes any liability for the use of this software.
37 *
38 * Stanford disclaimer of copyright
39 * --------------------------------
40 * Stanford University, owner of the copyright, hereby disclaims its
41 * copyright and all other rights in this software. Hence, anyone may
42 * freely use it for any purpose without restriction.
43 *
44 * Maintenance of notices
45 * ----------------------
46 * In the interest of clarity regarding the origin and status of this
47 * SLAC software, this and all the preceding Stanford University notices
48 * are to remain affixed to any copy or derivative of this software made
49 * or distributed by the recipient and are to be affixed to any copy of
50 * software made or distributed by the recipient that contains a copy or
51 * derivative of this software.
52 *
53 * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
54 */
55
56#ifndef RPCIO_H
57#define RPCIO_H
58
66#include <rpc/rpc.h>
67#include <errno.h>
68#include <sys/ioctl.h>
69#include <sys/param.h>
70#include <stdarg.h>
71
72#include "librtemsNfs.h"
73
74typedef struct RpcUdpServerRec_ *RpcUdpServer;
75typedef struct RpcUdpXactRec_ *RpcUdpXact;
76
77typedef RpcUdpXact RpcUdpClnt;
78
79#define RPCIOD_DEFAULT_ID 0xdef10000
80
81enum clnt_stat
82rpcUdpServerCreate(
83 struct sockaddr_in *paddr,
84 rpcprog_t prog,
85 rpcvers_t vers,
86 u_long uid, /* RPCIO_DEFAULT_ID picks default */
87 u_long gid, /* RPCIO_DEFAULT_ID picks default */
88 RpcUdpServer *pclnt /* new server is returned here */
89 );
90
91
92void
93rpcUdpServerDestroy(RpcUdpServer s);
94
99int
100 rpcUdpStats(FILE *f);
101
102enum clnt_stat
103rpcUdpClntCreate(
104 struct sockaddr_in *psaddr,
105 rpcprog_t prog,
106 rpcvers_t vers,
107 u_long uid, /* RPCIO_DEFAULT_ID picks default */
108 u_long gid, /* RPCIO_DEFAULT_ID picks default */
109 RpcUdpClnt *pclnt /* new client is returned here */
110 );
111
112void
113RpcUdpClntDestroy(RpcUdpClnt clnt);
114
118 typedef void *XdrProcT;
119typedef void *CaddrT;
120
121enum clnt_stat
122rpcUdpClntCall(
123 RpcUdpClnt clnt,
124 u_long proc,
125 XdrProcT xargs,
126 CaddrT pargs,
127 XdrProcT xres,
128 CaddrT pres,
129 struct timeval *timeout /* optional timeout; maybe NULL to pick default */
130 );
131
132 RpcUdpXact
133rpcUdpXactCreate(
134 u_long program,
135 u_long version,
136 u_long size
137 );
138
139void
140rpcUdpXactDestroy(
141 RpcUdpXact xact
142 );
143
147enum clnt_stat
148 rpcUdpSend(
149 RpcUdpXact xact,
150 RpcUdpServer srvr,
151 struct timeval *timeout, /* maybe NULL to pick default */
152 u_long proc,
153 xdrproc_t xres,
154 caddr_t pres,
155 xdrproc_t xargs,
156 caddr_t pargs,
157 ... /* 0 terminated xdrproc/pobj additional argument list */
158 );
159
163enum clnt_stat
164 rpcUdpRcv(RpcUdpXact xact);
165
166/* a yet simpler interface */
167enum clnt_stat
168rpcUdpCallRp(
169 struct sockaddr_in *pserver_addr,
170 u_long prog,
171 u_long vers,
172 u_long proc,
173 XdrProcT xargs,
174 CaddrT pargs,
175 XdrProcT xres,
176 CaddrT pres,
177 u_long uid, /* RPCIO_DEFAULT_ID picks default */
178 u_long gid, /* RPCIO_DEFAULT_ID picks default */
179 struct timeval *timeout /* NULL picks default */
180);
181
182
183
184/*
185 * @brief Manage pools of transactions.
186 *
187 * A pool of transactions. The idea is not to malloc/free them
188 * all the time but keep a limited number around in a 'pool'.
189 * Users who need a XACT may get it from the pool and put it back
190 * when done.
191 * The pool is implemented by RTEMS message queues who manage
192 * the required task synchronization.
193 * A requestor has different options if the pool is empty:
194 * - it can wait (block) for a XACT to become available
195 * - it can get an error status
196 * - or it can malloc an extra XACT from the heap which
197 * will eventually be released.
198 */
199
200typedef struct RpcUdpXactPoolRec_ *RpcUdpXactPool;
201
202/* NOTE: the pool is empty initially, must get messages (in
203 * GetCreate mode
204 */
205 RpcUdpXactPool
206rpcUdpXactPoolCreate(
207 rpcprog_t prog, rpcvers_t version,
208 int xactsize, int poolsize);
209
210void
211rpcUdpXactPoolDestroy(RpcUdpXactPool pool);
212
213typedef enum {
214 XactGetFail, /* call fails if no transaction available */
215 XactGetWait, /* call blocks until transaction available */
216 XactGetCreate /* a new transaction is allocated (and freed when put back to the pool */
217} XactPoolGetMode;
218
219 RpcUdpXact
220rpcUdpXactPoolGet(RpcUdpXactPool pool, XactPoolGetMode mode);
221
222void
223rpcUdpXactPoolPut(RpcUdpXact xact);
224
226#endif
rpcUdpSend
enum clnt_stat rpcUdpSend(RpcUdpXact xact, RpcUdpServer srvr, struct timeval *timeout, u_long proc, xdrproc_t xres, caddr_t pres, xdrproc_t xargs, caddr_t pargs,...)
Definition: rpcio.c:713
rpcUdpStats
int rpcUdpStats(FILE *f)
Dump statistics to a file (stdout if NULL);.
Definition: rpcio.c:594
rpcUdpRcv
enum clnt_stat rpcUdpRcv(RpcUdpXact xact)
Wait for a transaction to complete.
Definition: rpcio.c:790
XdrProcT
void * XdrProcT
Mute compiler warnings.
Definition: rpcio.h:118
RpcUdpServerRec_
Definition: rpcio.c:212
RpcUdpXactPoolRec_
Definition: rpcio.c:295
RpcUdpXactRec_
Definition: rpcio.c:270