rpc_msg.h revision 8858
11839Swollman/*
21839Swollman * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
31839Swollman * unrestricted use provided that this legend is included on all tape
41839Swollman * media and as a part of the software program in whole or part.  Users
51839Swollman * may copy or modify Sun RPC without charge, but are not authorized
61839Swollman * to license or distribute it to anyone else except as part of a product or
71839Swollman * program developed by the user.
88858Srgrimes *
91839Swollman * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
101839Swollman * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
111839Swollman * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
128858Srgrimes *
131839Swollman * Sun RPC is provided with no support and without any obligation on the
141839Swollman * part of Sun Microsystems, Inc. to assist in its use, correction,
151839Swollman * modification or enhancement.
168858Srgrimes *
171839Swollman * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
181839Swollman * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
191839Swollman * OR ANY PART THEREOF.
208858Srgrimes *
211839Swollman * In no event will Sun Microsystems, Inc. be liable for any lost revenue
221839Swollman * or profits or other special, indirect and consequential damages, even if
231839Swollman * Sun has been advised of the possibility of such damages.
248858Srgrimes *
251839Swollman * Sun Microsystems, Inc.
261839Swollman * 2550 Garcia Avenue
271839Swollman * Mountain View, California  94043
281903Swollman *
291903Swollman *	from: @(#)rpc_msg.h 1.7 86/07/16 SMI
301903Swollman *	from: @(#)rpc_msg.h	2.1 88/07/29 4.0 RPCSRC
318858Srgrimes *	$Id: rpc_msg.h,v 1.3 1995/03/12 12:13:37 bde Exp $
321839Swollman */
331839Swollman
341839Swollman/*
351839Swollman * rpc_msg.h
361839Swollman * rpc message definition
371839Swollman *
381839Swollman * Copyright (C) 1984, Sun Microsystems, Inc.
391839Swollman */
401839Swollman
411903Swollman#ifndef _RPC_RPCMSG_H
421903Swollman#define _RPC_RPCMSG_H
431903Swollman
441839Swollman#define RPC_MSG_VERSION		((u_long) 2)
451839Swollman#define RPC_SERVICE_PORT	((u_short) 2048)
461839Swollman
471839Swollman/*
481839Swollman * Bottom up definition of an rpc message.
491839Swollman * NOTE: call and reply use the same overall stuct but
501839Swollman * different parts of unions within it.
511839Swollman */
521839Swollman
531839Swollmanenum msg_type {
541839Swollman	CALL=0,
551839Swollman	REPLY=1
561839Swollman};
571839Swollman
581839Swollmanenum reply_stat {
591839Swollman	MSG_ACCEPTED=0,
601839Swollman	MSG_DENIED=1
611839Swollman};
621839Swollman
631839Swollmanenum accept_stat {
641839Swollman	SUCCESS=0,
651839Swollman	PROG_UNAVAIL=1,
661839Swollman	PROG_MISMATCH=2,
671839Swollman	PROC_UNAVAIL=3,
681839Swollman	GARBAGE_ARGS=4,
691839Swollman	SYSTEM_ERR=5
701839Swollman};
711839Swollman
721839Swollmanenum reject_stat {
731839Swollman	RPC_MISMATCH=0,
741839Swollman	AUTH_ERROR=1
751839Swollman};
761839Swollman
771839Swollman/*
781839Swollman * Reply part of an rpc exchange
791839Swollman */
801839Swollman
811839Swollman/*
821839Swollman * Reply to an rpc request that was accepted by the server.
831839Swollman * Note: there could be an error even though the request was
841839Swollman * accepted.
851839Swollman */
861839Swollmanstruct accepted_reply {
871839Swollman	struct opaque_auth	ar_verf;
881839Swollman	enum accept_stat	ar_stat;
891839Swollman	union {
901839Swollman		struct {
911839Swollman			u_long	low;
921839Swollman			u_long	high;
931839Swollman		} AR_versions;
941839Swollman		struct {
951839Swollman			caddr_t	where;
961839Swollman			xdrproc_t proc;
971839Swollman		} AR_results;
981839Swollman		/* and many other null cases */
991839Swollman	} ru;
1001839Swollman#define	ar_results	ru.AR_results
1011839Swollman#define	ar_vers		ru.AR_versions
1021839Swollman};
1031839Swollman
1041839Swollman/*
1051839Swollman * Reply to an rpc request that was rejected by the server.
1061839Swollman */
1071839Swollmanstruct rejected_reply {
1081839Swollman	enum reject_stat rj_stat;
1091839Swollman	union {
1101839Swollman		struct {
1111839Swollman			u_long low;
1121839Swollman			u_long high;
1131839Swollman		} RJ_versions;
1141839Swollman		enum auth_stat RJ_why;  /* why authentication did not work */
1151839Swollman	} ru;
1161839Swollman#define	rj_vers	ru.RJ_versions
1171839Swollman#define	rj_why	ru.RJ_why
1181839Swollman};
1191839Swollman
1201839Swollman/*
1211839Swollman * Body of a reply to an rpc request.
1221839Swollman */
1231839Swollmanstruct reply_body {
1241839Swollman	enum reply_stat rp_stat;
1251839Swollman	union {
1261839Swollman		struct accepted_reply RP_ar;
1271839Swollman		struct rejected_reply RP_dr;
1281839Swollman	} ru;
1291839Swollman#define	rp_acpt	ru.RP_ar
1301839Swollman#define	rp_rjct	ru.RP_dr
1311839Swollman};
1321839Swollman
1331839Swollman/*
1341839Swollman * Body of an rpc request call.
1351839Swollman */
1361839Swollmanstruct call_body {
1371839Swollman	u_long cb_rpcvers;	/* must be equal to two */
1381839Swollman	u_long cb_prog;
1391839Swollman	u_long cb_vers;
1401839Swollman	u_long cb_proc;
1411839Swollman	struct opaque_auth cb_cred;
1421839Swollman	struct opaque_auth cb_verf; /* protocol specific - provided by client */
1431839Swollman};
1441839Swollman
1451839Swollman/*
1461839Swollman * The rpc message
1471839Swollman */
1481839Swollmanstruct rpc_msg {
1491839Swollman	u_long			rm_xid;
1501839Swollman	enum msg_type		rm_direction;
1511839Swollman	union {
1521839Swollman		struct call_body RM_cmb;
1531839Swollman		struct reply_body RM_rmb;
1541839Swollman	} ru;
1551839Swollman#define	rm_call		ru.RM_cmb
1561839Swollman#define	rm_reply	ru.RM_rmb
1571839Swollman};
1581839Swollman#define	acpted_rply	ru.RM_rmb.ru.RP_ar
1591839Swollman#define	rjcted_rply	ru.RM_rmb.ru.RP_dr
1601839Swollman
1611903Swollman__BEGIN_DECLS
1621839Swollman/*
1631839Swollman * XDR routine to handle a rpc message.
1641839Swollman * xdr_callmsg(xdrs, cmsg)
1651839Swollman * 	XDR *xdrs;
1661839Swollman * 	struct rpc_msg *cmsg;
1671839Swollman */
1681903Swollmanextern bool_t	xdr_callmsg	__P((XDR *, struct rpc_msg *));
1691839Swollman
1701839Swollman/*
1711839Swollman * XDR routine to pre-serialize the static part of a rpc message.
1721839Swollman * xdr_callhdr(xdrs, cmsg)
1731839Swollman * 	XDR *xdrs;
1741839Swollman * 	struct rpc_msg *cmsg;
1751839Swollman */
1761903Swollmanextern bool_t	xdr_callhdr	__P((XDR *, struct rpc_msg *));
1771839Swollman
1781839Swollman/*
1791839Swollman * XDR routine to handle a rpc reply.
1801839Swollman * xdr_replymsg(xdrs, rmsg)
1811839Swollman * 	XDR *xdrs;
1821839Swollman * 	struct rpc_msg *rmsg;
1831839Swollman */
1841903Swollmanextern bool_t	xdr_replymsg	__P((XDR *, struct rpc_msg *));
1851839Swollman
1861839Swollman/*
1871839Swollman * Fills in the error part of a reply message.
1881839Swollman * _seterr_reply(msg, error)
1891839Swollman * 	struct rpc_msg *msg;
1901839Swollman * 	struct rpc_err *error;
1911839Swollman */
1927027Sbdestruct rpc_err;
1931903Swollmanextern void	_seterr_reply	__P((struct rpc_msg *, struct rpc_err *));
1941903Swollman__END_DECLS
1951903Swollman
1961903Swollman#endif /* !_RPC_RPCMSG_H */
197