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>
22 #include "afs/sysincludes.h"
23 #include "afsincludes.h"
25 #else /* defined(UKERNEL) */
26 #if defined(AFS_ALPHA_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
27 #include "afs/sysincludes.h"
28 #include "afsincludes.h"
31 #include "rpc/types.h"
34 #if !defined(AFS_ALPHA_ENV)
36 #define XDR_GETINT32 XDR_GETLONG
39 #define XDR_PUTINT32 XDR_PUTLONG
42 #endif /* defined(UKERNEL) */
50 #define NVALLOC(a) osi_Alloc(a)
51 #define NVFREE(a,b) osi_Free(a,b)
53 #define MAXBS 2048 /* try to avoid horrible allocs */
54 static afs_int32 bslosers = 0;
55 #define NVALLOC(a) malloc(a)
56 #define NVFREE(a,b) free(a)
59 /* these things are defined in R (but not RX's) library. For now, we add them
60 only for the kernel system. Later, when R is expunged, we'll remove the ifdef */
62 #ifndef AFS_USR_DARWIN_ENV
66 #if (defined(AFS_AIX_ENV) && !defined(AUTH_DES)) || (!defined(AFS_SUN_ENV)) && !defined(AFS_SGI_ENV) && !defined(AFS_ALPHA_ENV) && !defined(AFS_SUN5_ENV)
68 #if !defined(AFS_HPUX110_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV)
70 * XDR chars; from user mode xdr package.
73 xdr_char(register XDR * xdrs, char *sp)
81 return (XDR_PUTINT32(xdrs, &l));
84 if (!XDR_GETINT32(xdrs, &l)) {
95 #endif /* AFS_HPUX110_ENV && AFS_LINUX20_ENV */
97 #endif /* defined(AFS_AIX_ENV) && !defined(AUTH_DES) */
101 * Wrapper for xdr_string that can be called directly from
102 * routines like clnt_call; from user-mode xdr package.
105 #ifndef AFS_HPUX110_ENV
107 xdr_wrapstring(XDR * xdrs, char **cpp)
109 if (xdr_string(xdrs, cpp, 1024)) {
114 #endif /* AFS_HPUX110_ENV */
115 #endif /* AFS_SUN5_ENV */
120 * XDR a fixed length array. Unlike variable-length arrays,
121 * the storage of fixed length arrays is static and unfreeable.
122 * > basep: base of the array
123 * > size: size of the array
124 * > elemsize: size of each element
125 * > xdr_elem: routine to XDR each element
128 xdr_vector(register XDR * xdrs, register char *basep, register u_int nelem,
129 register u_int elemsize, register xdrproc_t xdr_elem)
132 register char *elptr;
135 for (i = 0; i < nelem; i++) {
136 if (!(*xdr_elem) (xdrs, elptr, (u_int) (~0))) {
148 xdr_CBS(XDR * x, struct CBS * abbs)
151 if (x->x_op == XDR_FREE) {
152 NVFREE(abbs->SeqBody, abbs->SeqLen);
156 if (x->x_op == XDR_ENCODE) {
157 xdr_afs_int32(x, &abbs->SeqLen);
158 xdr_opaque(x, abbs->SeqBody, abbs->SeqLen);
161 xdr_afs_int32(x, &len);
162 if (len < 0 || len > MAXBS) {
167 abbs->SeqBody = (char *)NVALLOC(len);
169 xdr_opaque(x, abbs->SeqBody, len);
175 xdr_BBS(XDR * x, struct BBS * abbs)
177 afs_int32 maxLen, len;
178 if (x->x_op == XDR_FREE) {
179 NVFREE(abbs->SeqBody, abbs->MaxSeqLen);
183 if (x->x_op == XDR_ENCODE) {
184 xdr_afs_int32(x, &abbs->MaxSeqLen);
185 xdr_afs_int32(x, &abbs->SeqLen);
186 xdr_opaque(x, abbs->SeqBody, abbs->SeqLen);
189 xdr_afs_int32(x, &maxLen);
190 xdr_afs_int32(x, &len);
191 if (len < 0 || len > MAXBS || len > maxLen) {
196 abbs->SeqBody = (char *)NVALLOC(maxLen);
197 abbs->MaxSeqLen = maxLen;
199 xdr_opaque(x, abbs->SeqBody, len);
205 xdr_AFSAccessList(XDR * x, AFSAccessList * abbs)
207 afs_int32 maxLen, len;
208 if (x->x_op == XDR_FREE) {
209 NVFREE(abbs->SeqBody, abbs->MaxSeqLen);
213 if (x->x_op == XDR_ENCODE) {
214 xdr_afs_int32(x, &abbs->MaxSeqLen);
215 xdr_afs_int32(x, &abbs->SeqLen);
216 xdr_opaque(x, abbs->SeqBody, abbs->SeqLen);
219 xdr_afs_int32(x, &maxLen);
220 xdr_afs_int32(x, &len);
221 if (len < 0 || len > MAXBS || len > maxLen) {
226 abbs->SeqBody = (char *)NVALLOC(maxLen);
227 abbs->MaxSeqLen = maxLen;
229 xdr_opaque(x, abbs->SeqBody, len);