rpc_msg.h revision 23037
1139735Simp/*
2129198Scognet * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
3129198Scognet * unrestricted use provided that this legend is included on all tape
4129198Scognet * media and as a part of the software program in whole or part.  Users
5129198Scognet * may copy or modify Sun RPC without charge, but are not authorized
6129198Scognet * to license or distribute it to anyone else except as part of a product or
7129198Scognet * program developed by the user.
8129198Scognet *
9129198Scognet * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
10129198Scognet * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
11129198Scognet * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
12129198Scognet *
13129198Scognet * Sun RPC is provided with no support and without any obligation on the
14129198Scognet * part of Sun Microsystems, Inc. to assist in its use, correction,
15129198Scognet * modification or enhancement.
16129198Scognet *
17129198Scognet * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
18129198Scognet * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
19129198Scognet * OR ANY PART THEREOF.
20129198Scognet *
21129198Scognet * In no event will Sun Microsystems, Inc. be liable for any lost revenue
22129198Scognet * or profits or other special, indirect and consequential damages, even if
23129198Scognet * Sun has been advised of the possibility of such damages.
24129198Scognet *
25129198Scognet * Sun Microsystems, Inc.
26129198Scognet * 2550 Garcia Avenue
27129198Scognet * Mountain View, California  94043
28129198Scognet *
29129198Scognet *	from: @(#)rpc_msg.h 1.7 86/07/16 SMI
30129198Scognet *	from: @(#)rpc_msg.h	2.1 88/07/29 4.0 RPCSRC
31129198Scognet *	$Id$
32129198Scognet */
33129198Scognet
34129198Scognet/*
35129198Scognet * rpc_msg.h
36129198Scognet * rpc message definition
37129198Scognet *
38129198Scognet * Copyright (C) 1984, Sun Microsystems, Inc.
39129198Scognet */
40129198Scognet
41129198Scognet#ifndef _RPC_RPCMSG_H
42129198Scognet#define _RPC_RPCMSG_H
43129198Scognet
44129198Scognet#define RPC_MSG_VERSION		((u_long) 2)
45129198Scognet#define RPC_SERVICE_PORT	((u_short) 2048)
46129198Scognet
47129198Scognet/*
48129198Scognet * Bottom up definition of an rpc message.
49129198Scognet * NOTE: call and reply use the same overall stuct but
50129198Scognet * different parts of unions within it.
51129198Scognet */
52135658Scognet
53129198Scognetenum msg_type {
54129198Scognet	CALL=0,
55129198Scognet	REPLY=1
56129198Scognet};
57129198Scognet
58129198Scognetenum reply_stat {
59129198Scognet	MSG_ACCEPTED=0,
60135658Scognet	MSG_DENIED=1
61129198Scognet};
62129198Scognet
63129198Scognetenum accept_stat {
64129198Scognet	SUCCESS=0,
65129198Scognet	PROG_UNAVAIL=1,
66129198Scognet	PROG_MISMATCH=2,
67129198Scognet	PROC_UNAVAIL=3,
68129198Scognet	GARBAGE_ARGS=4,
69129198Scognet	SYSTEM_ERR=5
70129198Scognet};
71129198Scognet
72129198Scognetenum reject_stat {
73135658Scognet	RPC_MISMATCH=0,
74129198Scognet	AUTH_ERROR=1
75129198Scognet};
76129198Scognet
77129198Scognet/*
78129198Scognet * Reply part of an rpc exchange
79130028Stjr */
80130028Stjr
81129198Scognet/*
82129198Scognet * Reply to an rpc request that was accepted by the server.
83129198Scognet * Note: there could be an error even though the request was
84129198Scognet * accepted.
85129198Scognet */
86129198Scognetstruct accepted_reply {
87129198Scognet	struct opaque_auth	ar_verf;
88129198Scognet	enum accept_stat	ar_stat;
89129198Scognet	union {
90129198Scognet		struct {
91129198Scognet			u_int32_t	low;
92129198Scognet			u_int32_t	high;
93135658Scognet		} AR_versions;
94135658Scognet		struct {
95129198Scognet			caddr_t	where;
96129198Scognet			xdrproc_t proc;
97129198Scognet		} AR_results;
98129198Scognet		/* and many other null cases */
99129198Scognet	} ru;
100129198Scognet#define	ar_results	ru.AR_results
101129198Scognet#define	ar_vers		ru.AR_versions
102129198Scognet};
103176886Scognet
104176886Scognet/*
105129198Scognet * Reply to an rpc request that was rejected by the server.
106176886Scognet */
107129198Scognetstruct rejected_reply {
108129198Scognet	enum reject_stat rj_stat;
109129198Scognet	union {
110129198Scognet		struct {
111129198Scognet			u_int32_t low;
112129198Scognet			u_int32_t high;
113129198Scognet		} RJ_versions;
114129198Scognet		enum auth_stat RJ_why;  /* why authentication did not work */
115129198Scognet	} ru;
116129198Scognet#define	rj_vers	ru.RJ_versions
117135658Scognet#define	rj_why	ru.RJ_why
118129198Scognet};
119129198Scognet
120129198Scognet/*
121129198Scognet * Body of a reply to an rpc request.
122129198Scognet */
123129198Scognetstruct reply_body {
124129198Scognet	enum reply_stat rp_stat;
125129198Scognet	union {
126130028Stjr		struct accepted_reply RP_ar;
127130023Stjr		struct rejected_reply RP_dr;
128129198Scognet	} ru;
129129198Scognet#define	rp_acpt	ru.RP_ar
130#define	rp_rjct	ru.RP_dr
131};
132
133/*
134 * Body of an rpc request call.
135 */
136struct call_body {
137	u_int32_t cb_rpcvers;	/* must be equal to two */
138	u_int32_t cb_prog;
139	u_int32_t cb_vers;
140	u_int32_t cb_proc;
141	struct opaque_auth cb_cred;
142	struct opaque_auth cb_verf; /* protocol specific - provided by client */
143};
144
145/*
146 * The rpc message
147 */
148struct rpc_msg {
149	u_int32_t		rm_xid;
150	enum msg_type		rm_direction;
151	union {
152		struct call_body RM_cmb;
153		struct reply_body RM_rmb;
154	} ru;
155#define	rm_call		ru.RM_cmb
156#define	rm_reply	ru.RM_rmb
157};
158#define	acpted_rply	ru.RM_rmb.ru.RP_ar
159#define	rjcted_rply	ru.RM_rmb.ru.RP_dr
160
161__BEGIN_DECLS
162/*
163 * XDR routine to handle a rpc message.
164 * xdr_callmsg(xdrs, cmsg)
165 * 	XDR *xdrs;
166 * 	struct rpc_msg *cmsg;
167 */
168extern bool_t	xdr_callmsg	__P((XDR *, struct rpc_msg *));
169
170/*
171 * XDR routine to pre-serialize the static part of a rpc message.
172 * xdr_callhdr(xdrs, cmsg)
173 * 	XDR *xdrs;
174 * 	struct rpc_msg *cmsg;
175 */
176extern bool_t	xdr_callhdr	__P((XDR *, struct rpc_msg *));
177
178/*
179 * XDR routine to handle a rpc reply.
180 * xdr_replymsg(xdrs, rmsg)
181 * 	XDR *xdrs;
182 * 	struct rpc_msg *rmsg;
183 */
184extern bool_t	xdr_replymsg	__P((XDR *, struct rpc_msg *));
185
186/*
187 * Fills in the error part of a reply message.
188 * _seterr_reply(msg, error)
189 * 	struct rpc_msg *msg;
190 * 	struct rpc_err *error;
191 */
192struct rpc_err;
193extern void	_seterr_reply	__P((struct rpc_msg *, struct rpc_err *));
194__END_DECLS
195
196#endif /* !_RPC_RPCMSG_H */
197