/* $NetBSD: rpc_msg.h,v 1.11 2000/06/02 22:57:56 fvdl Exp $ */12/*-3* SPDX-License-Identifier: BSD-3-Clause4*5* Copyright (c) 2009, Sun Microsystems, Inc.6* All rights reserved.7*8* Redistribution and use in source and binary forms, with or without9* modification, are permitted provided that the following conditions are met:10* - Redistributions of source code must retain the above copyright notice,11* this list of conditions and the following disclaimer.12* - Redistributions in binary form must reproduce the above copyright notice,13* this list of conditions and the following disclaimer in the documentation14* and/or other materials provided with the distribution.15* - Neither the name of Sun Microsystems, Inc. nor the names of its16* contributors may be used to endorse or promote products derived17* from this software without specific prior written permission.18*19* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"20* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE21* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE22* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE23* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR24* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF25* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS26* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN27* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)28* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE29* POSSIBILITY OF SUCH DAMAGE.30*/3132/*33* rpc_msg.h34* rpc message definition35*36* Copyright (C) 1984, Sun Microsystems, Inc.37*/3839#ifndef _RPC_RPC_MSG_H40#define _RPC_RPC_MSG_H4142#define RPC_MSG_VERSION ((uint32_t) 2)43#define RPC_SERVICE_PORT ((u_short) 2048)4445/*46* Bottom up definition of an rpc message.47* NOTE: call and reply use the same overall stuct but48* different parts of unions within it.49*/5051enum msg_type {52CALL=0,53REPLY=154};5556enum reply_stat {57MSG_ACCEPTED=0,58MSG_DENIED=159};6061enum accept_stat {62SUCCESS=0,63PROG_UNAVAIL=1,64PROG_MISMATCH=2,65PROC_UNAVAIL=3,66GARBAGE_ARGS=4,67SYSTEM_ERR=568};6970enum reject_stat {71RPC_MISMATCH=0,72AUTH_ERROR=173};7475/*76* Reply part of an rpc exchange77*/7879/*80* Reply to an rpc request that was accepted by the server.81* Note: there could be an error even though the request was82* accepted.83*/84struct accepted_reply {85struct opaque_auth ar_verf;86enum accept_stat ar_stat;87union {88struct {89rpcvers_t low;90rpcvers_t high;91} AR_versions;92struct {93caddr_t where;94xdrproc_t proc;95} AR_results;96/* and many other null cases */97} ru;98#define ar_results ru.AR_results99#define ar_vers ru.AR_versions100};101102/*103* Reply to an rpc request that was rejected by the server.104*/105struct rejected_reply {106enum reject_stat rj_stat;107union {108struct {109rpcvers_t low;110rpcvers_t high;111} RJ_versions;112enum auth_stat RJ_why; /* why authentication did not work */113} ru;114#define rj_vers ru.RJ_versions115#define rj_why ru.RJ_why116};117118/*119* Body of a reply to an rpc request.120*/121struct reply_body {122enum reply_stat rp_stat;123union {124struct accepted_reply RP_ar;125struct rejected_reply RP_dr;126} ru;127#define rp_acpt ru.RP_ar128#define rp_rjct ru.RP_dr129};130131/*132* Body of an rpc request call.133*/134struct call_body {135rpcvers_t cb_rpcvers; /* must be equal to two */136rpcprog_t cb_prog;137rpcvers_t cb_vers;138rpcproc_t cb_proc;139struct opaque_auth cb_cred;140struct opaque_auth cb_verf; /* protocol specific - provided by client */141};142143/*144* The rpc message145*/146struct rpc_msg {147uint32_t rm_xid;148enum msg_type rm_direction;149union {150struct call_body RM_cmb;151struct reply_body RM_rmb;152} ru;153#define rm_call ru.RM_cmb154#define rm_reply ru.RM_rmb155};156#define acpted_rply ru.RM_rmb.ru.RP_ar157#define rjcted_rply ru.RM_rmb.ru.RP_dr158159__BEGIN_DECLS160/*161* XDR routine to handle a rpc message.162* xdr_callmsg(xdrs, cmsg)163* XDR *xdrs;164* struct rpc_msg *cmsg;165*/166extern bool_t xdr_callmsg(XDR *, struct rpc_msg *);167168/*169* XDR routine to pre-serialize the static part of a rpc message.170* xdr_callhdr(xdrs, cmsg)171* XDR *xdrs;172* struct rpc_msg *cmsg;173*/174extern bool_t xdr_callhdr(XDR *, struct rpc_msg *);175176/*177* XDR routine to handle a rpc reply.178* xdr_replymsg(xdrs, rmsg)179* XDR *xdrs;180* struct rpc_msg *rmsg;181*/182extern bool_t xdr_replymsg(XDR *, struct rpc_msg *);183184185/*186* XDR routine to handle an accepted rpc reply.187* xdr_accepted_reply(xdrs, rej)188* XDR *xdrs;189* struct accepted_reply *rej;190*/191extern bool_t xdr_accepted_reply(XDR *, struct accepted_reply *);192193/*194* XDR routine to handle a rejected rpc reply.195* xdr_rejected_reply(xdrs, rej)196* XDR *xdrs;197* struct rejected_reply *rej;198*/199extern bool_t xdr_rejected_reply(XDR *, struct rejected_reply *);200201/*202* Fills in the error part of a reply message.203* _seterr_reply(msg, error)204* struct rpc_msg *msg;205* struct rpc_err *error;206*/207extern enum clnt_stat _seterr_reply(struct rpc_msg *, struct rpc_err *);208__END_DECLS209210#endif /* !_RPC_RPC_MSG_H */211212213