]> git.saurik.com Git - apple/libinfo.git/blame - rpc.subproj/rpc_msg.h
Libinfo-89.1.tar.gz
[apple/libinfo.git] / rpc.subproj / rpc_msg.h
CommitLineData
03fb6eb0
A
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.2 1999/10/14 21:56:54 wsanchez 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#define RPC_MSG_VERSION ((u_long) 2)
68#define RPC_SERVICE_PORT ((u_short) 2048)
69
70/*
71 * Bottom up definition of an rpc message.
72 * NOTE: call and reply use the same overall stuct but
73 * different parts of unions within it.
74 */
75
76enum msg_type {
77 CALL=0,
78 REPLY=1
79};
80
81enum reply_stat {
82 MSG_ACCEPTED=0,
83 MSG_DENIED=1
84};
85
86enum accept_stat {
87 SUCCESS=0,
88 PROG_UNAVAIL=1,
89 PROG_MISMATCH=2,
90 PROC_UNAVAIL=3,
91 GARBAGE_ARGS=4,
92 SYSTEM_ERR=5
93};
94
95enum reject_stat {
96 RPC_MISMATCH=0,
97 AUTH_ERROR=1
98};
99
100/*
101 * Reply part of an rpc exchange
102 */
103
104/*
105 * Reply to an rpc request that was accepted by the server.
106 * Note: there could be an error even though the request was
107 * accepted.
108 */
109struct accepted_reply {
110 struct opaque_auth ar_verf;
111 enum accept_stat ar_stat;
112 union {
113 struct {
114 u_long low;
115 u_long high;
116 } AR_versions;
117 struct {
118 caddr_t where;
119 xdrproc_t proc;
120 } AR_results;
121 /* and many other null cases */
122 } ru;
123#define ar_results ru.AR_results
124#define ar_vers ru.AR_versions
125};
126
127/*
128 * Reply to an rpc request that was rejected by the server.
129 */
130struct rejected_reply {
131 enum reject_stat rj_stat;
132 union {
133 struct {
134 u_long low;
135 u_long high;
136 } RJ_versions;
137 enum auth_stat RJ_why; /* why authentication did not work */
138 } ru;
139#define rj_vers ru.RJ_versions
140#define rj_why ru.RJ_why
141};
142
143/*
144 * Body of a reply to an rpc request.
145 */
146struct reply_body {
147 enum reply_stat rp_stat;
148 union {
149 struct accepted_reply RP_ar;
150 struct rejected_reply RP_dr;
151 } ru;
152#define rp_acpt ru.RP_ar
153#define rp_rjct ru.RP_dr
154};
155
156/*
157 * Body of an rpc request call.
158 */
159struct call_body {
160 u_long cb_rpcvers; /* must be equal to two */
161 u_long cb_prog;
162 u_long cb_vers;
163 u_long cb_proc;
164 struct opaque_auth cb_cred;
165 struct opaque_auth cb_verf; /* protocol specific - provided by client */
166};
167
168/*
169 * The rpc message
170 */
171struct rpc_msg {
172 u_long rm_xid;
173 enum msg_type rm_direction;
174 union {
175 struct call_body RM_cmb;
176 struct reply_body RM_rmb;
177 } ru;
178#define rm_call ru.RM_cmb
179#define rm_reply ru.RM_rmb
180};
181#define acpted_rply ru.RM_rmb.ru.RP_ar
182#define rjcted_rply ru.RM_rmb.ru.RP_dr
183
184__BEGIN_DECLS
185/*
186 * XDR routine to handle a rpc message.
187 * xdr_callmsg(xdrs, cmsg)
188 * XDR *xdrs;
189 * struct rpc_msg *cmsg;
190 */
191extern bool_t xdr_callmsg __P((XDR *, struct rpc_msg *));
192
193/*
194 * XDR routine to pre-serialize the static part of a rpc message.
195 * xdr_callhdr(xdrs, cmsg)
196 * XDR *xdrs;
197 * struct rpc_msg *cmsg;
198 */
199extern bool_t xdr_callhdr __P((XDR *, struct rpc_msg *));
200
201/*
202 * XDR routine to handle a rpc reply.
203 * xdr_replymsg(xdrs, rmsg)
204 * XDR *xdrs;
205 * struct rpc_msg *rmsg;
206 */
207extern bool_t xdr_replymsg __P((XDR *, struct rpc_msg *));
208
209/*
210 * Fills in the error part of a reply message.
211 * _seterr_reply(msg, error)
212 * struct rpc_msg *msg;
213 * struct rpc_err *error;
214 */
215extern void _seterr_reply __P((struct rpc_msg *, struct rpc_err *));
216__END_DECLS
217
218#endif /* !_RPC_RPCMSG_H */