rpc_msg.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. #ifndef _RPC_MSG_H
  32. #define _RPC_MSG_H 1
  33. #include <sys/cdefs.h>
  34. #include <rpc/xdr.h>
  35. #include <rpc/clnt.h>
  36. /*
  37. * rpc_msg.h
  38. * rpc message definition
  39. *
  40. * Copyright (C) 1984, Sun Microsystems, Inc.
  41. */
  42. #define RPC_MSG_VERSION ((u_long) 2)
  43. #define RPC_SERVICE_PORT ((u_short) 2048)
  44. __BEGIN_DECLS
  45. /*
  46. * Bottom up definition of an rpc message.
  47. * NOTE: call and reply use the same overall struct but
  48. * different parts of unions within it.
  49. */
  50. enum msg_type {
  51. CALL=0,
  52. REPLY=1
  53. };
  54. enum reply_stat {
  55. MSG_ACCEPTED=0,
  56. MSG_DENIED=1
  57. };
  58. enum accept_stat {
  59. SUCCESS=0,
  60. PROG_UNAVAIL=1,
  61. PROG_MISMATCH=2,
  62. PROC_UNAVAIL=3,
  63. GARBAGE_ARGS=4,
  64. SYSTEM_ERR=5
  65. };
  66. enum reject_stat {
  67. RPC_MISMATCH=0,
  68. AUTH_ERROR=1
  69. };
  70. /*
  71. * Reply part of an rpc exchange
  72. */
  73. /*
  74. * Reply to an rpc request that was accepted by the server.
  75. * Note: there could be an error even though the request was
  76. * accepted.
  77. */
  78. struct accepted_reply {
  79. struct opaque_auth ar_verf;
  80. enum accept_stat ar_stat;
  81. union {
  82. struct {
  83. u_long low;
  84. u_long high;
  85. } AR_versions;
  86. struct {
  87. caddr_t where;
  88. xdrproc_t proc;
  89. } AR_results;
  90. /* and many other null cases */
  91. } ru;
  92. #define ar_results ru.AR_results
  93. #define ar_vers ru.AR_versions
  94. };
  95. /*
  96. * Reply to an rpc request that was rejected by the server.
  97. */
  98. struct rejected_reply {
  99. enum reject_stat rj_stat;
  100. union {
  101. struct {
  102. u_long low;
  103. u_long high;
  104. } RJ_versions;
  105. enum auth_stat RJ_why; /* why authentication did not work */
  106. } ru;
  107. #define rj_vers ru.RJ_versions
  108. #define rj_why ru.RJ_why
  109. };
  110. /*
  111. * Body of a reply to an rpc request.
  112. */
  113. struct reply_body {
  114. enum reply_stat rp_stat;
  115. union {
  116. struct accepted_reply RP_ar;
  117. struct rejected_reply RP_dr;
  118. } ru;
  119. #define rp_acpt ru.RP_ar
  120. #define rp_rjct ru.RP_dr
  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. * The rpc message
  135. */
  136. struct rpc_msg {
  137. u_long rm_xid;
  138. enum msg_type rm_direction;
  139. union {
  140. struct call_body RM_cmb;
  141. struct reply_body RM_rmb;
  142. } ru;
  143. #define rm_call ru.RM_cmb
  144. #define rm_reply ru.RM_rmb
  145. };
  146. #define acpted_rply ru.RM_rmb.ru.RP_ar
  147. #define rjcted_rply ru.RM_rmb.ru.RP_dr
  148. /*
  149. * XDR routine to handle a rpc message.
  150. * xdr_callmsg(xdrs, cmsg)
  151. * XDR *xdrs;
  152. * struct rpc_msg *cmsg;
  153. */
  154. extern bool_t xdr_callmsg (XDR *__xdrs, struct rpc_msg *__cmsg) __THROW;
  155. libc_hidden_proto(xdr_callmsg)
  156. /*
  157. * XDR routine to pre-serialize the static part of a rpc message.
  158. * xdr_callhdr(xdrs, cmsg)
  159. * XDR *xdrs;
  160. * struct rpc_msg *cmsg;
  161. */
  162. extern bool_t xdr_callhdr (XDR *__xdrs, struct rpc_msg *__cmsg) __THROW;
  163. libc_hidden_proto(xdr_callhdr)
  164. /*
  165. * XDR routine to handle a rpc reply.
  166. * xdr_replymsg(xdrs, rmsg)
  167. * XDR *xdrs;
  168. * struct rpc_msg *rmsg;
  169. */
  170. extern bool_t xdr_replymsg (XDR *__xdrs, struct rpc_msg *__rmsg) __THROW;
  171. libc_hidden_proto(xdr_replymsg)
  172. /*
  173. * Fills in the error part of a reply message.
  174. * _seterr_reply(msg, error)
  175. * struct rpc_msg *msg;
  176. * struct rpc_err *error;
  177. */
  178. extern void _seterr_reply (struct rpc_msg *__msg, struct rpc_err *__error)
  179. __THROW;
  180. libc_hidden_proto(_seterr_reply)
  181. __END_DECLS
  182. #endif /* rpc/rpc_msg.h */