rpc_msg.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /* @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC */
  2. /*
  3. * Copyright (c) 2010, Oracle America, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. *
  10. * * Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. *
  13. * * Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in
  15. * the documentation and/or other materials provided with the
  16. * distribution.
  17. *
  18. * * Neither the name of the "Oracle America, Inc." nor the names of
  19. * its contributors may be used to endorse or promote products
  20. * derived from this software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
  23. * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  24. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  25. * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  26. * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  27. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
  28. * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  29. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  30. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  31. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  32. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. /* @(#)rpc_msg.h 1.7 86/07/16 SMI */
  35. /*
  36. * rpc_msg.h
  37. * rpc message definition
  38. */
  39. #ifndef GSSRPC_RPC_MSG_H
  40. #define GSSRPC_RPC_MSG_H
  41. GSSRPC__BEGIN_DECLS
  42. #define RPC_MSG_VERSION ((uint32_t) 2)
  43. #define RPC_SERVICE_PORT ((u_short) 2048)
  44. /*
  45. * Bottom up definition of an rpc message.
  46. * NOTE: call and reply use the same overall stuct but
  47. * different parts of unions within it.
  48. */
  49. enum msg_type {
  50. CALL=0,
  51. REPLY=1
  52. };
  53. enum reply_stat {
  54. MSG_ACCEPTED=0,
  55. MSG_DENIED=1
  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. enum reject_stat {
  66. RPC_MISMATCH=0,
  67. AUTH_ERROR=1
  68. };
  69. /*
  70. * Reply part of an rpc exchange
  71. */
  72. /*
  73. * Reply to an rpc request that was accepted by the server.
  74. * Note: there could be an error even though the request was
  75. * accepted.
  76. */
  77. struct accepted_reply {
  78. struct opaque_auth ar_verf;
  79. enum accept_stat ar_stat;
  80. union {
  81. struct {
  82. rpcvers_t low;
  83. rpcvers_t high;
  84. } AR_versions;
  85. struct {
  86. caddr_t where;
  87. xdrproc_t proc;
  88. } AR_results;
  89. /* and many other null cases */
  90. } ru;
  91. #define ar_results ru.AR_results
  92. #define ar_vers ru.AR_versions
  93. };
  94. /*
  95. * Reply to an rpc request that was rejected by the server.
  96. */
  97. struct rejected_reply {
  98. enum reject_stat rj_stat;
  99. union {
  100. struct {
  101. rpcvers_t low;
  102. rpcvers_t high;
  103. } RJ_versions;
  104. enum auth_stat RJ_why; /* why authentication did not work */
  105. } ru;
  106. #define rj_vers ru.RJ_versions
  107. #define rj_why ru.RJ_why
  108. };
  109. /*
  110. * Body of a reply to an rpc request.
  111. */
  112. struct reply_body {
  113. enum reply_stat rp_stat;
  114. union {
  115. struct accepted_reply RP_ar;
  116. struct rejected_reply RP_dr;
  117. } ru;
  118. #define rp_acpt ru.RP_ar
  119. #define rp_rjct ru.RP_dr
  120. };
  121. /*
  122. * Body of an rpc request call.
  123. */
  124. struct call_body {
  125. rpcvers_t cb_rpcvers; /* must be equal to two */
  126. rpcprog_t cb_prog;
  127. rpcvers_t cb_vers;
  128. rpcproc_t cb_proc;
  129. struct opaque_auth cb_cred;
  130. struct opaque_auth cb_verf; /* protocol specific - provided by client */
  131. };
  132. /*
  133. * The rpc message
  134. */
  135. struct rpc_msg {
  136. uint32_t rm_xid;
  137. enum msg_type rm_direction;
  138. union {
  139. struct call_body RM_cmb;
  140. struct reply_body RM_rmb;
  141. } ru;
  142. #define rm_call ru.RM_cmb
  143. #define rm_reply ru.RM_rmb
  144. };
  145. #define acpted_rply ru.RM_rmb.ru.RP_ar
  146. #define rjcted_rply ru.RM_rmb.ru.RP_dr
  147. /*
  148. * XDR routine to handle a rpc message.
  149. * xdr_callmsg(xdrs, cmsg)
  150. * XDR *xdrs;
  151. * struct rpc_msg *cmsg;
  152. */
  153. extern bool_t xdr_callmsg(XDR *, struct rpc_msg *);
  154. /*
  155. * XDR routine to pre-serialize the static part of a rpc message.
  156. * xdr_callhdr(xdrs, cmsg)
  157. * XDR *xdrs;
  158. * struct rpc_msg *cmsg;
  159. */
  160. extern bool_t xdr_callhdr(XDR *, struct rpc_msg *);
  161. /*
  162. * XDR routine to handle a rpc reply.
  163. * xdr_replymsg(xdrs, rmsg)
  164. * XDR *xdrs;
  165. * struct rpc_msg *rmsg;
  166. */
  167. extern bool_t xdr_replymsg(XDR *, struct rpc_msg *);
  168. /*
  169. * Fills in the error part of a reply message.
  170. * _seterr_reply(msg, error)
  171. * struct rpc_msg *msg;
  172. * struct rpc_err *error;
  173. */
  174. /*
  175. * RENAMED: should be _seterr_reply or __seterr_reply if we can use
  176. * reserved namespace.
  177. */
  178. extern void gssrpc__seterr_reply(struct rpc_msg *, struct rpc_err *);
  179. /* XDR the MSG_ACCEPTED part of a reply message union */
  180. extern bool_t xdr_accepted_reply(XDR *, struct accepted_reply *);
  181. /* XDR the MSG_DENIED part of a reply message union */
  182. extern bool_t xdr_rejected_reply(XDR *, struct rejected_reply *);
  183. GSSRPC__END_DECLS
  184. #endif /* !defined(GSSRPC_RPC_MSG_H) */