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