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
13 #include "../afs/param.h"
15 #include "../afs/sysincludes.h"
16 #include "../afs/afsincludes.h"
17 #include "../rx/xdr.h"
18 #else /* defined(UKERNEL) */
19 #if defined(AFS_ALPHA_ENV) || defined(AFS_LINUX20_ENV)
20 #include "../afs/sysincludes.h"
21 #include "../afs/afsincludes.h"
23 #include "../h/types.h"
24 #include "../rpc/types.h"
25 #include "../rpc/xdr.h"
27 #if !defined(AFS_ALPHA_ENV)
29 #define XDR_GETINT32 XDR_GETLONG
32 #define XDR_PUTINT32 XDR_PUTLONG
35 #ifndef AFS_LINUX22_ENV
36 #include "../rpc/auth.h"
38 #endif /* defined(UKERNEL) */
39 #include "../afsint/afsint.h"
41 # include <afs/param.h>
46 #define MAXBS 2048 /* try to avoid horrible allocs */
47 static afs_int32 bslosers = 0;
50 #define NVALLOC(a) osi_Alloc(a)
51 #define NVFREE(a,b) osi_Free(a,b)
53 #define NVALLOC(a) malloc(a)
54 #define NVFREE(a,b) free(a)
57 /* these things are defined in R (but not RX's) library. For now, we add them
58 only for the kernel system. Later, when R is expunged, we'll remove the ifdef */
63 #if (defined(AFS_AIX_ENV) && !defined(AUTH_DES)) || (!defined(AFS_SUN_ENV)) && !defined(AFS_SGI_ENV) && !defined(AFS_ALPHA_ENV) && !defined(AFS_SUN5_ENV)
65 #if !defined(AFS_HPUX110_ENV) && !defined(AFS_LINUX20_ENV)
67 * XDR chars; from user mode xdr package.
80 return (XDR_PUTINT32(xdrs, &l));
83 if (!XDR_GETINT32(xdrs, &l)) {
94 #endif /* AFS_HPUX110_ENV && AFS_LINUX20_ENV */
96 #endif /* defined(AFS_AIX_ENV) && !defined(AUTH_DES) */
100 * Wrapper for xdr_string that can be called directly from
101 * routines like clnt_call; from user-mode xdr package.
104 #ifndef AFS_HPUX110_ENV
106 xdr_wrapstring(xdrs, cpp)
110 if (xdr_string(xdrs, cpp, 1024)) {
115 #endif /* AFS_HPUX110_ENV */
116 #endif /* AFS_SUN5_ENV */
121 * XDR a fixed length array. Unlike variable-length arrays,
122 * the storage of fixed length arrays is static and unfreeable.
123 * > basep: base of the array
124 * > size: size of the array
125 * > elemsize: size of each element
126 * > xdr_elem: routine to XDR each element
129 xdr_vector(xdrs, basep, nelem, elemsize, xdr_elem)
131 register char *basep;
132 register u_int nelem;
133 register u_int elemsize;
134 register xdrproc_t xdr_elem;
137 register char *elptr;
140 for (i = 0; i < nelem; i++) {
141 if (! (*xdr_elem)(xdrs, elptr, (u_int) (~0))) {
155 if (x->x_op == XDR_FREE) {
156 NVFREE(abbs->SeqBody,abbs->SeqLen);
160 if (x->x_op == XDR_ENCODE) {
161 xdr_afs_int32(x, &abbs->SeqLen);
162 xdr_opaque(x, abbs->SeqBody, abbs->SeqLen);
166 xdr_afs_int32(x, &len);
167 if (len < 0 || len > MAXBS) {bslosers++; return FALSE;}
168 if (!abbs->SeqBody) abbs->SeqBody = (char *) NVALLOC(len);
170 xdr_opaque(x, abbs->SeqBody, len);
178 afs_int32 maxLen, len;
179 if (x->x_op == XDR_FREE) {
180 NVFREE(abbs->SeqBody, abbs->MaxSeqLen);
184 if (x->x_op == XDR_ENCODE) {
185 xdr_afs_int32(x, &abbs->MaxSeqLen);
186 xdr_afs_int32(x, &abbs->SeqLen);
187 xdr_opaque(x, abbs->SeqBody, abbs->SeqLen);
191 xdr_afs_int32(x, &maxLen);
192 xdr_afs_int32(x, &len);
193 if (len < 0 || len > MAXBS || len > maxLen) {bslosers++; return FALSE;}
194 if (!abbs->SeqBody) abbs->SeqBody = (char *) NVALLOC(maxLen);
195 abbs->MaxSeqLen = maxLen;
197 xdr_opaque(x, abbs->SeqBody, len);
202 xdr_AFSAccessList(x, abbs)
205 afs_int32 maxLen, len;
206 if (x->x_op == XDR_FREE) {
207 NVFREE(abbs->SeqBody, abbs->MaxSeqLen);
211 if (x->x_op == XDR_ENCODE) {
212 xdr_afs_int32(x, &abbs->MaxSeqLen);
213 xdr_afs_int32(x, &abbs->SeqLen);
214 xdr_opaque(x, abbs->SeqBody, abbs->SeqLen);
218 xdr_afs_int32(x, &maxLen);
219 xdr_afs_int32(x, &len);
220 if (len < 0 || len > MAXBS || len > maxLen) {bslosers++; return FALSE;}
221 if (!abbs->SeqBody) abbs->SeqBody = (char *) NVALLOC(maxLen);
222 abbs->MaxSeqLen = maxLen;
224 xdr_opaque(x, abbs->SeqBody, len);