xref: /freebsd/crypto/krb5/src/include/gssrpc/rpc_msg.h (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1*7f2fe78bSCy Schubert /* @(#)rpc_msg.h	2.1 88/07/29 4.0 RPCSRC */
2*7f2fe78bSCy Schubert /*
3*7f2fe78bSCy Schubert  * Copyright (c) 2010, Oracle America, Inc.
4*7f2fe78bSCy Schubert  *
5*7f2fe78bSCy Schubert  * All rights reserved.
6*7f2fe78bSCy Schubert  *
7*7f2fe78bSCy Schubert  * Redistribution and use in source and binary forms, with or without
8*7f2fe78bSCy Schubert  * modification, are permitted provided that the following conditions are met:
9*7f2fe78bSCy Schubert  *
10*7f2fe78bSCy Schubert  *     * Redistributions of source code must retain the above copyright
11*7f2fe78bSCy Schubert  *       notice, this list of conditions and the following disclaimer.
12*7f2fe78bSCy Schubert  *
13*7f2fe78bSCy Schubert  *     * Redistributions in binary form must reproduce the above copyright
14*7f2fe78bSCy Schubert  *       notice, this list of conditions and the following disclaimer in
15*7f2fe78bSCy Schubert  *       the documentation and/or other materials provided with the
16*7f2fe78bSCy Schubert  *       distribution.
17*7f2fe78bSCy Schubert  *
18*7f2fe78bSCy Schubert  *     * Neither the name of the "Oracle America, Inc." nor the names of
19*7f2fe78bSCy Schubert  *       its contributors may be used to endorse or promote products
20*7f2fe78bSCy Schubert  *       derived from this software without specific prior written permission.
21*7f2fe78bSCy Schubert  *
22*7f2fe78bSCy Schubert  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
23*7f2fe78bSCy Schubert  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24*7f2fe78bSCy Schubert  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25*7f2fe78bSCy Schubert  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26*7f2fe78bSCy Schubert  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27*7f2fe78bSCy Schubert  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
28*7f2fe78bSCy Schubert  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29*7f2fe78bSCy Schubert  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30*7f2fe78bSCy Schubert  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31*7f2fe78bSCy Schubert  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32*7f2fe78bSCy Schubert  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33*7f2fe78bSCy Schubert  */
34*7f2fe78bSCy Schubert /*      @(#)rpc_msg.h 1.7 86/07/16 SMI      */
35*7f2fe78bSCy Schubert 
36*7f2fe78bSCy Schubert /*
37*7f2fe78bSCy Schubert  * rpc_msg.h
38*7f2fe78bSCy Schubert  * rpc message definition
39*7f2fe78bSCy Schubert  */
40*7f2fe78bSCy Schubert 
41*7f2fe78bSCy Schubert #ifndef GSSRPC_RPC_MSG_H
42*7f2fe78bSCy Schubert #define GSSRPC_RPC_MSG_H
43*7f2fe78bSCy Schubert 
44*7f2fe78bSCy Schubert GSSRPC__BEGIN_DECLS
45*7f2fe78bSCy Schubert 
46*7f2fe78bSCy Schubert #define RPC_MSG_VERSION		((uint32_t) 2)
47*7f2fe78bSCy Schubert #define RPC_SERVICE_PORT	((u_short) 2048)
48*7f2fe78bSCy Schubert 
49*7f2fe78bSCy Schubert /*
50*7f2fe78bSCy Schubert  * Bottom up definition of an rpc message.
51*7f2fe78bSCy Schubert  * NOTE: call and reply use the same overall struct but
52*7f2fe78bSCy Schubert  * different parts of unions within it.
53*7f2fe78bSCy Schubert  */
54*7f2fe78bSCy Schubert 
55*7f2fe78bSCy Schubert enum msg_type {
56*7f2fe78bSCy Schubert 	CALL=0,
57*7f2fe78bSCy Schubert 	REPLY=1
58*7f2fe78bSCy Schubert };
59*7f2fe78bSCy Schubert 
60*7f2fe78bSCy Schubert enum reply_stat {
61*7f2fe78bSCy Schubert 	MSG_ACCEPTED=0,
62*7f2fe78bSCy Schubert 	MSG_DENIED=1
63*7f2fe78bSCy Schubert };
64*7f2fe78bSCy Schubert 
65*7f2fe78bSCy Schubert enum accept_stat {
66*7f2fe78bSCy Schubert 	SUCCESS=0,
67*7f2fe78bSCy Schubert 	PROG_UNAVAIL=1,
68*7f2fe78bSCy Schubert 	PROG_MISMATCH=2,
69*7f2fe78bSCy Schubert 	PROC_UNAVAIL=3,
70*7f2fe78bSCy Schubert 	GARBAGE_ARGS=4,
71*7f2fe78bSCy Schubert 	SYSTEM_ERR=5
72*7f2fe78bSCy Schubert };
73*7f2fe78bSCy Schubert 
74*7f2fe78bSCy Schubert enum reject_stat {
75*7f2fe78bSCy Schubert 	RPC_MISMATCH=0,
76*7f2fe78bSCy Schubert 	AUTH_ERROR=1
77*7f2fe78bSCy Schubert };
78*7f2fe78bSCy Schubert 
79*7f2fe78bSCy Schubert /*
80*7f2fe78bSCy Schubert  * Reply part of an rpc exchange
81*7f2fe78bSCy Schubert  */
82*7f2fe78bSCy Schubert 
83*7f2fe78bSCy Schubert /*
84*7f2fe78bSCy Schubert  * Reply to an rpc request that was accepted by the server.
85*7f2fe78bSCy Schubert  * Note: there could be an error even though the request was
86*7f2fe78bSCy Schubert  * accepted.
87*7f2fe78bSCy Schubert  */
88*7f2fe78bSCy Schubert struct accepted_reply {
89*7f2fe78bSCy Schubert 	struct opaque_auth	ar_verf;
90*7f2fe78bSCy Schubert 	enum accept_stat	ar_stat;
91*7f2fe78bSCy Schubert 	union {
92*7f2fe78bSCy Schubert 		struct {
93*7f2fe78bSCy Schubert 			rpcvers_t	low;
94*7f2fe78bSCy Schubert 			rpcvers_t	high;
95*7f2fe78bSCy Schubert 		} AR_versions;
96*7f2fe78bSCy Schubert 		struct {
97*7f2fe78bSCy Schubert 			caddr_t	where;
98*7f2fe78bSCy Schubert 			xdrproc_t proc;
99*7f2fe78bSCy Schubert 		} AR_results;
100*7f2fe78bSCy Schubert 		/* and many other null cases */
101*7f2fe78bSCy Schubert 	} ru;
102*7f2fe78bSCy Schubert #define	ar_results	ru.AR_results
103*7f2fe78bSCy Schubert #define	ar_vers		ru.AR_versions
104*7f2fe78bSCy Schubert };
105*7f2fe78bSCy Schubert 
106*7f2fe78bSCy Schubert /*
107*7f2fe78bSCy Schubert  * Reply to an rpc request that was rejected by the server.
108*7f2fe78bSCy Schubert  */
109*7f2fe78bSCy Schubert struct rejected_reply {
110*7f2fe78bSCy Schubert 	enum reject_stat rj_stat;
111*7f2fe78bSCy Schubert 	union {
112*7f2fe78bSCy Schubert 		struct {
113*7f2fe78bSCy Schubert 			rpcvers_t low;
114*7f2fe78bSCy Schubert 			rpcvers_t high;
115*7f2fe78bSCy Schubert 		} RJ_versions;
116*7f2fe78bSCy Schubert 		enum auth_stat RJ_why;  /* why authentication did not work */
117*7f2fe78bSCy Schubert 	} ru;
118*7f2fe78bSCy Schubert #define	rj_vers	ru.RJ_versions
119*7f2fe78bSCy Schubert #define	rj_why	ru.RJ_why
120*7f2fe78bSCy Schubert };
121*7f2fe78bSCy Schubert 
122*7f2fe78bSCy Schubert /*
123*7f2fe78bSCy Schubert  * Body of a reply to an rpc request.
124*7f2fe78bSCy Schubert  */
125*7f2fe78bSCy Schubert struct reply_body {
126*7f2fe78bSCy Schubert 	enum reply_stat rp_stat;
127*7f2fe78bSCy Schubert 	union {
128*7f2fe78bSCy Schubert 		struct accepted_reply RP_ar;
129*7f2fe78bSCy Schubert 		struct rejected_reply RP_dr;
130*7f2fe78bSCy Schubert 	} ru;
131*7f2fe78bSCy Schubert #define	rp_acpt	ru.RP_ar
132*7f2fe78bSCy Schubert #define	rp_rjct	ru.RP_dr
133*7f2fe78bSCy Schubert };
134*7f2fe78bSCy Schubert 
135*7f2fe78bSCy Schubert /*
136*7f2fe78bSCy Schubert  * Body of an rpc request call.
137*7f2fe78bSCy Schubert  */
138*7f2fe78bSCy Schubert struct call_body {
139*7f2fe78bSCy Schubert 	rpcvers_t cb_rpcvers;	/* must be equal to two */
140*7f2fe78bSCy Schubert 	rpcprog_t cb_prog;
141*7f2fe78bSCy Schubert 	rpcvers_t cb_vers;
142*7f2fe78bSCy Schubert 	rpcproc_t cb_proc;
143*7f2fe78bSCy Schubert 	struct opaque_auth cb_cred;
144*7f2fe78bSCy Schubert 	struct opaque_auth cb_verf; /* protocol specific - provided by client */
145*7f2fe78bSCy Schubert };
146*7f2fe78bSCy Schubert 
147*7f2fe78bSCy Schubert /*
148*7f2fe78bSCy Schubert  * The rpc message
149*7f2fe78bSCy Schubert  */
150*7f2fe78bSCy Schubert struct rpc_msg {
151*7f2fe78bSCy Schubert 	uint32_t		rm_xid;
152*7f2fe78bSCy Schubert 	enum msg_type		rm_direction;
153*7f2fe78bSCy Schubert 	union {
154*7f2fe78bSCy Schubert 		struct call_body RM_cmb;
155*7f2fe78bSCy Schubert 		struct reply_body RM_rmb;
156*7f2fe78bSCy Schubert 	} ru;
157*7f2fe78bSCy Schubert #define	rm_call		ru.RM_cmb
158*7f2fe78bSCy Schubert #define	rm_reply	ru.RM_rmb
159*7f2fe78bSCy Schubert };
160*7f2fe78bSCy Schubert #define	acpted_rply	ru.RM_rmb.ru.RP_ar
161*7f2fe78bSCy Schubert #define	rjcted_rply	ru.RM_rmb.ru.RP_dr
162*7f2fe78bSCy Schubert 
163*7f2fe78bSCy Schubert 
164*7f2fe78bSCy Schubert /*
165*7f2fe78bSCy Schubert  * XDR routine to handle a rpc message.
166*7f2fe78bSCy Schubert  * xdr_callmsg(xdrs, cmsg)
167*7f2fe78bSCy Schubert  * 	XDR *xdrs;
168*7f2fe78bSCy Schubert  * 	struct rpc_msg *cmsg;
169*7f2fe78bSCy Schubert  */
170*7f2fe78bSCy Schubert extern bool_t	xdr_callmsg(XDR *, struct rpc_msg *);
171*7f2fe78bSCy Schubert 
172*7f2fe78bSCy Schubert /*
173*7f2fe78bSCy Schubert  * XDR routine to pre-serialize the static part of a rpc message.
174*7f2fe78bSCy Schubert  * xdr_callhdr(xdrs, cmsg)
175*7f2fe78bSCy Schubert  * 	XDR *xdrs;
176*7f2fe78bSCy Schubert  * 	struct rpc_msg *cmsg;
177*7f2fe78bSCy Schubert  */
178*7f2fe78bSCy Schubert extern bool_t	xdr_callhdr(XDR *, struct rpc_msg *);
179*7f2fe78bSCy Schubert 
180*7f2fe78bSCy Schubert /*
181*7f2fe78bSCy Schubert  * XDR routine to handle a rpc reply.
182*7f2fe78bSCy Schubert  * xdr_replymsg(xdrs, rmsg)
183*7f2fe78bSCy Schubert  * 	XDR *xdrs;
184*7f2fe78bSCy Schubert  * 	struct rpc_msg *rmsg;
185*7f2fe78bSCy Schubert  */
186*7f2fe78bSCy Schubert extern bool_t	xdr_replymsg(XDR *, struct rpc_msg *);
187*7f2fe78bSCy Schubert 
188*7f2fe78bSCy Schubert /*
189*7f2fe78bSCy Schubert  * Fills in the error part of a reply message.
190*7f2fe78bSCy Schubert  * _seterr_reply(msg, error)
191*7f2fe78bSCy Schubert  * 	struct rpc_msg *msg;
192*7f2fe78bSCy Schubert  * 	struct rpc_err *error;
193*7f2fe78bSCy Schubert  */
194*7f2fe78bSCy Schubert /*
195*7f2fe78bSCy Schubert  * RENAMED: should be _seterr_reply or __seterr_reply if we can use
196*7f2fe78bSCy Schubert  * reserved namespace.
197*7f2fe78bSCy Schubert  */
198*7f2fe78bSCy Schubert extern void	gssrpc__seterr_reply(struct rpc_msg *, struct rpc_err *);
199*7f2fe78bSCy Schubert 
200*7f2fe78bSCy Schubert /* XDR the MSG_ACCEPTED part of a reply message union */
201*7f2fe78bSCy Schubert extern bool_t	xdr_accepted_reply(XDR *, struct accepted_reply *);
202*7f2fe78bSCy Schubert 
203*7f2fe78bSCy Schubert /* XDR the MSG_DENIED part of a reply message union */
204*7f2fe78bSCy Schubert extern bool_t	xdr_rejected_reply(XDR *, struct rejected_reply *);
205*7f2fe78bSCy Schubert GSSRPC__END_DECLS
206*7f2fe78bSCy Schubert 
207*7f2fe78bSCy Schubert #endif /* !defined(GSSRPC_RPC_MSG_H) */
208