home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 29 Fixes_o / 29-Fixes_o.zip / prgcsd.exe / CLNT.H < prev    next >
Text File  |  1992-11-12  |  11KB  |  314 lines

  1. /********************************************************copyrite.xmc***/
  2. /*                                                                     */
  3. /*   Licensed Materials - Property of IBM                              */
  4. /*                                                                     */
  5. /*   This module is "Restricted Materials of IBM":                     */
  6. /*      Program Number:   5798RXW                                      */
  7. /*      Program Name:     IBM TCP/IP Version 1.2 for OS/2              */
  8. /*   (C) Copyright IBM Corporation. 1990, 1991.                        */
  9. /*                                                                     */
  10. /*   See IBM Copyright Instructions.                                   */
  11. /*                                                                     */
  12. /********************************************************copyrite.xmc***/
  13. /*
  14.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  15.  * unrestricted use provided that this legend is included on all tape
  16.  * media and as a part of the software program in whole or part.  Users
  17.  * may copy or modify Sun RPC without charge, but are not authorized
  18.  * to license or distribute it to anyone else except as part of a product or
  19.  * program developed by the user.
  20.  *
  21.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  22.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  23.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  24.  *
  25.  * Sun RPC is provided with no support and without any obligation on the
  26.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  27.  * modification or enhancement.
  28.  *
  29.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  30.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  31.  * OR ANY PART THEREOF.
  32.  *
  33.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  34.  * or profits or other special, indirect and consequential damages, even if
  35.  * Sun has been advised of the possibility of such damages.
  36.  *
  37.  * Sun Microsystems, Inc.
  38.  * 2550 Garcia Avenue
  39.  * Mountain View, California  94043
  40.  */
  41. /*      @(#)clnt.h 1.1 86/02/03 SMI      */
  42.  
  43. /*
  44.  * clnt.h - Client side remote procedure call interface.
  45.  *
  46.  * Copyright (C) 1984, Sun Microsystems, Inc.
  47.  */
  48. #ifndef INCL_RPC_CLNT_H
  49. #define INCL_RPC_CLNT_H
  50. #ifndef __32BIT__
  51. #define _Packed
  52. #define _Seg16
  53. #define _Far16
  54. #define _Cdecl
  55. #endif
  56.  
  57.  
  58. #ifdef __32BIT__
  59. #define rpc_cerr _rpc_cerr
  60. #endif
  61.  
  62.  
  63. /*
  64.  * Rpc calls return an enum clnt_stat.  This should be looked at more,
  65.  * since each implementation is required to live with this (implementation
  66.  * independent) list of errors.
  67.  */
  68. enum clnt_stat {
  69.         RPC_SUCCESS=0,                  /* call succeeded */
  70.         /*
  71.          * local errors
  72.          */
  73.         RPC_CANTENCODEARGS=1,           /* can't encode arguments */
  74.         RPC_CANTDECODERES=2,            /* can't decode results */
  75.         RPC_CANTSEND=3,                 /* failure in sending call */
  76.         RPC_CANTRECV=4,                 /* failure in receiving result */
  77.         RPC_TIMEDOUT=5,                 /* call timed out */
  78.         /*
  79.          * remote errors
  80.          */
  81.         RPC_VERSMISMATCH=6,             /* rpc versions not compatible */
  82.         RPC_AUTHERROR=7,                /* authentication error */
  83.         RPC_PROGUNAVAIL=8,              /* program not available */
  84.         RPC_PROGVERSMISMATCH=9,         /* program version mismatched */
  85.         RPC_PROCUNAVAIL=10,             /* procedure unavailable */
  86.         RPC_CANTDECODEARGS=11,          /* decode arguments error */
  87.         RPC_SYSTEMERROR=12,             /* generic "other problem" */
  88.  
  89.         /*
  90.          * callrpc errors
  91.          */
  92.         RPC_UNKNOWNHOST=13,             /* unknown host name */
  93.  
  94.         /*
  95.          * _ create errors
  96.          */
  97.         RPC_PMAPFAILURE=14,             /* the pmapper failed in its call */
  98.         RPC_PROGNOTREGISTERED=15,       /* remote program is not registered */
  99.         /*
  100.          * unspecified error
  101.          */
  102.         RPC_FAILED=16
  103. #ifdef __32BIT__
  104.         ,
  105.         RPC_DUMMY=32767
  106. #endif
  107. };
  108.  
  109.  
  110. /*
  111.  * Error info.
  112.  */
  113. _Packed struct rpc_err {
  114.         enum clnt_stat re_status;
  115.         union {
  116.                 short RE_errno;           /* realated system error */
  117.                 enum auth_stat RE_why;  /* why the auth error occurred */
  118.                 struct {
  119.                         u_long low;     /* lowest verion supported */
  120.                         u_long high;    /* highest verion supported */
  121.                 } RE_vers;
  122.                 struct {                /* maybe meaningful if RPC_FAILED */
  123.                         long s1;
  124.                         long s2;
  125.                 } RE_lb;                /* life boot & debugging only */
  126.         } ru;
  127. #define re_errno        ru.RE_errno
  128. #define re_why          ru.RE_why
  129. #define re_vers         ru.RE_vers
  130. #define re_lb           ru.RE_lb
  131. };
  132.  
  133.  
  134. /*
  135.  * Client rpc handle.
  136.  * Created by individual implementations, see e.g. rpc_udp.c.
  137.  * Client is responsible for initializing auth, see e.g. auth_none.c.
  138.  */
  139. typedef _Packed struct {
  140.         AUTH    * _Seg16 cl_auth;                       /* authenticator */
  141.         struct clnt_ops {
  142.                 enum clnt_stat  (* _Seg16 _Far16 _Cdecl cl_call)(void * _Seg16,u_long,xdrproc_t,void * _Seg16,xdrproc_t,void * _Seg16,struct timeval);   /* call remote procedure */
  143.                 void            (* _Seg16 _Far16 _Cdecl cl_abort)(void * _Seg16);  /* abort a call */
  144.                 void            (* _Seg16 _Far16 _Cdecl cl_geterr)(void * _Seg16,_Packed struct rpc_err * _Seg16); /* get specific error code */
  145.                 bool_t          (* _Seg16 _Far16 _Cdecl cl_freeres)(void * _Seg16, xdrproc_t,void * _Seg16); /* frees results */
  146.                 void            (* _Seg16 _Far16 _Cdecl cl_destroy)(void * _Seg16);/* destroy this structure */
  147.         } * _Seg16 cl_ops;
  148.         char * _Seg16         cl_private;     /* private stuff */
  149. } CLIENT;
  150.  
  151.  
  152. /*
  153.  * client side rpc interface ops
  154.  *
  155.  * Parameter types are:
  156.  *
  157.  */
  158.  
  159. /*
  160.  * enum clnt_stat
  161.  * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout)
  162.  *      CLIENT *rh;
  163.  *      u_long proc;
  164.  *      xdrproc_t xargs;
  165.  *      caddr_t argsp;
  166.  *      xdrproc_t xres;
  167.  *      caddr_t resp;
  168.  *      struct timeval timeout;
  169.  */
  170. #define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs)     \
  171.         ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs))
  172. #define clnt_call(rh, proc, xargs, argsp, xres, resp, secs)     \
  173.         ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs))
  174.  
  175. /*
  176.  * void
  177.  * CLNT_ABORT(rh);
  178.  *      CLIENT *rh;
  179.  */
  180. #define CLNT_ABORT(rh)  ((*(rh)->cl_ops->cl_abort)(rh))
  181. #define clnt_abort(rh)  ((*(rh)->cl_ops->cl_abort)(rh))
  182.  
  183. /*
  184.  * struct rpc_err
  185.  * CLNT_GETERR(rh);
  186.  *      CLIENT *rh;
  187.  */
  188. #define CLNT_GETERR(rh,errp)    ((*(rh)->cl_ops->cl_geterr)(rh, errp))
  189. #define clnt_geterr(rh,errp)    ((*(rh)->cl_ops->cl_geterr)(rh, errp))
  190.  
  191.  
  192. /*
  193.  * bool_t
  194.  * CLNT_FREERES(rh, xres, resp);
  195.  *      CLIENT *rh;
  196.  *      xdrproc_t xres;
  197.  *      caddr_t resp;
  198.  */
  199. #define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
  200. #define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
  201.  
  202. /*
  203.  * void
  204.  * CLNT_DESTROY(rh);
  205.  *      CLIENT *rh;
  206.  */
  207. #define CLNT_DESTROY(rh)        ((*(rh)->cl_ops->cl_destroy)(rh))
  208. #define clnt_destroy(rh)        ((*(rh)->cl_ops->cl_destroy)(rh))
  209.  
  210.  
  211. /*
  212.  * RPCTEST is a test program which is accessable on every rpc
  213.  * transport/port.  It is used for testing, performance evaluation,
  214.  * and network administration.
  215.  */
  216.  
  217. #define RPCTEST_PROGRAM         ((u_long)1)
  218. #define RPCTEST_VERSION         ((u_long)1)
  219. #define RPCTEST_NULL_PROC       ((u_long)2)
  220. #define RPCTEST_NULL_BATCH_PROC ((u_long)3)
  221.  
  222. /*
  223.  * By convention, procedure 0 takes null arguments and returns them
  224.  */
  225.  
  226. #define NULLPROC ((u_long)0)
  227.  
  228. /*
  229.  * Below are the client handle creation routines for the various
  230.  * implementations of client side rpc.  They can return NULL if a
  231.  * creation failure occurs.
  232.  */
  233.  
  234. /*
  235.  * Memory based rpc (for speed check and testing)
  236.  * CLIENT *
  237.  * clntraw_create(prog, vers)
  238.  *      u_long prog;
  239.  *      u_long vers;
  240.  */
  241. #if 0
  242. extern CLIENT * _Seg16 _Far16 _Cdecl clntraw_create();
  243. #endif
  244.  
  245. /*
  246.  * TCP based rpc
  247.  * CLIENT *
  248.  * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
  249.  *      struct sockaddr_in *raddr;
  250.  *      u_long prog;
  251.  *      u_long version;
  252.  *      register int *sockp;
  253.  *      u_int sendsz;
  254.  *      u_int recvsz;
  255.  */
  256. #if 0
  257. extern CLIENT * _Seg16 _Far16 _Cdecl clnttcp_create(void);
  258. #endif
  259.  
  260. /*
  261.  * UDP based rpc.
  262.  * CLIENT *
  263.  * clntudp_create(raddr, program, version, wait, sockp)
  264.  *      struct sockaddr_in *raddr;
  265.  *      u_long program;
  266.  *      u_long version;
  267.  *      struct timeval wait;
  268.  *      int *sockp;
  269.  *
  270.  * Same as above, but you specify max packet sizes.
  271.  * CLIENT *
  272.  * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
  273.  *      struct sockaddr_in *raddr;
  274.  *      u_long program;
  275.  *      u_long version;
  276.  *      struct timeval wait;
  277.  *      int *sockp;
  278.  *      u_int sendsz;
  279.  *      u_int recvsz;
  280.  */
  281. #if 0
  282. extern CLIENT * _Seg16 _Far16 _Cdecl clntudp_create();
  283. extern CLIENT * _Seg16 _Far16 _Cdecl clntudp_bufcreate();
  284. #endif
  285.  
  286. /*
  287.  * If a creation fails, the following allows the user to figure out why.
  288.  */
  289. _Packed struct rpc_createerr {
  290.         enum clnt_stat cf_stat;
  291.         _Packed struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */
  292. };
  293.  
  294. extern _Packed struct rpc_createerr rpc_createerr;
  295.  
  296.  
  297. #define UDPMSGSIZE      8800    /* rpc imposed limit on udp msg size */
  298. #define RPCSMALLMSGSIZE 400     /* a more reasonable packet size */
  299.  
  300. /* from here on lint stuff O.V. */
  301. void _Far16 _Cdecl clnt_perror( CLIENT * _Seg16, char * _Seg16);
  302. void _Far16 _Cdecl clnt_perrno( enum clnt_stat);
  303. short _Far16 _Cdecl clnt_pcreateerror( char * _Seg16);
  304. CLIENT * _Seg16 _Far16 _Cdecl clntraw_create( u_long, u_long);
  305. short _Far16 _Cdecl callrpc(char * _Seg16, u_long, u_long, u_long, xdrproc_t, char * _Seg16, xdrproc_t, char * _Seg16);
  306. CLIENT * _Seg16
  307. _Far16 _Cdecl clnttcp_create( struct sockaddr_in * _Seg16, u_long, u_long, short * _Seg16, u_short, u_short);
  308. CLIENT * _Seg16
  309. _Far16 _Cdecl clntudp_bufcreate( struct sockaddr_in * _Seg16, u_long, u_long, struct timeval, short * _Seg16,
  310.                    u_short, u_short);
  311. CLIENT * _Seg16
  312. _Far16 _Cdecl clntudp_create( struct sockaddr_in * _Seg16, u_long, u_long, struct timeval, short * _Seg16);
  313. #endif
  314.