xref: /illumos-gate/usr/src/uts/common/rpc/xdr.h (revision c242f9a02a2ef021449275ae0a1d2581ee77231d)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
50a701b1eSRobert Gordon  * Common Development and Distribution License (the "License").
60a701b1eSRobert Gordon  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  *
21*c242f9a0Schunli zhang - Sun Microsystems - Irvine United States  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
227c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
237c478bd9Sstevel@tonic-gate  */
247c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
257c478bd9Sstevel@tonic-gate /* All Rights Reserved */
267c478bd9Sstevel@tonic-gate /*
277c478bd9Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley
287c478bd9Sstevel@tonic-gate  * 4.3 BSD under license from the Regents of the University of
297c478bd9Sstevel@tonic-gate  * California.
307c478bd9Sstevel@tonic-gate  */
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate /*
337c478bd9Sstevel@tonic-gate  * xdr.h, External Data Representation Serialization Routines.
347c478bd9Sstevel@tonic-gate  *
357c478bd9Sstevel@tonic-gate  */
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #ifndef _RPC_XDR_H
387c478bd9Sstevel@tonic-gate #define	_RPC_XDR_H
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #include <sys/byteorder.h>	/* For all ntoh* and hton*() kind of macros */
417c478bd9Sstevel@tonic-gate #include <rpc/types.h>	/* For all ntoh* and hton*() kind of macros */
427c478bd9Sstevel@tonic-gate #ifndef _KERNEL
437c478bd9Sstevel@tonic-gate #include <stdio.h> /* defines FILE *, used in ANSI C function prototypes */
447c478bd9Sstevel@tonic-gate #endif
457c478bd9Sstevel@tonic-gate #ifdef _KERNEL
467c478bd9Sstevel@tonic-gate #include <sys/stream.h>
477c478bd9Sstevel@tonic-gate #endif
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate #ifdef __cplusplus
507c478bd9Sstevel@tonic-gate extern "C" {
517c478bd9Sstevel@tonic-gate #endif
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate /*
547c478bd9Sstevel@tonic-gate  * XDR provides a conventional way for converting between C data
557c478bd9Sstevel@tonic-gate  * types and an external bit-string representation.  Library supplied
567c478bd9Sstevel@tonic-gate  * routines provide for the conversion on built-in C data types.  These
577c478bd9Sstevel@tonic-gate  * routines and utility routines defined here are used to help implement
587c478bd9Sstevel@tonic-gate  * a type encode/decode routine for each user-defined type.
597c478bd9Sstevel@tonic-gate  *
607c478bd9Sstevel@tonic-gate  * Each data type provides a single procedure which takes two arguments:
617c478bd9Sstevel@tonic-gate  *
627c478bd9Sstevel@tonic-gate  *	bool_t
637c478bd9Sstevel@tonic-gate  *	xdrproc(xdrs, argresp)
647c478bd9Sstevel@tonic-gate  *		XDR *xdrs;
657c478bd9Sstevel@tonic-gate  *		<type> *argresp;
667c478bd9Sstevel@tonic-gate  *
677c478bd9Sstevel@tonic-gate  * xdrs is an instance of a XDR handle, to which or from which the data
687c478bd9Sstevel@tonic-gate  * type is to be converted.  argresp is a pointer to the structure to be
697c478bd9Sstevel@tonic-gate  * converted.  The XDR handle contains an operation field which indicates
707c478bd9Sstevel@tonic-gate  * which of the operations (ENCODE, DECODE * or FREE) is to be performed.
717c478bd9Sstevel@tonic-gate  *
727c478bd9Sstevel@tonic-gate  * XDR_DECODE may allocate space if the pointer argresp is null.  This
737c478bd9Sstevel@tonic-gate  * data can be freed with the XDR_FREE operation.
747c478bd9Sstevel@tonic-gate  *
757c478bd9Sstevel@tonic-gate  * We write only one procedure per data type to make it easy
767c478bd9Sstevel@tonic-gate  * to keep the encode and decode procedures for a data type consistent.
777c478bd9Sstevel@tonic-gate  * In many cases the same code performs all operations on a user defined type,
787c478bd9Sstevel@tonic-gate  * because all the hard work is done in the component type routines.
797c478bd9Sstevel@tonic-gate  * decode as a series of calls on the nested data types.
807c478bd9Sstevel@tonic-gate  */
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate /*
837c478bd9Sstevel@tonic-gate  * Xdr operations.  XDR_ENCODE causes the type to be encoded into the
847c478bd9Sstevel@tonic-gate  * stream.  XDR_DECODE causes the type to be extracted from the stream.
857c478bd9Sstevel@tonic-gate  * XDR_FREE can be used to release the space allocated by an XDR_DECODE
867c478bd9Sstevel@tonic-gate  * request.
877c478bd9Sstevel@tonic-gate  */
887c478bd9Sstevel@tonic-gate enum xdr_op {
897c478bd9Sstevel@tonic-gate 	XDR_ENCODE = 0,
907c478bd9Sstevel@tonic-gate 	XDR_DECODE = 1,
917c478bd9Sstevel@tonic-gate 	XDR_FREE = 2
927c478bd9Sstevel@tonic-gate };
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate /*
957c478bd9Sstevel@tonic-gate  * This is the number of bytes per unit of external data.
967c478bd9Sstevel@tonic-gate  */
977c478bd9Sstevel@tonic-gate #define	BYTES_PER_XDR_UNIT	(4)
987c478bd9Sstevel@tonic-gate #define	RNDUP(x)  ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \
997c478bd9Sstevel@tonic-gate 		    * BYTES_PER_XDR_UNIT)
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate /*
1027c478bd9Sstevel@tonic-gate  * The XDR handle.
1037c478bd9Sstevel@tonic-gate  * Contains operation which is being applied to the stream,
1047c478bd9Sstevel@tonic-gate  * an operations vector for the paticular implementation (e.g. see xdr_mem.c),
1057c478bd9Sstevel@tonic-gate  * and two private fields for the use of the particular impelementation.
1067c478bd9Sstevel@tonic-gate  *
1077c478bd9Sstevel@tonic-gate  * PSARC 2003/523 Contract Private Interface
1087c478bd9Sstevel@tonic-gate  * XDR
1097c478bd9Sstevel@tonic-gate  * Changes must be reviewed by Solaris File Sharing
1107c478bd9Sstevel@tonic-gate  * Changes must be communicated to contract-2003-523@sun.com
1117c478bd9Sstevel@tonic-gate  */
1127c478bd9Sstevel@tonic-gate typedef struct XDR {
1137c478bd9Sstevel@tonic-gate 	enum xdr_op	x_op;	/* operation; fast additional param */
1147c478bd9Sstevel@tonic-gate 	struct xdr_ops *x_ops;
1157c478bd9Sstevel@tonic-gate 	caddr_t 	x_public; /* users' data */
1167c478bd9Sstevel@tonic-gate 	caddr_t		x_private; /* pointer to private data */
1177c478bd9Sstevel@tonic-gate 	caddr_t 	x_base;	/* private used for position info */
1187c478bd9Sstevel@tonic-gate 	int		x_handy; /* extra private word */
1197c478bd9Sstevel@tonic-gate } XDR;
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate /*
1227c478bd9Sstevel@tonic-gate  * PSARC 2003/523 Contract Private Interface
1237c478bd9Sstevel@tonic-gate  * xdr_ops
1247c478bd9Sstevel@tonic-gate  * Changes must be reviewed by Solaris File Sharing
1257c478bd9Sstevel@tonic-gate  * Changes must be communicated to contract-2003-523@sun.com
1267c478bd9Sstevel@tonic-gate  */
1277c478bd9Sstevel@tonic-gate struct xdr_ops {
1287c478bd9Sstevel@tonic-gate #ifdef __STDC__
1297c478bd9Sstevel@tonic-gate #if !defined(_KERNEL)
1307c478bd9Sstevel@tonic-gate 		bool_t	(*x_getlong)(struct XDR *, long *);
1317c478bd9Sstevel@tonic-gate 		/* get a long from underlying stream */
1327c478bd9Sstevel@tonic-gate 		bool_t	(*x_putlong)(struct XDR *, long *);
1337c478bd9Sstevel@tonic-gate 		/* put a long to " */
1347c478bd9Sstevel@tonic-gate #endif /* KERNEL */
1357c478bd9Sstevel@tonic-gate 		bool_t	(*x_getbytes)(struct XDR *, caddr_t, int);
1367c478bd9Sstevel@tonic-gate 		/* get some bytes from " */
1377c478bd9Sstevel@tonic-gate 		bool_t	(*x_putbytes)(struct XDR *, caddr_t, int);
1387c478bd9Sstevel@tonic-gate 		/* put some bytes to " */
1397c478bd9Sstevel@tonic-gate 		uint_t	(*x_getpostn)(struct XDR *);
1407c478bd9Sstevel@tonic-gate 		/* returns bytes off from beginning */
1417c478bd9Sstevel@tonic-gate 		bool_t  (*x_setpostn)(struct XDR *, uint_t);
1427c478bd9Sstevel@tonic-gate 		/* lets you reposition the stream */
1437c478bd9Sstevel@tonic-gate 		rpc_inline_t *(*x_inline)(struct XDR *, int);
1447c478bd9Sstevel@tonic-gate 		/* buf quick ptr to buffered data */
1457c478bd9Sstevel@tonic-gate 		void	(*x_destroy)(struct XDR *);
1467c478bd9Sstevel@tonic-gate 		/* free privates of this xdr_stream */
1477c478bd9Sstevel@tonic-gate 		bool_t	(*x_control)(struct XDR *, int, void *);
1487c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_KERNEL)
1497c478bd9Sstevel@tonic-gate 		bool_t	(*x_getint32)(struct XDR *, int32_t *);
1507c478bd9Sstevel@tonic-gate 		/* get a int from underlying stream */
1517c478bd9Sstevel@tonic-gate 		bool_t	(*x_putint32)(struct XDR *, int32_t *);
1527c478bd9Sstevel@tonic-gate 		/* put an int to " */
1537c478bd9Sstevel@tonic-gate #endif /* _LP64 || _KERNEL */
1547c478bd9Sstevel@tonic-gate #else
1557c478bd9Sstevel@tonic-gate #if !defined(_KERNEL)
1567c478bd9Sstevel@tonic-gate 		bool_t	(*x_getlong)();	/* get a long from underlying stream */
1577c478bd9Sstevel@tonic-gate 		bool_t	(*x_putlong)();	/* put a long to " */
1587c478bd9Sstevel@tonic-gate #endif /* KERNEL */
1597c478bd9Sstevel@tonic-gate 		bool_t	(*x_getbytes)(); /* get some bytes from " */
1607c478bd9Sstevel@tonic-gate 		bool_t	(*x_putbytes)(); /* put some bytes to " */
1617c478bd9Sstevel@tonic-gate 		uint_t	(*x_getpostn)(); /* returns bytes off from beginning */
1627c478bd9Sstevel@tonic-gate 		bool_t  (*x_setpostn)(); /* lets you reposition the stream */
1637c478bd9Sstevel@tonic-gate 		rpc_inline_t *(*x_inline)();
1647c478bd9Sstevel@tonic-gate 				/* buf quick ptr to buffered data */
1657c478bd9Sstevel@tonic-gate 		void	(*x_destroy)();	/* free privates of this xdr_stream */
1667c478bd9Sstevel@tonic-gate 		bool_t	(*x_control)();
1677c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_KERNEL)
1687c478bd9Sstevel@tonic-gate 		bool_t	(*x_getint32)();
1697c478bd9Sstevel@tonic-gate 		bool_t	(*x_putint32)();
1707c478bd9Sstevel@tonic-gate #endif /* _LP64 || defined(_KERNEL) */
1717c478bd9Sstevel@tonic-gate #endif
1727c478bd9Sstevel@tonic-gate };
1737c478bd9Sstevel@tonic-gate 
1747c478bd9Sstevel@tonic-gate /*
1757c478bd9Sstevel@tonic-gate  * Operations defined on a XDR handle
1767c478bd9Sstevel@tonic-gate  *
1777c478bd9Sstevel@tonic-gate  * XDR		*xdrs;
1787c478bd9Sstevel@tonic-gate  * long		*longp;
1797c478bd9Sstevel@tonic-gate  * caddr_t	 addr;
1807c478bd9Sstevel@tonic-gate  * uint_t	 len;
1817c478bd9Sstevel@tonic-gate  * uint_t	 pos;
1827c478bd9Sstevel@tonic-gate  */
1837c478bd9Sstevel@tonic-gate #if !defined(_KERNEL)
1847c478bd9Sstevel@tonic-gate #define	XDR_GETLONG(xdrs, longp)			\
1857c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_getlong)(xdrs, longp)
1867c478bd9Sstevel@tonic-gate #define	xdr_getlong(xdrs, longp)			\
1877c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_getlong)(xdrs, longp)
1887c478bd9Sstevel@tonic-gate 
1897c478bd9Sstevel@tonic-gate #define	XDR_PUTLONG(xdrs, longp)			\
1907c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_putlong)(xdrs, longp)
1917c478bd9Sstevel@tonic-gate #define	xdr_putlong(xdrs, longp)			\
1927c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_putlong)(xdrs, longp)
1937c478bd9Sstevel@tonic-gate #endif /* KERNEL */
1947c478bd9Sstevel@tonic-gate 
1957c478bd9Sstevel@tonic-gate 
1967c478bd9Sstevel@tonic-gate #if !defined(_LP64) && !defined(_KERNEL)
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate /*
1997c478bd9Sstevel@tonic-gate  * For binary compatability on ILP32 we do not change the shape
2007c478bd9Sstevel@tonic-gate  * of the XDR structure and the GET/PUTINT32 functions just use
2017c478bd9Sstevel@tonic-gate  * the get/putlong vectors which operate on identically-sized
2027c478bd9Sstevel@tonic-gate  * units of data.
2037c478bd9Sstevel@tonic-gate  */
2047c478bd9Sstevel@tonic-gate 
2057c478bd9Sstevel@tonic-gate #define	XDR_GETINT32(xdrs, int32p)			\
2067c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_getlong)(xdrs, (long *)int32p)
2077c478bd9Sstevel@tonic-gate #define	xdr_getint32(xdrs, int32p)			\
2087c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_getlong)(xdrs, (long *)int32p)
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate #define	XDR_PUTINT32(xdrs, int32p)			\
2117c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_putlong)(xdrs, (long *)int32p)
2127c478bd9Sstevel@tonic-gate #define	xdr_putint32(xdrs, int32p)			\
2137c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_putlong)(xdrs, (long *)int32p)
2147c478bd9Sstevel@tonic-gate 
2157c478bd9Sstevel@tonic-gate #else /* !_LP64 && !_KERNEL */
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate #define	XDR_GETINT32(xdrs, int32p)			\
2187c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_getint32)(xdrs, int32p)
2197c478bd9Sstevel@tonic-gate #define	xdr_getint32(xdrs, int32p)			\
2207c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_getint32)(xdrs, int32p)
2217c478bd9Sstevel@tonic-gate 
2227c478bd9Sstevel@tonic-gate #define	XDR_PUTINT32(xdrs, int32p)			\
2237c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_putint32)(xdrs, int32p)
2247c478bd9Sstevel@tonic-gate #define	xdr_putint32(xdrs, int32p)			\
2257c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_putint32)(xdrs, int32p)
2267c478bd9Sstevel@tonic-gate 
2277c478bd9Sstevel@tonic-gate #endif /* !_LP64 && !_KERNEL */
2287c478bd9Sstevel@tonic-gate 
2297c478bd9Sstevel@tonic-gate #define	XDR_GETBYTES(xdrs, addr, len)			\
2307c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len)
2317c478bd9Sstevel@tonic-gate #define	xdr_getbytes(xdrs, addr, len)			\
2327c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len)
2337c478bd9Sstevel@tonic-gate 
2347c478bd9Sstevel@tonic-gate #define	XDR_PUTBYTES(xdrs, addr, len)			\
2357c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len)
2367c478bd9Sstevel@tonic-gate #define	xdr_putbytes(xdrs, addr, len)			\
2377c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len)
2387c478bd9Sstevel@tonic-gate 
2397c478bd9Sstevel@tonic-gate #define	XDR_GETPOS(xdrs)				\
2407c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_getpostn)(xdrs)
2417c478bd9Sstevel@tonic-gate #define	xdr_getpos(xdrs)				\
2427c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_getpostn)(xdrs)
2437c478bd9Sstevel@tonic-gate 
2447c478bd9Sstevel@tonic-gate #define	XDR_SETPOS(xdrs, pos)				\
2457c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_setpostn)(xdrs, pos)
2467c478bd9Sstevel@tonic-gate #define	xdr_setpos(xdrs, pos)				\
2477c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_setpostn)(xdrs, pos)
2487c478bd9Sstevel@tonic-gate 
2497c478bd9Sstevel@tonic-gate #define	XDR_INLINE(xdrs, len)				\
2507c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_inline)(xdrs, len)
2517c478bd9Sstevel@tonic-gate #define	xdr_inline(xdrs, len)				\
2527c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_inline)(xdrs, len)
2537c478bd9Sstevel@tonic-gate 
2547c478bd9Sstevel@tonic-gate #define	XDR_DESTROY(xdrs)				\
2557c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_destroy)(xdrs)
2567c478bd9Sstevel@tonic-gate #define	xdr_destroy(xdrs)				\
2577c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_destroy)(xdrs)
2587c478bd9Sstevel@tonic-gate 
2597c478bd9Sstevel@tonic-gate #define	XDR_CONTROL(xdrs, req, op)			\
2607c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_control)(xdrs, req, op)
2617c478bd9Sstevel@tonic-gate #define	xdr_control(xdrs, req, op)			\
2627c478bd9Sstevel@tonic-gate 	(*(xdrs)->x_ops->x_control)(xdrs, req, op)
2637c478bd9Sstevel@tonic-gate 
2647c478bd9Sstevel@tonic-gate /*
2657c478bd9Sstevel@tonic-gate  * Support struct for discriminated unions.
2667c478bd9Sstevel@tonic-gate  * You create an array of xdrdiscrim structures, terminated with
2677c478bd9Sstevel@tonic-gate  * a entry with a null procedure pointer.  The xdr_union routine gets
2687c478bd9Sstevel@tonic-gate  * the discriminant value and then searches the array of structures
2697c478bd9Sstevel@tonic-gate  * for a matching value.  If a match is found the associated xdr routine
2707c478bd9Sstevel@tonic-gate  * is called to handle that part of the union.  If there is
2717c478bd9Sstevel@tonic-gate  * no match, then a default routine may be called.
2727c478bd9Sstevel@tonic-gate  * If there is no match and no default routine it is an error.
2737c478bd9Sstevel@tonic-gate  */
2747c478bd9Sstevel@tonic-gate 
2757c478bd9Sstevel@tonic-gate 
2767c478bd9Sstevel@tonic-gate /*
2777c478bd9Sstevel@tonic-gate  * A xdrproc_t exists for each data type which is to be encoded or decoded.
2787c478bd9Sstevel@tonic-gate  *
2797c478bd9Sstevel@tonic-gate  * The second argument to the xdrproc_t is a pointer to an opaque pointer.
2807c478bd9Sstevel@tonic-gate  * The opaque pointer generally points to a structure of the data type
2817c478bd9Sstevel@tonic-gate  * to be decoded.  If this pointer is 0, then the type routines should
2827c478bd9Sstevel@tonic-gate  * allocate dynamic storage of the appropriate size and return it.
2837c478bd9Sstevel@tonic-gate  * bool_t	(*xdrproc_t)(XDR *, void *);
2847c478bd9Sstevel@tonic-gate  */
2857c478bd9Sstevel@tonic-gate #ifdef __cplusplus
2867c478bd9Sstevel@tonic-gate typedef bool_t (*xdrproc_t)(XDR *, void *);
2877c478bd9Sstevel@tonic-gate #else
2887c478bd9Sstevel@tonic-gate #ifdef __STDC__
2897c478bd9Sstevel@tonic-gate typedef bool_t (*xdrproc_t)(); /* For Backward compatibility */
2907c478bd9Sstevel@tonic-gate #else
2917c478bd9Sstevel@tonic-gate typedef	bool_t (*xdrproc_t)();
2927c478bd9Sstevel@tonic-gate #endif
2937c478bd9Sstevel@tonic-gate #endif
2947c478bd9Sstevel@tonic-gate 
2957c478bd9Sstevel@tonic-gate #define	NULL_xdrproc_t ((xdrproc_t)0)
2967c478bd9Sstevel@tonic-gate 
2977c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_I32LPx)
2987c478bd9Sstevel@tonic-gate #define	xdr_rpcvers(xdrs, versp)	xdr_u_int(xdrs, versp)
2997c478bd9Sstevel@tonic-gate #define	xdr_rpcprog(xdrs, progp)	xdr_u_int(xdrs, progp)
3007c478bd9Sstevel@tonic-gate #define	xdr_rpcproc(xdrs, procp)	xdr_u_int(xdrs, procp)
3017c478bd9Sstevel@tonic-gate #define	xdr_rpcprot(xdrs, protp)	xdr_u_int(xdrs, protp)
3027c478bd9Sstevel@tonic-gate #define	xdr_rpcport(xdrs, portp)	xdr_u_int(xdrs, portp)
3037c478bd9Sstevel@tonic-gate #else
3047c478bd9Sstevel@tonic-gate #define	xdr_rpcvers(xdrs, versp)	xdr_u_long(xdrs, versp)
3057c478bd9Sstevel@tonic-gate #define	xdr_rpcprog(xdrs, progp)	xdr_u_long(xdrs, progp)
3067c478bd9Sstevel@tonic-gate #define	xdr_rpcproc(xdrs, procp)	xdr_u_long(xdrs, procp)
3077c478bd9Sstevel@tonic-gate #define	xdr_rpcprot(xdrs, protp)	xdr_u_long(xdrs, protp)
3087c478bd9Sstevel@tonic-gate #define	xdr_rpcport(xdrs, portp)	xdr_u_long(xdrs, portp)
3097c478bd9Sstevel@tonic-gate #endif
3107c478bd9Sstevel@tonic-gate 
3117c478bd9Sstevel@tonic-gate struct xdr_discrim {
3127c478bd9Sstevel@tonic-gate 	int	value;
3137c478bd9Sstevel@tonic-gate 	xdrproc_t proc;
3147c478bd9Sstevel@tonic-gate };
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate /*
3177c478bd9Sstevel@tonic-gate  * In-line routines for fast encode/decode of primitve data types.
3187c478bd9Sstevel@tonic-gate  * Caveat emptor: these use single memory cycles to get the
3197c478bd9Sstevel@tonic-gate  * data from the underlying buffer, and will fail to operate
3207c478bd9Sstevel@tonic-gate  * properly if the data is not aligned.  The standard way to use these
3217c478bd9Sstevel@tonic-gate  * is to say:
3227c478bd9Sstevel@tonic-gate  *	if ((buf = XDR_INLINE(xdrs, count)) == NULL)
3237c478bd9Sstevel@tonic-gate  *		return (FALSE);
3247c478bd9Sstevel@tonic-gate  *	<<< macro calls >>>
3257c478bd9Sstevel@tonic-gate  * where ``count'' is the number of bytes of data occupied
3267c478bd9Sstevel@tonic-gate  * by the primitive data types.
3277c478bd9Sstevel@tonic-gate  *
3287c478bd9Sstevel@tonic-gate  * N.B. and frozen for all time: each data type here uses 4 bytes
3297c478bd9Sstevel@tonic-gate  * of external representation.
3307c478bd9Sstevel@tonic-gate  */
3317c478bd9Sstevel@tonic-gate 
3327c478bd9Sstevel@tonic-gate #define	IXDR_GET_INT32(buf)		((int32_t)ntohl((uint32_t)*(buf)++))
3337c478bd9Sstevel@tonic-gate #define	IXDR_PUT_INT32(buf, v)		(*(buf)++ = (int32_t)htonl((uint32_t)v))
3347c478bd9Sstevel@tonic-gate #define	IXDR_GET_U_INT32(buf)		((uint32_t)IXDR_GET_INT32(buf))
3357c478bd9Sstevel@tonic-gate #define	IXDR_PUT_U_INT32(buf, v)	IXDR_PUT_INT32((buf), ((int32_t)(v)))
3367c478bd9Sstevel@tonic-gate 
3377c478bd9Sstevel@tonic-gate #if !defined(_KERNEL) && !defined(_LP64)
3387c478bd9Sstevel@tonic-gate 
3397c478bd9Sstevel@tonic-gate #define	IXDR_GET_LONG(buf)		((long)ntohl((ulong_t)*(buf)++))
3407c478bd9Sstevel@tonic-gate #define	IXDR_PUT_LONG(buf, v)		(*(buf)++ = (long)htonl((ulong_t)v))
3417c478bd9Sstevel@tonic-gate #define	IXDR_GET_U_LONG(buf)		((ulong_t)IXDR_GET_LONG(buf))
3427c478bd9Sstevel@tonic-gate #define	IXDR_PUT_U_LONG(buf, v)		IXDR_PUT_LONG((buf), ((long)(v)))
3437c478bd9Sstevel@tonic-gate 
3447c478bd9Sstevel@tonic-gate #define	IXDR_GET_BOOL(buf)		((bool_t)IXDR_GET_LONG(buf))
3457c478bd9Sstevel@tonic-gate #define	IXDR_GET_ENUM(buf, t)		((t)IXDR_GET_LONG(buf))
3467c478bd9Sstevel@tonic-gate #define	IXDR_GET_SHORT(buf)		((short)IXDR_GET_LONG(buf))
3477c478bd9Sstevel@tonic-gate #define	IXDR_GET_U_SHORT(buf)		((ushort_t)IXDR_GET_LONG(buf))
3487c478bd9Sstevel@tonic-gate 
3497c478bd9Sstevel@tonic-gate #define	IXDR_PUT_BOOL(buf, v)		IXDR_PUT_LONG((buf), ((long)(v)))
3507c478bd9Sstevel@tonic-gate #define	IXDR_PUT_ENUM(buf, v)		IXDR_PUT_LONG((buf), ((long)(v)))
3517c478bd9Sstevel@tonic-gate #define	IXDR_PUT_SHORT(buf, v)		IXDR_PUT_LONG((buf), ((long)(v)))
3527c478bd9Sstevel@tonic-gate #define	IXDR_PUT_U_SHORT(buf, v)	IXDR_PUT_LONG((buf), ((long)(v)))
3537c478bd9Sstevel@tonic-gate 
3547c478bd9Sstevel@tonic-gate #else
3557c478bd9Sstevel@tonic-gate 
3567c478bd9Sstevel@tonic-gate #define	IXDR_GET_BOOL(buf)		((bool_t)IXDR_GET_INT32(buf))
3577c478bd9Sstevel@tonic-gate #define	IXDR_GET_ENUM(buf, t)		((t)IXDR_GET_INT32(buf))
3587c478bd9Sstevel@tonic-gate #define	IXDR_GET_SHORT(buf)		((short)IXDR_GET_INT32(buf))
3597c478bd9Sstevel@tonic-gate #define	IXDR_GET_U_SHORT(buf)		((ushort_t)IXDR_GET_INT32(buf))
3607c478bd9Sstevel@tonic-gate 
3617c478bd9Sstevel@tonic-gate #define	IXDR_PUT_BOOL(buf, v)		IXDR_PUT_INT32((buf), ((int)(v)))
3627c478bd9Sstevel@tonic-gate #define	IXDR_PUT_ENUM(buf, v)		IXDR_PUT_INT32((buf), ((int)(v)))
3637c478bd9Sstevel@tonic-gate #define	IXDR_PUT_SHORT(buf, v)		IXDR_PUT_INT32((buf), ((int)(v)))
3647c478bd9Sstevel@tonic-gate #define	IXDR_PUT_U_SHORT(buf, v)	IXDR_PUT_INT32((buf), ((int)(v)))
3657c478bd9Sstevel@tonic-gate 
3667c478bd9Sstevel@tonic-gate #endif
3677c478bd9Sstevel@tonic-gate 
3687c478bd9Sstevel@tonic-gate #ifndef _LITTLE_ENDIAN
3697c478bd9Sstevel@tonic-gate #define	IXDR_GET_HYPER(buf, v)	{ \
3707c478bd9Sstevel@tonic-gate 			*((int32_t *)(&v)) = ntohl(*(uint32_t *)buf++); \
3717c478bd9Sstevel@tonic-gate 			*((int32_t *)(((char *)&v) + BYTES_PER_XDR_UNIT)) \
3727c478bd9Sstevel@tonic-gate 			= ntohl(*(uint32_t *)buf++); \
3737c478bd9Sstevel@tonic-gate 			}
3747c478bd9Sstevel@tonic-gate #define	IXDR_PUT_HYPER(buf, v)	{ \
3757c478bd9Sstevel@tonic-gate 			*(buf)++ = (int32_t)htonl(*(uint32_t *) \
3767c478bd9Sstevel@tonic-gate 				((char *)&v)); \
3777c478bd9Sstevel@tonic-gate 			*(buf)++ = \
3787c478bd9Sstevel@tonic-gate 				(int32_t)htonl(*(uint32_t *)(((char *)&v) \
3797c478bd9Sstevel@tonic-gate 				+ BYTES_PER_XDR_UNIT)); \
3807c478bd9Sstevel@tonic-gate 			}
3817c478bd9Sstevel@tonic-gate #else
3827c478bd9Sstevel@tonic-gate 
3837c478bd9Sstevel@tonic-gate #define	IXDR_GET_HYPER(buf, v)	{ \
3847c478bd9Sstevel@tonic-gate 			*((int32_t *)(((char *)&v) + \
3857c478bd9Sstevel@tonic-gate 				BYTES_PER_XDR_UNIT)) \
3867c478bd9Sstevel@tonic-gate 				= ntohl(*(uint32_t *)buf++); \
3877c478bd9Sstevel@tonic-gate 			*((int32_t *)(&v)) = \
3887c478bd9Sstevel@tonic-gate 				ntohl(*(uint32_t *)buf++); \
3897c478bd9Sstevel@tonic-gate 			}
3907c478bd9Sstevel@tonic-gate 
3917c478bd9Sstevel@tonic-gate #define	IXDR_PUT_HYPER(buf, v)	{ \
3927c478bd9Sstevel@tonic-gate 			*(buf)++ = \
3937c478bd9Sstevel@tonic-gate 				(int32_t)htonl(*(uint32_t *)(((char *)&v) + \
3947c478bd9Sstevel@tonic-gate 				BYTES_PER_XDR_UNIT)); \
3957c478bd9Sstevel@tonic-gate 			*(buf)++ = \
3967c478bd9Sstevel@tonic-gate 				(int32_t)htonl(*(uint32_t *)((char *)&v)); \
3977c478bd9Sstevel@tonic-gate 			}
3987c478bd9Sstevel@tonic-gate #endif
3997c478bd9Sstevel@tonic-gate #define	IXDR_GET_U_HYPER(buf, v)	IXDR_GET_HYPER(buf, v)
4007c478bd9Sstevel@tonic-gate #define	IXDR_PUT_U_HYPER(buf, v)	IXDR_PUT_HYPER(buf, v)
4017c478bd9Sstevel@tonic-gate 
4027c478bd9Sstevel@tonic-gate 
4037c478bd9Sstevel@tonic-gate /*
4047c478bd9Sstevel@tonic-gate  * These are the "generic" xdr routines.
4057c478bd9Sstevel@tonic-gate  */
4067c478bd9Sstevel@tonic-gate #ifdef __STDC__
4077c478bd9Sstevel@tonic-gate extern bool_t	xdr_void(void);
4087c478bd9Sstevel@tonic-gate extern bool_t	xdr_int(XDR *, int *);
4097c478bd9Sstevel@tonic-gate extern bool_t	xdr_u_int(XDR *, uint_t *);
4107c478bd9Sstevel@tonic-gate extern bool_t	xdr_long(XDR *, long *);
4117c478bd9Sstevel@tonic-gate extern bool_t	xdr_u_long(XDR *, ulong_t *);
4127c478bd9Sstevel@tonic-gate extern bool_t	xdr_short(XDR *, short *);
4137c478bd9Sstevel@tonic-gate extern bool_t	xdr_u_short(XDR *, ushort_t *);
4147c478bd9Sstevel@tonic-gate extern bool_t	xdr_bool(XDR *, bool_t *);
4157c478bd9Sstevel@tonic-gate extern bool_t	xdr_enum(XDR *, enum_t *);
4167c478bd9Sstevel@tonic-gate extern bool_t	xdr_array(XDR *, caddr_t *, uint_t *, const uint_t,
4177c478bd9Sstevel@tonic-gate 		    const uint_t, const xdrproc_t);
4187c478bd9Sstevel@tonic-gate extern bool_t	xdr_bytes(XDR *, char **, uint_t *, const uint_t);
4197c478bd9Sstevel@tonic-gate extern bool_t	xdr_opaque(XDR *, caddr_t, const uint_t);
4207c478bd9Sstevel@tonic-gate extern bool_t	xdr_string(XDR *, char **, const uint_t);
4217c478bd9Sstevel@tonic-gate extern bool_t	xdr_union(XDR *, enum_t *, char *,
4227c478bd9Sstevel@tonic-gate 		    const struct xdr_discrim *, const xdrproc_t);
4231fcced4cSJordan Brown extern bool_t	xdr_vector(XDR *, char *, const uint_t, const uint_t,
4241fcced4cSJordan Brown     const xdrproc_t);
4257c478bd9Sstevel@tonic-gate extern unsigned int  xdr_sizeof(xdrproc_t, void *);
4267c478bd9Sstevel@tonic-gate 
4277c478bd9Sstevel@tonic-gate extern bool_t   xdr_hyper(XDR *, longlong_t *);
4287c478bd9Sstevel@tonic-gate extern bool_t   xdr_longlong_t(XDR *, longlong_t *);
4297c478bd9Sstevel@tonic-gate extern bool_t   xdr_u_hyper(XDR *, u_longlong_t *);
4307c478bd9Sstevel@tonic-gate extern bool_t   xdr_u_longlong_t(XDR *, u_longlong_t *);
4317c478bd9Sstevel@tonic-gate 
4327c478bd9Sstevel@tonic-gate extern bool_t	xdr_char(XDR *, char *);
4331fcced4cSJordan Brown extern bool_t	xdr_u_char(XDR *, uchar_t *);
4347c478bd9Sstevel@tonic-gate extern bool_t	xdr_wrapstring(XDR *, char **);
4357c478bd9Sstevel@tonic-gate extern bool_t	xdr_reference(XDR *, caddr_t *, uint_t, const xdrproc_t);
4367c478bd9Sstevel@tonic-gate extern bool_t	xdr_pointer(XDR *, char **, uint_t, const xdrproc_t);
4377c478bd9Sstevel@tonic-gate extern void	xdr_free(xdrproc_t, char *);
4387c478bd9Sstevel@tonic-gate extern bool_t	xdr_time_t(XDR *, time_t *);
4397c478bd9Sstevel@tonic-gate 
4407c478bd9Sstevel@tonic-gate extern bool_t	xdr_int8_t(XDR *, int8_t *);
4417c478bd9Sstevel@tonic-gate extern bool_t	xdr_uint8_t(XDR *, uint8_t *);
4427c478bd9Sstevel@tonic-gate extern bool_t	xdr_int16_t(XDR *, int16_t *);
4437c478bd9Sstevel@tonic-gate extern bool_t	xdr_uint16_t(XDR *, uint16_t *);
4447c478bd9Sstevel@tonic-gate extern bool_t	xdr_int32_t(XDR *, int32_t *);
4457c478bd9Sstevel@tonic-gate extern bool_t	xdr_uint32_t(XDR *, uint32_t *);
4467c478bd9Sstevel@tonic-gate #if defined(_INT64_TYPE)
4477c478bd9Sstevel@tonic-gate extern bool_t	xdr_int64_t(XDR *, int64_t *);
4487c478bd9Sstevel@tonic-gate extern bool_t	xdr_uint64_t(XDR *, uint64_t *);
4497c478bd9Sstevel@tonic-gate #endif
4507c478bd9Sstevel@tonic-gate 
4517c478bd9Sstevel@tonic-gate #ifndef _KERNEL
4527c478bd9Sstevel@tonic-gate extern bool_t	xdr_float(XDR *, float *);
4537c478bd9Sstevel@tonic-gate extern bool_t	xdr_double(XDR *, double *);
4547c478bd9Sstevel@tonic-gate extern bool_t	xdr_quadruple(XDR *, long double *);
4557c478bd9Sstevel@tonic-gate #endif /* !_KERNEL */
4567c478bd9Sstevel@tonic-gate #else
4577c478bd9Sstevel@tonic-gate extern bool_t	xdr_void();
4587c478bd9Sstevel@tonic-gate extern bool_t	xdr_int();
4597c478bd9Sstevel@tonic-gate extern bool_t	xdr_u_int();
4607c478bd9Sstevel@tonic-gate extern bool_t	xdr_long();
4617c478bd9Sstevel@tonic-gate extern bool_t	xdr_u_long();
4627c478bd9Sstevel@tonic-gate extern bool_t	xdr_short();
4637c478bd9Sstevel@tonic-gate extern bool_t	xdr_u_short();
4647c478bd9Sstevel@tonic-gate extern bool_t	xdr_bool();
4657c478bd9Sstevel@tonic-gate extern bool_t	xdr_enum();
4667c478bd9Sstevel@tonic-gate extern bool_t	xdr_array();
4677c478bd9Sstevel@tonic-gate extern bool_t	xdr_bytes();
4687c478bd9Sstevel@tonic-gate extern bool_t	xdr_opaque();
4697c478bd9Sstevel@tonic-gate extern bool_t	xdr_string();
4707c478bd9Sstevel@tonic-gate extern bool_t	xdr_union();
4711fcced4cSJordan Brown extern bool_t	xdr_vector();
4727c478bd9Sstevel@tonic-gate 
4737c478bd9Sstevel@tonic-gate extern bool_t   xdr_hyper();
4747c478bd9Sstevel@tonic-gate extern bool_t   xdr_longlong_t();
4757c478bd9Sstevel@tonic-gate extern bool_t   xdr_u_hyper();
4767c478bd9Sstevel@tonic-gate extern bool_t   xdr_u_longlong_t();
4777c478bd9Sstevel@tonic-gate extern bool_t	xdr_char();
4781fcced4cSJordan Brown extern bool_t	xdr_u_char();
4797c478bd9Sstevel@tonic-gate extern bool_t	xdr_reference();
4807c478bd9Sstevel@tonic-gate extern bool_t	xdr_pointer();
4817c478bd9Sstevel@tonic-gate extern void	xdr_free();
4827c478bd9Sstevel@tonic-gate extern bool_t	xdr_wrapstring();
4837c478bd9Sstevel@tonic-gate extern bool_t	xdr_time_t();
4847c478bd9Sstevel@tonic-gate 
4857c478bd9Sstevel@tonic-gate extern bool_t	xdr_int8_t();
4867c478bd9Sstevel@tonic-gate extern bool_t	xdr_uint8_t();
4877c478bd9Sstevel@tonic-gate extern bool_t	xdr_int16_t();
4887c478bd9Sstevel@tonic-gate extern bool_t	xdr_uint16_t();
4897c478bd9Sstevel@tonic-gate extern bool_t	xdr_int32_t();
4907c478bd9Sstevel@tonic-gate extern bool_t	xdr_uint32_t();
4917c478bd9Sstevel@tonic-gate #if defined(_INT64_TYPE)
4927c478bd9Sstevel@tonic-gate extern bool_t	xdr_int64_t();
4937c478bd9Sstevel@tonic-gate extern bool_t	xdr_uint64_t();
4947c478bd9Sstevel@tonic-gate #endif
4957c478bd9Sstevel@tonic-gate 
4967c478bd9Sstevel@tonic-gate #ifndef _KERNEL
4977c478bd9Sstevel@tonic-gate extern bool_t	xdr_float();
4987c478bd9Sstevel@tonic-gate extern bool_t	xdr_double();
4997c478bd9Sstevel@tonic-gate extern bool_t   xdr_quadruple();
5007c478bd9Sstevel@tonic-gate #endif /* !_KERNEL */
5017c478bd9Sstevel@tonic-gate #endif
5027c478bd9Sstevel@tonic-gate 
5037c478bd9Sstevel@tonic-gate /*
5047c478bd9Sstevel@tonic-gate  * Common opaque bytes objects used by many rpc protocols;
5057c478bd9Sstevel@tonic-gate  * declared here due to commonality.
5067c478bd9Sstevel@tonic-gate  */
5077c478bd9Sstevel@tonic-gate #define	MAX_NETOBJ_SZ 1024
5087c478bd9Sstevel@tonic-gate struct netobj {
5097c478bd9Sstevel@tonic-gate 	uint_t	n_len;
5107c478bd9Sstevel@tonic-gate 	char	*n_bytes;
5117c478bd9Sstevel@tonic-gate };
5127c478bd9Sstevel@tonic-gate typedef struct netobj netobj;
5137c478bd9Sstevel@tonic-gate 
5147c478bd9Sstevel@tonic-gate #ifdef __STDC__
5157c478bd9Sstevel@tonic-gate extern bool_t   xdr_netobj(XDR *, netobj *);
5167c478bd9Sstevel@tonic-gate #else
5177c478bd9Sstevel@tonic-gate extern bool_t   xdr_netobj();
5187c478bd9Sstevel@tonic-gate #endif
5197c478bd9Sstevel@tonic-gate 
5207c478bd9Sstevel@tonic-gate /*
5217c478bd9Sstevel@tonic-gate  * These are XDR control operators
5227c478bd9Sstevel@tonic-gate  */
5237c478bd9Sstevel@tonic-gate 
5247c478bd9Sstevel@tonic-gate #define	XDR_GET_BYTES_AVAIL 1
5257c478bd9Sstevel@tonic-gate 
5267c478bd9Sstevel@tonic-gate struct xdr_bytesrec {
5277c478bd9Sstevel@tonic-gate 	bool_t xc_is_last_record;
5287c478bd9Sstevel@tonic-gate 	size_t xc_num_avail;
5297c478bd9Sstevel@tonic-gate };
5307c478bd9Sstevel@tonic-gate 
5317c478bd9Sstevel@tonic-gate typedef struct xdr_bytesrec xdr_bytesrec;
5327c478bd9Sstevel@tonic-gate 
5337c478bd9Sstevel@tonic-gate /*
5347c478bd9Sstevel@tonic-gate  * These are the request arguments to XDR_CONTROL.
5357c478bd9Sstevel@tonic-gate  *
5367c478bd9Sstevel@tonic-gate  * XDR_PEEK - returns the contents of the next XDR unit on the XDR stream.
5377c478bd9Sstevel@tonic-gate  * XDR_SKIPBYTES - skips the next N bytes in the XDR stream.
5387c478bd9Sstevel@tonic-gate  * XDR_RDMAGET - for xdr implementation over RDMA, gets private flags from
5397c478bd9Sstevel@tonic-gate  *		 the XDR stream being moved over RDMA
5407c478bd9Sstevel@tonic-gate  * XDR_RDMANOCHUNK - for xdr implementaion over RDMA, sets private flags in
5417c478bd9Sstevel@tonic-gate  *                   the XDR stream moving over RDMA.
5427c478bd9Sstevel@tonic-gate  */
5437c478bd9Sstevel@tonic-gate #ifdef _KERNEL
5447c478bd9Sstevel@tonic-gate #define	XDR_PEEK		2
5457c478bd9Sstevel@tonic-gate #define	XDR_SKIPBYTES		3
5460a701b1eSRobert Gordon #define	XDR_RDMA_GET_FLAGS	4
5470a701b1eSRobert Gordon #define	XDR_RDMA_SET_FLAGS	5
5480a701b1eSRobert Gordon #define	XDR_RDMA_ADD_CHUNK	6
5490a701b1eSRobert Gordon #define	XDR_RDMA_GET_CHUNK_LEN	7
5500a701b1eSRobert Gordon #define	XDR_RDMA_SET_WLIST	8
5510a701b1eSRobert Gordon #define	XDR_RDMA_GET_WLIST	9
5520a701b1eSRobert Gordon #define	XDR_RDMA_GET_WCINFO	10
5530a701b1eSRobert Gordon #define	XDR_RDMA_GET_RLIST	11
5547c478bd9Sstevel@tonic-gate #endif
5557c478bd9Sstevel@tonic-gate 
5567c478bd9Sstevel@tonic-gate /*
5577c478bd9Sstevel@tonic-gate  * These are the public routines for the various implementations of
5587c478bd9Sstevel@tonic-gate  * xdr streams.
5597c478bd9Sstevel@tonic-gate  */
5607c478bd9Sstevel@tonic-gate #ifndef _KERNEL
5617c478bd9Sstevel@tonic-gate #ifdef __STDC__
5627c478bd9Sstevel@tonic-gate extern void   xdrmem_create(XDR *, const caddr_t, const uint_t, const enum
5637c478bd9Sstevel@tonic-gate xdr_op);
5647c478bd9Sstevel@tonic-gate 	/* XDR using memory buffers */
5657c478bd9Sstevel@tonic-gate extern void   xdrstdio_create(XDR *, FILE *, const enum xdr_op);
5667c478bd9Sstevel@tonic-gate /* XDR using stdio library */
5677c478bd9Sstevel@tonic-gate extern void   xdrrec_create(XDR *, const uint_t, const uint_t, const caddr_t,
5687c478bd9Sstevel@tonic-gate int (*) (void *, caddr_t, int), int (*) (void *, caddr_t, int));
5697c478bd9Sstevel@tonic-gate /* XDR pseudo records for tcp */
5707c478bd9Sstevel@tonic-gate extern bool_t xdrrec_endofrecord(XDR *, bool_t);
5717c478bd9Sstevel@tonic-gate /* make end of xdr record */
5727c478bd9Sstevel@tonic-gate extern bool_t xdrrec_skiprecord(XDR *);
5737c478bd9Sstevel@tonic-gate /* move to beginning of next record */
5747c478bd9Sstevel@tonic-gate extern bool_t xdrrec_eof(XDR *);
5757c478bd9Sstevel@tonic-gate extern uint_t xdrrec_readbytes(XDR *, caddr_t, uint_t);
5767c478bd9Sstevel@tonic-gate /* true if no more input */
5777c478bd9Sstevel@tonic-gate #else
5787c478bd9Sstevel@tonic-gate extern void   xdrmem_create();
5797c478bd9Sstevel@tonic-gate extern void   xdrstdio_create();
5807c478bd9Sstevel@tonic-gate extern void   xdrrec_create();
5817c478bd9Sstevel@tonic-gate extern bool_t xdrrec_endofrecord();
5827c478bd9Sstevel@tonic-gate extern bool_t xdrrec_skiprecord();
5837c478bd9Sstevel@tonic-gate extern bool_t xdrrec_eof();
5847c478bd9Sstevel@tonic-gate extern uint_t xdrrec_readbytes();
5857c478bd9Sstevel@tonic-gate #endif
5867c478bd9Sstevel@tonic-gate #else
5877c478bd9Sstevel@tonic-gate 
588*c242f9a0Schunli zhang - Sun Microsystems - Irvine United States #define	DLEN(mp) (mp->b_cont ? msgdsize(mp) : (mp->b_wptr - mp->b_rptr))
589*c242f9a0Schunli zhang - Sun Microsystems - Irvine United States 
5907c478bd9Sstevel@tonic-gate extern void	xdrmem_create(XDR *, caddr_t, uint_t, enum xdr_op);
5917c478bd9Sstevel@tonic-gate extern void	xdrmblk_init(XDR *, mblk_t *, enum xdr_op, int);
5927c478bd9Sstevel@tonic-gate extern bool_t	xdrmblk_getmblk(XDR *, mblk_t **, uint_t *);
5937c478bd9Sstevel@tonic-gate extern bool_t	xdrmblk_putmblk(XDR *, mblk_t *, uint_t);
5947c478bd9Sstevel@tonic-gate extern struct xdr_ops xdrmblk_ops;
5950a701b1eSRobert Gordon extern struct xdr_ops xdrrdmablk_ops;
5960a701b1eSRobert Gordon extern struct xdr_ops xdrrdma_ops;
5977c478bd9Sstevel@tonic-gate 
5987c478bd9Sstevel@tonic-gate struct rpc_msg;
5997c478bd9Sstevel@tonic-gate extern bool_t	xdr_callmsg(XDR *, struct rpc_msg *);
6007c478bd9Sstevel@tonic-gate extern bool_t	xdr_replymsg_body(XDR *, struct rpc_msg *);
6017c478bd9Sstevel@tonic-gate extern bool_t	xdr_replymsg_hdr(XDR *, struct rpc_msg *);
6027c478bd9Sstevel@tonic-gate 
6037c478bd9Sstevel@tonic-gate #endif /* !_KERNEL */
6047c478bd9Sstevel@tonic-gate 
6057c478bd9Sstevel@tonic-gate #ifdef __cplusplus
6067c478bd9Sstevel@tonic-gate }
6077c478bd9Sstevel@tonic-gate #endif
6087c478bd9Sstevel@tonic-gate 
6097c478bd9Sstevel@tonic-gate #endif	/* !_RPC_XDR_H */
610