1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate * 22*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 23*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 24*7c478bd9Sstevel@tonic-gate */ 25*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 26*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 27*7c478bd9Sstevel@tonic-gate /* 28*7c478bd9Sstevel@tonic-gate * Portions of this source code were derived from Berkeley 29*7c478bd9Sstevel@tonic-gate * 4.3 BSD under license from the Regents of the University of 30*7c478bd9Sstevel@tonic-gate * California. 31*7c478bd9Sstevel@tonic-gate */ 32*7c478bd9Sstevel@tonic-gate 33*7c478bd9Sstevel@tonic-gate /* 34*7c478bd9Sstevel@tonic-gate * xdr.h, External Data Representation Serialization Routines. 35*7c478bd9Sstevel@tonic-gate * 36*7c478bd9Sstevel@tonic-gate */ 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate #ifndef _RPC_XDR_H 39*7c478bd9Sstevel@tonic-gate #define _RPC_XDR_H 40*7c478bd9Sstevel@tonic-gate 41*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 42*7c478bd9Sstevel@tonic-gate 43*7c478bd9Sstevel@tonic-gate #include <sys/byteorder.h> /* For all ntoh* and hton*() kind of macros */ 44*7c478bd9Sstevel@tonic-gate #include <rpc/types.h> /* For all ntoh* and hton*() kind of macros */ 45*7c478bd9Sstevel@tonic-gate #ifndef _KERNEL 46*7c478bd9Sstevel@tonic-gate #include <stdio.h> /* defines FILE *, used in ANSI C function prototypes */ 47*7c478bd9Sstevel@tonic-gate #endif 48*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 49*7c478bd9Sstevel@tonic-gate #include <sys/stream.h> 50*7c478bd9Sstevel@tonic-gate #endif 51*7c478bd9Sstevel@tonic-gate 52*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 53*7c478bd9Sstevel@tonic-gate extern "C" { 54*7c478bd9Sstevel@tonic-gate #endif 55*7c478bd9Sstevel@tonic-gate 56*7c478bd9Sstevel@tonic-gate /* 57*7c478bd9Sstevel@tonic-gate * XDR provides a conventional way for converting between C data 58*7c478bd9Sstevel@tonic-gate * types and an external bit-string representation. Library supplied 59*7c478bd9Sstevel@tonic-gate * routines provide for the conversion on built-in C data types. These 60*7c478bd9Sstevel@tonic-gate * routines and utility routines defined here are used to help implement 61*7c478bd9Sstevel@tonic-gate * a type encode/decode routine for each user-defined type. 62*7c478bd9Sstevel@tonic-gate * 63*7c478bd9Sstevel@tonic-gate * Each data type provides a single procedure which takes two arguments: 64*7c478bd9Sstevel@tonic-gate * 65*7c478bd9Sstevel@tonic-gate * bool_t 66*7c478bd9Sstevel@tonic-gate * xdrproc(xdrs, argresp) 67*7c478bd9Sstevel@tonic-gate * XDR *xdrs; 68*7c478bd9Sstevel@tonic-gate * <type> *argresp; 69*7c478bd9Sstevel@tonic-gate * 70*7c478bd9Sstevel@tonic-gate * xdrs is an instance of a XDR handle, to which or from which the data 71*7c478bd9Sstevel@tonic-gate * type is to be converted. argresp is a pointer to the structure to be 72*7c478bd9Sstevel@tonic-gate * converted. The XDR handle contains an operation field which indicates 73*7c478bd9Sstevel@tonic-gate * which of the operations (ENCODE, DECODE * or FREE) is to be performed. 74*7c478bd9Sstevel@tonic-gate * 75*7c478bd9Sstevel@tonic-gate * XDR_DECODE may allocate space if the pointer argresp is null. This 76*7c478bd9Sstevel@tonic-gate * data can be freed with the XDR_FREE operation. 77*7c478bd9Sstevel@tonic-gate * 78*7c478bd9Sstevel@tonic-gate * We write only one procedure per data type to make it easy 79*7c478bd9Sstevel@tonic-gate * to keep the encode and decode procedures for a data type consistent. 80*7c478bd9Sstevel@tonic-gate * In many cases the same code performs all operations on a user defined type, 81*7c478bd9Sstevel@tonic-gate * because all the hard work is done in the component type routines. 82*7c478bd9Sstevel@tonic-gate * decode as a series of calls on the nested data types. 83*7c478bd9Sstevel@tonic-gate */ 84*7c478bd9Sstevel@tonic-gate 85*7c478bd9Sstevel@tonic-gate /* 86*7c478bd9Sstevel@tonic-gate * Xdr operations. XDR_ENCODE causes the type to be encoded into the 87*7c478bd9Sstevel@tonic-gate * stream. XDR_DECODE causes the type to be extracted from the stream. 88*7c478bd9Sstevel@tonic-gate * XDR_FREE can be used to release the space allocated by an XDR_DECODE 89*7c478bd9Sstevel@tonic-gate * request. 90*7c478bd9Sstevel@tonic-gate */ 91*7c478bd9Sstevel@tonic-gate enum xdr_op { 92*7c478bd9Sstevel@tonic-gate XDR_ENCODE = 0, 93*7c478bd9Sstevel@tonic-gate XDR_DECODE = 1, 94*7c478bd9Sstevel@tonic-gate XDR_FREE = 2 95*7c478bd9Sstevel@tonic-gate }; 96*7c478bd9Sstevel@tonic-gate 97*7c478bd9Sstevel@tonic-gate /* 98*7c478bd9Sstevel@tonic-gate * This is the number of bytes per unit of external data. 99*7c478bd9Sstevel@tonic-gate */ 100*7c478bd9Sstevel@tonic-gate #define BYTES_PER_XDR_UNIT (4) 101*7c478bd9Sstevel@tonic-gate #define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \ 102*7c478bd9Sstevel@tonic-gate * BYTES_PER_XDR_UNIT) 103*7c478bd9Sstevel@tonic-gate 104*7c478bd9Sstevel@tonic-gate /* 105*7c478bd9Sstevel@tonic-gate * The XDR handle. 106*7c478bd9Sstevel@tonic-gate * Contains operation which is being applied to the stream, 107*7c478bd9Sstevel@tonic-gate * an operations vector for the paticular implementation (e.g. see xdr_mem.c), 108*7c478bd9Sstevel@tonic-gate * and two private fields for the use of the particular impelementation. 109*7c478bd9Sstevel@tonic-gate * 110*7c478bd9Sstevel@tonic-gate * PSARC 2003/523 Contract Private Interface 111*7c478bd9Sstevel@tonic-gate * XDR 112*7c478bd9Sstevel@tonic-gate * Changes must be reviewed by Solaris File Sharing 113*7c478bd9Sstevel@tonic-gate * Changes must be communicated to contract-2003-523@sun.com 114*7c478bd9Sstevel@tonic-gate */ 115*7c478bd9Sstevel@tonic-gate typedef struct XDR { 116*7c478bd9Sstevel@tonic-gate enum xdr_op x_op; /* operation; fast additional param */ 117*7c478bd9Sstevel@tonic-gate struct xdr_ops *x_ops; 118*7c478bd9Sstevel@tonic-gate caddr_t x_public; /* users' data */ 119*7c478bd9Sstevel@tonic-gate caddr_t x_private; /* pointer to private data */ 120*7c478bd9Sstevel@tonic-gate caddr_t x_base; /* private used for position info */ 121*7c478bd9Sstevel@tonic-gate int x_handy; /* extra private word */ 122*7c478bd9Sstevel@tonic-gate } XDR; 123*7c478bd9Sstevel@tonic-gate 124*7c478bd9Sstevel@tonic-gate /* 125*7c478bd9Sstevel@tonic-gate * PSARC 2003/523 Contract Private Interface 126*7c478bd9Sstevel@tonic-gate * xdr_ops 127*7c478bd9Sstevel@tonic-gate * Changes must be reviewed by Solaris File Sharing 128*7c478bd9Sstevel@tonic-gate * Changes must be communicated to contract-2003-523@sun.com 129*7c478bd9Sstevel@tonic-gate */ 130*7c478bd9Sstevel@tonic-gate struct xdr_ops { 131*7c478bd9Sstevel@tonic-gate #ifdef __STDC__ 132*7c478bd9Sstevel@tonic-gate #if !defined(_KERNEL) 133*7c478bd9Sstevel@tonic-gate bool_t (*x_getlong)(struct XDR *, long *); 134*7c478bd9Sstevel@tonic-gate /* get a long from underlying stream */ 135*7c478bd9Sstevel@tonic-gate bool_t (*x_putlong)(struct XDR *, long *); 136*7c478bd9Sstevel@tonic-gate /* put a long to " */ 137*7c478bd9Sstevel@tonic-gate #endif /* KERNEL */ 138*7c478bd9Sstevel@tonic-gate bool_t (*x_getbytes)(struct XDR *, caddr_t, int); 139*7c478bd9Sstevel@tonic-gate /* get some bytes from " */ 140*7c478bd9Sstevel@tonic-gate bool_t (*x_putbytes)(struct XDR *, caddr_t, int); 141*7c478bd9Sstevel@tonic-gate /* put some bytes to " */ 142*7c478bd9Sstevel@tonic-gate uint_t (*x_getpostn)(struct XDR *); 143*7c478bd9Sstevel@tonic-gate /* returns bytes off from beginning */ 144*7c478bd9Sstevel@tonic-gate bool_t (*x_setpostn)(struct XDR *, uint_t); 145*7c478bd9Sstevel@tonic-gate /* lets you reposition the stream */ 146*7c478bd9Sstevel@tonic-gate rpc_inline_t *(*x_inline)(struct XDR *, int); 147*7c478bd9Sstevel@tonic-gate /* buf quick ptr to buffered data */ 148*7c478bd9Sstevel@tonic-gate void (*x_destroy)(struct XDR *); 149*7c478bd9Sstevel@tonic-gate /* free privates of this xdr_stream */ 150*7c478bd9Sstevel@tonic-gate bool_t (*x_control)(struct XDR *, int, void *); 151*7c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_KERNEL) 152*7c478bd9Sstevel@tonic-gate bool_t (*x_getint32)(struct XDR *, int32_t *); 153*7c478bd9Sstevel@tonic-gate /* get a int from underlying stream */ 154*7c478bd9Sstevel@tonic-gate bool_t (*x_putint32)(struct XDR *, int32_t *); 155*7c478bd9Sstevel@tonic-gate /* put an int to " */ 156*7c478bd9Sstevel@tonic-gate #endif /* _LP64 || _KERNEL */ 157*7c478bd9Sstevel@tonic-gate #else 158*7c478bd9Sstevel@tonic-gate #if !defined(_KERNEL) 159*7c478bd9Sstevel@tonic-gate bool_t (*x_getlong)(); /* get a long from underlying stream */ 160*7c478bd9Sstevel@tonic-gate bool_t (*x_putlong)(); /* put a long to " */ 161*7c478bd9Sstevel@tonic-gate #endif /* KERNEL */ 162*7c478bd9Sstevel@tonic-gate bool_t (*x_getbytes)(); /* get some bytes from " */ 163*7c478bd9Sstevel@tonic-gate bool_t (*x_putbytes)(); /* put some bytes to " */ 164*7c478bd9Sstevel@tonic-gate uint_t (*x_getpostn)(); /* returns bytes off from beginning */ 165*7c478bd9Sstevel@tonic-gate bool_t (*x_setpostn)(); /* lets you reposition the stream */ 166*7c478bd9Sstevel@tonic-gate rpc_inline_t *(*x_inline)(); 167*7c478bd9Sstevel@tonic-gate /* buf quick ptr to buffered data */ 168*7c478bd9Sstevel@tonic-gate void (*x_destroy)(); /* free privates of this xdr_stream */ 169*7c478bd9Sstevel@tonic-gate bool_t (*x_control)(); 170*7c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_KERNEL) 171*7c478bd9Sstevel@tonic-gate bool_t (*x_getint32)(); 172*7c478bd9Sstevel@tonic-gate bool_t (*x_putint32)(); 173*7c478bd9Sstevel@tonic-gate #endif /* _LP64 || defined(_KERNEL) */ 174*7c478bd9Sstevel@tonic-gate #endif 175*7c478bd9Sstevel@tonic-gate }; 176*7c478bd9Sstevel@tonic-gate 177*7c478bd9Sstevel@tonic-gate /* 178*7c478bd9Sstevel@tonic-gate * Operations defined on a XDR handle 179*7c478bd9Sstevel@tonic-gate * 180*7c478bd9Sstevel@tonic-gate * XDR *xdrs; 181*7c478bd9Sstevel@tonic-gate * long *longp; 182*7c478bd9Sstevel@tonic-gate * caddr_t addr; 183*7c478bd9Sstevel@tonic-gate * uint_t len; 184*7c478bd9Sstevel@tonic-gate * uint_t pos; 185*7c478bd9Sstevel@tonic-gate */ 186*7c478bd9Sstevel@tonic-gate #if !defined(_KERNEL) 187*7c478bd9Sstevel@tonic-gate #define XDR_GETLONG(xdrs, longp) \ 188*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_getlong)(xdrs, longp) 189*7c478bd9Sstevel@tonic-gate #define xdr_getlong(xdrs, longp) \ 190*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_getlong)(xdrs, longp) 191*7c478bd9Sstevel@tonic-gate 192*7c478bd9Sstevel@tonic-gate #define XDR_PUTLONG(xdrs, longp) \ 193*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_putlong)(xdrs, longp) 194*7c478bd9Sstevel@tonic-gate #define xdr_putlong(xdrs, longp) \ 195*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_putlong)(xdrs, longp) 196*7c478bd9Sstevel@tonic-gate #endif /* KERNEL */ 197*7c478bd9Sstevel@tonic-gate 198*7c478bd9Sstevel@tonic-gate 199*7c478bd9Sstevel@tonic-gate #if !defined(_LP64) && !defined(_KERNEL) 200*7c478bd9Sstevel@tonic-gate 201*7c478bd9Sstevel@tonic-gate /* 202*7c478bd9Sstevel@tonic-gate * For binary compatability on ILP32 we do not change the shape 203*7c478bd9Sstevel@tonic-gate * of the XDR structure and the GET/PUTINT32 functions just use 204*7c478bd9Sstevel@tonic-gate * the get/putlong vectors which operate on identically-sized 205*7c478bd9Sstevel@tonic-gate * units of data. 206*7c478bd9Sstevel@tonic-gate */ 207*7c478bd9Sstevel@tonic-gate 208*7c478bd9Sstevel@tonic-gate #define XDR_GETINT32(xdrs, int32p) \ 209*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_getlong)(xdrs, (long *)int32p) 210*7c478bd9Sstevel@tonic-gate #define xdr_getint32(xdrs, int32p) \ 211*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_getlong)(xdrs, (long *)int32p) 212*7c478bd9Sstevel@tonic-gate 213*7c478bd9Sstevel@tonic-gate #define XDR_PUTINT32(xdrs, int32p) \ 214*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_putlong)(xdrs, (long *)int32p) 215*7c478bd9Sstevel@tonic-gate #define xdr_putint32(xdrs, int32p) \ 216*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_putlong)(xdrs, (long *)int32p) 217*7c478bd9Sstevel@tonic-gate 218*7c478bd9Sstevel@tonic-gate #else /* !_LP64 && !_KERNEL */ 219*7c478bd9Sstevel@tonic-gate 220*7c478bd9Sstevel@tonic-gate #define XDR_GETINT32(xdrs, int32p) \ 221*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_getint32)(xdrs, int32p) 222*7c478bd9Sstevel@tonic-gate #define xdr_getint32(xdrs, int32p) \ 223*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_getint32)(xdrs, int32p) 224*7c478bd9Sstevel@tonic-gate 225*7c478bd9Sstevel@tonic-gate #define XDR_PUTINT32(xdrs, int32p) \ 226*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_putint32)(xdrs, int32p) 227*7c478bd9Sstevel@tonic-gate #define xdr_putint32(xdrs, int32p) \ 228*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_putint32)(xdrs, int32p) 229*7c478bd9Sstevel@tonic-gate 230*7c478bd9Sstevel@tonic-gate #endif /* !_LP64 && !_KERNEL */ 231*7c478bd9Sstevel@tonic-gate 232*7c478bd9Sstevel@tonic-gate #define XDR_GETBYTES(xdrs, addr, len) \ 233*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) 234*7c478bd9Sstevel@tonic-gate #define xdr_getbytes(xdrs, addr, len) \ 235*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) 236*7c478bd9Sstevel@tonic-gate 237*7c478bd9Sstevel@tonic-gate #define XDR_PUTBYTES(xdrs, addr, len) \ 238*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) 239*7c478bd9Sstevel@tonic-gate #define xdr_putbytes(xdrs, addr, len) \ 240*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) 241*7c478bd9Sstevel@tonic-gate 242*7c478bd9Sstevel@tonic-gate #define XDR_GETPOS(xdrs) \ 243*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_getpostn)(xdrs) 244*7c478bd9Sstevel@tonic-gate #define xdr_getpos(xdrs) \ 245*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_getpostn)(xdrs) 246*7c478bd9Sstevel@tonic-gate 247*7c478bd9Sstevel@tonic-gate #define XDR_SETPOS(xdrs, pos) \ 248*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) 249*7c478bd9Sstevel@tonic-gate #define xdr_setpos(xdrs, pos) \ 250*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) 251*7c478bd9Sstevel@tonic-gate 252*7c478bd9Sstevel@tonic-gate #define XDR_INLINE(xdrs, len) \ 253*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_inline)(xdrs, len) 254*7c478bd9Sstevel@tonic-gate #define xdr_inline(xdrs, len) \ 255*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_inline)(xdrs, len) 256*7c478bd9Sstevel@tonic-gate 257*7c478bd9Sstevel@tonic-gate #define XDR_DESTROY(xdrs) \ 258*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_destroy)(xdrs) 259*7c478bd9Sstevel@tonic-gate #define xdr_destroy(xdrs) \ 260*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_destroy)(xdrs) 261*7c478bd9Sstevel@tonic-gate 262*7c478bd9Sstevel@tonic-gate #define XDR_CONTROL(xdrs, req, op) \ 263*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_control)(xdrs, req, op) 264*7c478bd9Sstevel@tonic-gate #define xdr_control(xdrs, req, op) \ 265*7c478bd9Sstevel@tonic-gate (*(xdrs)->x_ops->x_control)(xdrs, req, op) 266*7c478bd9Sstevel@tonic-gate 267*7c478bd9Sstevel@tonic-gate /* 268*7c478bd9Sstevel@tonic-gate * Support struct for discriminated unions. 269*7c478bd9Sstevel@tonic-gate * You create an array of xdrdiscrim structures, terminated with 270*7c478bd9Sstevel@tonic-gate * a entry with a null procedure pointer. The xdr_union routine gets 271*7c478bd9Sstevel@tonic-gate * the discriminant value and then searches the array of structures 272*7c478bd9Sstevel@tonic-gate * for a matching value. If a match is found the associated xdr routine 273*7c478bd9Sstevel@tonic-gate * is called to handle that part of the union. If there is 274*7c478bd9Sstevel@tonic-gate * no match, then a default routine may be called. 275*7c478bd9Sstevel@tonic-gate * If there is no match and no default routine it is an error. 276*7c478bd9Sstevel@tonic-gate */ 277*7c478bd9Sstevel@tonic-gate 278*7c478bd9Sstevel@tonic-gate 279*7c478bd9Sstevel@tonic-gate /* 280*7c478bd9Sstevel@tonic-gate * A xdrproc_t exists for each data type which is to be encoded or decoded. 281*7c478bd9Sstevel@tonic-gate * 282*7c478bd9Sstevel@tonic-gate * The second argument to the xdrproc_t is a pointer to an opaque pointer. 283*7c478bd9Sstevel@tonic-gate * The opaque pointer generally points to a structure of the data type 284*7c478bd9Sstevel@tonic-gate * to be decoded. If this pointer is 0, then the type routines should 285*7c478bd9Sstevel@tonic-gate * allocate dynamic storage of the appropriate size and return it. 286*7c478bd9Sstevel@tonic-gate * bool_t (*xdrproc_t)(XDR *, void *); 287*7c478bd9Sstevel@tonic-gate */ 288*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 289*7c478bd9Sstevel@tonic-gate typedef bool_t (*xdrproc_t)(XDR *, void *); 290*7c478bd9Sstevel@tonic-gate #else 291*7c478bd9Sstevel@tonic-gate #ifdef __STDC__ 292*7c478bd9Sstevel@tonic-gate typedef bool_t (*xdrproc_t)(); /* For Backward compatibility */ 293*7c478bd9Sstevel@tonic-gate #else 294*7c478bd9Sstevel@tonic-gate typedef bool_t (*xdrproc_t)(); 295*7c478bd9Sstevel@tonic-gate #endif 296*7c478bd9Sstevel@tonic-gate #endif 297*7c478bd9Sstevel@tonic-gate 298*7c478bd9Sstevel@tonic-gate #define NULL_xdrproc_t ((xdrproc_t)0) 299*7c478bd9Sstevel@tonic-gate 300*7c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_I32LPx) 301*7c478bd9Sstevel@tonic-gate #define xdr_rpcvers(xdrs, versp) xdr_u_int(xdrs, versp) 302*7c478bd9Sstevel@tonic-gate #define xdr_rpcprog(xdrs, progp) xdr_u_int(xdrs, progp) 303*7c478bd9Sstevel@tonic-gate #define xdr_rpcproc(xdrs, procp) xdr_u_int(xdrs, procp) 304*7c478bd9Sstevel@tonic-gate #define xdr_rpcprot(xdrs, protp) xdr_u_int(xdrs, protp) 305*7c478bd9Sstevel@tonic-gate #define xdr_rpcport(xdrs, portp) xdr_u_int(xdrs, portp) 306*7c478bd9Sstevel@tonic-gate #else 307*7c478bd9Sstevel@tonic-gate #define xdr_rpcvers(xdrs, versp) xdr_u_long(xdrs, versp) 308*7c478bd9Sstevel@tonic-gate #define xdr_rpcprog(xdrs, progp) xdr_u_long(xdrs, progp) 309*7c478bd9Sstevel@tonic-gate #define xdr_rpcproc(xdrs, procp) xdr_u_long(xdrs, procp) 310*7c478bd9Sstevel@tonic-gate #define xdr_rpcprot(xdrs, protp) xdr_u_long(xdrs, protp) 311*7c478bd9Sstevel@tonic-gate #define xdr_rpcport(xdrs, portp) xdr_u_long(xdrs, portp) 312*7c478bd9Sstevel@tonic-gate #endif 313*7c478bd9Sstevel@tonic-gate 314*7c478bd9Sstevel@tonic-gate struct xdr_discrim { 315*7c478bd9Sstevel@tonic-gate int value; 316*7c478bd9Sstevel@tonic-gate xdrproc_t proc; 317*7c478bd9Sstevel@tonic-gate }; 318*7c478bd9Sstevel@tonic-gate 319*7c478bd9Sstevel@tonic-gate /* 320*7c478bd9Sstevel@tonic-gate * In-line routines for fast encode/decode of primitve data types. 321*7c478bd9Sstevel@tonic-gate * Caveat emptor: these use single memory cycles to get the 322*7c478bd9Sstevel@tonic-gate * data from the underlying buffer, and will fail to operate 323*7c478bd9Sstevel@tonic-gate * properly if the data is not aligned. The standard way to use these 324*7c478bd9Sstevel@tonic-gate * is to say: 325*7c478bd9Sstevel@tonic-gate * if ((buf = XDR_INLINE(xdrs, count)) == NULL) 326*7c478bd9Sstevel@tonic-gate * return (FALSE); 327*7c478bd9Sstevel@tonic-gate * <<< macro calls >>> 328*7c478bd9Sstevel@tonic-gate * where ``count'' is the number of bytes of data occupied 329*7c478bd9Sstevel@tonic-gate * by the primitive data types. 330*7c478bd9Sstevel@tonic-gate * 331*7c478bd9Sstevel@tonic-gate * N.B. and frozen for all time: each data type here uses 4 bytes 332*7c478bd9Sstevel@tonic-gate * of external representation. 333*7c478bd9Sstevel@tonic-gate */ 334*7c478bd9Sstevel@tonic-gate 335*7c478bd9Sstevel@tonic-gate #define IXDR_GET_INT32(buf) ((int32_t)ntohl((uint32_t)*(buf)++)) 336*7c478bd9Sstevel@tonic-gate #define IXDR_PUT_INT32(buf, v) (*(buf)++ = (int32_t)htonl((uint32_t)v)) 337*7c478bd9Sstevel@tonic-gate #define IXDR_GET_U_INT32(buf) ((uint32_t)IXDR_GET_INT32(buf)) 338*7c478bd9Sstevel@tonic-gate #define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_INT32((buf), ((int32_t)(v))) 339*7c478bd9Sstevel@tonic-gate 340*7c478bd9Sstevel@tonic-gate #if !defined(_KERNEL) && !defined(_LP64) 341*7c478bd9Sstevel@tonic-gate 342*7c478bd9Sstevel@tonic-gate #define IXDR_GET_LONG(buf) ((long)ntohl((ulong_t)*(buf)++)) 343*7c478bd9Sstevel@tonic-gate #define IXDR_PUT_LONG(buf, v) (*(buf)++ = (long)htonl((ulong_t)v)) 344*7c478bd9Sstevel@tonic-gate #define IXDR_GET_U_LONG(buf) ((ulong_t)IXDR_GET_LONG(buf)) 345*7c478bd9Sstevel@tonic-gate #define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) 346*7c478bd9Sstevel@tonic-gate 347*7c478bd9Sstevel@tonic-gate #define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf)) 348*7c478bd9Sstevel@tonic-gate #define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf)) 349*7c478bd9Sstevel@tonic-gate #define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf)) 350*7c478bd9Sstevel@tonic-gate #define IXDR_GET_U_SHORT(buf) ((ushort_t)IXDR_GET_LONG(buf)) 351*7c478bd9Sstevel@tonic-gate 352*7c478bd9Sstevel@tonic-gate #define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) 353*7c478bd9Sstevel@tonic-gate #define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) 354*7c478bd9Sstevel@tonic-gate #define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) 355*7c478bd9Sstevel@tonic-gate #define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) 356*7c478bd9Sstevel@tonic-gate 357*7c478bd9Sstevel@tonic-gate #else 358*7c478bd9Sstevel@tonic-gate 359*7c478bd9Sstevel@tonic-gate #define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_INT32(buf)) 360*7c478bd9Sstevel@tonic-gate #define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_INT32(buf)) 361*7c478bd9Sstevel@tonic-gate #define IXDR_GET_SHORT(buf) ((short)IXDR_GET_INT32(buf)) 362*7c478bd9Sstevel@tonic-gate #define IXDR_GET_U_SHORT(buf) ((ushort_t)IXDR_GET_INT32(buf)) 363*7c478bd9Sstevel@tonic-gate 364*7c478bd9Sstevel@tonic-gate #define IXDR_PUT_BOOL(buf, v) IXDR_PUT_INT32((buf), ((int)(v))) 365*7c478bd9Sstevel@tonic-gate #define IXDR_PUT_ENUM(buf, v) IXDR_PUT_INT32((buf), ((int)(v))) 366*7c478bd9Sstevel@tonic-gate #define IXDR_PUT_SHORT(buf, v) IXDR_PUT_INT32((buf), ((int)(v))) 367*7c478bd9Sstevel@tonic-gate #define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_INT32((buf), ((int)(v))) 368*7c478bd9Sstevel@tonic-gate 369*7c478bd9Sstevel@tonic-gate #endif 370*7c478bd9Sstevel@tonic-gate 371*7c478bd9Sstevel@tonic-gate #ifndef _LITTLE_ENDIAN 372*7c478bd9Sstevel@tonic-gate #define IXDR_GET_HYPER(buf, v) { \ 373*7c478bd9Sstevel@tonic-gate *((int32_t *)(&v)) = ntohl(*(uint32_t *)buf++); \ 374*7c478bd9Sstevel@tonic-gate *((int32_t *)(((char *)&v) + BYTES_PER_XDR_UNIT)) \ 375*7c478bd9Sstevel@tonic-gate = ntohl(*(uint32_t *)buf++); \ 376*7c478bd9Sstevel@tonic-gate } 377*7c478bd9Sstevel@tonic-gate #define IXDR_PUT_HYPER(buf, v) { \ 378*7c478bd9Sstevel@tonic-gate *(buf)++ = (int32_t)htonl(*(uint32_t *) \ 379*7c478bd9Sstevel@tonic-gate ((char *)&v)); \ 380*7c478bd9Sstevel@tonic-gate *(buf)++ = \ 381*7c478bd9Sstevel@tonic-gate (int32_t)htonl(*(uint32_t *)(((char *)&v) \ 382*7c478bd9Sstevel@tonic-gate + BYTES_PER_XDR_UNIT)); \ 383*7c478bd9Sstevel@tonic-gate } 384*7c478bd9Sstevel@tonic-gate #else 385*7c478bd9Sstevel@tonic-gate 386*7c478bd9Sstevel@tonic-gate #define IXDR_GET_HYPER(buf, v) { \ 387*7c478bd9Sstevel@tonic-gate *((int32_t *)(((char *)&v) + \ 388*7c478bd9Sstevel@tonic-gate BYTES_PER_XDR_UNIT)) \ 389*7c478bd9Sstevel@tonic-gate = ntohl(*(uint32_t *)buf++); \ 390*7c478bd9Sstevel@tonic-gate *((int32_t *)(&v)) = \ 391*7c478bd9Sstevel@tonic-gate ntohl(*(uint32_t *)buf++); \ 392*7c478bd9Sstevel@tonic-gate } 393*7c478bd9Sstevel@tonic-gate 394*7c478bd9Sstevel@tonic-gate #define IXDR_PUT_HYPER(buf, v) { \ 395*7c478bd9Sstevel@tonic-gate *(buf)++ = \ 396*7c478bd9Sstevel@tonic-gate (int32_t)htonl(*(uint32_t *)(((char *)&v) + \ 397*7c478bd9Sstevel@tonic-gate BYTES_PER_XDR_UNIT)); \ 398*7c478bd9Sstevel@tonic-gate *(buf)++ = \ 399*7c478bd9Sstevel@tonic-gate (int32_t)htonl(*(uint32_t *)((char *)&v)); \ 400*7c478bd9Sstevel@tonic-gate } 401*7c478bd9Sstevel@tonic-gate #endif 402*7c478bd9Sstevel@tonic-gate #define IXDR_GET_U_HYPER(buf, v) IXDR_GET_HYPER(buf, v) 403*7c478bd9Sstevel@tonic-gate #define IXDR_PUT_U_HYPER(buf, v) IXDR_PUT_HYPER(buf, v) 404*7c478bd9Sstevel@tonic-gate 405*7c478bd9Sstevel@tonic-gate 406*7c478bd9Sstevel@tonic-gate /* 407*7c478bd9Sstevel@tonic-gate * These are the "generic" xdr routines. 408*7c478bd9Sstevel@tonic-gate */ 409*7c478bd9Sstevel@tonic-gate #ifdef __STDC__ 410*7c478bd9Sstevel@tonic-gate extern bool_t xdr_void(void); 411*7c478bd9Sstevel@tonic-gate extern bool_t xdr_int(XDR *, int *); 412*7c478bd9Sstevel@tonic-gate extern bool_t xdr_u_int(XDR *, uint_t *); 413*7c478bd9Sstevel@tonic-gate extern bool_t xdr_long(XDR *, long *); 414*7c478bd9Sstevel@tonic-gate extern bool_t xdr_u_long(XDR *, ulong_t *); 415*7c478bd9Sstevel@tonic-gate extern bool_t xdr_short(XDR *, short *); 416*7c478bd9Sstevel@tonic-gate extern bool_t xdr_u_short(XDR *, ushort_t *); 417*7c478bd9Sstevel@tonic-gate extern bool_t xdr_bool(XDR *, bool_t *); 418*7c478bd9Sstevel@tonic-gate extern bool_t xdr_enum(XDR *, enum_t *); 419*7c478bd9Sstevel@tonic-gate extern bool_t xdr_array(XDR *, caddr_t *, uint_t *, const uint_t, 420*7c478bd9Sstevel@tonic-gate const uint_t, const xdrproc_t); 421*7c478bd9Sstevel@tonic-gate extern bool_t xdr_bytes(XDR *, char **, uint_t *, const uint_t); 422*7c478bd9Sstevel@tonic-gate extern bool_t xdr_opaque(XDR *, caddr_t, const uint_t); 423*7c478bd9Sstevel@tonic-gate extern bool_t xdr_string(XDR *, char **, const uint_t); 424*7c478bd9Sstevel@tonic-gate extern bool_t xdr_union(XDR *, enum_t *, char *, 425*7c478bd9Sstevel@tonic-gate const struct xdr_discrim *, const xdrproc_t); 426*7c478bd9Sstevel@tonic-gate extern unsigned int xdr_sizeof(xdrproc_t, void *); 427*7c478bd9Sstevel@tonic-gate 428*7c478bd9Sstevel@tonic-gate extern bool_t xdr_hyper(XDR *, longlong_t *); 429*7c478bd9Sstevel@tonic-gate extern bool_t xdr_longlong_t(XDR *, longlong_t *); 430*7c478bd9Sstevel@tonic-gate extern bool_t xdr_u_hyper(XDR *, u_longlong_t *); 431*7c478bd9Sstevel@tonic-gate extern bool_t xdr_u_longlong_t(XDR *, u_longlong_t *); 432*7c478bd9Sstevel@tonic-gate 433*7c478bd9Sstevel@tonic-gate extern bool_t xdr_char(XDR *, char *); 434*7c478bd9Sstevel@tonic-gate extern bool_t xdr_wrapstring(XDR *, char **); 435*7c478bd9Sstevel@tonic-gate extern bool_t xdr_reference(XDR *, caddr_t *, uint_t, const xdrproc_t); 436*7c478bd9Sstevel@tonic-gate extern bool_t xdr_pointer(XDR *, char **, uint_t, const xdrproc_t); 437*7c478bd9Sstevel@tonic-gate extern void xdr_free(xdrproc_t, char *); 438*7c478bd9Sstevel@tonic-gate extern bool_t xdr_time_t(XDR *, time_t *); 439*7c478bd9Sstevel@tonic-gate 440*7c478bd9Sstevel@tonic-gate extern bool_t xdr_int8_t(XDR *, int8_t *); 441*7c478bd9Sstevel@tonic-gate extern bool_t xdr_uint8_t(XDR *, uint8_t *); 442*7c478bd9Sstevel@tonic-gate extern bool_t xdr_int16_t(XDR *, int16_t *); 443*7c478bd9Sstevel@tonic-gate extern bool_t xdr_uint16_t(XDR *, uint16_t *); 444*7c478bd9Sstevel@tonic-gate extern bool_t xdr_int32_t(XDR *, int32_t *); 445*7c478bd9Sstevel@tonic-gate extern bool_t xdr_uint32_t(XDR *, uint32_t *); 446*7c478bd9Sstevel@tonic-gate #if defined(_INT64_TYPE) 447*7c478bd9Sstevel@tonic-gate extern bool_t xdr_int64_t(XDR *, int64_t *); 448*7c478bd9Sstevel@tonic-gate extern bool_t xdr_uint64_t(XDR *, uint64_t *); 449*7c478bd9Sstevel@tonic-gate #endif 450*7c478bd9Sstevel@tonic-gate 451*7c478bd9Sstevel@tonic-gate #ifndef _KERNEL 452*7c478bd9Sstevel@tonic-gate extern bool_t xdr_u_char(XDR *, uchar_t *); 453*7c478bd9Sstevel@tonic-gate extern bool_t xdr_vector(XDR *, char *, const uint_t, const uint_t, const 454*7c478bd9Sstevel@tonic-gate xdrproc_t); 455*7c478bd9Sstevel@tonic-gate extern bool_t xdr_float(XDR *, float *); 456*7c478bd9Sstevel@tonic-gate extern bool_t xdr_double(XDR *, double *); 457*7c478bd9Sstevel@tonic-gate extern bool_t xdr_quadruple(XDR *, long double *); 458*7c478bd9Sstevel@tonic-gate #endif /* !_KERNEL */ 459*7c478bd9Sstevel@tonic-gate #else 460*7c478bd9Sstevel@tonic-gate extern bool_t xdr_void(); 461*7c478bd9Sstevel@tonic-gate extern bool_t xdr_int(); 462*7c478bd9Sstevel@tonic-gate extern bool_t xdr_u_int(); 463*7c478bd9Sstevel@tonic-gate extern bool_t xdr_long(); 464*7c478bd9Sstevel@tonic-gate extern bool_t xdr_u_long(); 465*7c478bd9Sstevel@tonic-gate extern bool_t xdr_short(); 466*7c478bd9Sstevel@tonic-gate extern bool_t xdr_u_short(); 467*7c478bd9Sstevel@tonic-gate extern bool_t xdr_bool(); 468*7c478bd9Sstevel@tonic-gate extern bool_t xdr_enum(); 469*7c478bd9Sstevel@tonic-gate extern bool_t xdr_array(); 470*7c478bd9Sstevel@tonic-gate extern bool_t xdr_bytes(); 471*7c478bd9Sstevel@tonic-gate extern bool_t xdr_opaque(); 472*7c478bd9Sstevel@tonic-gate extern bool_t xdr_string(); 473*7c478bd9Sstevel@tonic-gate extern bool_t xdr_union(); 474*7c478bd9Sstevel@tonic-gate 475*7c478bd9Sstevel@tonic-gate extern bool_t xdr_hyper(); 476*7c478bd9Sstevel@tonic-gate extern bool_t xdr_longlong_t(); 477*7c478bd9Sstevel@tonic-gate extern bool_t xdr_u_hyper(); 478*7c478bd9Sstevel@tonic-gate extern bool_t xdr_u_longlong_t(); 479*7c478bd9Sstevel@tonic-gate extern bool_t xdr_char(); 480*7c478bd9Sstevel@tonic-gate extern bool_t xdr_reference(); 481*7c478bd9Sstevel@tonic-gate extern bool_t xdr_pointer(); 482*7c478bd9Sstevel@tonic-gate extern void xdr_free(); 483*7c478bd9Sstevel@tonic-gate extern bool_t xdr_wrapstring(); 484*7c478bd9Sstevel@tonic-gate extern bool_t xdr_time_t(); 485*7c478bd9Sstevel@tonic-gate 486*7c478bd9Sstevel@tonic-gate extern bool_t xdr_int8_t(); 487*7c478bd9Sstevel@tonic-gate extern bool_t xdr_uint8_t(); 488*7c478bd9Sstevel@tonic-gate extern bool_t xdr_int16_t(); 489*7c478bd9Sstevel@tonic-gate extern bool_t xdr_uint16_t(); 490*7c478bd9Sstevel@tonic-gate extern bool_t xdr_int32_t(); 491*7c478bd9Sstevel@tonic-gate extern bool_t xdr_uint32_t(); 492*7c478bd9Sstevel@tonic-gate #if defined(_INT64_TYPE) 493*7c478bd9Sstevel@tonic-gate extern bool_t xdr_int64_t(); 494*7c478bd9Sstevel@tonic-gate extern bool_t xdr_uint64_t(); 495*7c478bd9Sstevel@tonic-gate #endif 496*7c478bd9Sstevel@tonic-gate 497*7c478bd9Sstevel@tonic-gate #ifndef _KERNEL 498*7c478bd9Sstevel@tonic-gate extern bool_t xdr_u_char(); 499*7c478bd9Sstevel@tonic-gate extern bool_t xdr_vector(); 500*7c478bd9Sstevel@tonic-gate extern bool_t xdr_float(); 501*7c478bd9Sstevel@tonic-gate extern bool_t xdr_double(); 502*7c478bd9Sstevel@tonic-gate extern bool_t xdr_quadruple(); 503*7c478bd9Sstevel@tonic-gate #endif /* !_KERNEL */ 504*7c478bd9Sstevel@tonic-gate #endif 505*7c478bd9Sstevel@tonic-gate 506*7c478bd9Sstevel@tonic-gate /* 507*7c478bd9Sstevel@tonic-gate * Common opaque bytes objects used by many rpc protocols; 508*7c478bd9Sstevel@tonic-gate * declared here due to commonality. 509*7c478bd9Sstevel@tonic-gate */ 510*7c478bd9Sstevel@tonic-gate #define MAX_NETOBJ_SZ 1024 511*7c478bd9Sstevel@tonic-gate struct netobj { 512*7c478bd9Sstevel@tonic-gate uint_t n_len; 513*7c478bd9Sstevel@tonic-gate char *n_bytes; 514*7c478bd9Sstevel@tonic-gate }; 515*7c478bd9Sstevel@tonic-gate typedef struct netobj netobj; 516*7c478bd9Sstevel@tonic-gate 517*7c478bd9Sstevel@tonic-gate #ifdef __STDC__ 518*7c478bd9Sstevel@tonic-gate extern bool_t xdr_netobj(XDR *, netobj *); 519*7c478bd9Sstevel@tonic-gate #else 520*7c478bd9Sstevel@tonic-gate extern bool_t xdr_netobj(); 521*7c478bd9Sstevel@tonic-gate #endif 522*7c478bd9Sstevel@tonic-gate 523*7c478bd9Sstevel@tonic-gate /* 524*7c478bd9Sstevel@tonic-gate * These are XDR control operators 525*7c478bd9Sstevel@tonic-gate */ 526*7c478bd9Sstevel@tonic-gate 527*7c478bd9Sstevel@tonic-gate #define XDR_GET_BYTES_AVAIL 1 528*7c478bd9Sstevel@tonic-gate 529*7c478bd9Sstevel@tonic-gate struct xdr_bytesrec { 530*7c478bd9Sstevel@tonic-gate bool_t xc_is_last_record; 531*7c478bd9Sstevel@tonic-gate size_t xc_num_avail; 532*7c478bd9Sstevel@tonic-gate }; 533*7c478bd9Sstevel@tonic-gate 534*7c478bd9Sstevel@tonic-gate typedef struct xdr_bytesrec xdr_bytesrec; 535*7c478bd9Sstevel@tonic-gate 536*7c478bd9Sstevel@tonic-gate /* 537*7c478bd9Sstevel@tonic-gate * These are the request arguments to XDR_CONTROL. 538*7c478bd9Sstevel@tonic-gate * 539*7c478bd9Sstevel@tonic-gate * XDR_PEEK - returns the contents of the next XDR unit on the XDR stream. 540*7c478bd9Sstevel@tonic-gate * XDR_SKIPBYTES - skips the next N bytes in the XDR stream. 541*7c478bd9Sstevel@tonic-gate * XDR_RDMAGET - for xdr implementation over RDMA, gets private flags from 542*7c478bd9Sstevel@tonic-gate * the XDR stream being moved over RDMA 543*7c478bd9Sstevel@tonic-gate * XDR_RDMANOCHUNK - for xdr implementaion over RDMA, sets private flags in 544*7c478bd9Sstevel@tonic-gate * the XDR stream moving over RDMA. 545*7c478bd9Sstevel@tonic-gate */ 546*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 547*7c478bd9Sstevel@tonic-gate #define XDR_PEEK 2 548*7c478bd9Sstevel@tonic-gate #define XDR_SKIPBYTES 3 549*7c478bd9Sstevel@tonic-gate #define XDR_RDMAGET 4 550*7c478bd9Sstevel@tonic-gate #define XDR_RDMASET 5 551*7c478bd9Sstevel@tonic-gate #endif 552*7c478bd9Sstevel@tonic-gate 553*7c478bd9Sstevel@tonic-gate /* 554*7c478bd9Sstevel@tonic-gate * These are the public routines for the various implementations of 555*7c478bd9Sstevel@tonic-gate * xdr streams. 556*7c478bd9Sstevel@tonic-gate */ 557*7c478bd9Sstevel@tonic-gate #ifndef _KERNEL 558*7c478bd9Sstevel@tonic-gate #ifdef __STDC__ 559*7c478bd9Sstevel@tonic-gate extern void xdrmem_create(XDR *, const caddr_t, const uint_t, const enum 560*7c478bd9Sstevel@tonic-gate xdr_op); 561*7c478bd9Sstevel@tonic-gate /* XDR using memory buffers */ 562*7c478bd9Sstevel@tonic-gate extern void xdrstdio_create(XDR *, FILE *, const enum xdr_op); 563*7c478bd9Sstevel@tonic-gate /* XDR using stdio library */ 564*7c478bd9Sstevel@tonic-gate extern void xdrrec_create(XDR *, const uint_t, const uint_t, const caddr_t, 565*7c478bd9Sstevel@tonic-gate int (*) (void *, caddr_t, int), int (*) (void *, caddr_t, int)); 566*7c478bd9Sstevel@tonic-gate /* XDR pseudo records for tcp */ 567*7c478bd9Sstevel@tonic-gate extern bool_t xdrrec_endofrecord(XDR *, bool_t); 568*7c478bd9Sstevel@tonic-gate /* make end of xdr record */ 569*7c478bd9Sstevel@tonic-gate extern bool_t xdrrec_skiprecord(XDR *); 570*7c478bd9Sstevel@tonic-gate /* move to beginning of next record */ 571*7c478bd9Sstevel@tonic-gate extern bool_t xdrrec_eof(XDR *); 572*7c478bd9Sstevel@tonic-gate extern uint_t xdrrec_readbytes(XDR *, caddr_t, uint_t); 573*7c478bd9Sstevel@tonic-gate /* true if no more input */ 574*7c478bd9Sstevel@tonic-gate #else 575*7c478bd9Sstevel@tonic-gate extern void xdrmem_create(); 576*7c478bd9Sstevel@tonic-gate extern void xdrstdio_create(); 577*7c478bd9Sstevel@tonic-gate extern void xdrrec_create(); 578*7c478bd9Sstevel@tonic-gate extern bool_t xdrrec_endofrecord(); 579*7c478bd9Sstevel@tonic-gate extern bool_t xdrrec_skiprecord(); 580*7c478bd9Sstevel@tonic-gate extern bool_t xdrrec_eof(); 581*7c478bd9Sstevel@tonic-gate extern uint_t xdrrec_readbytes(); 582*7c478bd9Sstevel@tonic-gate #endif 583*7c478bd9Sstevel@tonic-gate #else 584*7c478bd9Sstevel@tonic-gate 585*7c478bd9Sstevel@tonic-gate extern void xdrmem_create(XDR *, caddr_t, uint_t, enum xdr_op); 586*7c478bd9Sstevel@tonic-gate extern void xdrmblk_init(XDR *, mblk_t *, enum xdr_op, int); 587*7c478bd9Sstevel@tonic-gate extern bool_t xdrmblk_getmblk(XDR *, mblk_t **, uint_t *); 588*7c478bd9Sstevel@tonic-gate extern bool_t xdrmblk_putmblk(XDR *, mblk_t *, uint_t); 589*7c478bd9Sstevel@tonic-gate 590*7c478bd9Sstevel@tonic-gate extern struct xdr_ops xdrmblk_ops; 591*7c478bd9Sstevel@tonic-gate 592*7c478bd9Sstevel@tonic-gate struct rpc_msg; 593*7c478bd9Sstevel@tonic-gate extern bool_t xdr_callmsg(XDR *, struct rpc_msg *); 594*7c478bd9Sstevel@tonic-gate extern bool_t xdr_replymsg_body(XDR *, struct rpc_msg *); 595*7c478bd9Sstevel@tonic-gate extern bool_t xdr_replymsg_hdr(XDR *, struct rpc_msg *); 596*7c478bd9Sstevel@tonic-gate 597*7c478bd9Sstevel@tonic-gate #endif /* !_KERNEL */ 598*7c478bd9Sstevel@tonic-gate 599*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 600*7c478bd9Sstevel@tonic-gate } 601*7c478bd9Sstevel@tonic-gate #endif 602*7c478bd9Sstevel@tonic-gate 603*7c478bd9Sstevel@tonic-gate #endif /* !_RPC_XDR_H */ 604