2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
12 #include "../afs/param.h"
14 #include <afs/param.h>
21 #include "../afs/sysincludes.h"
22 #include "../afs/afsincludes.h"
23 #include "../rx/xdr.h"
24 #else /* defined(UKERNEL) */
25 #if defined(AFS_ALPHA_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
26 #include "../afs/sysincludes.h"
27 #include "../afs/afsincludes.h"
29 #include "../h/types.h"
30 #include "../rpc/types.h"
31 #include "../rpc/xdr.h"
33 #if !defined(AFS_ALPHA_ENV)
35 #define XDR_GETINT32 XDR_GETLONG
38 #define XDR_PUTINT32 XDR_PUTLONG
41 #ifndef AFS_LINUX22_ENV
42 #include "../rpc/auth.h"
44 #endif /* defined(UKERNEL) */
45 #include "../afsint/afsint.h"
51 #define MAXBS 2048 /* try to avoid horrible allocs */
52 static afs_int32 bslosers = 0;
55 #define NVALLOC(a) osi_Alloc(a)
56 #define NVFREE(a,b) osi_Free(a,b)
58 #define NVALLOC(a) malloc(a)
59 #define NVFREE(a,b) free(a)
62 /* these things are defined in R (but not RX's) library. For now, we add them
63 only for the kernel system. Later, when R is expunged, we'll remove the ifdef */
65 #ifndef AFS_USR_DARWIN_ENV
69 #if (defined(AFS_AIX_ENV) && !defined(AUTH_DES)) || (!defined(AFS_SUN_ENV)) && !defined(AFS_SGI_ENV) && !defined(AFS_ALPHA_ENV) && !defined(AFS_SUN5_ENV)
71 #if !defined(AFS_HPUX110_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_FBSD_ENV)
73 * XDR chars; from user mode xdr package.
86 return (XDR_PUTINT32(xdrs, &l));
89 if (!XDR_GETINT32(xdrs, &l)) {
100 #endif /* AFS_HPUX110_ENV && AFS_LINUX20_ENV */
102 #endif /* defined(AFS_AIX_ENV) && !defined(AUTH_DES) */
106 * Wrapper for xdr_string that can be called directly from
107 * routines like clnt_call; from user-mode xdr package.
110 #ifndef AFS_HPUX110_ENV
112 xdr_wrapstring(xdrs, cpp)
116 if (xdr_string(xdrs, cpp, 1024)) {
121 #endif /* AFS_HPUX110_ENV */
122 #endif /* AFS_SUN5_ENV */
127 * XDR a fixed length array. Unlike variable-length arrays,
128 * the storage of fixed length arrays is static and unfreeable.
129 * > basep: base of the array
130 * > size: size of the array
131 * > elemsize: size of each element
132 * > xdr_elem: routine to XDR each element
135 xdr_vector(xdrs, basep, nelem, elemsize, xdr_elem)
137 register char *basep;
138 register u_int nelem;
139 register u_int elemsize;
140 register xdrproc_t xdr_elem;
143 register char *elptr;
146 for (i = 0; i < nelem; i++) {
147 if (! (*xdr_elem)(xdrs, elptr, (u_int) (~0))) {
162 if (x->x_op == XDR_FREE) {
163 NVFREE(abbs->SeqBody,abbs->SeqLen);
167 if (x->x_op == XDR_ENCODE) {
168 xdr_afs_int32(x, &abbs->SeqLen);
169 xdr_opaque(x, abbs->SeqBody, abbs->SeqLen);
173 xdr_afs_int32(x, &len);
174 if (len < 0 || len > MAXBS) {bslosers++; return FALSE;}
175 if (!abbs->SeqBody) abbs->SeqBody = (char *) NVALLOC(len);
177 xdr_opaque(x, abbs->SeqBody, len);
185 afs_int32 maxLen, len;
186 if (x->x_op == XDR_FREE) {
187 NVFREE(abbs->SeqBody, abbs->MaxSeqLen);
191 if (x->x_op == XDR_ENCODE) {
192 xdr_afs_int32(x, &abbs->MaxSeqLen);
193 xdr_afs_int32(x, &abbs->SeqLen);
194 xdr_opaque(x, abbs->SeqBody, abbs->SeqLen);
198 xdr_afs_int32(x, &maxLen);
199 xdr_afs_int32(x, &len);
200 if (len < 0 || len > MAXBS || len > maxLen) {bslosers++; return FALSE;}
201 if (!abbs->SeqBody) abbs->SeqBody = (char *) NVALLOC(maxLen);
202 abbs->MaxSeqLen = maxLen;
204 xdr_opaque(x, abbs->SeqBody, len);
209 xdr_AFSAccessList(x, abbs)
212 afs_int32 maxLen, len;
213 if (x->x_op == XDR_FREE) {
214 NVFREE(abbs->SeqBody, abbs->MaxSeqLen);
218 if (x->x_op == XDR_ENCODE) {
219 xdr_afs_int32(x, &abbs->MaxSeqLen);
220 xdr_afs_int32(x, &abbs->SeqLen);
221 xdr_opaque(x, abbs->SeqBody, abbs->SeqLen);
225 xdr_afs_int32(x, &maxLen);
226 xdr_afs_int32(x, &len);
227 if (len < 0 || len > MAXBS || len > maxLen) {bslosers++; return FALSE;}
228 if (!abbs->SeqBody) abbs->SeqBody = (char *) NVALLOC(maxLen);
229 abbs->MaxSeqLen = maxLen;
231 xdr_opaque(x, abbs->SeqBody, len);