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  * xdr.h, External Data Representation Serialization Routines.
     32  *
     33  * Copyright (C) 1984, Sun Microsystems, Inc.
     34  */
     35 
     36 #ifndef XDR_H
     37 #define XDR_H
     38 
     39 #ifdef __cplusplus
     40 extern "C" {
     41 #endif
     42 
     43 /*===========================================================================
     44   Macros for calling primitive XDR routines (this is independent of RPC)
     45   ===========================================================================*/
     46 
     47 #define XDR_RECV_BYTES(XDR, BUF, LEN) (XDR)->xops->recv_bytes(XDR, BUF, LEN)
     48 #define XDR_RECV_INT16(XDR, VALUE)    (XDR)->xops->recv_int16(XDR, VALUE)
     49 #define XDR_RECV_INT32(XDR, VALUE)    (XDR)->xops->recv_int32(XDR, VALUE)
     50 #define XDR_RECV_INT8(XDR, VALUE)     (XDR)->xops->recv_int8(XDR, VALUE)
     51 #define XDR_RECV_UINT(XDR, VALUE)     (XDR)->xops->recv_uint32(XDR, (uint32 *)(VALUE))
     52 #define XDR_RECV_UINT32(XDR, VALUE)   (XDR)->xops->recv_uint32(XDR, VALUE)
     53 #define XDR_SEND_BYTES(XDR, BUF, LEN) (XDR)->xops->send_bytes(XDR, BUF, LEN)
     54 #define XDR_SEND_INT16(XDR, VALUE)    (XDR)->xops->send_int16(XDR, VALUE)
     55 #define XDR_SEND_INT32(XDR, VALUE)    (XDR)->xops->send_int32(XDR, VALUE)
     56 #define XDR_SEND_INT8(XDR, VALUE)     (XDR)->xops->send_int8(XDR, VALUE)
     57 #define XDR_SEND_UINT(XDR, VALUE)     (XDR)->xops->send_uint32(XDR, (uint32 *)(VALUE))
     58 #define XDR_SEND_UINT32(XDR, VALUE)   (XDR)->xops->send_uint32(XDR, VALUE)
     59 
     60 /*===========================================================================
     61   Macros for sending and receiving an RPC message through the transport
     62   ===========================================================================*/
     63 
     64 #define XDR_MSG_START(XDR, TYPE)      (XDR)->xops->msg_start(XDR, TYPE)
     65 #define XDR_MSG_SEND(XDR)             (XDR)->xops->msg_send(XDR)
     66 #define XDR_MSG_DONE(XDR)             (XDR)->xops->msg_done(XDR)
     67 #define XDR_MSG_ABORT(XDR)            (XDR)->xops->msg_abort(XDR)
     68 
     69 extern bool_t xdr_call_msg_start (XDR *xdr, uint32 prog, uint32 ver, uint32 proc, opaque_auth *cred, opaque_auth *verf);
     70 extern bool_t xdr_reply_msg_start (XDR *xdr, opaque_auth *verf);
     71 extern bool_t xdr_send_auth (XDR *xdr, const opaque_auth *auth);
     72 extern bool_t xdr_send_reply_header (XDR *xdr, rpc_reply_header const *reply);
     73 extern void   xdr_free (xdrproc_t proc, char *objp);
     74 
     75 /***********************************************************************
     76         Support for rpcgen
     77  ***********************************************************************/
     78 
     79 #define XDR_SEND_ENUM(XDR, VALUE) xdr_send_enum(XDR, (void *) (VALUE), sizeof(*(VALUE)))
     80 #define XDR_RECV_ENUM(XDR, VALUE) xdr_recv_enum(XDR, (void *) (VALUE), sizeof(*(VALUE)))
     81 extern bool_t xdr_send_enum (XDR *xdr, const void *value, uint32 size);
     82 extern bool_t xdr_recv_enum (XDR *xdr, void *value, uint32 size);
     83 
     84 extern bool_t xdr_bytes (XDR *xdr, char **cpp, u_int *sizep, u_int maxsize);
     85 extern bool_t xdr_enum (XDR *xdr, enum_t *ep);
     86 extern bool_t xdr_pointer (XDR *xdrs, char **_objpp, u_int obj_size, xdrproc_t xdr_obj);
     87 extern bool_t xdr_int (XDR *xdr, int *ip);
     88 extern bool_t xdr_u_int (XDR *xdr, u_int *ip);
     89 extern bool_t xdr_char (XDR *xdr, char *cp);
     90 extern bool_t xdr_u_char (XDR *xdr, u_char *cp);
     91 extern bool_t xdr_long (XDR *xdr, long *ulp);
     92 extern bool_t xdr_u_long (XDR *xdr, u_long *ulp);
     93 #define xdr_uint32 xdr_u_long
     94 extern bool_t xdr_quad_t (XDR *xdrs, quad_t *llp);
     95 extern bool_t xdr_u_quad_t (XDR *__xdrs, u_quad_t *__ullp);
     96 extern bool_t xdr_short (XDR *xdr, short *sp);
     97 extern bool_t xdr_u_short (XDR *xdr, u_short *usp);
     98 extern bool_t xdr_vector (XDR *xdrs, char *basep, u_int nelem, u_int elemsize, xdrproc_t xdr_elem);
     99 extern bool_t xdr_void (void);
    100 extern bool_t xdr_opaque (XDR *xdr, caddr_t cp, u_int cnt);
    101 extern bool_t xdr_string (XDR *xdr, char **cpp, u_int maxsize);
    102 
    103 extern bool_t xdr_array (
    104     XDR *xdrs,
    105     caddr_t *addrp,/* array pointer */
    106     u_int *sizep,  /* number of elements */
    107     u_int maxsize,  /* max numberof elements */
    108     u_int elsize,  /* size in bytes of each element */
    109     xdrproc_t elproc); /* xdr routine to handle each element */
    110 
    111 #ifdef __cplusplus
    112 }
    113 #endif
    114 
    115 #endif /* rpc/xdr.h */
    116