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