rpc_msg.h revision 25520
11592Srgrimes/*
21592Srgrimes * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
31592Srgrimes * unrestricted use provided that this legend is included on all tape
41592Srgrimes * media and as a part of the software program in whole or part.  Users
51592Srgrimes * may copy or modify Sun RPC without charge, but are not authorized
61592Srgrimes * to license or distribute it to anyone else except as part of a product or
71592Srgrimes * program developed by the user.
81592Srgrimes *
91592Srgrimes * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
101592Srgrimes * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
111592Srgrimes * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
12262136Sbrueffer *
131592Srgrimes * Sun RPC is provided with no support and without any obligation on the
141592Srgrimes * part of Sun Microsystems, Inc. to assist in its use, correction,
151592Srgrimes * modification or enhancement.
161592Srgrimes *
171592Srgrimes * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
181592Srgrimes * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
191592Srgrimes * OR ANY PART THEREOF.
201592Srgrimes *
211592Srgrimes * In no event will Sun Microsystems, Inc. be liable for any lost revenue
221592Srgrimes * or profits or other special, indirect and consequential damages, even if
231592Srgrimes * Sun has been advised of the possibility of such damages.
241592Srgrimes *
251592Srgrimes * Sun Microsystems, Inc.
261592Srgrimes * 2550 Garcia Avenue
271592Srgrimes * Mountain View, California  94043
281592Srgrimes *
2950476Speter *	from: @(#)rpc_msg.h 1.7 86/07/16 SMI
301592Srgrimes *	from: @(#)rpc_msg.h	2.1 88/07/29 4.0 RPCSRC
31240506Seadler *	$Id: rpc_msg.h,v 1.8 1997/02/23 09:17:24 peter Exp $
321592Srgrimes */
3379529Sru
341592Srgrimes/*
351592Srgrimes * rpc_msg.h
361592Srgrimes * rpc message definition
371592Srgrimes *
3868949Sru * Copyright (C) 1984, Sun Microsystems, Inc.
391592Srgrimes */
4099500Scharnier
4199500Scharnier#ifndef _RPC_RPCMSG_H
4299500Scharnier#define _RPC_RPCMSG_H
431592Srgrimes#include <rpc/types.h>
4499500Scharnier#include <rpc/xdr.h>
4599500Scharnier#include <rpc/auth.h>
4699500Scharnier
471592Srgrimes#define RPC_MSG_VERSION		((u_long) 2)
481592Srgrimes#define RPC_SERVICE_PORT	((u_short) 2048)
491592Srgrimes
501592Srgrimes/*
511592Srgrimes * Bottom up definition of an rpc message.
521592Srgrimes * NOTE: call and reply use the same overall stuct but
531592Srgrimes * different parts of unions within it.
541592Srgrimes */
55101783Sru
561592Srgrimesenum msg_type {
571592Srgrimes	CALL=0,
58101783Sru	REPLY=1
591592Srgrimes};
601592Srgrimes
61101783Sruenum reply_stat {
621592Srgrimes	MSG_ACCEPTED=0,
63101783Sru	MSG_DENIED=1
641592Srgrimes};
651592Srgrimes
66101783Sruenum accept_stat {
67101783Sru	SUCCESS=0,
681592Srgrimes	PROG_UNAVAIL=1,
69101783Sru	PROG_MISMATCH=2,
70101783Sru	PROC_UNAVAIL=3,
71101783Sru	GARBAGE_ARGS=4,
721592Srgrimes	SYSTEM_ERR=5
73101783Sru};
741592Srgrimes
753618Sacheenum reject_stat {
7699632Sjohan	RPC_MISMATCH=0,
77101783Sru	AUTH_ERROR=1
7899632Sjohan};
7999632Sjohan
80101783Sru/*
81101783Sru * Reply part of an rpc exchange
82101783Sru */
83101783Sru
8499632Sjohan/*
85101783Sru * Reply to an rpc request that was accepted by the server.
86101783Sru * Note: there could be an error even though the request was
87101783Sru * accepted.
881592Srgrimes */
89101783Srustruct accepted_reply {
90202756Sed	struct opaque_auth	ar_verf;
91141851Sru	enum accept_stat	ar_stat;
923618Sache	union {
933618Sache		struct {
941592Srgrimes			u_int32_t	low;
951592Srgrimes			u_int32_t	high;
961592Srgrimes		} AR_versions;
971592Srgrimes		struct {
98140414Sru			caddr_t	where;
99140414Sru			xdrproc_t proc;
100140414Sru		} AR_results;
101140414Sru		/* and many other null cases */
102140414Sru	} ru;
1031592Srgrimes#define	ar_results	ru.AR_results
1041592Srgrimes#define	ar_vers		ru.AR_versions
1051592Srgrimes};
1061592Srgrimes
1071592Srgrimes/*
1081592Srgrimes * Reply to an rpc request that was rejected by the server.
1091592Srgrimes */
1101592Srgrimesstruct rejected_reply {
1111592Srgrimes	enum reject_stat rj_stat;
112	union {
113		struct {
114			u_int32_t low;
115			u_int32_t high;
116		} RJ_versions;
117		enum auth_stat RJ_why;  /* why authentication did not work */
118	} ru;
119#define	rj_vers	ru.RJ_versions
120#define	rj_why	ru.RJ_why
121};
122
123/*
124 * Body of a reply to an rpc request.
125 */
126struct reply_body {
127	enum reply_stat rp_stat;
128	union {
129		struct accepted_reply RP_ar;
130		struct rejected_reply RP_dr;
131	} ru;
132#define	rp_acpt	ru.RP_ar
133#define	rp_rjct	ru.RP_dr
134};
135
136/*
137 * Body of an rpc request call.
138 */
139struct call_body {
140	u_int32_t cb_rpcvers;	/* must be equal to two */
141	u_int32_t cb_prog;
142	u_int32_t cb_vers;
143	u_int32_t cb_proc;
144	struct opaque_auth cb_cred;
145	struct opaque_auth cb_verf; /* protocol specific - provided by client */
146};
147
148/*
149 * The rpc message
150 */
151struct rpc_msg {
152	u_int32_t		rm_xid;
153	enum msg_type		rm_direction;
154	union {
155		struct call_body RM_cmb;
156		struct reply_body RM_rmb;
157	} ru;
158#define	rm_call		ru.RM_cmb
159#define	rm_reply	ru.RM_rmb
160};
161#define	acpted_rply	ru.RM_rmb.ru.RP_ar
162#define	rjcted_rply	ru.RM_rmb.ru.RP_dr
163
164__BEGIN_DECLS
165/*
166 * XDR routine to handle a rpc message.
167 * xdr_callmsg(xdrs, cmsg)
168 * 	XDR *xdrs;
169 * 	struct rpc_msg *cmsg;
170 */
171extern bool_t	xdr_callmsg	__P((XDR *, struct rpc_msg *));
172
173/*
174 * XDR routine to pre-serialize the static part of a rpc message.
175 * xdr_callhdr(xdrs, cmsg)
176 * 	XDR *xdrs;
177 * 	struct rpc_msg *cmsg;
178 */
179extern bool_t	xdr_callhdr	__P((XDR *, struct rpc_msg *));
180
181/*
182 * XDR routine to handle a rpc reply.
183 * xdr_replymsg(xdrs, rmsg)
184 * 	XDR *xdrs;
185 * 	struct rpc_msg *rmsg;
186 */
187extern bool_t	xdr_replymsg	__P((XDR *, struct rpc_msg *));
188
189/*
190 * Fills in the error part of a reply message.
191 * _seterr_reply(msg, error)
192 * 	struct rpc_msg *msg;
193 * 	struct rpc_err *error;
194 */
195struct rpc_err;
196extern void	_seterr_reply	__P((struct rpc_msg *, struct rpc_err *));
197__END_DECLS
198
199#endif /* !_RPC_RPCMSG_H */
200