Import TBBT (NFS trace replay).
[bluesky.git] / TBBT / trace_play / rpc / rpc_msg.h
1 /*
2  * @(#)rpc_msg.h     2.1     97/10/23
3  */
4 /* @(#)rpc_msg.h        2.1 88/07/29 4.0 RPCSRC */
5 /*
6  *   Copyright (c) 1992-1997,2001 by Standard Performance Evaluation Corporation
7  *      All rights reserved.
8  *              Standard Performance Evaluation Corporation (SPEC)
9  *              6585 Merchant Place, Suite 100
10  *              Warrenton, VA 20187
11  *
12  *      This product contains benchmarks acquired from several sources who
13  *      understand and agree with SPEC's goal of creating fair and objective
14  *      benchmarks to measure computer performance.
15  *
16  *      This copyright notice is placed here only to protect SPEC in the
17  *      event the source is misused in any manner that is contrary to the
18  *      spirit, the goals and the intent of SPEC.
19  *
20  *      The source code is provided to the user or company under the license
21  *      agreement for the SPEC Benchmark Suite for this product.
22  */
23 /*
24  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
25  * unrestricted use provided that this legend is included on all tape
26  * media and as a part of the software program in whole or part.  Users
27  * may copy or modify Sun RPC without charge, but are not authorized
28  * to license or distribute it to anyone else except as part of a product or
29  * program developed by the user.
30  * 
31  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
32  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
33  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
34  * 
35  * Sun RPC is provided with no support and without any obligation on the
36  * part of Sun Microsystems, Inc. to assist in its use, correction,
37  * modification or enhancement.
38  * 
39  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
40  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
41  * OR ANY PART THEREOF.
42  * 
43  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
44  * or profits or other special, indirect and consequential damages, even if
45  * Sun has been advised of the possibility of such damages.
46  * 
47  * Sun Microsystems, Inc.
48  * 2550 Garcia Avenue
49  * Mountain View, California  94043
50  */
51 /*      @(#)rpc_msg.h 1.7 86/07/16 SMI      */
52
53 /*
54  * rpc_msg.h
55  * rpc message definition
56  *
57  * Copyright (C) 1984, Sun Microsystems, Inc.
58  */
59
60 #ifndef __RPC_MSG_H
61 #define __RPC_MSG_H
62
63 #define RPC_MSG_VERSION         ((uint32_t) 2)
64 #define RPC_SERVICE_PORT        ((uint16_t) 2048)
65
66 /*
67  * Bottom up definition of an rpc message.
68  * NOTE: call and reply use the same overall stuct but
69  * different parts of unions within it.
70  */
71
72 enum msg_type {
73         CALL=0,
74         REPLY=1
75 };
76
77 enum reply_stat {
78         MSG_ACCEPTED=0,
79         MSG_DENIED=1
80 };
81
82 enum accept_stat {
83         SUCCESS=0,
84         PROG_UNAVAIL=1,
85         PROG_MISMATCH=2,
86         PROC_UNAVAIL=3,
87         GARBAGE_ARGS=4,
88         SYSTEM_ERR=5
89 };
90
91 enum reject_stat {
92         RPC_MISMATCH=0,
93         AUTH_ERROR=1
94 };
95
96 /*
97  * Reply part of an rpc exchange
98  */
99
100 /*
101  * Reply to an rpc request that was accepted by the server.
102  * Note: there could be an error even though the request was
103  * accepted.
104  */
105 struct accepted_reply {
106         struct opaque_auth      ar_verf;
107         enum accept_stat        ar_stat;
108         union {
109                 struct {
110                         uint32_t        low;
111                         uint32_t        high;
112                 } AR_versions;
113                 struct {
114                         void *  where;
115                         xdrproc_t proc;
116                 } AR_results;
117                 /* and many other null cases */
118         } ru;
119 #define ar_results      ru.AR_results
120 #define ar_vers         ru.AR_versions
121 };
122
123 /*
124  * Reply to an rpc request that was rejected by the server.
125  */
126 struct rejected_reply {
127         enum reject_stat rj_stat;
128         union {
129                 struct {
130                         uint32_t low;
131                         uint32_t high;
132                 } RJ_versions;
133                 enum auth_stat RJ_why;  /* why authentication did not work */
134         } ru;
135 #define rj_vers ru.RJ_versions
136 #define rj_why  ru.RJ_why
137 };
138
139 /*
140  * Body of a reply to an rpc request.
141  */
142 struct reply_body {
143         enum reply_stat rp_stat;
144         union {
145                 struct accepted_reply RP_ar;
146                 struct rejected_reply RP_dr;
147         } ru;
148 #define rp_acpt ru.RP_ar
149 #define rp_rjct ru.RP_dr
150 };
151
152 /*
153  * Body of an rpc request call.
154  */
155 struct call_body {
156         uint32_t cb_rpcvers;    /* must be equal to two */
157         uint32_t cb_prog;
158         uint32_t cb_vers;
159         uint32_t cb_proc;
160         struct opaque_auth cb_cred;
161         struct opaque_auth cb_verf; /* protocol specific - provided by client */
162 };
163
164 /*
165  * The rpc message
166  */
167 struct rpc_msg {
168         uint32_t                rm_xid;
169         enum msg_type           rm_direction;
170         union {
171                 struct call_body RM_cmb;
172                 struct reply_body RM_rmb;
173         } ru;
174 #define rm_call         ru.RM_cmb
175 #define rm_reply        ru.RM_rmb
176 };
177 #define acpted_rply     ru.RM_rmb.ru.RP_ar
178 #define rjcted_rply     ru.RM_rmb.ru.RP_dr
179
180
181 /*
182  * XDR routine to handle a rpc message.
183  * xdr_callmsg(xdrs, cmsg)
184  *      XDR *xdrs;
185  *      struct rpc_msg *cmsg;
186  */
187 extern bool_t   xdr_callmsg(XDR *, struct rpc_msg *);
188
189 /*
190  * XDR routine to pre-serialize the static part of a rpc message.
191  * xdr_callhdr(xdrs, cmsg)
192  *      XDR *xdrs;
193  *      struct rpc_msg *cmsg;
194  */
195 extern bool_t   xdr_callhdr(XDR *, struct rpc_msg *);
196
197 /*
198  * XDR routine to handle a rpc reply.
199  * xdr_replymsg(xdrs, rmsg)
200  *      XDR *xdrs;
201  *      struct rpc_msg *rmsg;
202  */
203 extern bool_t   xdr_replymsg(XDR *, struct rpc_msg *);
204
205 /*
206  * Fills in the error part of a reply message.
207  * _seterr_reply(msg, error)
208  *      struct rpc_msg *msg;
209  *      struct rpc_err *error;
210  */
211 extern void     _seterr_reply(struct rpc_msg *, struct rpc_err *);
212
213 extern int      _rpc_dtablesize(void);
214 extern bool_t   xdr_opaque_auth(XDR *, struct opaque_auth *);
215 #endif /* __RPC_MSG_H */