Home | History | Annotate | Download | only in rpc
      1 /*
      2  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
      3  * unrestricted use provided that this legend is included on all tape
      4  * media and as a part of the software program in whole or part.  Users
      5  * may copy or modify Sun RPC without charge, but are not authorized
      6  * to license or distribute it to anyone else except as part of a product or
      7  * program developed by the user.
      8  *
      9  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
     10  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
     11  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
     12  *
     13  * Sun RPC is provided with no support and without any obligation on the
     14  * part of Sun Microsystems, Inc. to assist in its use, correction,
     15  * modification or enhancement.
     16  *
     17  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
     18  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
     19  * OR ANY PART THEREOF.
     20  *
     21  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
     22  * or profits or other special, indirect and consequential damages, even if
     23  * Sun has been advised of the possibility of such damages.
     24  *
     25  * Sun Microsystems, Inc.
     26  * 2550 Garcia Avenue
     27  * Mountain View, California  94043
     28  */
     29 
     30 /*
     31  * clnt.h - Client side remote procedure call interface.
     32  *
     33  * Copyright (C) 1984, Sun Microsystems, Inc.
     34  */
     35 
     36 #ifndef _RPC_CLNT_H
     37 #define _RPC_CLNT_H 1
     38 
     39 #ifdef __cplusplus
     40 extern "C" {
     41 #endif
     42 
     43 #include <sys/time.h>
     44 
     45 /*
     46  * Rpc calls return an enum clnt_stat.  This should be looked at more,
     47  * since each implementation is required to live with this (implementation
     48  * independent) list of errors.
     49  */
     50 enum clnt_stat {
     51   RPC_SUCCESS=0,      /* call succeeded */
     52   /*
     53    * local errors
     54    */
     55   RPC_CANTENCODEARGS=1,    /* can't encode arguments */
     56   RPC_CANTDECODERES=2,    /* can't decode results */
     57   RPC_CANTSEND=3,      /* failure in sending call */
     58   RPC_CANTRECV=4,      /* failure in receiving result */
     59   RPC_TIMEDOUT=5,      /* call timed out */
     60   /*
     61    * remote errors
     62    */
     63   RPC_VERSMISMATCH=6,    /* rpc versions not compatible */
     64   RPC_AUTHERROR=7,    /* authentication error */
     65   RPC_PROGUNAVAIL=8,    /* program not available */
     66   RPC_PROGVERSMISMATCH=9,    /* program version mismatched */
     67   RPC_PROCUNAVAIL=10,    /* procedure unavailable */
     68   RPC_CANTDECODEARGS=11,    /* decode arguments error */
     69   RPC_SYSTEMERROR=12,    /* generic "other problem" */
     70   RPC_NOBROADCAST = 21,    /* Broadcasting not supported */
     71   /*
     72    * callrpc & clnt_create errors
     73    */
     74   RPC_UNKNOWNHOST=13,    /* unknown host name */
     75   RPC_UNKNOWNPROTO=17,    /* unknown protocol */
     76   RPC_UNKNOWNADDR = 19,    /* Remote address unknown */
     77 
     78   /*
     79    * rpcbind errors
     80    */
     81   RPC_RPCBFAILURE=14,    /* portmapper failed in its call */
     82 #define RPC_PMAPFAILURE RPC_RPCBFAILURE
     83   RPC_PROGNOTREGISTERED=15,  /* remote program is not registered */
     84   RPC_N2AXLATEFAILURE = 22,  /* Name to addr translation failed */
     85   /*
     86    * unspecified error
     87    */
     88   RPC_FAILED=16,
     89   RPC_INTR=18,
     90   RPC_TLIERROR=20,
     91   RPC_UDERROR=23,
     92   /*
     93    * asynchronous errors
     94    */
     95   RPC_INPROGRESS = 24,
     96   RPC_STALERACHANDLE = 25
     97 };
     98 
     99 struct CLIENT;
    100 typedef struct CLIENT CLIENT;
    101 /* client call callback.
    102  * Callback called when the reply is recieved or there is an error in
    103  * getting reply.
    104  */
    105 typedef void (*clnt_call_cb)
    106 (
    107   CLIENT * clnt,
    108   void * cookie,
    109   caddr_t results,
    110   rpc_reply_header error
    111 );
    112 
    113 typedef void (*clnt_call_non_blocking_cb)
    114 (
    115   CLIENT * clnt,
    116   void * cookie,
    117   caddr_t results,
    118   rpc_reply_header error
    119 );
    120 
    121 /*
    122  * By convention, procedure 0 takes null arguments and returns them
    123  */
    124 #define NULLPROC ((rpcproc_t)0)
    125 
    126 /*===========================================================================
    127 FUNCTION CLNT_CALL
    128 
    129 DESCRIPTION
    130   RPCGEN support routine. This routine is called by client routines generated
    131   by RPCGEN. It generates and sends an RPC message to a server.
    132 
    133   This is a blocking call.
    134 
    135 DEPENDENCIES
    136   None.
    137 
    138 ARGUMENTS
    139   xdr - the XDR to use to send the RPC message
    140   proc - the server procedure to call
    141   xdr_args - function pointer for encoding the RPC message args
    142   args_ptr - pointer to args data structure
    143   xdr_results - function pointer for decoding the RPC response
    144   rets_ptr - pointer to results data structure
    145   timeout - return after timeout (ignored)
    146 
    147 RETURN VALUE
    148   RPC_SUCCESS - if successful
    149   error code otherwise
    150 
    151 SIDE EFFECTS
    152   None.
    153 ===========================================================================*/
    154 extern enum clnt_stat
    155 clnt_call
    156 (
    157   CLIENT *h,
    158   u_long proc,
    159   xdrproc_t xdr_args,
    160   caddr_t args_ptr,
    161   xdrproc_t xdr_results,
    162   caddr_t rets_ptr,
    163   struct timeval timeout
    164 );
    165 
    166 /*===========================================================================
    167 FUNCTION CLNT_CALL_NON_BLOCKING
    168 
    169 DESCRIPTION
    170   RPCGEN support routine. This routine is called by client routines generated
    171   by RPCGEN. It generates and sends an RPC message to a server.
    172 
    173   This is a non-blocking call. It registers clnt_call_callback to be called
    174   when the RPC response is received.
    175 
    176 DEPENDENCIES
    177   None.
    178 
    179 ARGUMENTS
    180   xdr - the XDR to use to send the RPC message
    181   proc - the server procedure to call
    182   xdr_args - function pointer for encoding the RPC message args
    183   args_ptr - pointer to args data structure
    184   xdr_results - function pointer for decoding the RPC response
    185   results_size - size of the results data structure
    186   result_cb - function pointer to be called with the results
    187   cb_data - cookie for results call back function
    188 
    189 RETURN VALUE
    190   RPC_SUCCESS - if successful
    191   error code otherwise
    192 
    193 SIDE EFFECTS
    194   None.
    195 ===========================================================================*/
    196 extern enum clnt_stat
    197 clnt_call_non_blocking
    198 (
    199   CLIENT *h,
    200   u_long proc,
    201   xdrproc_t xdr_args,
    202   caddr_t args_ptr,
    203   xdrproc_t xdr_results,
    204   int results_size,
    205   clnt_call_cb result_cb,
    206   void * cb_data
    207 );
    208 
    209 extern bool_t clnt_freeres( CLIENT *xdr, xdrproc_t xdr_res, caddr_t res_ptr );
    210 extern void clnt_destroy( CLIENT *xdr );
    211 extern CLIENT * clnt_create ( char * host, uint32 prog, uint32 vers,
    212                               char * proto);
    213 
    214 #ifdef __cplusplus
    215 }
    216 #endif
    217 
    218 #endif /* rpc/clnt.h */
    219