xref: /onnv-gate/usr/src/lib/libbc/inc/include/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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
23*0Sstevel@tonic-gate 
24*0Sstevel@tonic-gate /*
25*0Sstevel@tonic-gate  * rpc message definition
26*0Sstevel@tonic-gate  *
27*0Sstevel@tonic-gate  * Copyright (C) 1984, Sun Microsystems, Inc.
28*0Sstevel@tonic-gate  */
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #ifndef _rpc_rpc_msg_h
31*0Sstevel@tonic-gate #define	_rpc_rpc_msg_h
32*0Sstevel@tonic-gate 
33*0Sstevel@tonic-gate #define	RPC_MSG_VERSION		((u_long) 2)
34*0Sstevel@tonic-gate #define	RPC_SERVICE_PORT	((u_short) 2048)
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate /*
37*0Sstevel@tonic-gate  * Bottom up definition of an rpc message.
38*0Sstevel@tonic-gate  * NOTE: call and reply use the same overall stuct but
39*0Sstevel@tonic-gate  * different parts of unions within it.
40*0Sstevel@tonic-gate  */
41*0Sstevel@tonic-gate 
42*0Sstevel@tonic-gate enum msg_type {
43*0Sstevel@tonic-gate 	CALL=0,
44*0Sstevel@tonic-gate 	REPLY=1
45*0Sstevel@tonic-gate };
46*0Sstevel@tonic-gate 
47*0Sstevel@tonic-gate enum reply_stat {
48*0Sstevel@tonic-gate 	MSG_ACCEPTED=0,
49*0Sstevel@tonic-gate 	MSG_DENIED=1
50*0Sstevel@tonic-gate };
51*0Sstevel@tonic-gate 
52*0Sstevel@tonic-gate enum accept_stat {
53*0Sstevel@tonic-gate 	SUCCESS=0,
54*0Sstevel@tonic-gate 	PROG_UNAVAIL=1,
55*0Sstevel@tonic-gate 	PROG_MISMATCH=2,
56*0Sstevel@tonic-gate 	PROC_UNAVAIL=3,
57*0Sstevel@tonic-gate 	GARBAGE_ARGS=4,
58*0Sstevel@tonic-gate 	SYSTEM_ERR=5
59*0Sstevel@tonic-gate };
60*0Sstevel@tonic-gate 
61*0Sstevel@tonic-gate enum reject_stat {
62*0Sstevel@tonic-gate 	RPC_MISMATCH=0,
63*0Sstevel@tonic-gate 	AUTH_ERROR=1
64*0Sstevel@tonic-gate };
65*0Sstevel@tonic-gate 
66*0Sstevel@tonic-gate /*
67*0Sstevel@tonic-gate  * Reply part of an rpc exchange
68*0Sstevel@tonic-gate  */
69*0Sstevel@tonic-gate 
70*0Sstevel@tonic-gate /*
71*0Sstevel@tonic-gate  * Reply to an rpc request that was accepted by the server.
72*0Sstevel@tonic-gate  * Note: there could be an error even though the request was
73*0Sstevel@tonic-gate  * accepted.
74*0Sstevel@tonic-gate  */
75*0Sstevel@tonic-gate struct accepted_reply {
76*0Sstevel@tonic-gate 	struct opaque_auth	ar_verf;
77*0Sstevel@tonic-gate 	enum accept_stat	ar_stat;
78*0Sstevel@tonic-gate 	union {
79*0Sstevel@tonic-gate 		struct {
80*0Sstevel@tonic-gate 			u_long	low;
81*0Sstevel@tonic-gate 			u_long	high;
82*0Sstevel@tonic-gate 		} AR_versions;
83*0Sstevel@tonic-gate 		struct {
84*0Sstevel@tonic-gate 			caddr_t	where;
85*0Sstevel@tonic-gate 			xdrproc_t proc;
86*0Sstevel@tonic-gate 		} AR_results;
87*0Sstevel@tonic-gate 		/* and many other null cases */
88*0Sstevel@tonic-gate 	} ru;
89*0Sstevel@tonic-gate #define	ar_results	ru.AR_results
90*0Sstevel@tonic-gate #define	ar_vers		ru.AR_versions
91*0Sstevel@tonic-gate };
92*0Sstevel@tonic-gate 
93*0Sstevel@tonic-gate /*
94*0Sstevel@tonic-gate  * Reply to an rpc request that was rejected by the server.
95*0Sstevel@tonic-gate  */
96*0Sstevel@tonic-gate struct rejected_reply {
97*0Sstevel@tonic-gate 	enum reject_stat rj_stat;
98*0Sstevel@tonic-gate 	union {
99*0Sstevel@tonic-gate 		struct {
100*0Sstevel@tonic-gate 			u_long low;
101*0Sstevel@tonic-gate 			u_long high;
102*0Sstevel@tonic-gate 		} RJ_versions;
103*0Sstevel@tonic-gate 		enum auth_stat RJ_why;  /* why authentication did not work */
104*0Sstevel@tonic-gate 	} ru;
105*0Sstevel@tonic-gate #define	rj_vers	ru.RJ_versions
106*0Sstevel@tonic-gate #define	rj_why	ru.RJ_why
107*0Sstevel@tonic-gate };
108*0Sstevel@tonic-gate 
109*0Sstevel@tonic-gate /*
110*0Sstevel@tonic-gate  * Body of a reply to an rpc request.
111*0Sstevel@tonic-gate  */
112*0Sstevel@tonic-gate struct reply_body {
113*0Sstevel@tonic-gate 	enum reply_stat rp_stat;
114*0Sstevel@tonic-gate 	union {
115*0Sstevel@tonic-gate 		struct accepted_reply RP_ar;
116*0Sstevel@tonic-gate 		struct rejected_reply RP_dr;
117*0Sstevel@tonic-gate 	} ru;
118*0Sstevel@tonic-gate #define	rp_acpt	ru.RP_ar
119*0Sstevel@tonic-gate #define	rp_rjct	ru.RP_dr
120*0Sstevel@tonic-gate };
121*0Sstevel@tonic-gate 
122*0Sstevel@tonic-gate /*
123*0Sstevel@tonic-gate  * Body of an rpc request call.
124*0Sstevel@tonic-gate  */
125*0Sstevel@tonic-gate struct call_body {
126*0Sstevel@tonic-gate 	u_long cb_rpcvers;	/* must be equal to two */
127*0Sstevel@tonic-gate 	u_long cb_prog;
128*0Sstevel@tonic-gate 	u_long cb_vers;
129*0Sstevel@tonic-gate 	u_long cb_proc;
130*0Sstevel@tonic-gate 	struct opaque_auth cb_cred;
131*0Sstevel@tonic-gate 	struct opaque_auth cb_verf; /* protocol specific - provided by client */
132*0Sstevel@tonic-gate };
133*0Sstevel@tonic-gate 
134*0Sstevel@tonic-gate /*
135*0Sstevel@tonic-gate  * The rpc message
136*0Sstevel@tonic-gate  */
137*0Sstevel@tonic-gate struct rpc_msg {
138*0Sstevel@tonic-gate 	u_long			rm_xid;
139*0Sstevel@tonic-gate 	enum msg_type		rm_direction;
140*0Sstevel@tonic-gate 	union {
141*0Sstevel@tonic-gate 		struct call_body RM_cmb;
142*0Sstevel@tonic-gate 		struct reply_body RM_rmb;
143*0Sstevel@tonic-gate 	} ru;
144*0Sstevel@tonic-gate #define	rm_call		ru.RM_cmb
145*0Sstevel@tonic-gate #define	rm_reply	ru.RM_rmb
146*0Sstevel@tonic-gate };
147*0Sstevel@tonic-gate #define	acpted_rply	ru.RM_rmb.ru.RP_ar
148*0Sstevel@tonic-gate #define	rjcted_rply	ru.RM_rmb.ru.RP_dr
149*0Sstevel@tonic-gate 
150*0Sstevel@tonic-gate 
151*0Sstevel@tonic-gate /*
152*0Sstevel@tonic-gate  * XDR routine to handle a rpc message.
153*0Sstevel@tonic-gate  * xdr_callmsg(xdrs, cmsg)
154*0Sstevel@tonic-gate  * 	XDR *xdrs;
155*0Sstevel@tonic-gate  * 	struct rpc_msg *cmsg;
156*0Sstevel@tonic-gate  */
157*0Sstevel@tonic-gate extern bool_t	xdr_callmsg();
158*0Sstevel@tonic-gate 
159*0Sstevel@tonic-gate /*
160*0Sstevel@tonic-gate  * XDR routine to pre-serialize the static part of a rpc message.
161*0Sstevel@tonic-gate  * xdr_callhdr(xdrs, cmsg)
162*0Sstevel@tonic-gate  * 	XDR *xdrs;
163*0Sstevel@tonic-gate  * 	struct rpc_msg *cmsg;
164*0Sstevel@tonic-gate  */
165*0Sstevel@tonic-gate extern bool_t	xdr_callhdr();
166*0Sstevel@tonic-gate 
167*0Sstevel@tonic-gate /*
168*0Sstevel@tonic-gate  * XDR routine to handle a rpc reply.
169*0Sstevel@tonic-gate  * xdr_replymsg(xdrs, rmsg)
170*0Sstevel@tonic-gate  * 	XDR *xdrs;
171*0Sstevel@tonic-gate  * 	struct rpc_msg *rmsg;
172*0Sstevel@tonic-gate  */
173*0Sstevel@tonic-gate extern bool_t	xdr_replymsg();
174*0Sstevel@tonic-gate 
175*0Sstevel@tonic-gate /*
176*0Sstevel@tonic-gate  * Fills in the error part of a reply message.
177*0Sstevel@tonic-gate  * _seterr_reply(msg, error)
178*0Sstevel@tonic-gate  * 	struct rpc_msg *msg;
179*0Sstevel@tonic-gate  * 	struct rpc_err *error;
180*0Sstevel@tonic-gate  */
181*0Sstevel@tonic-gate extern void	_seterr_reply();
182*0Sstevel@tonic-gate 
183*0Sstevel@tonic-gate #endif /*!_rpc_rpc_msg_h*/
184