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
11 * xdr_rx.c. XDR using RX.
14 #include <afsconfig.h>
16 #include "afs/param.h"
18 #include <afs/param.h>
29 #include <net/net_globals.h>
30 #endif /* AFS_OSF_ENV */
31 #ifdef AFS_LINUX20_ENV
34 #include "rpc/types.h"
42 #endif /* AFS_ALPHA_ENV */
43 #ifdef AFS_LINUX22_ENV
45 #define quad_t __quad_t
46 #define u_quad_t __u_quad_t
50 #include "netinet/in.h"
52 #include "afs/sysincludes.h"
53 #include "rpc/types.h"
58 #include "afs/longc_procs.h"
61 #include <sys/types.h>
64 #include <netinet/in.h>
71 * This section should really go in the param.*.h files.
75 * kernel version needs to agree with <rpc/xdr.h>
77 # if defined(AFS_SUN57_ENV)
78 # define AFS_RPC_INLINE_T rpc_inline_t
79 # elif defined(AFS_DUX40_ENV)
80 # define AFS_RPC_INLINE_T int
82 # define AFS_RPC_INLINE_T long
86 * user version needs to agree with "xdr.h", i.e. <rx/xdr.h>
88 # define AFS_RPC_INLINE_T afs_int32
91 /* Static prototypes */
92 #if (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV)
93 static bool_t xdrrx_getint64(XDR * xdrs, long *lp);
94 static bool_t xdrrx_putint64(XDR * xdrs, long *lp);
95 #endif /* (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV) */
97 static bool_t xdrrx_getint32(XDR * xdrs, afs_int32 * lp);
98 static bool_t xdrrx_putint32(register XDR * xdrs, register afs_int32 * lp);
99 static bool_t xdrrx_getbytes(register XDR * xdrs, register caddr_t addr,
101 static bool_t xdrrx_putbytes(register XDR * xdrs, register caddr_t addr,
103 static AFS_RPC_INLINE_T *xdrrx_inline(register XDR * xdrs,
108 * Ops vector for stdio type XDR
110 static struct xdr_ops xdrrx_ops = {
111 #if defined(KERNEL) && ((defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV))
114 #endif /* defined(KERNEL) && ((defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV)) */
115 #if !(defined(KERNEL) && defined(AFS_SUN57_ENV))
116 xdrrx_getint32, /* deserialize an afs_int32 */
117 xdrrx_putint32, /* serialize an afs_int32 */
119 xdrrx_getbytes, /* deserialize counted bytes */
120 xdrrx_putbytes, /* serialize counted bytes */
121 0, /* get offset in the stream: not supported. */
122 0, /* set offset in the stream: not supported. */
123 xdrrx_inline, /* prime stream for inline macros */
124 0, /* destroy stream */
125 #if defined(KERNEL) && defined(AFS_SUN57_ENV)
127 xdrrx_getint32, /* deserialize an afs_int32 */
128 xdrrx_putint32, /* serialize an afs_int32 */
133 * Initialize an rx xdr handle, for a given rx call. op must be XDR_ENCODE or XDR_DECODE.
134 * Call must have been returned by rx_MakeCall or rx_GetCall. Stream should be a pointer to a local rx_stream structure.
137 xdrrx_create(register XDR * xdrs, register struct rx_call *call,
138 register enum xdr_op op)
141 xdrs->x_ops = &xdrrx_ops;
142 xdrs->x_private = (caddr_t) call;
145 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
146 #define STACK_TO_PIN 2*PAGESIZE /* 8K */
147 int rx_pin_failed = 0;
150 #if (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV)
152 xdrrx_getint64(XDR * xdrs, long *lp)
154 register struct rx_call *call = ((struct rx_call *)(xdrs)->x_private);
157 if (rx_Read32(call, &i) == sizeof(i)) {
165 xdrrx_putint64(XDR * xdrs, long *lp)
167 afs_int32 code, i = htonl(*lp);
168 register struct rx_call *call = ((struct rx_call *)(xdrs)->x_private);
170 code = (rx_Write32(call, &i) == sizeof(i));
173 #endif /* (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV) */
176 xdrrx_getint32(XDR * xdrs, afs_int32 * lp)
179 register struct rx_call *call = ((struct rx_call *)(xdrs)->x_private);
180 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
181 char *saddr = (char *)&l;
182 saddr -= STACK_TO_PIN;
184 * Hack of hacks: Aix3.2 only guarantees that the next 2K of stack in pinned. Under
185 * splnet (disables interrupts), which is set throughout rx, we can't swap in stack
186 * pages if we need so we panic. Since sometimes, under splnet, we'll use more than
187 * 2K stack we could try to bring the next few stack pages in here before we call the rx
188 * layer. Of course this doesn't guarantee that those stack pages won't be swapped
189 * out between here and calling splnet. So we now pin (and unpin) them instead to
190 * guarantee that they remain there.
192 if (pin(saddr, STACK_TO_PIN)) {
193 /* XXX There's little we can do by continue XXX */
198 if (rx_Read32(call, &l) == sizeof(l)) {
200 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
202 unpin(saddr, STACK_TO_PIN);
206 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
208 unpin(saddr, STACK_TO_PIN);
214 xdrrx_putint32(register XDR * xdrs, register afs_int32 * lp)
216 afs_int32 code, l = htonl(*lp);
217 register struct rx_call *call = ((struct rx_call *)(xdrs)->x_private);
218 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
219 char *saddr = (char *)&code;
220 saddr -= STACK_TO_PIN;
222 * Hack of hacks: Aix3.2 only guarantees that the next 2K of stack in pinned. Under
223 * splnet (disables interrupts), which is set throughout rx, we can't swap in stack
224 * pages if we need so we panic. Since sometimes, under splnet, we'll use more than
225 * 2K stack we could try to bring the next few stack pages in here before we call the rx
226 * layer. Of course this doesn't guarantee that those stack pages won't be swapped
227 * out between here and calling splnet. So we now pin (and unpin) them instead to
228 * guarantee that they remain there.
230 if (pin(saddr, STACK_TO_PIN)) {
235 code = (rx_Write32(call, &l) == sizeof(l));
236 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
238 unpin(saddr, STACK_TO_PIN);
244 xdrrx_getbytes(register XDR * xdrs, register caddr_t addr, register u_int len)
247 register struct rx_call *call = ((struct rx_call *)(xdrs)->x_private);
248 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
249 char *saddr = (char *)&code;
250 saddr -= STACK_TO_PIN;
252 * Hack of hacks: Aix3.2 only guarantees that the next 2K of stack in pinned. Under
253 * splnet (disables interrupts), which is set throughout rx, we can't swap in stack
254 * pages if we need so we panic. Since sometimes, under splnet, we'll use more than
255 * 2K stack we could try to bring the next few stack pages in here before we call the rx
256 * layer. Of course this doesn't guarantee that those stack pages won't be swapped
257 * out between here and calling splnet. So we now pin (and unpin) them instead to
258 * guarantee that they remain there.
260 if (pin(saddr, STACK_TO_PIN)) {
261 /* XXX There's little we can do by continue XXX */
266 code = (rx_Read(call, addr, len) == len);
267 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
269 unpin(saddr, STACK_TO_PIN);
275 xdrrx_putbytes(register XDR * xdrs, register caddr_t addr, register u_int len)
278 register struct rx_call *call = ((struct rx_call *)(xdrs)->x_private);
279 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
280 char *saddr = (char *)&code;
281 saddr -= STACK_TO_PIN;
283 * Hack of hacks: Aix3.2 only guarantees that the next 2K of stack in pinned. Under
284 * splnet (disables interrupts), which is set throughout rx, we can't swap in stack
285 * pages if we need so we panic. Since sometimes, under splnet, we'll use more than
286 * 2K stack we could try to bring the next few stack pages in here before we call the rx
287 * layer. Of course this doesn't guarantee that those stack pages won't be swapped
288 * out between here and calling splnet. So we now pin (and unpin) them instead to
289 * guarantee that they remain there.
291 if (pin(saddr, STACK_TO_PIN)) {
292 /* XXX There's little we can do by continue XXX */
297 code = (rx_Write(call, addr, len) == len);
298 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
300 unpin(saddr, STACK_TO_PIN);
305 #ifdef undef /* not used */
307 xdrrx_getpos(register XDR * xdrs)
309 /* Not supported. What error code should we return? (It doesn't matter: it will never be called, anyway!) */
314 xdrrx_setpos(register XDR * xdrs, u_int pos)
321 static AFS_RPC_INLINE_T *
322 xdrrx_inline(register XDR * xdrs, register u_int len)
324 /* I don't know what this routine is supposed to do, but the stdio module returns null, so we will, too */