Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

clnt.h

Go to the documentation of this file.
00001 /* $Id$ */
00002 /*      $OpenBSD: clnt.h,v 1.4 1998/03/19 00:27:17 millert Exp $        */
00003 /*      $NetBSD: clnt.h,v 1.6 1995/04/29 05:27:58 cgd Exp $     */
00004 
00005 /*
00006  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
00007  * unrestricted use provided that this legend is included on all tape
00008  * media and as a part of the software program in whole or part.  Users
00009  * may copy or modify Sun RPC without charge, but are not authorized
00010  * to license or distribute it to anyone else except as part of a product or
00011  * program developed by the user.
00012  * 
00013  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
00014  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
00015  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
00016  * 
00017  * Sun RPC is provided with no support and without any obligation on the
00018  * part of Sun Microsystems, Inc. to assist in its use, correction,
00019  * modification or enhancement.
00020  * 
00021  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
00022  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
00023  * OR ANY PART THEREOF.
00024  * 
00025  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
00026  * or profits or other special, indirect and consequential damages, even if
00027  * Sun has been advised of the possibility of such damages.
00028  * 
00029  * Sun Microsystems, Inc.
00030  * 2550 Garcia Avenue
00031  * Mountain View, California  94043
00032  *
00033  *      from: @(#)clnt.h 1.31 88/02/08 SMI
00034  *      @(#)clnt.h      2.1 88/07/29 4.0 RPCSRC
00035  */
00036 
00037 /*
00038  * clnt.h - Client side remote procedure call interface.
00039  *
00040  * Copyright (C) 1984, Sun Microsystems, Inc.
00041  */
00042 
00043 #ifndef _RPC_CLNT_H_
00044 #define _RPC_CLNT_H_
00045 #ifndef WIN32
00046         #include <sys/cdefs.h>
00047 #endif
00048 
00049 /*
00050  * Rpc calls return an enum clnt_stat.  This should be looked at more,
00051  * since each implementation is required to live with this (implementation
00052  * independent) list of errors.
00053  */
00054 enum clnt_stat {
00055         RPC_SUCCESS=0,                  /* call succeeded */
00056         /*
00057          * local errors
00058          */
00059         RPC_CANTENCODEARGS=1,           /* can't encode arguments */
00060         RPC_CANTDECODERES=2,            /* can't decode results */
00061         RPC_CANTSEND=3,                 /* failure in sending call */
00062         RPC_CANTRECV=4,                 /* failure in receiving result */
00063         RPC_TIMEDOUT=5,                 /* call timed out */
00064         /*
00065          * remote errors
00066          */
00067         RPC_VERSMISMATCH=6,             /* rpc versions not compatible */
00068         RPC_AUTHERROR=7,                /* authentication error */
00069         RPC_PROGUNAVAIL=8,              /* program not available */
00070         RPC_PROGVERSMISMATCH=9,         /* program version mismatched */
00071         RPC_PROCUNAVAIL=10,             /* procedure unavailable */
00072         RPC_CANTDECODEARGS=11,          /* decode arguments error */
00073         RPC_SYSTEMERROR=12,             /* generic "other problem" */
00074 
00075         /*
00076          * callrpc & clnt_create errors
00077          */
00078         RPC_UNKNOWNHOST=13,             /* unknown host name */
00079         RPC_UNKNOWNPROTO=17,            /* unkown protocol */
00080 
00081         /*
00082          * _ create errors
00083          */
00084         RPC_PMAPFAILURE=14,             /* the pmapper failed in its call */
00085         RPC_PROGNOTREGISTERED=15,       /* remote program is not registered */
00086         /*
00087          * unspecified error
00088          */
00089         RPC_FAILED=16
00090 };
00091 
00092 
00093 /*
00094  * Error info.
00095  */
00096 struct rpc_err {
00097         enum clnt_stat re_status;
00098         union {
00099                 int RE_errno;           /* realated system error */
00100                 enum auth_stat RE_why;  /* why the auth error occurred */
00101                 struct {
00102                         u_int32_t low;  /* lowest verion supported */
00103                         u_int32_t high; /* highest verion supported */
00104                 } RE_vers;
00105                 struct {                /* maybe meaningful if RPC_FAILED */
00106                         int32_t s1;
00107                         int32_t s2;
00108                 } RE_lb;                /* life boot & debugging only */
00109         } ru;
00110 #define re_errno        ru.RE_errno
00111 #define re_why          ru.RE_why
00112 #define re_vers         ru.RE_vers
00113 #define re_lb           ru.RE_lb
00114 };
00115 
00116 
00117 /*
00118  * Client rpc handle.
00119  * Created by individual implementations, see e.g. rpc_udp.c.
00120  * Client is responsible for initializing auth, see e.g. auth_none.c.
00121  */
00122 typedef struct __rpc_client {
00123         AUTH    *cl_auth;                       /* authenticator */
00124         struct clnt_ops {
00125                 /* call remote procedure */
00126                 enum clnt_stat  (*cl_call) __P((struct __rpc_client *,
00127                                     u_long, xdrproc_t, caddr_t, xdrproc_t,
00128                                     caddr_t, struct timeval));
00129                 /* abort a call */
00130                 void            (*cl_abort) __P((struct __rpc_client *));
00131                 /* get specific error code */
00132                 void            (*cl_geterr) __P((struct __rpc_client *,
00133                                     struct rpc_err *));
00134                 /* frees results */
00135                 bool_t          (*cl_freeres) __P((struct __rpc_client *,
00136                                     xdrproc_t, caddr_t));
00137                 /* destroy this structure */
00138                 void            (*cl_destroy) __P((struct __rpc_client *));
00139                 /* the ioctl() of rpc */
00140                 bool_t          (*cl_control) __P((struct __rpc_client *, u_int,
00141                                     void *));
00142         } *cl_ops;
00143         caddr_t                 cl_private;     /* private stuff */
00144 } CLIENT;
00145 
00146 
00147 /*
00148  * client side rpc interface ops
00149  *
00150  * Parameter types are:
00151  *
00152  */
00153 
00154 /*
00155  * enum clnt_stat
00156  * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout)
00157  *      CLIENT *rh;
00158  *      u_long proc;
00159  *      xdrproc_t xargs;
00160  *      caddr_t argsp;
00161  *      xdrproc_t xres;
00162  *      caddr_t resp;
00163  *      struct timeval timeout;
00164  */
00165 #define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs)             \
00166         ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, (caddr_t)argsp,      \
00167             xres, (caddr_t)resp, secs))
00168 #define clnt_call(rh, proc, xargs, argsp, xres, resp, secs)             \
00169         ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, (caddr_t)argsp,      \
00170             xres, (caddr_t)resp, secs))
00171 
00172 /*
00173  * void
00174  * CLNT_ABORT(rh);
00175  *      CLIENT *rh;
00176  */
00177 #define CLNT_ABORT(rh)  ((*(rh)->cl_ops->cl_abort)(rh))
00178 #define clnt_abort(rh)  ((*(rh)->cl_ops->cl_abort)(rh))
00179 
00180 /*
00181  * struct rpc_err
00182  * CLNT_GETERR(rh);
00183  *      CLIENT *rh;
00184  */
00185 #define CLNT_GETERR(rh,errp)    ((*(rh)->cl_ops->cl_geterr)(rh, errp))
00186 #define clnt_geterr(rh,errp)    ((*(rh)->cl_ops->cl_geterr)(rh, errp))
00187 
00188 
00189 /*
00190  * bool_t
00191  * CLNT_FREERES(rh, xres, resp);
00192  *      CLIENT *rh;
00193  *      xdrproc_t xres;
00194  *      caddr_t resp;
00195  */
00196 #define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
00197 #define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
00198 
00199 /*
00200  * bool_t
00201  * CLNT_CONTROL(cl, request, info)
00202  *      CLIENT *cl;
00203  *      u_int request;
00204  *      char *info;
00205  */
00206 #define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
00207 #define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
00208 
00209 /*
00210  * control operations that apply to both udp and tcp transports
00211  */
00212 #define CLSET_TIMEOUT       1   /* set timeout (timeval) */
00213 #define CLGET_TIMEOUT       2   /* get timeout (timeval) */
00214 #define CLGET_SERVER_ADDR   3   /* get server's address (sockaddr) */
00215 /*
00216  * udp only control operations
00217  */
00218 #define CLSET_RETRY_TIMEOUT 4   /* set retry timeout (timeval) */
00219 #define CLGET_RETRY_TIMEOUT 5   /* get retry timeout (timeval) */
00220 
00221 /*
00222  * void
00223  * CLNT_DESTROY(rh);
00224  *      CLIENT *rh;
00225  */
00226 #define CLNT_DESTROY(rh)        ((*(rh)->cl_ops->cl_destroy)(rh))
00227 #define clnt_destroy(rh)        ((*(rh)->cl_ops->cl_destroy)(rh))
00228 
00229 
00230 /*
00231  * RPCTEST is a test program which is accessable on every rpc
00232  * transport/port.  It is used for testing, performance evaluation,
00233  * and network administration.
00234  */
00235 
00236 #define RPCTEST_PROGRAM         ((u_long)1)
00237 #define RPCTEST_VERSION         ((u_long)1)
00238 #define RPCTEST_NULL_PROC       ((u_long)2)
00239 #define RPCTEST_NULL_BATCH_PROC ((u_long)3)
00240 
00241 /*
00242  * By convention, procedure 0 takes null arguments and returns them
00243  */
00244 
00245 #define NULLPROC ((u_int)0)
00246 
00247 /*
00248  * Below are the client handle creation routines for the various
00249  * implementations of client side rpc.  They can return NULL if a 
00250  * creation failure occurs.
00251  */
00252 
00253 /*
00254  * Memory based rpc (for speed check and testing)
00255  * CLIENT *
00256  * clntraw_create(prog, vers)
00257  *      u_long prog;
00258  *      u_long vers;
00259  */
00260 __BEGIN_DECLS
00261 extern CLIENT *clntraw_create   __P((u_long, u_long));
00262 __END_DECLS
00263 
00264 
00265 /*
00266  * Generic client creation routine. Supported protocols are "udp" and "tcp"
00267  * CLIENT *
00268  * clnt_create(host, prog, vers, prot);
00269  *      char *host;     -- hostname
00270  *      u_long prog;    -- program number
00271  *      u_long vers;    -- version number
00272  *      char *prot;     -- protocol
00273  */
00274 __BEGIN_DECLS
00275 extern CLIENT *clnt_create      __P((char *, u_long, u_long, char *));
00276 __END_DECLS
00277 
00278 
00279 /*
00280  * TCP based rpc
00281  * CLIENT *
00282  * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
00283  *      struct sockaddr_in *raddr;
00284  *      u_long prog;
00285  *      u_long version;
00286  *      register int *sockp;
00287  *      u_int sendsz;
00288  *      u_int recvsz;
00289  */
00290 __BEGIN_DECLS
00291 extern CLIENT *clnttcp_create   __P((struct sockaddr_in *,
00292                                      u_long,
00293                                      u_long,
00294                                      int *,
00295                                      u_int,
00296                                      u_int));
00297 __END_DECLS
00298 
00299 
00300 /*
00301  * UDP based rpc.
00302  * CLIENT *
00303  * clntudp_create(raddr, program, version, wait, sockp)
00304  *      struct sockaddr_in *raddr;
00305  *      u_long program;
00306  *      u_long version;
00307  *      struct timeval wait;
00308  *      int *sockp;
00309  *
00310  * Same as above, but you specify max packet sizes.
00311  * CLIENT *
00312  * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
00313  *      struct sockaddr_in *raddr;
00314  *      u_long program;
00315  *      u_long version;
00316  *      struct timeval wait;
00317  *      int *sockp;
00318  *      u_int sendsz;
00319  *      u_int recvsz;
00320  */
00321 __BEGIN_DECLS
00322 extern CLIENT *clntudp_create   __P((struct sockaddr_in *,
00323                                      u_long,
00324                                      u_long,
00325                                      struct timeval,
00326                                      int *));
00327 extern CLIENT *clntudp_bufcreate __P((struct sockaddr_in *,
00328                                      u_long,
00329                                      u_long,
00330                                      struct timeval,
00331                                      int *,
00332                                      u_int,
00333                                      u_int));
00334 __END_DECLS
00335 
00336 
00337 /*
00338  * Print why creation failed
00339  */
00340 __BEGIN_DECLS
00341 extern void clnt_pcreateerror   __P((char *));                  /* stderr */
00342 extern char *clnt_spcreateerror __P((char *));                  /* string */
00343 __END_DECLS
00344 
00345 /*
00346  * Like clnt_perror(), but is more verbose in its output
00347  */ 
00348 __BEGIN_DECLS
00349 extern void clnt_perrno         __P((enum clnt_stat));          /* stderr */
00350 extern char *clnt_sperrno       __P((enum clnt_stat));          /* string */
00351 __END_DECLS
00352 
00353 /*
00354  * Print an English error message, given the client error code
00355  */
00356 __BEGIN_DECLS
00357 extern void clnt_perror         __P((CLIENT *, char *));        /* stderr */
00358 extern char *clnt_sperror       __P((CLIENT *, char *));        /* string */
00359 __END_DECLS
00360 
00361 
00362 /* 
00363  * If a creation fails, the following allows the user to figure out why.
00364  */
00365 struct rpc_createerr {
00366         enum clnt_stat cf_stat;
00367         struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */
00368 };
00369 
00370 extern struct rpc_createerr rpc_createerr;
00371 
00372 
00373 #define UDPMSGSIZE      8800    /* rpc imposed limit on udp msg size */
00374 #define RPCSMALLMSGSIZE 400     /* a more reasonable packet size */
00375 
00376 #endif /* !_RPC_CLNT_H */

Generated on Sun May 14 14:51:20 2006 by  doxygen 1.4.2