home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Headers / bsd / rpc / rpc_msg.h < prev    next >
C/C++ Source or Header  |  1990-04-26  |  3KB  |  163 lines

  1. /*    @(#)rpc_msg.h    1.1 88/03/04 4.0NFSSRC SMI    */
  2.  
  3. /* 
  4.  * Copyright (c) 1988 by Sun Microsystems, Inc.
  5.  *      @(#)rpc_msg.h 1.8 88/02/08 SMI      
  6.  */
  7.  
  8.  
  9. /*
  10.  * rpc_msg.h
  11.  * rpc message definition
  12.  */
  13.  
  14. #define RPC_MSG_VERSION        ((u_long) 2)
  15. #define RPC_SERVICE_PORT    ((u_short) 2048)
  16.  
  17. /*
  18.  * Bottom up definition of an rpc message.
  19.  * NOTE: call and reply use the same overall stuct but
  20.  * different parts of unions within it.
  21.  */
  22.  
  23. enum msg_type {
  24.     CALL=0,
  25.     REPLY=1
  26. };
  27.  
  28. enum reply_stat {
  29.     MSG_ACCEPTED=0,
  30.     MSG_DENIED=1
  31. };
  32.  
  33. enum accept_stat {
  34.     SUCCESS=0,
  35.     PROG_UNAVAIL=1,
  36.     PROG_MISMATCH=2,
  37.     PROC_UNAVAIL=3,
  38.     GARBAGE_ARGS=4,
  39.     SYSTEM_ERR=5
  40. };
  41.  
  42. enum reject_stat {
  43.     RPC_MISMATCH=0,
  44.     AUTH_ERROR=1
  45. };
  46.  
  47. /*
  48.  * Reply part of an rpc exchange
  49.  */
  50.  
  51. /*
  52.  * Reply to an rpc request that was accepted by the server.
  53.  * Note: there could be an error even though the request was
  54.  * accepted.
  55.  */
  56. struct accepted_reply {
  57.     struct opaque_auth    ar_verf;
  58.     enum accept_stat    ar_stat;
  59.     union {
  60.         struct {
  61.             u_long    low;
  62.             u_long    high;
  63.         } AR_versions;
  64.         struct {
  65.             caddr_t    where;
  66.             xdrproc_t proc;
  67.         } AR_results;
  68.         /* and many other null cases */
  69.     } ru;
  70. #define    ar_results    ru.AR_results
  71. #define    ar_vers        ru.AR_versions
  72. };
  73.  
  74. /*
  75.  * Reply to an rpc request that was rejected by the server.
  76.  */
  77. struct rejected_reply {
  78.     enum reject_stat rj_stat;
  79.     union {
  80.         struct {
  81.             u_long low;
  82.             u_long high;
  83.         } RJ_versions;
  84.         enum auth_stat RJ_why;  /* why authentication did not work */
  85.     } ru;
  86. #define    rj_vers    ru.RJ_versions
  87. #define    rj_why    ru.RJ_why
  88. };
  89.  
  90. /*
  91.  * Body of a reply to an rpc request.
  92.  */
  93. struct reply_body {
  94.     enum reply_stat rp_stat;
  95.     union {
  96.         struct accepted_reply RP_ar;
  97.         struct rejected_reply RP_dr;
  98.     } ru;
  99. #define    rp_acpt    ru.RP_ar
  100. #define    rp_rjct    ru.RP_dr
  101. };
  102.  
  103. /*
  104.  * Body of an rpc request call.
  105.  */
  106. struct call_body {
  107.     u_long cb_rpcvers;    /* must be equal to two */
  108.     u_long cb_prog;
  109.     u_long cb_vers;
  110.     u_long cb_proc;
  111.     struct opaque_auth cb_cred;
  112.     struct opaque_auth cb_verf; /* protocol specific - provided by client */
  113. };
  114.  
  115. /*
  116.  * The rpc message
  117.  */
  118. struct rpc_msg {
  119.     u_long            rm_xid;
  120.     enum msg_type        rm_direction;
  121.     union {
  122.         struct call_body RM_cmb;
  123.         struct reply_body RM_rmb;
  124.     } ru;
  125. #define    rm_call        ru.RM_cmb
  126. #define    rm_reply    ru.RM_rmb
  127. };
  128. #define    acpted_rply    ru.RM_rmb.ru.RP_ar
  129. #define    rjcted_rply    ru.RM_rmb.ru.RP_dr
  130.  
  131.  
  132. /*
  133.  * XDR routine to handle a rpc message.
  134.  * xdr_callmsg(xdrs, cmsg)
  135.  *     XDR *xdrs;
  136.  *     struct rpc_msg *cmsg;
  137.  */
  138. extern bool_t    xdr_callmsg();
  139.  
  140. /*
  141.  * XDR routine to pre-serialize the static part of a rpc message.
  142.  * xdr_callhdr(xdrs, cmsg)
  143.  *     XDR *xdrs;
  144.  *     struct rpc_msg *cmsg;
  145.  */
  146. extern bool_t    xdr_callhdr();
  147.  
  148. /*
  149.  * XDR routine to handle a rpc reply.
  150.  * xdr_replymsg(xdrs, rmsg)
  151.  *     XDR *xdrs;
  152.  *     struct rpc_msg *rmsg;
  153.  */
  154. extern bool_t    xdr_replymsg();
  155.  
  156. /*
  157.  * Fills in the error part of a reply message.
  158.  * _seterr_reply(msg, error)
  159.  *     struct rpc_msg *msg;
  160.  *     struct rpc_err *error;
  161.  */
  162. extern void    _seterr_reply();
  163.