1
0

rpc_msg.h 4.4 KB

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