source: rtems/cpukit/libfs/src/nfsclient/src/rpcio.h @ bc26d607

4.104.115
Last change on this file since bc26d607 was bc26d607, checked in by Ralf Corsepius <ralf.corsepius@…>, on 05/27/10 at 07:41:51

2010-05-27 Ralf Corsépius <ralf.corsepius@…>

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