RTEMS  5.0.0
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 
74 typedef struct RpcUdpServerRec_ *RpcUdpServer;
75 typedef struct RpcUdpXactRec_ *RpcUdpXact;
76 
77 typedef RpcUdpXact RpcUdpClnt;
78 
79 #define RPCIOD_DEFAULT_ID 0xdef10000
80 
81 enum clnt_stat
82 rpcUdpServerCreate(
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 
92 void
93 rpcUdpServerDestroy(RpcUdpServer s);
94 
99 int
100 rpcUdpStats(FILE *f);
101 
102 enum clnt_stat
103 rpcUdpClntCreate(
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 
112 void
113 RpcUdpClntDestroy(RpcUdpClnt clnt);
114 
118 typedef void *XdrProcT;
119 typedef void *CaddrT;
120 
121 enum clnt_stat
122 rpcUdpClntCall(
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
133 rpcUdpXactCreate(
134  u_long program,
135  u_long version,
136  u_long size
137  );
138 
139 void
140 rpcUdpXactDestroy(
141  RpcUdpXact xact
142  );
143 
147 enum 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 
163 enum clnt_stat
164 rpcUdpRcv(RpcUdpXact xact);
165 
166 /* a yet simpler interface */
167 enum clnt_stat
168 rpcUdpCallRp(
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 
200 typedef struct RpcUdpXactPoolRec_ *RpcUdpXactPool;
201 
202 /* NOTE: the pool is empty initially, must get messages (in
203  * GetCreate mode
204  */
205 RpcUdpXactPool
206 rpcUdpXactPoolCreate(
207  rpcprog_t prog, rpcvers_t version,
208  int xactsize, int poolsize);
209 
210 void
211 rpcUdpXactPoolDestroy(RpcUdpXactPool pool);
212 
213 typedef 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
220 rpcUdpXactPoolGet(RpcUdpXactPool pool, XactPoolGetMode mode);
221 
222 void
223 rpcUdpXactPoolPut(RpcUdpXact xact);
224 
226 #endif
Definition: rpcio.c:230
int rpcUdpStats(FILE *f)
Dump statistics to a file (stdout if NULL);.
Definition: rpcio.c:612
Definition: rpcio.c:288
Definition: rpcio.c:313
void * XdrProcT
Mute compiler warnings.
Definition: rpcio.h:118
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:731
enum clnt_stat rpcUdpRcv(RpcUdpXact xact)
Wait for a transaction to complete.
Definition: rpcio.c:808
unsigned size
Definition: tte.h:74