rpc_msg.h 4.8 KB

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