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