xref: /onnv-gate/usr/src/uts/common/rpc/rpc_msg.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
27*0Sstevel@tonic-gate /* All Rights Reserved */
28*0Sstevel@tonic-gate /*
29*0Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley
30*0Sstevel@tonic-gate  * 4.3 BSD under license from the Regents of the University of
31*0Sstevel@tonic-gate  * California.
32*0Sstevel@tonic-gate  */
33*0Sstevel@tonic-gate 
34*0Sstevel@tonic-gate #ifndef _RPC_RPC_MSG_H
35*0Sstevel@tonic-gate #define	_RPC_RPC_MSG_H
36*0Sstevel@tonic-gate 
37*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
38*0Sstevel@tonic-gate 
39*0Sstevel@tonic-gate #include <rpc/clnt.h>
40*0Sstevel@tonic-gate /*
41*0Sstevel@tonic-gate  * rpc_msg.h
42*0Sstevel@tonic-gate  * rpc message definition
43*0Sstevel@tonic-gate  */
44*0Sstevel@tonic-gate 
45*0Sstevel@tonic-gate #ifdef __cplusplus
46*0Sstevel@tonic-gate extern "C" {
47*0Sstevel@tonic-gate #endif
48*0Sstevel@tonic-gate 
49*0Sstevel@tonic-gate #define	RPC_MSG_VERSION		((uint32_t)2)
50*0Sstevel@tonic-gate #define	RPC_SERVICE_PORT	((ushort_t)2048)
51*0Sstevel@tonic-gate 
52*0Sstevel@tonic-gate /*
53*0Sstevel@tonic-gate  * Bottom up definition of an rpc message.
54*0Sstevel@tonic-gate  * NOTE: call and reply use the same overall stuct but
55*0Sstevel@tonic-gate  * different parts of unions within it.
56*0Sstevel@tonic-gate  */
57*0Sstevel@tonic-gate 
58*0Sstevel@tonic-gate enum msg_type {
59*0Sstevel@tonic-gate 	CALL = 0,
60*0Sstevel@tonic-gate 	REPLY = 1
61*0Sstevel@tonic-gate };
62*0Sstevel@tonic-gate 
63*0Sstevel@tonic-gate enum reply_stat {
64*0Sstevel@tonic-gate 	MSG_ACCEPTED = 0,
65*0Sstevel@tonic-gate 	MSG_DENIED = 1
66*0Sstevel@tonic-gate };
67*0Sstevel@tonic-gate 
68*0Sstevel@tonic-gate enum accept_stat {
69*0Sstevel@tonic-gate 	SUCCESS = 0,
70*0Sstevel@tonic-gate 	PROG_UNAVAIL = 1,
71*0Sstevel@tonic-gate 	PROG_MISMATCH = 2,
72*0Sstevel@tonic-gate 	PROC_UNAVAIL = 3,
73*0Sstevel@tonic-gate 	GARBAGE_ARGS = 4,
74*0Sstevel@tonic-gate 	SYSTEM_ERR = 5
75*0Sstevel@tonic-gate };
76*0Sstevel@tonic-gate 
77*0Sstevel@tonic-gate enum reject_stat {
78*0Sstevel@tonic-gate 	RPC_MISMATCH = 0,
79*0Sstevel@tonic-gate 	AUTH_ERROR = 1
80*0Sstevel@tonic-gate };
81*0Sstevel@tonic-gate 
82*0Sstevel@tonic-gate /*
83*0Sstevel@tonic-gate  * Reply part of an rpc exchange
84*0Sstevel@tonic-gate  */
85*0Sstevel@tonic-gate 
86*0Sstevel@tonic-gate /*
87*0Sstevel@tonic-gate  * Reply to an rpc request that was accepted by the server.
88*0Sstevel@tonic-gate  * Note: there could be an error even though the request was
89*0Sstevel@tonic-gate  * accepted.
90*0Sstevel@tonic-gate  */
91*0Sstevel@tonic-gate struct accepted_reply {
92*0Sstevel@tonic-gate 	struct opaque_auth	ar_verf;
93*0Sstevel@tonic-gate 	enum accept_stat	ar_stat;
94*0Sstevel@tonic-gate 	union {
95*0Sstevel@tonic-gate 		struct {
96*0Sstevel@tonic-gate 			rpcvers_t low;
97*0Sstevel@tonic-gate 			rpcvers_t high;
98*0Sstevel@tonic-gate 		} AR_versions;
99*0Sstevel@tonic-gate 		struct {
100*0Sstevel@tonic-gate 			caddr_t	where;
101*0Sstevel@tonic-gate 			xdrproc_t proc;
102*0Sstevel@tonic-gate 		} AR_results;
103*0Sstevel@tonic-gate 		/* and many other null cases */
104*0Sstevel@tonic-gate 	} ru;
105*0Sstevel@tonic-gate #define	ar_results	ru.AR_results
106*0Sstevel@tonic-gate #define	ar_vers		ru.AR_versions
107*0Sstevel@tonic-gate };
108*0Sstevel@tonic-gate 
109*0Sstevel@tonic-gate /*
110*0Sstevel@tonic-gate  * Reply to an rpc request that was rejected by the server.
111*0Sstevel@tonic-gate  */
112*0Sstevel@tonic-gate struct rejected_reply {
113*0Sstevel@tonic-gate 	enum reject_stat rj_stat;
114*0Sstevel@tonic-gate 	union {
115*0Sstevel@tonic-gate 		struct {
116*0Sstevel@tonic-gate 			rpcvers_t low;
117*0Sstevel@tonic-gate 			rpcvers_t high;
118*0Sstevel@tonic-gate 		} RJ_versions;
119*0Sstevel@tonic-gate 		enum auth_stat RJ_why;  /* why authentication did not work */
120*0Sstevel@tonic-gate 	} ru;
121*0Sstevel@tonic-gate #define	rj_vers	ru.RJ_versions
122*0Sstevel@tonic-gate #define	rj_why	ru.RJ_why
123*0Sstevel@tonic-gate };
124*0Sstevel@tonic-gate 
125*0Sstevel@tonic-gate /*
126*0Sstevel@tonic-gate  * Body of a reply to an rpc request.
127*0Sstevel@tonic-gate  */
128*0Sstevel@tonic-gate struct reply_body {
129*0Sstevel@tonic-gate 	enum reply_stat rp_stat;
130*0Sstevel@tonic-gate 	union {
131*0Sstevel@tonic-gate 		struct accepted_reply RP_ar;
132*0Sstevel@tonic-gate 		struct rejected_reply RP_dr;
133*0Sstevel@tonic-gate 	} ru;
134*0Sstevel@tonic-gate #define	rp_acpt	ru.RP_ar
135*0Sstevel@tonic-gate #define	rp_rjct	ru.RP_dr
136*0Sstevel@tonic-gate };
137*0Sstevel@tonic-gate 
138*0Sstevel@tonic-gate /*
139*0Sstevel@tonic-gate  * Body of an rpc request call.
140*0Sstevel@tonic-gate  */
141*0Sstevel@tonic-gate struct call_body {
142*0Sstevel@tonic-gate 	rpcvers_t cb_rpcvers;	/* must be equal to two */
143*0Sstevel@tonic-gate 	rpcprog_t cb_prog;
144*0Sstevel@tonic-gate 	rpcvers_t cb_vers;
145*0Sstevel@tonic-gate 	rpcproc_t cb_proc;
146*0Sstevel@tonic-gate 	struct opaque_auth cb_cred;
147*0Sstevel@tonic-gate 	struct opaque_auth cb_verf; /* protocol specific - provided by client */
148*0Sstevel@tonic-gate };
149*0Sstevel@tonic-gate 
150*0Sstevel@tonic-gate /*
151*0Sstevel@tonic-gate  * The rpc message
152*0Sstevel@tonic-gate  */
153*0Sstevel@tonic-gate struct rpc_msg {
154*0Sstevel@tonic-gate 	uint32_t		rm_xid;
155*0Sstevel@tonic-gate 	enum msg_type		rm_direction;
156*0Sstevel@tonic-gate 	union {
157*0Sstevel@tonic-gate 		struct call_body RM_cmb;
158*0Sstevel@tonic-gate 		struct reply_body RM_rmb;
159*0Sstevel@tonic-gate 	} ru;
160*0Sstevel@tonic-gate #define	rm_call		ru.RM_cmb
161*0Sstevel@tonic-gate #define	rm_reply	ru.RM_rmb
162*0Sstevel@tonic-gate };
163*0Sstevel@tonic-gate #define	acpted_rply	ru.RM_rmb.ru.RP_ar
164*0Sstevel@tonic-gate #define	rjcted_rply	ru.RM_rmb.ru.RP_dr
165*0Sstevel@tonic-gate 
166*0Sstevel@tonic-gate 
167*0Sstevel@tonic-gate /*
168*0Sstevel@tonic-gate  * XDR routine to handle a rpc message.
169*0Sstevel@tonic-gate  * xdr_callmsg(xdrs, cmsg)
170*0Sstevel@tonic-gate  * 	XDR *xdrs;
171*0Sstevel@tonic-gate  * 	struct rpc_msg *cmsg;
172*0Sstevel@tonic-gate  */
173*0Sstevel@tonic-gate #ifdef __STDC__
174*0Sstevel@tonic-gate extern bool_t	xdr_callmsg(XDR *, struct rpc_msg *);
175*0Sstevel@tonic-gate #else
176*0Sstevel@tonic-gate extern bool_t	xdr_callmsg();
177*0Sstevel@tonic-gate #endif
178*0Sstevel@tonic-gate 
179*0Sstevel@tonic-gate 
180*0Sstevel@tonic-gate /*
181*0Sstevel@tonic-gate  * XDR routine to pre-serialize the static part of a rpc message.
182*0Sstevel@tonic-gate  * xdr_callhdr(xdrs, cmsg)
183*0Sstevel@tonic-gate  * 	XDR *xdrs;
184*0Sstevel@tonic-gate  * 	struct rpc_msg *cmsg;
185*0Sstevel@tonic-gate  */
186*0Sstevel@tonic-gate #ifdef __STDC__
187*0Sstevel@tonic-gate extern bool_t	xdr_callhdr(XDR *, struct rpc_msg *);
188*0Sstevel@tonic-gate #else
189*0Sstevel@tonic-gate extern bool_t	xdr_callhdr();
190*0Sstevel@tonic-gate #endif
191*0Sstevel@tonic-gate 
192*0Sstevel@tonic-gate 
193*0Sstevel@tonic-gate /*
194*0Sstevel@tonic-gate  * XDR routine to handle a rpc reply.
195*0Sstevel@tonic-gate  * xdr_replymsg(xdrs, rmsg)
196*0Sstevel@tonic-gate  * 	XDR *xdrs;
197*0Sstevel@tonic-gate  * 	struct rpc_msg *rmsg;
198*0Sstevel@tonic-gate  *
199*0Sstevel@tonic-gate  * xdr_accepted_reply(xdrs, ar)
200*0Sstevel@tonic-gate  *	XDR *xdrs;
201*0Sstevel@tonic-gate  *	const struct accepted_reply *ar;
202*0Sstevel@tonic-gate  *
203*0Sstevel@tonic-gate  * xdr_rejected_reply(xdrs, rr)
204*0Sstevel@tonic-gate  *	XDR *xdrs;
205*0Sstevel@tonic-gate  *	const struct rejected_reply *rr;
206*0Sstevel@tonic-gate  */
207*0Sstevel@tonic-gate #ifdef __STDC__
208*0Sstevel@tonic-gate extern bool_t	xdr_replymsg(XDR *, struct rpc_msg *);
209*0Sstevel@tonic-gate extern bool_t	xdr_accepted_reply(XDR *, struct accepted_reply *);
210*0Sstevel@tonic-gate extern bool_t	xdr_rejected_reply(XDR *, struct rejected_reply *);
211*0Sstevel@tonic-gate #else
212*0Sstevel@tonic-gate extern bool_t	xdr_replymsg();
213*0Sstevel@tonic-gate extern bool_t	xdr_accepted_reply();
214*0Sstevel@tonic-gate extern bool_t	xdr_rejected_reply();
215*0Sstevel@tonic-gate #endif
216*0Sstevel@tonic-gate 
217*0Sstevel@tonic-gate 
218*0Sstevel@tonic-gate #ifdef _KERNEL
219*0Sstevel@tonic-gate /*
220*0Sstevel@tonic-gate  * Fills in the error part of a reply message.
221*0Sstevel@tonic-gate  * _seterr_reply(msg, error)
222*0Sstevel@tonic-gate  * 	struct rpc_msg *msg;
223*0Sstevel@tonic-gate  * 	struct rpc_err *error;
224*0Sstevel@tonic-gate  */
225*0Sstevel@tonic-gate #ifdef __STDC__
226*0Sstevel@tonic-gate extern void	_seterr_reply(struct rpc_msg *, struct rpc_err *);
227*0Sstevel@tonic-gate #else
228*0Sstevel@tonic-gate extern void	_seterr_reply();
229*0Sstevel@tonic-gate #endif
230*0Sstevel@tonic-gate #else
231*0Sstevel@tonic-gate /*
232*0Sstevel@tonic-gate  * Fills in the error part of a reply message.
233*0Sstevel@tonic-gate  * __seterr_reply(msg, error)
234*0Sstevel@tonic-gate  * 	struct rpc_msg *msg;
235*0Sstevel@tonic-gate  * 	struct rpc_err *error;
236*0Sstevel@tonic-gate  */
237*0Sstevel@tonic-gate #ifdef __STDC__
238*0Sstevel@tonic-gate extern void	__seterr_reply(struct rpc_msg *, struct rpc_err *);
239*0Sstevel@tonic-gate #else
240*0Sstevel@tonic-gate extern void	__seterr_reply();
241*0Sstevel@tonic-gate #endif
242*0Sstevel@tonic-gate #endif
243*0Sstevel@tonic-gate 
244*0Sstevel@tonic-gate #ifdef _KERNEL
245*0Sstevel@tonic-gate /*
246*0Sstevel@tonic-gate  * Frees any verifier that xdr_replymsg() (DECODE) allocated.
247*0Sstevel@tonic-gate  */
248*0Sstevel@tonic-gate bool_t xdr_rpc_free_verifier(register XDR *xdrs, register struct rpc_msg *msg);
249*0Sstevel@tonic-gate 
250*0Sstevel@tonic-gate #endif
251*0Sstevel@tonic-gate 
252*0Sstevel@tonic-gate #ifdef __cplusplus
253*0Sstevel@tonic-gate }
254*0Sstevel@tonic-gate #endif
255*0Sstevel@tonic-gate 
256*0Sstevel@tonic-gate #endif	/* _RPC_RPC_MSG_H */
257