/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2016 Nexenta Systems, Inc. All rights reserved.
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Portions of this source code were derived from Berkeley
* 4.3 BSD under license from the Regents of the University of
* California.
*/
/*
* xdr.h, External Data Representation Serialization Routines.
*
*/
#ifndef _RPC_XDR_H
#define _RPC_XDR_H
#if !defined(_KERNEL) && !defined(_FAKE_KERNEL)
#include <stdio.h> /* defines FILE *, used in ANSI C function prototypes */
#else /* _KERNEL */
#endif /* _KERNEL */
#ifdef __cplusplus
extern "C" {
#endif
/*
* XDR provides a conventional way for converting between C data
* types and an external bit-string representation. Library supplied
* routines provide for the conversion on built-in C data types. These
* routines and utility routines defined here are used to help implement
*
* Each data type provides a single procedure which takes two arguments:
*
* bool_t
* xdrproc(xdrs, argresp)
* XDR *xdrs;
* <type> *argresp;
*
* xdrs is an instance of a XDR handle, to which or from which the data
* type is to be converted. argresp is a pointer to the structure to be
* converted. The XDR handle contains an operation field which indicates
* which of the operations (ENCODE, DECODE * or FREE) is to be performed.
*
* XDR_DECODE may allocate space if the pointer argresp is null. This
* data can be freed with the XDR_FREE operation.
*
* We write only one procedure per data type to make it easy
* to keep the encode and decode procedures for a data type consistent.
* In many cases the same code performs all operations on a user defined type,
* because all the hard work is done in the component type routines.
* decode as a series of calls on the nested data types.
*/
/*
* Xdr operations. XDR_ENCODE causes the type to be encoded into the
* stream. XDR_DECODE causes the type to be extracted from the stream.
* XDR_FREE can be used to release the space allocated by an XDR_DECODE
* request.
*/
enum xdr_op {
XDR_ENCODE = 0,
};
/*
* This is the number of bytes per unit of external data.
*/
/*
* The XDR handle.
* Contains operation which is being applied to the stream,
* an operations vector for the paticular implementation (e.g. see xdr_mem.c),
* and two private fields for the use of the particular impelementation.
*
* PSARC 2003/523 Contract Private Interface
* XDR
* Changes must be reviewed by Solaris File Sharing
* Changes must be communicated to contract-2003-523@sun.com
*/
typedef struct XDR {
} XDR;
/*
* PSARC 2003/523 Contract Private Interface
* xdr_ops
* Changes must be reviewed by Solaris File Sharing
* Changes must be communicated to contract-2003-523@sun.com
*/
struct xdr_ops {
#ifdef __STDC__
#if !defined(_KERNEL)
/* get a long from underlying stream */
/* put a long to " */
#endif /* KERNEL */
/* get some bytes from " */
/* put some bytes to " */
/* returns bytes off from beginning */
/* lets you reposition the stream */
/* buf quick ptr to buffered data */
/* free privates of this xdr_stream */
/* get a int from underlying stream */
/* put an int to " */
#endif /* _LP64 || _KERNEL */
#else
#if !defined(_KERNEL)
#endif /* KERNEL */
rpc_inline_t *(*x_inline)();
/* buf quick ptr to buffered data */
void (*x_destroy)(); /* free privates of this xdr_stream */
bool_t (*x_getint32)();
bool_t (*x_putint32)();
#endif /* _LP64 || defined(_KERNEL) */
#endif
};
/*
* Operations defined on a XDR handle
*
* XDR *xdrs;
* long *longp;
* caddr_t addr;
* uint_t len;
* uint_t pos;
*/
#if !defined(_KERNEL)
#endif /* KERNEL */
/*
* For binary compatability on ILP32 we do not change the shape
* units of data.
*/
#else /* !_LP64 && !_KERNEL */
#endif /* !_LP64 && !_KERNEL */
/*
* Support struct for discriminated unions.
* You create an array of xdrdiscrim structures, terminated with
* a entry with a null procedure pointer. The xdr_union routine gets
* the discriminant value and then searches the array of structures
* for a matching value. If a match is found the associated xdr routine
* is called to handle that part of the union. If there is
* no match, then a default routine may be called.
* If there is no match and no default routine it is an error.
*/
/*
* A xdrproc_t exists for each data type which is to be encoded or decoded.
*
* The second argument to the xdrproc_t is a pointer to an opaque pointer.
* The opaque pointer generally points to a structure of the data type
* to be decoded. If this pointer is 0, then the type routines should
* allocate dynamic storage of the appropriate size and return it.
* bool_t (*xdrproc_t)(XDR *, void *);
*/
#ifdef __cplusplus
#else
#ifdef __STDC__
#else
#endif
#endif
#else
#endif
struct xdr_discrim {
int value;
};
/*
* Caveat emptor: these use single memory cycles to get the
* data from the underlying buffer, and will fail to operate
* properly if the data is not aligned. The standard way to use these
* is to say:
* if ((buf = XDR_INLINE(xdrs, count)) == NULL)
* return (FALSE);
* <<< macro calls >>>
* where ``count'' is the number of bytes of data occupied
* by the primitive data types.
*
* N.B. and frozen for all time: each data type here uses 4 bytes
* of external representation.
*/
#else
#endif
#ifndef _LITTLE_ENDIAN
*((int32_t *)(((char *)&v) + BYTES_PER_XDR_UNIT)) \
}
((char *)&v)); \
*(buf)++ = \
+ BYTES_PER_XDR_UNIT)); \
}
#else
*((int32_t *)(((char *)&v) + \
*((int32_t *)(&v)) = \
}
*(buf)++ = \
BYTES_PER_XDR_UNIT)); \
*(buf)++ = \
}
#endif
/*
* These are the "generic" xdr routines.
*/
#ifdef __STDC__
const struct xdr_discrim *, const xdrproc_t);
const xdrproc_t);
extern unsigned int xdr_sizeof(xdrproc_t, void *);
#if defined(_INT64_TYPE)
#endif
#ifndef _KERNEL
#endif /* !_KERNEL */
#else
extern bool_t xdr_u_long();
extern bool_t xdr_u_short();
extern bool_t xdr_opaque();
extern bool_t xdr_string();
extern bool_t xdr_vector();
extern bool_t xdr_longlong_t();
extern bool_t xdr_u_hyper();
extern bool_t xdr_u_longlong_t();
extern bool_t xdr_u_char();
extern bool_t xdr_reference();
extern bool_t xdr_pointer();
extern void xdr_free();
extern bool_t xdr_wrapstring();
extern bool_t xdr_time_t();
extern bool_t xdr_int8_t();
extern bool_t xdr_uint8_t();
extern bool_t xdr_int16_t();
extern bool_t xdr_uint16_t();
extern bool_t xdr_int32_t();
extern bool_t xdr_uint32_t();
#if defined(_INT64_TYPE)
extern bool_t xdr_int64_t();
extern bool_t xdr_uint64_t();
#endif
#ifndef _KERNEL
extern bool_t xdr_double();
extern bool_t xdr_quadruple();
#endif /* !_KERNEL */
#endif
/*
* Common opaque bytes objects used by many rpc protocols;
* declared here due to commonality.
*/
struct netobj {
char *n_bytes;
};
#ifdef __STDC__
#else
extern bool_t xdr_netobj();
#endif
/*
* These are XDR control operators
*/
struct xdr_bytesrec {
};
/*
* These are the request arguments to XDR_CONTROL.
*
* XDR_PEEK - returns the contents of the next XDR unit on the XDR stream.
* XDR_SKIPBYTES - skips the next N bytes in the XDR stream.
* XDR_RDMAGET - for xdr implementation over RDMA, gets private flags from
* the XDR stream being moved over RDMA
* XDR_RDMANOCHUNK - for xdr implementaion over RDMA, sets private flags in
* the XDR stream moving over RDMA.
*/
#ifdef _KERNEL
#endif
/*
* These are the public routines for the various implementations of
* xdr streams.
*/
#if !defined(_KERNEL) && !defined(_FAKE_KERNEL)
#ifdef __STDC__
xdr_op);
/* XDR using memory buffers */
/* XDR using stdio library */
/* XDR pseudo records for tcp */
/* make end of xdr record */
/* move to beginning of next record */
/* true if no more input */
#else
extern void xdrmem_create();
extern void xdrstdio_create();
extern void xdrrec_create();
extern bool_t xdrrec_endofrecord();
extern bool_t xdrrec_skiprecord();
extern bool_t xdrrec_eof();
extern uint_t xdrrec_readbytes();
#endif
#else
extern struct xdr_ops xdrmblk_ops;
extern struct xdr_ops xdrrdmablk_ops;
extern struct xdr_ops xdrrdma_ops;
struct rpc_msg;
#endif /* !_KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* !_RPC_XDR_H */