Remove building with NOCRYPTO option
[minix3.git] / lib / libc / rpc / xdr.c
blobeb46fc491ec84cd8b9d3e45c7d64cf08282c69a0
1 /* $NetBSD: xdr.c,v 1.33 2013/03/11 20:19:29 tron Exp $ */
3 /*
4 * Copyright (c) 2010, Oracle America, Inc.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following
14 * disclaimer in the documentation and/or other materials
15 * provided with the distribution.
16 * * Neither the name of the "Oracle America, Inc." nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include <sys/cdefs.h>
35 #if defined(LIBC_SCCS) && !defined(lint)
36 #if 0
37 static char *sccsid = "@(#)xdr.c 1.35 87/08/12";
38 static char *sccsid = "@(#)xdr.c 2.1 88/07/29 4.0 RPCSRC";
39 #else
40 __RCSID("$NetBSD: xdr.c,v 1.33 2013/03/11 20:19:29 tron Exp $");
41 #endif
42 #endif
45 * xdr.c, Generic XDR routines implementation.
47 * Copyright (C) 1986, Sun Microsystems, Inc.
49 * These are the "generic" xdr routines used to serialize and de-serialize
50 * most common data items. See xdr.h for more info on the interface to
51 * xdr.
54 #include "namespace.h"
56 #include <assert.h>
57 #include <err.h>
58 #include <stdio.h>
59 #include <stdlib.h>
60 #include <string.h>
62 #include <rpc/types.h>
63 #include <rpc/xdr.h>
65 #ifdef __weak_alias
66 __weak_alias(xdr_bool,_xdr_bool)
67 __weak_alias(xdr_bytes,_xdr_bytes)
68 __weak_alias(xdr_char,_xdr_char)
69 __weak_alias(xdr_enum,_xdr_enum)
70 __weak_alias(xdr_free,_xdr_free)
71 __weak_alias(xdr_hyper,_xdr_hyper)
72 __weak_alias(xdr_int,_xdr_int)
73 __weak_alias(xdr_int16_t,_xdr_int16_t)
74 __weak_alias(xdr_int32_t,_xdr_int32_t)
75 __weak_alias(xdr_int64_t,_xdr_int64_t)
76 __weak_alias(xdr_long,_xdr_long)
77 __weak_alias(xdr_longlong_t,_xdr_longlong_t)
78 __weak_alias(xdr_netobj,_xdr_netobj)
79 __weak_alias(xdr_opaque,_xdr_opaque)
80 __weak_alias(xdr_short,_xdr_short)
81 __weak_alias(xdr_string,_xdr_string)
82 __weak_alias(xdr_u_char,_xdr_u_char)
83 __weak_alias(xdr_u_hyper,_xdr_u_hyper)
84 __weak_alias(xdr_u_int,_xdr_u_int)
85 __weak_alias(xdr_u_int16_t,_xdr_u_int16_t)
86 __weak_alias(xdr_u_int32_t,_xdr_u_int32_t)
87 __weak_alias(xdr_u_int64_t,_xdr_u_int64_t)
88 __weak_alias(xdr_u_long,_xdr_u_long)
89 __weak_alias(xdr_u_longlong_t,_xdr_u_longlong_t)
90 __weak_alias(xdr_u_short,_xdr_u_short)
91 __weak_alias(xdr_union,_xdr_union)
92 __weak_alias(xdr_void,_xdr_void)
93 __weak_alias(xdr_wrapstring,_xdr_wrapstring)
94 #endif
97 * constants specific to the xdr "protocol"
99 #define XDR_FALSE ((long) 0)
100 #define XDR_TRUE ((long) 1)
101 #define LASTUNSIGNED ((u_int) 0-1)
104 * for unit alignment
106 static const char xdr_zero[BYTES_PER_XDR_UNIT] = { 0, 0, 0, 0 };
109 * Free a data structure using XDR
110 * Not a filter, but a convenient utility nonetheless
112 void
113 xdr_free(xdrproc_t proc, char *objp)
115 XDR x;
117 x.x_op = XDR_FREE;
118 (*proc)(&x, objp);
122 * XDR nothing
124 bool_t
125 xdr_void(void) {
127 return (TRUE);
132 * XDR integers
134 bool_t
135 xdr_int(XDR *xdrs, int *ip)
137 long l;
139 _DIAGASSERT(xdrs != NULL);
140 _DIAGASSERT(ip != NULL);
142 switch (xdrs->x_op) {
144 case XDR_ENCODE:
145 l = (long) *ip;
146 return (XDR_PUTLONG(xdrs, &l));
148 case XDR_DECODE:
149 if (!XDR_GETLONG(xdrs, &l)) {
150 return (FALSE);
152 *ip = (int) l;
153 return (TRUE);
155 case XDR_FREE:
156 return (TRUE);
158 /* NOTREACHED */
159 return (FALSE);
163 * XDR unsigned integers
165 bool_t
166 xdr_u_int(XDR *xdrs, u_int *up)
168 u_long l;
170 _DIAGASSERT(xdrs != NULL);
171 _DIAGASSERT(up != NULL);
173 switch (xdrs->x_op) {
175 case XDR_ENCODE:
176 l = (u_long) *up;
177 return (XDR_PUTLONG(xdrs, (long *)&l));
179 case XDR_DECODE:
180 if (!XDR_GETLONG(xdrs, (long *)&l)) {
181 return (FALSE);
183 *up = (u_int) l;
184 return (TRUE);
186 case XDR_FREE:
187 return (TRUE);
189 /* NOTREACHED */
190 return (FALSE);
195 * XDR long integers
196 * same as xdr_u_long - open coded to save a proc call!
198 bool_t
199 xdr_long(XDR *xdrs, long *lp)
202 _DIAGASSERT(xdrs != NULL);
203 _DIAGASSERT(lp != NULL);
205 switch (xdrs->x_op) {
206 case XDR_ENCODE:
207 return (XDR_PUTLONG(xdrs, lp));
208 case XDR_DECODE:
209 return (XDR_GETLONG(xdrs, lp));
210 case XDR_FREE:
211 return (TRUE);
213 /* NOTREACHED */
214 return (FALSE);
218 * XDR unsigned long integers
219 * same as xdr_long - open coded to save a proc call!
221 bool_t
222 xdr_u_long(XDR *xdrs, u_long *ulp)
225 _DIAGASSERT(xdrs != NULL);
226 _DIAGASSERT(ulp != NULL);
228 switch (xdrs->x_op) {
229 case XDR_ENCODE:
230 return (XDR_PUTLONG(xdrs, (long *)ulp));
231 case XDR_DECODE:
232 return (XDR_GETLONG(xdrs, (long *)ulp));
233 case XDR_FREE:
234 return (TRUE);
236 /* NOTREACHED */
237 return (FALSE);
242 * XDR 32-bit integers
243 * same as xdr_u_int32_t - open coded to save a proc call!
245 bool_t
246 xdr_int32_t(XDR *xdrs, int32_t *int32_p)
248 long l;
250 _DIAGASSERT(xdrs != NULL);
251 _DIAGASSERT(int32_p != NULL);
253 switch (xdrs->x_op) {
255 case XDR_ENCODE:
256 l = (long) *int32_p;
257 return (XDR_PUTLONG(xdrs, &l));
259 case XDR_DECODE:
260 if (!XDR_GETLONG(xdrs, &l)) {
261 return (FALSE);
263 *int32_p = (int32_t) l;
264 return (TRUE);
266 case XDR_FREE:
267 return (TRUE);
269 /* NOTREACHED */
270 return (FALSE);
274 * XDR unsigned 32-bit integers
275 * same as xdr_int32_t - open coded to save a proc call!
277 bool_t
278 xdr_u_int32_t(XDR *xdrs, u_int32_t *u_int32_p)
280 u_long l;
282 _DIAGASSERT(xdrs != NULL);
283 _DIAGASSERT(u_int32_p != NULL);
285 switch (xdrs->x_op) {
287 case XDR_ENCODE:
288 l = (u_long) *u_int32_p;
289 return (XDR_PUTLONG(xdrs, (long *)&l));
291 case XDR_DECODE:
292 if (!XDR_GETLONG(xdrs, (long *)&l)) {
293 return (FALSE);
295 *u_int32_p = (u_int32_t) l;
296 return (TRUE);
298 case XDR_FREE:
299 return (TRUE);
301 /* NOTREACHED */
302 return (FALSE);
307 * XDR short integers
309 bool_t
310 xdr_short(XDR *xdrs, short *sp)
312 long l;
314 _DIAGASSERT(xdrs != NULL);
315 _DIAGASSERT(sp != NULL);
317 switch (xdrs->x_op) {
319 case XDR_ENCODE:
320 l = (long) *sp;
321 return (XDR_PUTLONG(xdrs, &l));
323 case XDR_DECODE:
324 if (!XDR_GETLONG(xdrs, &l)) {
325 return (FALSE);
327 *sp = (short) l;
328 return (TRUE);
330 case XDR_FREE:
331 return (TRUE);
333 /* NOTREACHED */
334 return (FALSE);
338 * XDR unsigned short integers
340 bool_t
341 xdr_u_short(XDR *xdrs, u_short *usp)
343 u_long l;
345 _DIAGASSERT(xdrs != NULL);
346 _DIAGASSERT(usp != NULL);
348 switch (xdrs->x_op) {
350 case XDR_ENCODE:
351 l = (u_long) *usp;
352 return (XDR_PUTLONG(xdrs, (long *)&l));
354 case XDR_DECODE:
355 if (!XDR_GETLONG(xdrs, (long *)&l)) {
356 return (FALSE);
358 *usp = (u_short) l;
359 return (TRUE);
361 case XDR_FREE:
362 return (TRUE);
364 /* NOTREACHED */
365 return (FALSE);
370 * XDR 16-bit integers
372 bool_t
373 xdr_int16_t(XDR *xdrs, int16_t *int16_p)
375 long l;
377 _DIAGASSERT(xdrs != NULL);
378 _DIAGASSERT(int16_p != NULL);
380 switch (xdrs->x_op) {
382 case XDR_ENCODE:
383 l = (long) *int16_p;
384 return (XDR_PUTLONG(xdrs, &l));
386 case XDR_DECODE:
387 if (!XDR_GETLONG(xdrs, &l)) {
388 return (FALSE);
390 *int16_p = (int16_t) l;
391 return (TRUE);
393 case XDR_FREE:
394 return (TRUE);
396 /* NOTREACHED */
397 return (FALSE);
401 * XDR unsigned 16-bit integers
403 bool_t
404 xdr_u_int16_t(XDR *xdrs, u_int16_t *u_int16_p)
406 u_long l;
408 _DIAGASSERT(xdrs != NULL);
409 _DIAGASSERT(u_int16_p != NULL);
411 switch (xdrs->x_op) {
413 case XDR_ENCODE:
414 l = (u_long) *u_int16_p;
415 return (XDR_PUTLONG(xdrs, (long *)&l));
417 case XDR_DECODE:
418 if (!XDR_GETLONG(xdrs, (long *)&l)) {
419 return (FALSE);
421 *u_int16_p = (u_int16_t) l;
422 return (TRUE);
424 case XDR_FREE:
425 return (TRUE);
427 /* NOTREACHED */
428 return (FALSE);
433 * XDR a char
435 bool_t
436 xdr_char(XDR *xdrs, char *cp)
438 int i;
440 _DIAGASSERT(xdrs != NULL);
441 _DIAGASSERT(cp != NULL);
443 i = (*cp);
444 if (!xdr_int(xdrs, &i)) {
445 return (FALSE);
447 *cp = i;
448 return (TRUE);
452 * XDR an unsigned char
454 bool_t
455 xdr_u_char(XDR *xdrs, u_char *cp)
457 u_int u;
459 _DIAGASSERT(xdrs != NULL);
460 _DIAGASSERT(cp != NULL);
462 u = (*cp);
463 if (!xdr_u_int(xdrs, &u)) {
464 return (FALSE);
466 *cp = u;
467 return (TRUE);
471 * XDR booleans
473 bool_t
474 xdr_bool(XDR *xdrs, bool_t *bp)
476 long lb;
478 _DIAGASSERT(xdrs != NULL);
479 _DIAGASSERT(bp != NULL);
481 switch (xdrs->x_op) {
483 case XDR_ENCODE:
484 lb = *bp ? XDR_TRUE : XDR_FALSE;
485 return (XDR_PUTLONG(xdrs, &lb));
487 case XDR_DECODE:
488 if (!XDR_GETLONG(xdrs, &lb)) {
489 return (FALSE);
491 *bp = (lb == XDR_FALSE) ? FALSE : TRUE;
492 return (TRUE);
494 case XDR_FREE:
495 return (TRUE);
497 /* NOTREACHED */
498 return (FALSE);
502 * XDR enumerations
504 bool_t
505 xdr_enum(XDR *xdrs, enum_t *ep)
507 long l;
509 _DIAGASSERT(xdrs != NULL);
510 _DIAGASSERT(ep != NULL);
512 switch (xdrs->x_op) {
514 case XDR_ENCODE:
515 l = (long) *ep;
516 return (XDR_PUTLONG(xdrs, &l));
518 case XDR_DECODE:
519 if (!XDR_GETLONG(xdrs, &l)) {
520 return (FALSE);
522 *ep = (enum_t) l;
523 return (TRUE);
525 case XDR_FREE:
526 return (TRUE);
528 /* NOTREACHED */
529 return (FALSE);
533 * XDR opaque data
534 * Allows the specification of a fixed size sequence of opaque bytes.
535 * cp points to the opaque object and cnt gives the byte length.
537 bool_t
538 xdr_opaque(XDR *xdrs, caddr_t cp, u_int cnt)
540 u_int rndup;
541 static int crud[BYTES_PER_XDR_UNIT];
543 _DIAGASSERT(xdrs != NULL);
545 * if no data we are done
547 if (cnt == 0)
548 return (TRUE);
549 _DIAGASSERT(cp != NULL);
552 * round byte count to full xdr units
554 rndup = cnt % BYTES_PER_XDR_UNIT;
555 if (rndup > 0)
556 rndup = BYTES_PER_XDR_UNIT - rndup;
558 if (xdrs->x_op == XDR_DECODE) {
559 if (!XDR_GETBYTES(xdrs, cp, cnt)) {
560 return (FALSE);
562 if (rndup == 0)
563 return (TRUE);
564 return (XDR_GETBYTES(xdrs, (caddr_t)(void *)crud, rndup));
567 if (xdrs->x_op == XDR_ENCODE) {
568 if (!XDR_PUTBYTES(xdrs, cp, cnt)) {
569 return (FALSE);
571 if (rndup == 0)
572 return (TRUE);
573 return (XDR_PUTBYTES(xdrs, xdr_zero, rndup));
576 if (xdrs->x_op == XDR_FREE) {
577 return (TRUE);
580 return (FALSE);
584 * XDR counted bytes
585 * *cpp is a pointer to the bytes, *sizep is the count.
586 * If *cpp is NULL maxsize bytes are allocated
588 bool_t
589 xdr_bytes(XDR *xdrs, char **cpp, u_int *sizep, u_int maxsize)
591 char *sp; /* sp is the actual string pointer */
592 u_int nodesize;
594 _DIAGASSERT(xdrs != NULL);
595 _DIAGASSERT(cpp != NULL);
596 _DIAGASSERT(sizep != NULL);
598 sp = *cpp;
601 * first deal with the length since xdr bytes are counted
603 if (! xdr_u_int(xdrs, sizep)) {
604 return (FALSE);
606 nodesize = *sizep;
607 if ((nodesize > maxsize) && (xdrs->x_op != XDR_FREE)) {
608 return (FALSE);
612 * now deal with the actual bytes
614 switch (xdrs->x_op) {
616 case XDR_DECODE:
617 if (nodesize == 0) {
618 return (TRUE);
620 if (sp == NULL) {
621 *cpp = sp = mem_alloc(nodesize);
623 if (sp == NULL) {
624 warn("%s: out of memory", __func__);
625 return (FALSE);
627 /* FALLTHROUGH */
629 case XDR_ENCODE:
630 return (xdr_opaque(xdrs, sp, nodesize));
632 case XDR_FREE:
633 if (sp != NULL) {
634 mem_free(sp, nodesize);
635 *cpp = NULL;
637 return (TRUE);
639 /* NOTREACHED */
640 return (FALSE);
644 * Implemented here due to commonality of the object.
646 bool_t
647 xdr_netobj(XDR *xdrs, struct netobj *np)
650 _DIAGASSERT(xdrs != NULL);
651 _DIAGASSERT(np != NULL);
653 return (xdr_bytes(xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ));
657 * XDR a descriminated union
658 * Support routine for discriminated unions.
659 * You create an array of xdrdiscrim structures, terminated with
660 * an entry with a null procedure pointer. The routine gets
661 * the discriminant value and then searches the array of xdrdiscrims
662 * looking for that value. It calls the procedure given in the xdrdiscrim
663 * to handle the discriminant. If there is no specific routine a default
664 * routine may be called.
665 * If there is no specific or default routine an error is returned.
667 bool_t
668 xdr_union(
669 XDR *xdrs,
670 enum_t *dscmp, /* enum to decide which arm to work on */
671 char *unp, /* the union itself */
672 const struct xdr_discrim *choices, /* [value, xdr proc] for each arm */
673 xdrproc_t dfault /* default xdr routine */
676 enum_t dscm;
678 _DIAGASSERT(xdrs != NULL);
679 _DIAGASSERT(dscmp != NULL);
680 _DIAGASSERT(unp != NULL);
681 _DIAGASSERT(choices != NULL);
682 /* dfault may be NULL */
685 * we deal with the discriminator; it's an enum
687 if (! xdr_enum(xdrs, dscmp)) {
688 return (FALSE);
690 dscm = *dscmp;
693 * search choices for a value that matches the discriminator.
694 * if we find one, execute the xdr routine for that value.
696 for (; choices->proc != NULL_xdrproc_t; choices++) {
697 if (choices->value == dscm)
698 return ((*(choices->proc))(xdrs, unp));
702 * no match - execute the default xdr routine if there is one
704 return ((dfault == NULL_xdrproc_t) ? FALSE :
705 (*dfault)(xdrs, unp));
710 * Non-portable xdr primitives.
711 * Care should be taken when moving these routines to new architectures.
716 * XDR null terminated ASCII strings
717 * xdr_string deals with "C strings" - arrays of bytes that are
718 * terminated by a NULL character. The parameter cpp references a
719 * pointer to storage; If the pointer is null, then the necessary
720 * storage is allocated. The last parameter is the max allowed length
721 * of the string as specified by a protocol.
723 bool_t
724 xdr_string(XDR *xdrs, char **cpp, u_int maxsize)
726 char *sp; /* sp is the actual string pointer */
727 u_int size = 0; /* XXX: GCC */
728 u_int nodesize;
729 size_t len;
731 _DIAGASSERT(xdrs != NULL);
732 _DIAGASSERT(cpp != NULL);
734 sp = *cpp;
737 * first deal with the length since xdr strings are counted-strings
739 switch (xdrs->x_op) {
740 case XDR_FREE:
741 if (sp == NULL) {
742 return(TRUE); /* already free */
744 /* FALLTHROUGH */
745 case XDR_ENCODE:
746 len = strlen(sp);
747 _DIAGASSERT(__type_fit(u_int, len));
748 size = (u_int)len;
749 break;
750 case XDR_DECODE:
751 break;
753 if (! xdr_u_int(xdrs, &size)) {
754 return (FALSE);
756 if (size > maxsize) {
757 return (FALSE);
759 nodesize = size + 1;
762 * now deal with the actual bytes
764 switch (xdrs->x_op) {
766 case XDR_DECODE:
767 if (nodesize == 0) {
768 return (TRUE);
770 if (sp == NULL)
771 *cpp = sp = mem_alloc(nodesize);
772 if (sp == NULL) {
773 warn("%s: out of memory", __func__);
774 return (FALSE);
776 sp[size] = 0;
777 /* FALLTHROUGH */
779 case XDR_ENCODE:
780 return (xdr_opaque(xdrs, sp, size));
782 case XDR_FREE:
783 mem_free(sp, nodesize);
784 *cpp = NULL;
785 return (TRUE);
787 /* NOTREACHED */
788 return (FALSE);
792 * Wrapper for xdr_string that can be called directly from
793 * routines like clnt_call
795 bool_t
796 xdr_wrapstring(XDR *xdrs, char **cpp)
799 _DIAGASSERT(xdrs != NULL);
800 _DIAGASSERT(cpp != NULL);
802 return xdr_string(xdrs, cpp, LASTUNSIGNED);
806 * NOTE: xdr_hyper(), xdr_u_hyper(), xdr_longlong_t(), and xdr_u_longlong_t()
807 * are in the "non-portable" section because they require that a `long long'
808 * be a 64-bit type.
810 * --thorpej@NetBSD.org, November 30, 1999
814 * XDR 64-bit integers
816 bool_t
817 xdr_int64_t(XDR *xdrs, int64_t *llp)
819 u_long ul[2];
821 _DIAGASSERT(xdrs != NULL);
822 _DIAGASSERT(llp != NULL);
824 switch (xdrs->x_op) {
825 case XDR_ENCODE:
826 ul[0] = (u_long)(((uint64_t)*llp >> 32) &
827 (uint64_t)0xffffffffULL);
828 ul[1] = (u_long)(((uint64_t)*llp) &
829 (uint64_t)0xffffffffULL);
830 if (XDR_PUTLONG(xdrs, (long *)&ul[0]) == FALSE)
831 return (FALSE);
832 return (XDR_PUTLONG(xdrs, (long *)&ul[1]));
833 case XDR_DECODE:
834 if (XDR_GETLONG(xdrs, (long *)&ul[0]) == FALSE)
835 return (FALSE);
836 if (XDR_GETLONG(xdrs, (long *)&ul[1]) == FALSE)
837 return (FALSE);
838 *llp = (int64_t)
839 (((u_int64_t)ul[0] << 32) | ((u_int64_t)ul[1]));
840 return (TRUE);
841 case XDR_FREE:
842 return (TRUE);
844 /* NOTREACHED */
845 return (FALSE);
850 * XDR unsigned 64-bit integers
852 bool_t
853 xdr_u_int64_t(XDR *xdrs, u_int64_t *ullp)
855 u_long ul[2];
857 _DIAGASSERT(xdrs != NULL);
858 _DIAGASSERT(ullp != NULL);
860 switch (xdrs->x_op) {
861 case XDR_ENCODE:
862 ul[0] = (u_long)(*ullp >> 32) & 0xffffffffUL;
863 ul[1] = (u_long)(*ullp) & 0xffffffffUL;
864 if (XDR_PUTLONG(xdrs, (long *)&ul[0]) == FALSE)
865 return (FALSE);
866 return (XDR_PUTLONG(xdrs, (long *)&ul[1]));
867 case XDR_DECODE:
868 if (XDR_GETLONG(xdrs, (long *)&ul[0]) == FALSE)
869 return (FALSE);
870 if (XDR_GETLONG(xdrs, (long *)&ul[1]) == FALSE)
871 return (FALSE);
872 *ullp = (u_int64_t)
873 (((u_int64_t)ul[0] << 32) | ((u_int64_t)ul[1]));
874 return (TRUE);
875 case XDR_FREE:
876 return (TRUE);
878 /* NOTREACHED */
879 return (FALSE);
884 * XDR hypers
886 bool_t
887 xdr_hyper(XDR *xdrs, longlong_t *llp)
890 _DIAGASSERT(xdrs != NULL);
891 _DIAGASSERT(llp != NULL);
894 * Don't bother open-coding this; it's a fair amount of code. Just
895 * call xdr_int64_t().
897 return (xdr_int64_t(xdrs, (int64_t *)llp));
902 * XDR unsigned hypers
904 bool_t
905 xdr_u_hyper(XDR *xdrs, u_longlong_t *ullp)
908 _DIAGASSERT(xdrs != NULL);
909 _DIAGASSERT(ullp != NULL);
912 * Don't bother open-coding this; it's a fair amount of code. Just
913 * call xdr_u_int64_t().
915 return (xdr_u_int64_t(xdrs, (u_int64_t *)ullp));
920 * XDR longlong_t's
922 bool_t
923 xdr_longlong_t(XDR *xdrs, longlong_t *llp)
926 _DIAGASSERT(xdrs != NULL);
927 _DIAGASSERT(llp != NULL);
930 * Don't bother open-coding this; it's a fair amount of code. Just
931 * call xdr_int64_t().
933 return (xdr_int64_t(xdrs, (int64_t *)llp));
938 * XDR u_longlong_t's
940 bool_t
941 xdr_u_longlong_t(XDR *xdrs, u_longlong_t *ullp)
944 _DIAGASSERT(xdrs != NULL);
945 _DIAGASSERT(ullp != NULL);
948 * Don't bother open-coding this; it's a fair amount of code. Just
949 * call xdr_u_int64_t().
951 return (xdr_u_int64_t(xdrs, (u_int64_t *)ullp));