174462Salfred/* $NetBSD: rpc_msg.h,v 1.11 2000/06/02 22:57:56 fvdl Exp $ */ 274462Salfred 3261046Smav/*- 4261046Smav * Copyright (c) 2009, Sun Microsystems, Inc. 5261046Smav * All rights reserved. 68858Srgrimes * 7261046Smav * Redistribution and use in source and binary forms, with or without 8261046Smav * modification, are permitted provided that the following conditions are met: 9261046Smav * - Redistributions of source code must retain the above copyright notice, 10261046Smav * this list of conditions and the following disclaimer. 11261046Smav * - Redistributions in binary form must reproduce the above copyright notice, 12261046Smav * this list of conditions and the following disclaimer in the documentation 13261046Smav * and/or other materials provided with the distribution. 14261046Smav * - Neither the name of Sun Microsystems, Inc. nor the names of its 15261046Smav * contributors may be used to endorse or promote products derived 16261046Smav * from this software without specific prior written permission. 178858Srgrimes * 18261046Smav * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19261046Smav * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20261046Smav * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21261046Smav * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 22261046Smav * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23261046Smav * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24261046Smav * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25261046Smav * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26261046Smav * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27261046Smav * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28261046Smav * POSSIBILITY OF SUCH DAMAGE. 298858Srgrimes * 301903Swollman * from: @(#)rpc_msg.h 1.7 86/07/16 SMI 311903Swollman * from: @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC 3250473Speter * $FreeBSD$ 331839Swollman */ 341839Swollman 351839Swollman/* 361839Swollman * rpc_msg.h 371839Swollman * rpc message definition 381839Swollman * 391839Swollman * Copyright (C) 1984, Sun Microsystems, Inc. 401839Swollman */ 411839Swollman 4274462Salfred#ifndef _RPC_RPC_MSG_H 4374462Salfred#define _RPC_RPC_MSG_H 441903Swollman 4574462Salfred#define RPC_MSG_VERSION ((u_int32_t) 2) 461839Swollman#define RPC_SERVICE_PORT ((u_short) 2048) 471839Swollman 481839Swollman/* 491839Swollman * Bottom up definition of an rpc message. 501839Swollman * NOTE: call and reply use the same overall stuct but 511839Swollman * different parts of unions within it. 521839Swollman */ 531839Swollman 541839Swollmanenum msg_type { 551839Swollman CALL=0, 561839Swollman REPLY=1 571839Swollman}; 581839Swollman 591839Swollmanenum reply_stat { 601839Swollman MSG_ACCEPTED=0, 611839Swollman MSG_DENIED=1 621839Swollman}; 631839Swollman 641839Swollmanenum accept_stat { 651839Swollman SUCCESS=0, 661839Swollman PROG_UNAVAIL=1, 671839Swollman PROG_MISMATCH=2, 681839Swollman PROC_UNAVAIL=3, 691839Swollman GARBAGE_ARGS=4, 701839Swollman SYSTEM_ERR=5 711839Swollman}; 721839Swollman 731839Swollmanenum reject_stat { 741839Swollman RPC_MISMATCH=0, 751839Swollman AUTH_ERROR=1 761839Swollman}; 771839Swollman 781839Swollman/* 791839Swollman * Reply part of an rpc exchange 801839Swollman */ 811839Swollman 821839Swollman/* 831839Swollman * Reply to an rpc request that was accepted by the server. 841839Swollman * Note: there could be an error even though the request was 851839Swollman * accepted. 861839Swollman */ 871839Swollmanstruct accepted_reply { 881839Swollman struct opaque_auth ar_verf; 891839Swollman enum accept_stat ar_stat; 901839Swollman union { 911839Swollman struct { 9274462Salfred rpcvers_t low; 9374462Salfred rpcvers_t high; 941839Swollman } AR_versions; 951839Swollman struct { 961839Swollman caddr_t where; 971839Swollman xdrproc_t proc; 981839Swollman } AR_results; 991839Swollman /* and many other null cases */ 1001839Swollman } ru; 1011839Swollman#define ar_results ru.AR_results 1021839Swollman#define ar_vers ru.AR_versions 1031839Swollman}; 1041839Swollman 1051839Swollman/* 1061839Swollman * Reply to an rpc request that was rejected by the server. 1071839Swollman */ 1081839Swollmanstruct rejected_reply { 1091839Swollman enum reject_stat rj_stat; 1101839Swollman union { 1111839Swollman struct { 11274462Salfred rpcvers_t low; 11374462Salfred rpcvers_t high; 1141839Swollman } RJ_versions; 1151839Swollman enum auth_stat RJ_why; /* why authentication did not work */ 1161839Swollman } ru; 1171839Swollman#define rj_vers ru.RJ_versions 1181839Swollman#define rj_why ru.RJ_why 1191839Swollman}; 1201839Swollman 1211839Swollman/* 1221839Swollman * Body of a reply to an rpc request. 1231839Swollman */ 1241839Swollmanstruct reply_body { 1251839Swollman enum reply_stat rp_stat; 1261839Swollman union { 1271839Swollman struct accepted_reply RP_ar; 1281839Swollman struct rejected_reply RP_dr; 1291839Swollman } ru; 1301839Swollman#define rp_acpt ru.RP_ar 1311839Swollman#define rp_rjct ru.RP_dr 1321839Swollman}; 1331839Swollman 1341839Swollman/* 1351839Swollman * Body of an rpc request call. 1361839Swollman */ 1371839Swollmanstruct call_body { 13874462Salfred rpcvers_t cb_rpcvers; /* must be equal to two */ 13974462Salfred rpcprog_t cb_prog; 14074462Salfred rpcvers_t cb_vers; 14174462Salfred rpcproc_t cb_proc; 1421839Swollman struct opaque_auth cb_cred; 1431839Swollman struct opaque_auth cb_verf; /* protocol specific - provided by client */ 1441839Swollman}; 1451839Swollman 1461839Swollman/* 1471839Swollman * The rpc message 1481839Swollman */ 1491839Swollmanstruct rpc_msg { 15021059Speter u_int32_t rm_xid; 1511839Swollman enum msg_type rm_direction; 1521839Swollman union { 1531839Swollman struct call_body RM_cmb; 1541839Swollman struct reply_body RM_rmb; 1551839Swollman } ru; 1561839Swollman#define rm_call ru.RM_cmb 1571839Swollman#define rm_reply ru.RM_rmb 1581839Swollman}; 1591839Swollman#define acpted_rply ru.RM_rmb.ru.RP_ar 1601839Swollman#define rjcted_rply ru.RM_rmb.ru.RP_dr 1611839Swollman 1621903Swollman__BEGIN_DECLS 1631839Swollman/* 1641839Swollman * XDR routine to handle a rpc message. 1651839Swollman * xdr_callmsg(xdrs, cmsg) 1661839Swollman * XDR *xdrs; 1671839Swollman * struct rpc_msg *cmsg; 1681839Swollman */ 16993032Simpextern bool_t xdr_callmsg(XDR *, struct rpc_msg *); 1701839Swollman 1711839Swollman/* 1721839Swollman * XDR routine to pre-serialize the static part of a rpc message. 1731839Swollman * xdr_callhdr(xdrs, cmsg) 1741839Swollman * XDR *xdrs; 1751839Swollman * struct rpc_msg *cmsg; 1761839Swollman */ 17793032Simpextern bool_t xdr_callhdr(XDR *, struct rpc_msg *); 1781839Swollman 1791839Swollman/* 1801839Swollman * XDR routine to handle a rpc reply. 1811839Swollman * xdr_replymsg(xdrs, rmsg) 1821839Swollman * XDR *xdrs; 1831839Swollman * struct rpc_msg *rmsg; 1841839Swollman */ 18593032Simpextern bool_t xdr_replymsg(XDR *, struct rpc_msg *); 1861839Swollman 18774462Salfred 1881839Swollman/* 189108533Sschweikh * XDR routine to handle an accepted rpc reply. 19074462Salfred * xdr_accepted_reply(xdrs, rej) 19174462Salfred * XDR *xdrs; 19274462Salfred * struct accepted_reply *rej; 19374462Salfred */ 19493032Simpextern bool_t xdr_accepted_reply(XDR *, struct accepted_reply *); 19574462Salfred 19674462Salfred/* 19774462Salfred * XDR routine to handle a rejected rpc reply. 19874462Salfred * xdr_rejected_reply(xdrs, rej) 19974462Salfred * XDR *xdrs; 20074462Salfred * struct rejected_reply *rej; 20174462Salfred */ 20293032Simpextern bool_t xdr_rejected_reply(XDR *, struct rejected_reply *); 20374462Salfred 20474462Salfred/* 2051839Swollman * Fills in the error part of a reply message. 2061839Swollman * _seterr_reply(msg, error) 2071839Swollman * struct rpc_msg *msg; 2081839Swollman * struct rpc_err *error; 2091839Swollman */ 21093032Simpextern void _seterr_reply(struct rpc_msg *, struct rpc_err *); 2111903Swollman__END_DECLS 2121903Swollman 21374462Salfred#endif /* !_RPC_RPC_MSG_H */ 214