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