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