rpc_msg.h 4.1 KB

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