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