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