home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 6 File / 06-File.zip / mc454src.zip / mc-4.5.4.src / os2emx / rpc / rpc_msg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-04  |  4.4 KB  |  205 lines

  1. /* modified 1995 by hv for EMX OS/2
  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.  *    from: @(#)rpc_msg.h 1.7 86/07/16 SMI
  31.  *    from: @(#)rpc_msg.h    2.1 88/07/29 4.0 RPCSRC
  32.  *    rpc_msg.h,v 1.4 1995/05/30 04:55:25 rgrimes Exp
  33.  */
  34.  
  35. /*
  36.  * rpc_msg.h
  37.  * rpc message definition
  38.  *
  39.  * Copyright (C) 1984, Sun Microsystems, Inc.
  40.  */
  41.  
  42. #ifndef _RPC_RPCMSG_H
  43. #define _RPC_RPCMSG_H
  44.  
  45. #if defined(__cplusplus)
  46. extern "C" {
  47. #endif
  48.  
  49.  
  50. #define RPC_MSG_VERSION        ((u_long) 2)
  51. #define RPC_SERVICE_PORT    ((u_short) 2048)
  52.  
  53. /*
  54.  * Bottom up definition of an rpc message.
  55.  * NOTE: call and reply use the same overall stuct but
  56.  * different parts of unions within it.
  57.  */
  58.  
  59. enum msg_type {
  60.     CALL=0,
  61.     REPLY=1
  62. };
  63.  
  64. enum reply_stat {
  65.     MSG_ACCEPTED=0,
  66.     MSG_DENIED=1
  67. };
  68.  
  69. enum accept_stat {
  70.     SUCCESS=0,
  71.     PROG_UNAVAIL=1,
  72.     PROG_MISMATCH=2,
  73.     PROC_UNAVAIL=3,
  74.     GARBAGE_ARGS=4,
  75.     SYSTEM_ERR=5
  76. };
  77.  
  78. enum reject_stat {
  79.     RPC_MISMATCH=0,
  80.     AUTH_ERROR=1
  81. };
  82.  
  83. /*
  84.  * Reply part of an rpc exchange
  85.  */
  86.  
  87. /*
  88.  * Reply to an rpc request that was accepted by the server.
  89.  * Note: there could be an error even though the request was
  90.  * accepted.
  91.  */
  92. struct accepted_reply {
  93.     struct opaque_auth    ar_verf;
  94.     enum accept_stat    ar_stat;
  95.     union {
  96.         struct {
  97.             u_long    low;
  98.             u_long    high;
  99.         } AR_versions;
  100.         struct {
  101.             caddr_t    where;
  102.             xdrproc_t proc;
  103.         } AR_results;
  104.         /* and many other null cases */
  105.     } ru;
  106. #define    ar_results    ru.AR_results
  107. #define    ar_vers        ru.AR_versions
  108. };
  109.  
  110. /*
  111.  * Reply to an rpc request that was rejected by the server.
  112.  */
  113. struct rejected_reply {
  114.     enum reject_stat rj_stat;
  115.     union {
  116.         struct {
  117.             u_long low;
  118.             u_long high;
  119.         } RJ_versions;
  120.         enum auth_stat RJ_why;  /* why authentication did not work */
  121.     } ru;
  122. #define    rj_vers    ru.RJ_versions
  123. #define    rj_why    ru.RJ_why
  124. };
  125.  
  126. /*
  127.  * Body of a reply to an rpc request.
  128.  */
  129. struct reply_body {
  130.     enum reply_stat rp_stat;
  131.     union {
  132.         struct accepted_reply RP_ar;
  133.         struct rejected_reply RP_dr;
  134.     } ru;
  135. #define    rp_acpt    ru.RP_ar
  136. #define    rp_rjct    ru.RP_dr
  137. };
  138.  
  139. /*
  140.  * Body of an rpc request call.
  141.  */
  142. struct call_body {
  143.     u_long cb_rpcvers;    /* must be equal to two */
  144.     u_long cb_prog;
  145.     u_long cb_vers;
  146.     u_long cb_proc;
  147.     struct opaque_auth cb_cred;
  148.     struct opaque_auth cb_verf; /* protocol specific - provided by client */
  149. };
  150.  
  151. /*
  152.  * The rpc message
  153.  */
  154. struct rpc_msg {
  155.     u_long            rm_xid;
  156.     enum msg_type        rm_direction;
  157.     union {
  158.         struct call_body RM_cmb;
  159.         struct reply_body RM_rmb;
  160.     } ru;
  161. #define    rm_call        ru.RM_cmb
  162. #define    rm_reply    ru.RM_rmb
  163. };
  164. #define    acpted_rply    ru.RM_rmb.ru.RP_ar
  165. #define    rjcted_rply    ru.RM_rmb.ru.RP_dr
  166.  
  167. /*
  168.  * XDR routine to handle a rpc message.
  169.  * xdr_callmsg(xdrs, cmsg)
  170.  *     XDR *xdrs;
  171.  *     struct rpc_msg *cmsg;
  172.  */
  173. bool_t    xdr_callmsg    (XDR *, struct rpc_msg *);
  174.  
  175. /*
  176.  * XDR routine to pre-serialize the static part of a rpc message.
  177.  * xdr_callhdr(xdrs, cmsg)
  178.  *     XDR *xdrs;
  179.  *     struct rpc_msg *cmsg;
  180.  */
  181. bool_t    xdr_callhdr    (XDR *, struct rpc_msg *);
  182.  
  183. /*
  184.  * XDR routine to handle a rpc reply.
  185.  * xdr_replymsg(xdrs, rmsg)
  186.  *     XDR *xdrs;
  187.  *     struct rpc_msg *rmsg;
  188.  */
  189. bool_t    xdr_replymsg    (XDR *, struct rpc_msg *);
  190.  
  191. /*
  192.  * Fills in the error part of a reply message.
  193.  * _seterr_reply(msg, error)
  194.  *     struct rpc_msg *msg;
  195.  *     struct rpc_err *error;
  196.  */
  197. struct rpc_err;
  198. void    _seterr_reply    (struct rpc_msg *, struct rpc_err *);
  199.  
  200. #if defined(__cplusplus)
  201. }
  202. #endif
  203.  
  204. #endif /* !_RPC_RPCMSG_H */
  205.