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