1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 #pragma ident "%Z%%M% %I% %E% SMI" 23 24 /* 25 * rpc message definition 26 * 27 * Copyright (C) 1984, Sun Microsystems, Inc. 28 */ 29 30 #ifndef _rpc_rpc_msg_h 31 #define _rpc_rpc_msg_h 32 33 #define RPC_MSG_VERSION ((u_long) 2) 34 #define RPC_SERVICE_PORT ((u_short) 2048) 35 36 /* 37 * Bottom up definition of an rpc message. 38 * NOTE: call and reply use the same overall stuct but 39 * different parts of unions within it. 40 */ 41 42 enum msg_type { 43 CALL=0, 44 REPLY=1 45 }; 46 47 enum reply_stat { 48 MSG_ACCEPTED=0, 49 MSG_DENIED=1 50 }; 51 52 enum accept_stat { 53 SUCCESS=0, 54 PROG_UNAVAIL=1, 55 PROG_MISMATCH=2, 56 PROC_UNAVAIL=3, 57 GARBAGE_ARGS=4, 58 SYSTEM_ERR=5 59 }; 60 61 enum reject_stat { 62 RPC_MISMATCH=0, 63 AUTH_ERROR=1 64 }; 65 66 /* 67 * Reply part of an rpc exchange 68 */ 69 70 /* 71 * Reply to an rpc request that was accepted by the server. 72 * Note: there could be an error even though the request was 73 * accepted. 74 */ 75 struct accepted_reply { 76 struct opaque_auth ar_verf; 77 enum accept_stat ar_stat; 78 union { 79 struct { 80 u_long low; 81 u_long high; 82 } AR_versions; 83 struct { 84 caddr_t where; 85 xdrproc_t proc; 86 } AR_results; 87 /* and many other null cases */ 88 } ru; 89 #define ar_results ru.AR_results 90 #define ar_vers ru.AR_versions 91 }; 92 93 /* 94 * Reply to an rpc request that was rejected by the server. 95 */ 96 struct rejected_reply { 97 enum reject_stat rj_stat; 98 union { 99 struct { 100 u_long low; 101 u_long high; 102 } RJ_versions; 103 enum auth_stat RJ_why; /* why authentication did not work */ 104 } ru; 105 #define rj_vers ru.RJ_versions 106 #define rj_why ru.RJ_why 107 }; 108 109 /* 110 * Body of a reply to an rpc request. 111 */ 112 struct reply_body { 113 enum reply_stat rp_stat; 114 union { 115 struct accepted_reply RP_ar; 116 struct rejected_reply RP_dr; 117 } ru; 118 #define rp_acpt ru.RP_ar 119 #define rp_rjct ru.RP_dr 120 }; 121 122 /* 123 * Body of an rpc request call. 124 */ 125 struct call_body { 126 u_long cb_rpcvers; /* must be equal to two */ 127 u_long cb_prog; 128 u_long cb_vers; 129 u_long cb_proc; 130 struct opaque_auth cb_cred; 131 struct opaque_auth cb_verf; /* protocol specific - provided by client */ 132 }; 133 134 /* 135 * The rpc message 136 */ 137 struct rpc_msg { 138 u_long rm_xid; 139 enum msg_type rm_direction; 140 union { 141 struct call_body RM_cmb; 142 struct reply_body RM_rmb; 143 } ru; 144 #define rm_call ru.RM_cmb 145 #define rm_reply ru.RM_rmb 146 }; 147 #define acpted_rply ru.RM_rmb.ru.RP_ar 148 #define rjcted_rply ru.RM_rmb.ru.RP_dr 149 150 151 /* 152 * XDR routine to handle a rpc message. 153 * xdr_callmsg(xdrs, cmsg) 154 * XDR *xdrs; 155 * struct rpc_msg *cmsg; 156 */ 157 extern bool_t xdr_callmsg(); 158 159 /* 160 * XDR routine to pre-serialize the static part of a rpc message. 161 * xdr_callhdr(xdrs, cmsg) 162 * XDR *xdrs; 163 * struct rpc_msg *cmsg; 164 */ 165 extern bool_t xdr_callhdr(); 166 167 /* 168 * XDR routine to handle a rpc reply. 169 * xdr_replymsg(xdrs, rmsg) 170 * XDR *xdrs; 171 * struct rpc_msg *rmsg; 172 */ 173 extern bool_t xdr_replymsg(); 174 175 /* 176 * Fills in the error part of a reply message. 177 * _seterr_reply(msg, error) 178 * struct rpc_msg *msg; 179 * struct rpc_err *error; 180 */ 181 extern void _seterr_reply(); 182 183 #endif /*!_rpc_rpc_msg_h*/ 184