1 /* 2 * Copyright (c) 2006-2018, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 */ 9 /* @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC */ 10 /* 11 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 12 * unrestricted use provided that this legend is included on all tape 13 * media and as a part of the software program in whole or part. Users 14 * may copy or modify Sun RPC without charge, but are not authorized 15 * to license or distribute it to anyone else except as part of a product or 16 * program developed by the user. 17 * 18 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 19 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 20 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 21 * 22 * Sun RPC is provided with no support and without any obligation on the 23 * part of Sun Microsystems, Inc. to assist in its use, correction, 24 * modification or enhancement. 25 * 26 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 27 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 28 * OR ANY PART THEREOF. 29 * 30 * In no event will Sun Microsystems, Inc. be liable for any lost revenue 31 * or profits or other special, indirect and consequential damages, even if 32 * Sun has been advised of the possibility of such damages. 33 * 34 * Sun Microsystems, Inc. 35 * 2550 Garcia Avenue 36 * Mountain View, California 94043 37 */ 38 /* @(#)rpc_msg.h 1.7 86/07/16 SMI */ 39 40 #ifndef _RPC_MSG_H 41 #define _RPC_MSG_H 1 42 43 #include <rpc/xdr.h> 44 #include <rpc/clnt.h> 45 46 /* 47 * rpc_msg.h 48 * rpc message definition 49 * 50 * Copyright (C) 1984, Sun Microsystems, Inc. 51 */ 52 53 #define RPC_MSG_VERSION ((unsigned long) 2) 54 #define RPC_SERVICE_PORT ((unsigned short) 2048) 55 56 /* 57 * Bottom up definition of an rpc message. 58 * NOTE: call and reply use the same overall struct but 59 * different parts of unions within it. 60 */ 61 62 enum msg_type { 63 CALL=0, 64 REPLY=1 65 }; 66 67 enum reply_stat { 68 MSG_ACCEPTED=0, 69 MSG_DENIED=1 70 }; 71 72 enum accept_stat { 73 SUCCESS=0, 74 PROG_UNAVAIL=1, 75 PROG_MISMATCH=2, 76 PROC_UNAVAIL=3, 77 GARBAGE_ARGS=4, 78 SYSTEM_ERR=5 79 }; 80 81 enum reject_stat { 82 RPC_MISMATCH=0, 83 AUTH_ERROR=1 84 }; 85 86 /* 87 * Reply part of an rpc exchange 88 */ 89 90 /* 91 * Reply to an rpc request that was accepted by the server. 92 * Note: there could be an error even though the request was 93 * accepted. 94 */ 95 struct accepted_reply { 96 struct opaque_auth ar_verf; 97 int ar_stat; 98 union { 99 struct { 100 unsigned long low; 101 unsigned long high; 102 } AR_versions; 103 struct { 104 char* where; 105 xdrproc_t proc; 106 } AR_results; 107 /* and many other null cases */ 108 } ru; 109 #define ar_results ru.AR_results 110 #define ar_vers ru.AR_versions 111 }; 112 113 /* 114 * Reply to an rpc request that was rejected by the server. 115 */ 116 struct rejected_reply { 117 int rj_stat; 118 union { 119 struct { 120 unsigned long low; 121 unsigned long high; 122 } RJ_versions; 123 int RJ_why; /* why authentication did not work */ 124 } ru; 125 #define rj_vers ru.RJ_versions 126 #define rj_why ru.RJ_why 127 }; 128 129 /* 130 * Body of a reply to an rpc request. 131 */ 132 struct reply_body { 133 int rp_stat; 134 union { 135 struct accepted_reply RP_ar; 136 struct rejected_reply RP_dr; 137 } ru; 138 #define rp_acpt ru.RP_ar 139 #define rp_rjct ru.RP_dr 140 }; 141 142 /* 143 * Body of an rpc request call. 144 */ 145 struct call_body { 146 unsigned long cb_rpcvers; /* must be equal to two */ 147 unsigned long cb_prog; 148 unsigned long cb_vers; 149 unsigned long cb_proc; 150 struct opaque_auth cb_cred; 151 struct opaque_auth cb_verf; /* protocol specific - provided by client */ 152 }; 153 154 /* 155 * The rpc message 156 */ 157 struct rpc_msg { 158 unsigned long rm_xid; 159 int rm_direction; 160 union { 161 struct call_body RM_cmb; 162 struct reply_body RM_rmb; 163 } ru; 164 #define rm_call ru.RM_cmb 165 #define rm_reply ru.RM_rmb 166 }; 167 #define acpted_rply ru.RM_rmb.ru.RP_ar 168 #define rjcted_rply ru.RM_rmb.ru.RP_dr 169 170 171 /* 172 * XDR routine to handle a rpc message. 173 * xdr_callmsg(xdrs, cmsg) 174 * XDR *xdrs; 175 * struct rpc_msg *cmsg; 176 */ 177 extern bool_t xdr_callmsg (XDR *__xdrs, struct rpc_msg *__cmsg); 178 179 /* 180 * XDR routine to pre-serialize the static part of a rpc message. 181 * xdr_callhdr(xdrs, cmsg) 182 * XDR *xdrs; 183 * struct rpc_msg *cmsg; 184 */ 185 extern bool_t xdr_callhdr (XDR *__xdrs, struct rpc_msg *__cmsg); 186 187 /* 188 * XDR routine to handle a rpc reply. 189 * xdr_replymsg(xdrs, rmsg) 190 * XDR *xdrs; 191 * struct rpc_msg *rmsg; 192 */ 193 extern bool_t xdr_replymsg (XDR *__xdrs, struct rpc_msg *__rmsg); 194 195 /* 196 * Fills in the error part of a reply message. 197 * _seterr_reply(msg, error) 198 * struct rpc_msg *msg; 199 * struct rpc_err *error; 200 */ 201 extern void _seterr_reply (struct rpc_msg *__msg, struct rpc_err *__error); 202 203 #endif /* rpc/rpc_msg.h */ 204