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