xref: /netbsd/include/rpc/rpc_msg.h (revision 1ad8067c)
1*1ad8067cSwiz /*	$NetBSD: rpc_msg.h,v 1.15 2006/02/25 00:58:34 wiz Exp $	*/
24d2cbfceScgd 
3e63190e8Sderaadt /*
4e63190e8Sderaadt  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
5e63190e8Sderaadt  * unrestricted use provided that this legend is included on all tape
6e63190e8Sderaadt  * media and as a part of the software program in whole or part.  Users
7e63190e8Sderaadt  * may copy or modify Sun RPC without charge, but are not authorized
8e63190e8Sderaadt  * to license or distribute it to anyone else except as part of a product or
9e63190e8Sderaadt  * program developed by the user.
10e63190e8Sderaadt  *
11e63190e8Sderaadt  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
12e63190e8Sderaadt  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
13e63190e8Sderaadt  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
14e63190e8Sderaadt  *
15e63190e8Sderaadt  * Sun RPC is provided with no support and without any obligation on the
16e63190e8Sderaadt  * part of Sun Microsystems, Inc. to assist in its use, correction,
17e63190e8Sderaadt  * modification or enhancement.
18e63190e8Sderaadt  *
19e63190e8Sderaadt  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
20e63190e8Sderaadt  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
21e63190e8Sderaadt  * OR ANY PART THEREOF.
22e63190e8Sderaadt  *
23e63190e8Sderaadt  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
24e63190e8Sderaadt  * or profits or other special, indirect and consequential damages, even if
25e63190e8Sderaadt  * Sun has been advised of the possibility of such damages.
26e63190e8Sderaadt  *
27e63190e8Sderaadt  * Sun Microsystems, Inc.
28e63190e8Sderaadt  * 2550 Garcia Avenue
29e63190e8Sderaadt  * Mountain View, California  94043
30e9d867efSmycroft  *
31e9d867efSmycroft  *	from: @(#)rpc_msg.h 1.7 86/07/16 SMI
324d2cbfceScgd  *	@(#)rpc_msg.h	2.1 88/07/29 4.0 RPCSRC
33e63190e8Sderaadt  */
34e63190e8Sderaadt 
35e63190e8Sderaadt /*
36e63190e8Sderaadt  * rpc_msg.h
37423e29d2Slukem  * rpc message definition
38e63190e8Sderaadt  *
39e63190e8Sderaadt  * Copyright (C) 1984, Sun Microsystems, Inc.
40e63190e8Sderaadt  */
41e63190e8Sderaadt 
423d7d6c33Sperry #ifndef _RPC_RPC_MSG_H_
433d7d6c33Sperry #define _RPC_RPC_MSG_H_
44e9d4dc6eSbrezak 
455f65228bSperry #define RPC_MSG_VERSION		((uint32_t) 2)
46423e29d2Slukem #define RPC_SERVICE_PORT	((u_short) 2048)
47e63190e8Sderaadt 
48e63190e8Sderaadt /*
49423e29d2Slukem  * Bottom up definition of an rpc message.
50*1ad8067cSwiz  * NOTE: call and reply use the same overall struct but
51e63190e8Sderaadt  * different parts of unions within it.
52e63190e8Sderaadt  */
53e63190e8Sderaadt 
54e63190e8Sderaadt enum msg_type {
55e63190e8Sderaadt 	CALL=0,
56e63190e8Sderaadt 	REPLY=1
57e63190e8Sderaadt };
58e63190e8Sderaadt 
59e63190e8Sderaadt enum reply_stat {
60e63190e8Sderaadt 	MSG_ACCEPTED=0,
61e63190e8Sderaadt 	MSG_DENIED=1
62e63190e8Sderaadt };
63e63190e8Sderaadt 
64e63190e8Sderaadt enum accept_stat {
65e63190e8Sderaadt 	SUCCESS=0,
66e63190e8Sderaadt 	PROG_UNAVAIL=1,
67e63190e8Sderaadt 	PROG_MISMATCH=2,
68e63190e8Sderaadt 	PROC_UNAVAIL=3,
69e63190e8Sderaadt 	GARBAGE_ARGS=4,
70e63190e8Sderaadt 	SYSTEM_ERR=5
71e63190e8Sderaadt };
72e63190e8Sderaadt 
73e63190e8Sderaadt enum reject_stat {
74e63190e8Sderaadt 	RPC_MISMATCH=0,
75e63190e8Sderaadt 	AUTH_ERROR=1
76e63190e8Sderaadt };
77e63190e8Sderaadt 
78e63190e8Sderaadt /*
79423e29d2Slukem  * Reply part of an rpc exchange
80e63190e8Sderaadt  */
81e63190e8Sderaadt 
82e63190e8Sderaadt /*
83423e29d2Slukem  * Reply to an rpc request that was accepted by the server.
84e63190e8Sderaadt  * Note: there could be an error even though the request was
85e63190e8Sderaadt  * accepted.
86e63190e8Sderaadt  */
87e63190e8Sderaadt struct accepted_reply {
88e63190e8Sderaadt 	struct opaque_auth	ar_verf;
89e63190e8Sderaadt 	enum accept_stat	ar_stat;
90e63190e8Sderaadt 	union {
91e63190e8Sderaadt 		struct {
92c257a3b3Sfvdl 			rpcvers_t low;
93c257a3b3Sfvdl 			rpcvers_t high;
94e63190e8Sderaadt 		} AR_versions;
95e63190e8Sderaadt 		struct {
96347f995cSyamt 			const char *where;
97e63190e8Sderaadt 			xdrproc_t proc;
98e63190e8Sderaadt 		} AR_results;
99e63190e8Sderaadt 		/* and many other null cases */
100e63190e8Sderaadt 	} ru;
101e63190e8Sderaadt #define	ar_results	ru.AR_results
102e63190e8Sderaadt #define	ar_vers		ru.AR_versions
103e63190e8Sderaadt };
104e63190e8Sderaadt 
105e63190e8Sderaadt /*
106423e29d2Slukem  * Reply to an rpc request that was rejected by the server.
107e63190e8Sderaadt  */
108e63190e8Sderaadt struct rejected_reply {
109e63190e8Sderaadt 	enum reject_stat rj_stat;
110e63190e8Sderaadt 	union {
111e63190e8Sderaadt 		struct {
112c257a3b3Sfvdl 			rpcvers_t low;
113c257a3b3Sfvdl 			rpcvers_t high;
114e63190e8Sderaadt 		} RJ_versions;
115e63190e8Sderaadt 		enum auth_stat RJ_why;  /* why authentication did not work */
116e63190e8Sderaadt 	} ru;
117e63190e8Sderaadt #define	rj_vers	ru.RJ_versions
118e63190e8Sderaadt #define	rj_why	ru.RJ_why
119e63190e8Sderaadt };
120e63190e8Sderaadt 
121e63190e8Sderaadt /*
122423e29d2Slukem  * Body of a reply to an rpc request.
123e63190e8Sderaadt  */
124e63190e8Sderaadt struct reply_body {
125e63190e8Sderaadt 	enum reply_stat rp_stat;
126e63190e8Sderaadt 	union {
127e63190e8Sderaadt 		struct accepted_reply RP_ar;
128e63190e8Sderaadt 		struct rejected_reply RP_dr;
129e63190e8Sderaadt 	} ru;
130e63190e8Sderaadt #define	rp_acpt	ru.RP_ar
131e63190e8Sderaadt #define	rp_rjct	ru.RP_dr
132e63190e8Sderaadt };
133e63190e8Sderaadt 
134e63190e8Sderaadt /*
135423e29d2Slukem  * Body of an rpc request call.
136e63190e8Sderaadt  */
137e63190e8Sderaadt struct call_body {
138c257a3b3Sfvdl 	rpcvers_t cb_rpcvers;	/* must be equal to two */
139c257a3b3Sfvdl 	rpcprog_t cb_prog;
140c257a3b3Sfvdl 	rpcvers_t cb_vers;
141c257a3b3Sfvdl 	rpcproc_t cb_proc;
142e63190e8Sderaadt 	struct opaque_auth cb_cred;
143e63190e8Sderaadt 	struct opaque_auth cb_verf; /* protocol specific - provided by client */
144e63190e8Sderaadt };
145e63190e8Sderaadt 
146e63190e8Sderaadt /*
147423e29d2Slukem  * The rpc message
148e63190e8Sderaadt  */
149e63190e8Sderaadt struct rpc_msg {
1505f65228bSperry 	uint32_t		rm_xid;
151e63190e8Sderaadt 	enum msg_type		rm_direction;
152e63190e8Sderaadt 	union {
153e63190e8Sderaadt 		struct call_body RM_cmb;
154e63190e8Sderaadt 		struct reply_body RM_rmb;
155e63190e8Sderaadt 	} ru;
156e63190e8Sderaadt #define	rm_call		ru.RM_cmb
157e63190e8Sderaadt #define	rm_reply	ru.RM_rmb
158e63190e8Sderaadt };
159e63190e8Sderaadt #define	acpted_rply	ru.RM_rmb.ru.RP_ar
160e63190e8Sderaadt #define	rjcted_rply	ru.RM_rmb.ru.RP_dr
161e63190e8Sderaadt 
162e9d4dc6eSbrezak __BEGIN_DECLS
163e63190e8Sderaadt /*
1648cc8e93aSlukem  * XDR routine to handle an rpc message.
165e63190e8Sderaadt  * xdr_callmsg(xdrs, cmsg)
166e63190e8Sderaadt  * 	XDR *xdrs;
167e63190e8Sderaadt  * 	struct rpc_msg *cmsg;
168e63190e8Sderaadt  */
16919b7469aSperry extern bool_t	xdr_callmsg	(XDR *, struct rpc_msg *);
170e63190e8Sderaadt 
171e63190e8Sderaadt /*
1728cc8e93aSlukem  * XDR routine to pre-serialize the static part of an rpc message.
173e63190e8Sderaadt  * xdr_callhdr(xdrs, cmsg)
174e63190e8Sderaadt  * 	XDR *xdrs;
175e63190e8Sderaadt  * 	struct rpc_msg *cmsg;
176e63190e8Sderaadt  */
17719b7469aSperry extern bool_t	xdr_callhdr	(XDR *, struct rpc_msg *);
178e63190e8Sderaadt 
179e63190e8Sderaadt /*
1808cc8e93aSlukem  * XDR routine to handle an rpc reply.
181e63190e8Sderaadt  * xdr_replymsg(xdrs, rmsg)
182e63190e8Sderaadt  * 	XDR *xdrs;
183e63190e8Sderaadt  * 	struct rpc_msg *rmsg;
184e63190e8Sderaadt  */
18519b7469aSperry extern bool_t	xdr_replymsg	(XDR *, struct rpc_msg *);
186e63190e8Sderaadt 
187c970a909Schristos 
188c970a909Schristos /*
189423e29d2Slukem  * XDR routine to handle a accepted rpc reply.
190c970a909Schristos  * xdr_accepted_reply(xdrs, rej)
191c970a909Schristos  * 	XDR *xdrs;
192c970a909Schristos  * 	struct accepted_reply *rej;
193c970a909Schristos  */
19419b7469aSperry extern bool_t	xdr_accepted_reply	(XDR *, struct accepted_reply *);
195c970a909Schristos 
196c970a909Schristos /*
197423e29d2Slukem  * XDR routine to handle a rejected rpc reply.
198c970a909Schristos  * xdr_rejected_reply(xdrs, rej)
199c970a909Schristos  * 	XDR *xdrs;
200c970a909Schristos  * 	struct rejected_reply *rej;
201c970a909Schristos  */
20219b7469aSperry extern bool_t	xdr_rejected_reply	(XDR *, struct rejected_reply *);
203c970a909Schristos 
204e63190e8Sderaadt /*
205e63190e8Sderaadt  * Fills in the error part of a reply message.
206e63190e8Sderaadt  * _seterr_reply(msg, error)
207e63190e8Sderaadt  * 	struct rpc_msg *msg;
208e63190e8Sderaadt  * 	struct rpc_err *error;
209e63190e8Sderaadt  */
21019b7469aSperry extern void	_seterr_reply	(struct rpc_msg *, struct rpc_err *);
211e9d4dc6eSbrezak __END_DECLS
212e9d4dc6eSbrezak 
2133d7d6c33Sperry #endif /* !_RPC_RPC_MSG_H_ */
214