Blame tirpc/rpc/rpc_msg.h

Packit 00408a
/*	$NetBSD: rpc_msg.h,v 1.11 2000/06/02 22:57:56 fvdl Exp $	*/
Packit 00408a
Packit 00408a
/*
Packit 00408a
 * Copyright (c) 2009, Sun Microsystems, Inc.
Packit 00408a
 * All rights reserved.
Packit 00408a
 *
Packit 00408a
 * Redistribution and use in source and binary forms, with or without
Packit 00408a
 * modification, are permitted provided that the following conditions are met:
Packit 00408a
 * - Redistributions of source code must retain the above copyright notice,
Packit 00408a
 *   this list of conditions and the following disclaimer.
Packit 00408a
 * - Redistributions in binary form must reproduce the above copyright notice,
Packit 00408a
 *   this list of conditions and the following disclaimer in the documentation
Packit 00408a
 *   and/or other materials provided with the distribution.
Packit 00408a
 * - Neither the name of Sun Microsystems, Inc. nor the names of its
Packit 00408a
 *   contributors may be used to endorse or promote products derived
Packit 00408a
 *   from this software without specific prior written permission.
Packit 00408a
 *
Packit 00408a
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Packit 00408a
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit 00408a
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit 00408a
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
Packit 00408a
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
Packit 00408a
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
Packit 00408a
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
Packit 00408a
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
Packit 00408a
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
Packit 00408a
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
Packit 00408a
 * POSSIBILITY OF SUCH DAMAGE.
Packit 00408a
 *
Packit 00408a
 *	from: @(#)rpc_msg.h 1.7 86/07/16 SMI
Packit 00408a
 *	from: @(#)rpc_msg.h	2.1 88/07/29 4.0 RPCSRC
Packit 00408a
 * $FreeBSD: src/include/rpc/rpc_msg.h,v 1.15 2003/01/01 18:48:42 schweikh Exp $
Packit 00408a
 */
Packit 00408a
Packit 00408a
/*
Packit 00408a
 * rpc_msg.h
Packit 00408a
 * rpc message definition
Packit 00408a
 *
Packit 00408a
 * Copyright (C) 1984, Sun Microsystems, Inc.
Packit 00408a
 */
Packit 00408a
Packit 00408a
#ifndef _TIRPC_RPC_MSG_H
Packit 00408a
#define _TIRPC_RPC_MSG_H
Packit 00408a
Packit 00408a
#define RPC_MSG_VERSION		((u_int32_t) 2)
Packit 00408a
#define RPC_SERVICE_PORT	((u_short) 2048)
Packit 00408a
Packit 00408a
#include <rpc/auth.h>
Packit 00408a
Packit 00408a
/*
Packit 00408a
 * Bottom up definition of an rpc message.
Packit 00408a
 * NOTE: call and reply use the same overall stuct but
Packit 00408a
 * different parts of unions within it.
Packit 00408a
 */
Packit 00408a
Packit 00408a
enum msg_type {
Packit 00408a
	CALL=0,
Packit 00408a
	REPLY=1
Packit 00408a
};
Packit 00408a
Packit 00408a
enum reply_stat {
Packit 00408a
	MSG_ACCEPTED=0,
Packit 00408a
	MSG_DENIED=1
Packit 00408a
};
Packit 00408a
Packit 00408a
enum accept_stat {
Packit 00408a
	SUCCESS=0,
Packit 00408a
	PROG_UNAVAIL=1,
Packit 00408a
	PROG_MISMATCH=2,
Packit 00408a
	PROC_UNAVAIL=3,
Packit 00408a
	GARBAGE_ARGS=4,
Packit 00408a
	SYSTEM_ERR=5
Packit 00408a
};
Packit 00408a
Packit 00408a
enum reject_stat {
Packit 00408a
	RPC_MISMATCH=0,
Packit 00408a
	AUTH_ERROR=1
Packit 00408a
};
Packit 00408a
Packit 00408a
/*
Packit 00408a
 * Reply part of an rpc exchange
Packit 00408a
 */
Packit 00408a
Packit 00408a
/*
Packit 00408a
 * Reply to an rpc request that was accepted by the server.
Packit 00408a
 * Note: there could be an error even though the request was
Packit 00408a
 * accepted.
Packit 00408a
 */
Packit 00408a
struct accepted_reply {
Packit 00408a
	struct opaque_auth	ar_verf;
Packit 00408a
	enum accept_stat	ar_stat;
Packit 00408a
	union {
Packit 00408a
		struct {
Packit 00408a
			rpcvers_t low;
Packit 00408a
			rpcvers_t high;
Packit 00408a
		} AR_versions;
Packit 00408a
		struct {
Packit 00408a
			caddr_t	where;
Packit 00408a
			xdrproc_t proc;
Packit 00408a
		} AR_results;
Packit 00408a
		/* and many other null cases */
Packit 00408a
	} ru;
Packit 00408a
#define	ar_results	ru.AR_results
Packit 00408a
#define	ar_vers		ru.AR_versions
Packit 00408a
};
Packit 00408a
Packit 00408a
/*
Packit 00408a
 * Reply to an rpc request that was rejected by the server.
Packit 00408a
 */
