xref: /freebsd/lib/libc/xdr/xdr.c (revision 333fc21e3cd79bca0c94d7722c5a56cb5ad078d1)
1 /*	$NetBSD: xdr.c,v 1.22 2000/07/06 03:10:35 christos Exp $	*/
2 
3 /*
4  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
5  * unrestricted use provided that this legend is included on all tape
6  * media and as a part of the software program in whole or part.  Users
7  * may copy or modify Sun RPC without charge, but are not authorized
8  * to license or distribute it to anyone else except as part of a product or
9  * program developed by the user.
10  *
11  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
12  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
13  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
14  *
15  * Sun RPC is provided with no support and without any obligation on the
16  * part of Sun Microsystems, Inc. to assist in its use, correction,
17  * modification or enhancement.
18  *
19  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
20  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
21  * OR ANY PART THEREOF.
22  *
23  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
24  * or profits or other special, indirect and consequential damages, even if
25  * Sun has been advised of the possibility of such damages.
26  *
27  * Sun Microsystems, Inc.
28  * 2550 Garcia Avenue
29  * Mountain View, California  94043
30  */
31 
32 #if defined(LIBC_SCCS) && !defined(lint)
33 static char *sccsid = "@(#)xdr.c 1.35 87/08/12";
34 static char *sccsid = "@(#)xdr.c	2.1 88/07/29 4.0 RPCSRC";
35 #endif
36 #include <sys/cdefs.h>
37 __FBSDID("$FreeBSD$");
38 
39 /*
40  * xdr.c, Generic XDR routines implementation.
41  *
42  * Copyright (C) 1986, Sun Microsystems, Inc.
43  *
44  * These are the "generic" xdr routines used to serialize and de-serialize
45  * most common data items.  See xdr.h for more info on the interface to
46  * xdr.
47  */
48 
49 #include "namespace.h"
50 #include <err.h>
51 #include <stdio.h>
52 #include <stdlib.h>
53 #include <string.h>
54 
55 #include <rpc/types.h>
56 #include <rpc/xdr.h>
57 #include "un-namespace.h"
58 
59 typedef quad_t          longlong_t;     /* ANSI long long type */
60 typedef u_quad_t        u_longlong_t;   /* ANSI unsigned long long type */
61 
62 /*
63  * constants specific to the xdr "protocol"
64  */
65 #define XDR_FALSE	((long) 0)
66 #define XDR_TRUE	((long) 1)
67 #define LASTUNSIGNED	((u_int) 0-1)
68 
69 /*
70  * for unit alignment
71  */
72 static const char xdr_zero[BYTES_PER_XDR_UNIT] = { 0, 0, 0, 0 };
73 
74 /*
75  * Free a data structure using XDR
76  * Not a filter, but a convenient utility nonetheless
77  */
78 void
79 xdr_free(proc, objp)
80 	xdrproc_t proc;
81 	char *objp;
82 {
83 	XDR x;
84 
85 	x.x_op = XDR_FREE;
86 	(*proc)(&x, objp);
87 }
88 
89 /*
90  * XDR nothing
91  */
92 bool_t
93 xdr_void(/* xdrs, addr */)
94 	/* XDR *xdrs; */
95 	/* caddr_t addr; */
96 {
97 
98 	return (TRUE);
99 }
100 
101 
102 /*
103  * XDR integers
104  */
105 bool_t
106 xdr_int(xdrs, ip)
107 	XDR *xdrs;
108 	int *ip;
109 {
110 	long l;
111 
112 	switch (xdrs->x_op) {
113 
114 	case XDR_ENCODE:
115 		l = (long) *ip;
116 		return (XDR_PUTLONG(xdrs, &l));
117 
118 	case XDR_DECODE:
119 		if (!XDR_GETLONG(xdrs, &l)) {
120 			return (FALSE);
121 		}
122 		*ip = (int) l;
123 		return (TRUE);
124 
125 	case XDR_FREE:
126 		return (TRUE);
127 	}
128 	/* NOTREACHED */
129 	return (FALSE);
130 }
131 
132 /*
133  * XDR unsigned integers
134  */
135 bool_t
136 xdr_u_int(xdrs, up)
137 	XDR *xdrs;
138 	u_int *up;
139 {
140 	u_long l;
141 
142 	switch (xdrs->x_op) {
143 
144 	case XDR_ENCODE:
145 		l = (u_long) *up;
146 		return (XDR_PUTLONG(xdrs, (long *)&l));
147 
148 	case XDR_DECODE:
149 		if (!XDR_GETLONG(xdrs, (long *)&l)) {
150 			return (FALSE);
151 		}
152 		*up = (u_int) l;
153 		return (TRUE);
154 
155 	case XDR_FREE:
156 		return (TRUE);
157 	}
158 	/* NOTREACHED */
159 	return (FALSE);
160 }
161 
162 
163 /*
164  * XDR long integers
165  * same as xdr_u_long - open coded to save a proc call!
166  */
167 bool_t
168 xdr_long(xdrs, lp)
169 	XDR *xdrs;
170 	long *lp;
171 {
172 	switch (xdrs->x_op) {
173 	case XDR_ENCODE:
174 		return (XDR_PUTLONG(xdrs, lp));
175 	case XDR_DECODE:
176 		return (XDR_GETLONG(xdrs, lp));
177 	case XDR_FREE:
178 		return (TRUE);
179 	}
180 	/* NOTREACHED */
181 	return (FALSE);
182 }
183 
184 /*
185  * XDR unsigned long integers
186  * same as xdr_long - open coded to save a proc call!
187  */
188 bool_t
189 xdr_u_long(xdrs, ulp)
190 	XDR *xdrs;
191 	u_long *ulp;
192 {
193 	switch (xdrs->x_op) {
194 	case XDR_ENCODE:
195 		return (XDR_PUTLONG(xdrs, (long *)ulp));
196 	case XDR_DECODE:
197 		return (XDR_GETLONG(xdrs, (long *)ulp));
198 	case XDR_FREE:
199 		return (TRUE);
200 	}
201 	/* NOTREACHED */
202 	return (FALSE);
203 }
204 
205 
206 /*
207  * XDR 32-bit integers
208  * same as xdr_u_int32_t - open coded to save a proc call!
209  */
210 bool_t
211 xdr_int32_t(xdrs, int32_p)
212 	XDR *xdrs;
213 	int32_t *int32_p;
214 {
215 	long l;
216 
217 	switch (xdrs->x_op) {
218 
219 	case XDR_ENCODE:
220 		l = (long) *int32_p;
221 		return (XDR_PUTLONG(xdrs, &l));
222 
223 	case XDR_DECODE:
224 		if (!XDR_GETLONG(xdrs, &l)) {
225 			return (FALSE);
226 		}
227 		*int32_p = (int32_t) l;
228 		return (TRUE);
229 
230 	case XDR_FREE:
231 		return (TRUE);
232 	}
233 	/* NOTREACHED */
234 	return (FALSE);
235 }
236 
237 /*
238  * XDR unsigned 32-bit integers
239  * same as xdr_int32_t - open coded to save a proc call!
240  */
241 bool_t
242 xdr_u_int32_t(xdrs, u_int32_p)
243 	XDR *xdrs;
244 	u_int32_t *u_int32_p;
245 {
246 	u_long l;
247 
248 	switch (xdrs->x_op) {
249 
250 	case XDR_ENCODE:
251 		l = (u_long) *u_int32_p;
252 		return (XDR_PUTLONG(xdrs, (long *)&l));
253 
254 	case XDR_DECODE:
255 		if (!XDR_GETLONG(xdrs, (long *)&l)) {
256 			return (FALSE);
257 		}
258 		*u_int32_p = (u_int32_t) l;
259 		return (TRUE);
260 
261 	case XDR_FREE:
262 		return (TRUE);
263 	}
264 	/* NOTREACHED */
265 	return (FALSE);
266 }
267 
268 
269 /*
270  * XDR short integers
271  */
272 bool_t
273 xdr_short(xdrs, sp)
274 	XDR *xdrs;
275 	short *sp;
276 {
277 	long l;
278 
279 	switch (xdrs->x_op) {
280 
281 	case XDR_ENCODE:
282 		l = (long) *sp;
283 		return (XDR_PUTLONG(xdrs, &l));
284 
285 	case XDR_DECODE:
286 		if (!XDR_GETLONG(xdrs, &l)) {
287 			return (FALSE);
288 		}
289 		*sp = (short) l;
290 		return (TRUE);
291 
292 	case XDR_FREE:
293 		return (TRUE);
294 	}
295 	/* NOTREACHED */
296 	return (FALSE);
297 }
298 
299 /*
300  * XDR unsigned short integers
301  */
302 bool_t
303 xdr_u_short(xdrs, usp)
304 	XDR *xdrs;
305 	u_short *usp;
306 {
307 	u_long l;
308 
309 	switch (xdrs->x_op) {
310 
311 	case XDR_ENCODE:
312 		l = (u_long) *usp;
313 		return (XDR_PUTLONG(xdrs, (long *)&l));
314 
315 	case XDR_DECODE:
316 		if (!XDR_GETLONG(xdrs, (long *)&l)) {
317 			return (FALSE);
318 		}
319 		*usp = (u_short) l;
320 		return (TRUE);
321 
322 	case XDR_FREE:
323 		return (TRUE);
324 	}
325 	/* NOTREACHED */
326 	return (FALSE);
327 }
328 
329 
330 /*
331  * XDR 16-bit integers
332  */
333 bool_t
334 xdr_int16_t(xdrs, int16_p)
335 	XDR *xdrs;
336 	int16_t *int16_p;
337 {
338 	long l;
339 
340 	switch (xdrs->x_op) {
341 
342 	case XDR_ENCODE:
343 		l = (long) *int16_p;
344 		return (XDR_PUTLONG(xdrs, &l));
345 
346 	case XDR_DECODE:
347 		if (!XDR_GETLONG(xdrs, &l)) {
348 			return (FALSE);
349 		}
350 		*int16_p = (int16_t) l;
351 		return (TRUE);
352 
353 	case XDR_FREE:
354 		return (TRUE);
355 	}
356 	/* NOTREACHED */
357 	return (FALSE);
358 }
359 
360 /*
361  * XDR unsigned 16-bit integers
362  */
363 bool_t
364 xdr_u_int16_t(xdrs, u_int16_p)
365 	XDR *xdrs;
366 	u_int16_t *u_int16_p;
367 {
368 	u_long l;
369 
370 	switch (xdrs->x_op) {
371 
372 	case XDR_ENCODE:
373 		l = (u_long) *u_int16_p;
374 		return (XDR_PUTLONG(xdrs, (long *)&l));
375 
376 	case XDR_DECODE:
377 		if (!XDR_GETLONG(xdrs, (long *)&l)) {
378 			return (FALSE);
379 		}
380 		*u_int16_p = (u_int16_t) l;
381 		return (TRUE);
382 
383 	case XDR_FREE:
384 		return (TRUE);
385 	}
386 	/* NOTREACHED */
387 	return (FALSE);
388 }
389 
390 
391 /*
392  * XDR a char
393  */
394 bool_t
395 xdr_char(xdrs, cp)
396 	XDR *xdrs;
397 	char *cp;
398 {
399 	int i;
400 
401 	i = (*cp);
402 	if (!xdr_int(xdrs, &i)) {
403 		return (FALSE);
404 	}
405 	*cp = i;
406 	return (TRUE);
407 }
408 
409 /*
410  * XDR an unsigned char
411  */
412 bool_t
413 xdr_u_char(xdrs, cp)
414 	XDR *xdrs;
415 	u_char *cp;
416 {
417 	u_int u;
418 
419 	u = (*cp);
420 	if (!xdr_u_int(xdrs, &u)) {
421 		return (FALSE);
422 	}
423 	*cp = u;
424 	return (TRUE);
425 }
426 
427 /*
428  * XDR booleans
429  */
430 bool_t
431 xdr_bool(xdrs, bp)
432 	XDR *xdrs;
433 	bool_t *bp;
434 {
435 	long lb;
436 
437 	switch (xdrs->x_op) {
438 
439 	case XDR_ENCODE:
440 		lb = *bp ? XDR_TRUE : XDR_FALSE;
441 		return (XDR_PUTLONG(xdrs, &lb));
442 
443 	case XDR_DECODE:
444 		if (!XDR_GETLONG(xdrs, &lb)) {
445 			return (FALSE);
446 		}
447 		*bp = (lb == XDR_FALSE) ? FALSE : TRUE;
448 		return (TRUE);
449 
450 	case XDR_FREE:
451 		return (TRUE);
452 	}
453 	/* NOTREACHED */
454 	return (FALSE);
455 }
456 
457 /*
458  * XDR enumerations
459  */
460 bool_t
461 xdr_enum(xdrs, ep)
462 	XDR *xdrs;
463 	enum_t *ep;
464 {
465 	enum sizecheck { SIZEVAL };	/* used to find the size of an enum */
466 
467 	/*
468 	 * enums are treated as ints
469 	 */
470 	/* LINTED */ if (sizeof (enum sizecheck) == sizeof (long)) {
471 		return (xdr_long(xdrs, (long *)(void *)ep));
472 	} else /* LINTED */ if (sizeof (enum sizecheck) == sizeof (int)) {
473 		return (xdr_int(xdrs, (int *)(void *)ep));
474 	} else /* LINTED */ if (sizeof (enum sizecheck) == sizeof (short)) {
475 		return (xdr_short(xdrs, (short *)(void *)ep));
476 	} else {
477 		return (FALSE);
478 	}
479 }
480 
481 /*
482  * XDR opaque data
483  * Allows the specification of a fixed size sequence of opaque bytes.
484  * cp points to the opaque object and cnt gives the byte length.
485  */
486 bool_t
487 xdr_opaque(xdrs, cp, cnt)
488 	XDR *xdrs;
489 	caddr_t cp;
490 	u_int cnt;
491 {
492 	u_int rndup;
493 	static int crud[BYTES_PER_XDR_UNIT];
494 
495 	/*
496 	 * if no data we are done
497 	 */
498 	if (cnt == 0)
499 		return (TRUE);
500 
501 	/*
502 	 * round byte count to full xdr units
503 	 */
504 	rndup = cnt % BYTES_PER_XDR_UNIT;
505 	if (rndup > 0)
506 		rndup = BYTES_PER_XDR_UNIT - rndup;
507 
508 	if (xdrs->x_op == XDR_DECODE) {
509 		if (!XDR_GETBYTES(xdrs, cp, cnt)) {
510 			return (FALSE);
511 		}
512 		if (rndup == 0)
513 			return (TRUE);
514 		return (XDR_GETBYTES(xdrs, (caddr_t)(void *)crud, rndup));
515 	}
516 
517 	if (xdrs->x_op == XDR_ENCODE) {
518 		if (!XDR_PUTBYTES(xdrs, cp, cnt)) {
519 			return (FALSE);
520 		}
521 		if (rndup == 0)
522 			return (TRUE);
523 		return (XDR_PUTBYTES(xdrs, xdr_zero, rndup));
524 	}
525 
526 	if (xdrs->x_op == XDR_FREE) {
527 		return (TRUE);
528 	}
529 
530 	return (FALSE);
531 }
532 
533 /*
534  * XDR counted bytes
535  * *cpp is a pointer to the bytes, *sizep is the count.
536  * If *cpp is NULL maxsize bytes are allocated
537  */
538 bool_t
539 xdr_bytes(xdrs, cpp, sizep, maxsize)
540 	XDR *xdrs;
541 	char **cpp;
542 	u_int *sizep;
543 	u_int maxsize;
544 {
545 	char *sp = *cpp;  /* sp is the actual string pointer */
546 	u_int nodesize;
547 
548 	/*
549 	 * first deal with the length since xdr bytes are counted
550 	 */
551 	if (! xdr_u_int(xdrs, sizep)) {
552 		return (FALSE);
553 	}
554 	nodesize = *sizep;
555 	if ((nodesize > maxsize) && (xdrs->x_op != XDR_FREE)) {
556 		return (FALSE);
557 	}
558 
559 	/*
560 	 * now deal with the actual bytes
561 	 */
562 	switch (xdrs->x_op) {
563 
564 	case XDR_DECODE:
565 		if (nodesize == 0) {
566 			return (TRUE);
567 		}
568 		if (sp == NULL) {
569 			*cpp = sp = mem_alloc(nodesize);
570 		}
571 		if (sp == NULL) {
572 			warnx("xdr_bytes: out of memory");
573 			return (FALSE);
574 		}
575 		/* FALLTHROUGH */
576 
577 	case XDR_ENCODE:
578 		return (xdr_opaque(xdrs, sp, nodesize));
579 
580 	case XDR_FREE:
581 		if (sp != NULL) {
582 			mem_free(sp, nodesize);
583 			*cpp = NULL;
584 		}
585 		return (TRUE);
586 	}
587 	/* NOTREACHED */
588 	return (FALSE);
589 }
590 
591 /*
592  * Implemented here due to commonality of the object.
593  */
594 bool_t
595 xdr_netobj(xdrs, np)
596 	XDR *xdrs;
597 	struct netobj *np;
598 {
599 
600 	return (xdr_bytes(xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ));
601 }
602 
603 /*
604  * XDR a descriminated union
605  * Support routine for discriminated unions.
606  * You create an array of xdrdiscrim structures, terminated with
607  * an entry with a null procedure pointer.  The routine gets
608  * the discriminant value and then searches the array of xdrdiscrims
609  * looking for that value.  It calls the procedure given in the xdrdiscrim
610  * to handle the discriminant.  If there is no specific routine a default
611  * routine may be called.
612  * If there is no specific or default routine an error is returned.
613  */
614 bool_t
615 xdr_union(xdrs, dscmp, unp, choices, dfault)
616 	XDR *xdrs;
617 	enum_t *dscmp;		/* enum to decide which arm to work on */
618 	char *unp;		/* the union itself */
619 	const struct xdr_discrim *choices;	/* [value, xdr proc] for each arm */
620 	xdrproc_t dfault;	/* default xdr routine */
621 {
622 	enum_t dscm;
623 
624 	/*
625 	 * we deal with the discriminator;  it's an enum
626 	 */
627 	if (! xdr_enum(xdrs, dscmp)) {
628 		return (FALSE);
629 	}
630 	dscm = *dscmp;
631 
632 	/*
633 	 * search choices for a value that matches the discriminator.
634 	 * if we find one, execute the xdr routine for that value.
635 	 */
636 	for (; choices->proc != NULL_xdrproc_t; choices++) {
637 		if (choices->value == dscm)
638 			return ((*(choices->proc))(xdrs, unp));
639 	}
640 
641 	/*
642 	 * no match - execute the default xdr routine if there is one
643 	 */
644 	return ((dfault == NULL_xdrproc_t) ? FALSE :
645 	    (*dfault)(xdrs, unp));
646 }
647 
648 
649 /*
650  * Non-portable xdr primitives.
651  * Care should be taken when moving these routines to new architectures.
652  */
653 
654 
655 /*
656  * XDR null terminated ASCII strings
657  * xdr_string deals with "C strings" - arrays of bytes that are
658  * terminated by a NULL character.  The parameter cpp references a
659  * pointer to storage; If the pointer is null, then the necessary
660  * storage is allocated.  The last parameter is the max allowed length
661  * of the string as specified by a protocol.
662  */
663 bool_t
664 xdr_string(xdrs, cpp, maxsize)
665 	XDR *xdrs;
666 	char **cpp;
667 	u_int maxsize;
668 {
669 	char *sp = *cpp;  /* sp is the actual string pointer */
670 	u_int size;
671 	u_int nodesize;
672 
673 	/*
674 	 * first deal with the length since xdr strings are counted-strings
675 	 */
676 	switch (xdrs->x_op) {
677 	case XDR_FREE:
678 		if (sp == NULL) {
679 			return(TRUE);	/* already free */
680 		}
681 		/* FALLTHROUGH */
682 	case XDR_ENCODE:
683 		size = strlen(sp);
684 		break;
685 	case XDR_DECODE:
686 		break;
687 	}
688 	if (! xdr_u_int(xdrs, &size)) {
689 		return (FALSE);
690 	}
691 	if (size > maxsize) {
692 		return (FALSE);
693 	}
694 	nodesize = size + 1;
695 
696 	/*
697 	 * now deal with the actual bytes
698 	 */
699 	switch (xdrs->x_op) {
700 
701 	case XDR_DECODE:
702 		if (nodesize == 0) {
703 			return (TRUE);
704 		}
705 		if (sp == NULL)
706 			*cpp = sp = mem_alloc(nodesize);
707 		if (sp == NULL) {
708 			warnx("xdr_string: out of memory");
709 			return (FALSE);
710 		}
711 		sp[size] = 0;
712 		/* FALLTHROUGH */
713 
714 	case XDR_ENCODE:
715 		return (xdr_opaque(xdrs, sp, size));
716 
717 	case XDR_FREE:
718 		mem_free(sp, nodesize);
719 		*cpp = NULL;
720 		return (TRUE);
721 	}
722 	/* NOTREACHED */
723 	return (FALSE);
724 }
725 
726 /*
727  * Wrapper for xdr_string that can be called directly from
728  * routines like clnt_call
729  */
730 bool_t
731 xdr_wrapstring(xdrs, cpp)
732 	XDR *xdrs;
733 	char **cpp;
734 {
735 	return xdr_string(xdrs, cpp, LASTUNSIGNED);
736 }
737 
738 /*
739  * NOTE: xdr_hyper(), xdr_u_hyper(), xdr_longlong_t(), and xdr_u_longlong_t()
740  * are in the "non-portable" section because they require that a `long long'
741  * be a 64-bit type.
742  *
743  *	--thorpej@netbsd.org, November 30, 1999
744  */
745 
746 /*
747  * XDR 64-bit integers
748  */
749 bool_t
750 xdr_int64_t(xdrs, llp)
751 	XDR *xdrs;
752 	int64_t *llp;
753 {
754 	u_long ul[2];
755 
756 	switch (xdrs->x_op) {
757 	case XDR_ENCODE:
758 		ul[0] = (u_long)((u_int64_t)*llp >> 32) & 0xffffffff;
759 		ul[1] = (u_long)((u_int64_t)*llp) & 0xffffffff;
760 		if (XDR_PUTLONG(xdrs, (long *)&ul[0]) == FALSE)
761 			return (FALSE);
762 		return (XDR_PUTLONG(xdrs, (long *)&ul[1]));
763 	case XDR_DECODE:
764 		if (XDR_GETLONG(xdrs, (long *)&ul[0]) == FALSE)
765 			return (FALSE);
766 		if (XDR_GETLONG(xdrs, (long *)&ul[1]) == FALSE)
767 			return (FALSE);
768 		*llp = (int64_t)
769 		    (((u_int64_t)ul[0] << 32) | ((u_int64_t)ul[1]));
770 		return (TRUE);
771 	case XDR_FREE:
772 		return (TRUE);
773 	}
774 	/* NOTREACHED */
775 	return (FALSE);
776 }
777 
778 
779 /*
780  * XDR unsigned 64-bit integers
781  */
782 bool_t
783 xdr_u_int64_t(xdrs, ullp)
784 	XDR *xdrs;
785 	u_int64_t *ullp;
786 {
787 	u_long ul[2];
788 
789 	switch (xdrs->x_op) {
790 	case XDR_ENCODE:
791 		ul[0] = (u_long)(*ullp >> 32) & 0xffffffff;
792 		ul[1] = (u_long)(*ullp) & 0xffffffff;
793 		if (XDR_PUTLONG(xdrs, (long *)&ul[0]) == FALSE)
794 			return (FALSE);
795 		return (XDR_PUTLONG(xdrs, (long *)&ul[1]));
796 	case XDR_DECODE:
797 		if (XDR_GETLONG(xdrs, (long *)&ul[0]) == FALSE)
798 			return (FALSE);
799 		if (XDR_GETLONG(xdrs, (long *)&ul[1]) == FALSE)
800 			return (FALSE);
801 		*ullp = (u_int64_t)
802 		    (((u_int64_t)ul[0] << 32) | ((u_int64_t)ul[1]));
803 		return (TRUE);
804 	case XDR_FREE:
805 		return (TRUE);
806 	}
807 	/* NOTREACHED */
808 	return (FALSE);
809 }
810 
811 
812 /*
813  * XDR hypers
814  */
815 bool_t
816 xdr_hyper(xdrs, llp)
817 	XDR *xdrs;
818 	longlong_t *llp;
819 {
820 
821 	/*
822 	 * Don't bother open-coding this; it's a fair amount of code.  Just
823 	 * call xdr_int64_t().
824 	 */
825 	return (xdr_int64_t(xdrs, (int64_t *)llp));
826 }
827 
828 
829 /*
830  * XDR unsigned hypers
831  */
832 bool_t
833 xdr_u_hyper(xdrs, ullp)
834 	XDR *xdrs;
835 	u_longlong_t *ullp;
836 {
837 
838 	/*
839 	 * Don't bother open-coding this; it's a fair amount of code.  Just
840 	 * call xdr_u_int64_t().
841 	 */
842 	return (xdr_u_int64_t(xdrs, (u_int64_t *)ullp));
843 }
844 
845 
846 /*
847  * XDR longlong_t's
848  */
849 bool_t
850 xdr_longlong_t(xdrs, llp)
851 	XDR *xdrs;
852 	longlong_t *llp;
853 {
854 
855 	/*
856 	 * Don't bother open-coding this; it's a fair amount of code.  Just
857 	 * call xdr_int64_t().
858 	 */
859 	return (xdr_int64_t(xdrs, (int64_t *)llp));
860 }
861 
862 
863 /*
864  * XDR u_longlong_t's
865  */
866 bool_t
867 xdr_u_longlong_t(xdrs, ullp)
868 	XDR *xdrs;
869 	u_longlong_t *ullp;
870 {
871 
872 	/*
873 	 * Don't bother open-coding this; it's a fair amount of code.  Just
874 	 * call xdr_u_int64_t().
875 	 */
876 	return (xdr_u_int64_t(xdrs, (u_int64_t *)ullp));
877 }
878