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