rpc_msg.h revision 184588
1177633Sdfr/* $NetBSD: rpc_msg.h,v 1.11 2000/06/02 22:57:56 fvdl Exp $ */ 2177633Sdfr 3177633Sdfr/* 4177633Sdfr * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 5177633Sdfr * unrestricted use provided that this legend is included on all tape 6177633Sdfr * media and as a part of the software program in whole or part. Users 7177633Sdfr * may copy or modify Sun RPC without charge, but are not authorized 8177633Sdfr * to license or distribute it to anyone else except as part of a product or 9177633Sdfr * program developed by the user. 10177633Sdfr * 11177633Sdfr * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 12177633Sdfr * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 13177633Sdfr * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 14177633Sdfr * 15177633Sdfr * Sun RPC is provided with no support and without any obligation on the 16177633Sdfr * part of Sun Microsystems, Inc. to assist in its use, correction, 17177633Sdfr * modification or enhancement. 18177633Sdfr * 19177633Sdfr * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 20177633Sdfr * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 21177633Sdfr * OR ANY PART THEREOF. 22177633Sdfr * 23177633Sdfr * In no event will Sun Microsystems, Inc. be liable for any lost revenue 24177633Sdfr * or profits or other special, indirect and consequential damages, even if 25177633Sdfr * Sun has been advised of the possibility of such damages. 26177633Sdfr * 27177633Sdfr * Sun Microsystems, Inc. 28177633Sdfr * 2550 Garcia Avenue 29177633Sdfr * Mountain View, California 94043 30177633Sdfr * 31177633Sdfr * from: @(#)rpc_msg.h 1.7 86/07/16 SMI 32177633Sdfr * from: @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC 33177633Sdfr * $FreeBSD: head/sys/rpc/rpc_msg.h 184588 2008-11-03 10:38:00Z dfr $ 34177633Sdfr */ 35177633Sdfr 36177633Sdfr/* 37177633Sdfr * rpc_msg.h 38177633Sdfr * rpc message definition 39177633Sdfr * 40177633Sdfr * Copyright (C) 1984, Sun Microsystems, Inc. 41177633Sdfr */ 42177633Sdfr 43177633Sdfr#ifndef _RPC_RPC_MSG_H 44177633Sdfr#define _RPC_RPC_MSG_H 45177633Sdfr 46177633Sdfr#define RPC_MSG_VERSION ((uint32_t) 2) 47177633Sdfr#define RPC_SERVICE_PORT ((u_short) 2048) 48177633Sdfr 49177633Sdfr/* 50177633Sdfr * Bottom up definition of an rpc message. 51177633Sdfr * NOTE: call and reply use the same overall stuct but 52177633Sdfr * different parts of unions within it. 53177633Sdfr */ 54177633Sdfr 55177633Sdfrenum msg_type { 56177633Sdfr CALL=0, 57177633Sdfr REPLY=1 58177633Sdfr}; 59177633Sdfr 60177633Sdfrenum reply_stat { 61177633Sdfr MSG_ACCEPTED=0, 62177633Sdfr MSG_DENIED=1 63177633Sdfr}; 64177633Sdfr 65177633Sdfrenum accept_stat { 66177633Sdfr SUCCESS=0, 67177633Sdfr PROG_UNAVAIL=1, 68177633Sdfr PROG_MISMATCH=2, 69177633Sdfr PROC_UNAVAIL=3, 70177633Sdfr GARBAGE_ARGS=4, 71177633Sdfr SYSTEM_ERR=5 72177633Sdfr}; 73177633Sdfr 74177633Sdfrenum reject_stat { 75177633Sdfr RPC_MISMATCH=0, 76177633Sdfr AUTH_ERROR=1 77177633Sdfr}; 78177633Sdfr 79177633Sdfr/* 80177633Sdfr * Reply part of an rpc exchange 81177633Sdfr */ 82177633Sdfr 83177633Sdfr/* 84177633Sdfr * Reply to an rpc request that was accepted by the server. 85177633Sdfr * Note: there could be an error even though the request was 86177633Sdfr * accepted. 87177633Sdfr */ 88177633Sdfrstruct accepted_reply { 89177633Sdfr struct opaque_auth ar_verf; 90177633Sdfr enum accept_stat ar_stat; 91177633Sdfr union { 92177633Sdfr struct { 93177633Sdfr rpcvers_t low; 94177633Sdfr rpcvers_t high; 95177633Sdfr } AR_versions; 96177633Sdfr struct { 97177633Sdfr caddr_t where; 98177633Sdfr xdrproc_t proc; 99177633Sdfr } AR_results; 100177633Sdfr /* and many other null cases */ 101177633Sdfr } ru; 102177633Sdfr#define ar_results ru.AR_results 103177633Sdfr#define ar_vers ru.AR_versions 104177633Sdfr}; 105177633Sdfr 106177633Sdfr/* 107177633Sdfr * Reply to an rpc request that was rejected by the server. 108177633Sdfr */ 109177633Sdfrstruct rejected_reply { 110177633Sdfr enum reject_stat rj_stat; 111177633Sdfr union { 112177633Sdfr struct { 113177633Sdfr rpcvers_t low; 114177633Sdfr rpcvers_t high; 115177633Sdfr } RJ_versions; 116177633Sdfr enum auth_stat RJ_why; /* why authentication did not work */ 117177633Sdfr } ru; 118177633Sdfr#define rj_vers ru.RJ_versions 119177633Sdfr#define rj_why ru.RJ_why 120177633Sdfr}; 121177633Sdfr 122177633Sdfr/* 123177633Sdfr * Body of a reply to an rpc request. 124177633Sdfr */ 125177633Sdfrstruct reply_body { 126177633Sdfr enum reply_stat rp_stat; 127177633Sdfr union { 128177633Sdfr struct accepted_reply RP_ar; 129177633Sdfr struct rejected_reply RP_dr; 130177633Sdfr } ru; 131177633Sdfr#define rp_acpt ru.RP_ar 132177633Sdfr#define rp_rjct ru.RP_dr 133177633Sdfr}; 134177633Sdfr 135177633Sdfr/* 136177633Sdfr * Body of an rpc request call. 137177633Sdfr */ 138177633Sdfrstruct call_body { 139177633Sdfr rpcvers_t cb_rpcvers; /* must be equal to two */ 140177633Sdfr rpcprog_t cb_prog; 141177633Sdfr rpcvers_t cb_vers; 142177633Sdfr rpcproc_t cb_proc; 143177633Sdfr struct opaque_auth cb_cred; 144177633Sdfr struct opaque_auth cb_verf; /* protocol specific - provided by client */ 145177633Sdfr}; 146177633Sdfr 147177633Sdfr/* 148177633Sdfr * The rpc message 149177633Sdfr */ 150177633Sdfrstruct rpc_msg { 151177633Sdfr uint32_t rm_xid; 152177633Sdfr enum msg_type rm_direction; 153177633Sdfr union { 154177633Sdfr struct call_body RM_cmb; 155177633Sdfr struct reply_body RM_rmb; 156177633Sdfr } ru; 157177633Sdfr#define rm_call ru.RM_cmb 158177633Sdfr#define rm_reply ru.RM_rmb 159177633Sdfr}; 160177633Sdfr#define acpted_rply ru.RM_rmb.ru.RP_ar 161177633Sdfr#define rjcted_rply ru.RM_rmb.ru.RP_dr 162177633Sdfr 163177633Sdfr__BEGIN_DECLS 164177633Sdfr/* 165177633Sdfr * XDR routine to handle a rpc message. 166177633Sdfr * xdr_callmsg(xdrs, cmsg) 167177633Sdfr * XDR *xdrs; 168177633Sdfr * struct rpc_msg *cmsg; 169177633Sdfr */ 170177633Sdfrextern bool_t xdr_callmsg(XDR *, struct rpc_msg *); 171177633Sdfr 172177633Sdfr/* 173177633Sdfr * XDR routine to pre-serialize the static part of a rpc message. 174177633Sdfr * xdr_callhdr(xdrs, cmsg) 175177633Sdfr * XDR *xdrs; 176177633Sdfr * struct rpc_msg *cmsg; 177177633Sdfr */ 178177633Sdfrextern bool_t xdr_callhdr(XDR *, struct rpc_msg *); 179177633Sdfr 180177633Sdfr/* 181177633Sdfr * XDR routine to handle a rpc reply. 182177633Sdfr * xdr_replymsg(xdrs, rmsg) 183177633Sdfr * XDR *xdrs; 184177633Sdfr * struct rpc_msg *rmsg; 185177633Sdfr */ 186177633Sdfrextern bool_t xdr_replymsg(XDR *, struct rpc_msg *); 187177633Sdfr 188177633Sdfr 189177633Sdfr/* 190177633Sdfr * XDR routine to handle an accepted rpc reply. 191177633Sdfr * xdr_accepted_reply(xdrs, rej) 192177633Sdfr * XDR *xdrs; 193177633Sdfr * struct accepted_reply *rej; 194177633Sdfr */ 195177633Sdfrextern bool_t xdr_accepted_reply(XDR *, struct accepted_reply *); 196177633Sdfr 197177633Sdfr/* 198177633Sdfr * XDR routine to handle a rejected rpc reply. 199177633Sdfr * xdr_rejected_reply(xdrs, rej) 200177633Sdfr * XDR *xdrs; 201177633Sdfr * struct rejected_reply *rej; 202177633Sdfr */ 203177633Sdfrextern bool_t xdr_rejected_reply(XDR *, struct rejected_reply *); 204177633Sdfr 205177633Sdfr/* 206177633Sdfr * Fills in the error part of a reply message. 207177633Sdfr * _seterr_reply(msg, error) 208177633Sdfr * struct rpc_msg *msg; 209177633Sdfr * struct rpc_err *error; 210177633Sdfr */ 211184588Sdfrextern enum clnt_stat _seterr_reply(struct rpc_msg *, struct rpc_err *); 212177633Sdfr__END_DECLS 213177633Sdfr 214177633Sdfr#endif /* !_RPC_RPC_MSG_H */ 215