Packit 00408a
struct rejected_reply {
Packit 00408a
	enum reject_stat rj_stat;
Packit 00408a
	union {
Packit 00408a
		struct {
Packit 00408a
			rpcvers_t low;
Packit 00408a
			rpcvers_t high;
Packit 00408a
		} RJ_versions;
Packit 00408a
		enum auth_stat RJ_why;  /* why authentication did not work */
Packit 00408a
	} ru;
Packit 00408a
#define	rj_vers	ru.RJ_versions
Packit 00408a
#define	rj_why	ru.RJ_why
Packit 00408a
};
Packit 00408a
Packit 00408a
/*
Packit 00408a
 * Body of a reply to an rpc request.
Packit 00408a
 */
Packit 00408a
struct reply_body {
Packit 00408a
	enum reply_stat rp_stat;
Packit 00408a
	union {
Packit 00408a
		struct accepted_reply RP_ar;
Packit 00408a
		struct rejected_reply RP_dr;
Packit 00408a
	} ru;
Packit 00408a
#define	rp_acpt	ru.RP_ar
Packit 00408a
#define	rp_rjct	ru.RP_dr
Packit 00408a
};
Packit 00408a
Packit 00408a
/*
Packit 00408a
 * Body of an rpc request call.
Packit 00408a
 */
Packit 00408a
struct call_body {
Packit 00408a
	rpcvers_t cb_rpcvers;	/* must be equal to two */
Packit 00408a
	rpcprog_t cb_prog;
Packit 00408a
	rpcvers_t cb_vers;
Packit 00408a
	rpcproc_t cb_proc;
Packit 00408a
	struct opaque_auth cb_cred;
Packit 00408a
	struct opaque_auth cb_verf; /* protocol specific - provided by client */
Packit 00408a
};
Packit 00408a
Packit 00408a
/*
Packit 00408a
 * The rpc message
Packit 00408a
 */
Packit 00408a
struct rpc_msg {
Packit 00408a
	u_int32_t		rm_xid;
Packit 00408a
	enum msg_type		rm_direction;
Packit 00408a
	union {
Packit 00408a
		struct call_body RM_cmb;
Packit 00408a
		struct reply_body RM_rmb;
Packit 00408a
	} ru;
Packit 00408a
#define	rm_call		ru.RM_cmb
Packit 00408a
#define	rm_reply	ru.RM_rmb
Packit 00408a
};
Packit 00408a
#define	acpted_rply	ru.RM_rmb.ru.RP_ar
Packit 00408a
#define	rjcted_rply	ru.RM_rmb.ru.RP_dr
Packit 00408a
Packit 00408a
#ifdef __cplusplus
Packit 00408a
extern "C" {
Packit 00408a
#endif
Packit 00408a
/*
Packit 00408a
 * XDR routine to handle a rpc message.
Packit 00408a
 * xdr_callmsg(xdrs, cmsg)
Packit 00408a
 * 	XDR *xdrs;
Packit 00408a
 * 	struct rpc_msg *cmsg;
Packit 00408a
 */
Packit 00408a
extern bool_t	xdr_callmsg(XDR *, struct rpc_msg *);
Packit 00408a
Packit 00408a
/*
Packit 00408a
 * XDR routine to pre-serialize the static part of a rpc message.
Packit 00408a
 * xdr_callhdr(xdrs, cmsg)
Packit 00408a
 * 	XDR *xdrs;
Packit 00408a
 * 	struct rpc_msg *cmsg;
Packit 00408a
 */
Packit 00408a
extern bool_t	xdr_callhdr(XDR *, struct rpc_msg *);
Packit 00408a
Packit 00408a
/*
Packit 00408a
 * XDR routine to handle a rpc reply.
Packit 00408a
 * xdr_replymsg(xdrs, rmsg)
Packit 00408a
 * 	XDR *xdrs;
Packit 00408a
 * 	struct rpc_msg *rmsg;
Packit 00408a
 */
Packit 00408a
extern bool_t	xdr_replymsg(XDR *, struct rpc_msg *);
Packit 00408a
Packit 00408a
Packit 00408a
/*
Packit 00408a
 * XDR routine to handle an accepted rpc reply.
Packit 00408a
 * xdr_accepted_reply(xdrs, rej)
Packit 00408a
 * 	XDR *xdrs;
Packit 00408a
 * 	struct accepted_reply *rej;
Packit 00408a
 */
Packit 00408a
extern bool_t	xdr_accepted_reply(XDR *, struct accepted_reply *);
Packit 00408a
Packit 00408a
/*
Packit 00408a
 * XDR routine to handle a rejected rpc reply.
Packit 00408a
 * xdr_rejected_reply(xdrs, rej)
Packit 00408a
 * 	XDR *xdrs;
Packit 00408a
 * 	struct rejected_reply *rej;
Packit 00408a
 */
Packit 00408a
extern bool_t	xdr_rejected_reply(XDR *, struct rejected_reply *);
Packit 00408a
Packit 00408a
/*
Packit 00408a
 * Fills in the error part of a reply message.
Packit 00408a
 * _seterr_reply(msg, error)
Packit 00408a
 * 	struct rpc_msg *msg;
Packit 00408a
 * 	struct rpc_err *error;
Packit 00408a
 */
Packit 00408a
extern void	_seterr_reply(struct rpc_msg *, struct rpc_err *);
Packit 00408a
#ifdef __cplusplus
Packit 00408a
}
Packit 00408a
#endif
Packit 00408a
Packit 00408a
#endif /* !_TIRPC_RPC_MSG_H */