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