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.
15 #include "../afs/param.h"
17 #include <afs/param.h>
19 #include <afsconfig.h>
25 #include "../h/types.h"
28 #include <net/net_globals.h>
29 #endif /* AFS_OSF_ENV */
30 #ifdef AFS_LINUX20_ENV
31 #include "../h/socket.h"
33 #include "../rpc/types.h"
41 #endif /* AFS_ALPHA_ENV */
42 #ifdef AFS_LINUX22_ENV
44 #define quad_t __quad_t
45 #define u_quad_t __u_quad_t
48 #include "../rpc/xdr.h"
49 #include "../netinet/in.h"
51 #include "../afs/sysincludes.h"
52 #include "../rpc/types.h"
53 #include "../rpc/xdr.h"
57 #include "../afs/longc_procs.h"
60 #include <sys/types.h>
63 #include <netinet/in.h>
70 * This section should really go in the param.*.h files.
74 * kernel version needs to agree with <rpc/xdr.h>
76 # if defined(AFS_SUN57_ENV)
77 # define AFS_RPC_INLINE_T rpc_inline_t
78 # elif defined(AFS_DUX40_ENV)
79 # define AFS_RPC_INLINE_T int
81 # define AFS_RPC_INLINE_T long
85 * user version needs to agree with "xdr.h", i.e. <rx/xdr.h>
87 # define AFS_RPC_INLINE_T afs_int32
90 #if (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV)
91 static bool_t xdrrx_getint64();
92 static bool_t xdrrx_putint64();
93 #endif /* defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT) || defined(AFS_HPUX_64BIT_ENV) */
94 static bool_t xdrrx_getint32();
95 static bool_t xdrrx_putint32();
96 static bool_t xdrrx_getbytes();
97 static bool_t xdrrx_putbytes();
98 static AFS_RPC_INLINE_T * xdrrx_inline();
102 * Ops vector for stdio type XDR
104 static struct xdr_ops xdrrx_ops = {
105 #if (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV)
108 #endif /* (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV) */
109 #if !(defined(KERNEL) && defined(AFS_SUN57_ENV)) && !defined(AFS_HPUX_64BIT_ENV)
110 xdrrx_getint32, /* deserialize an afs_int32 */
111 xdrrx_putint32, /* serialize an afs_int32 */
113 xdrrx_getbytes, /* deserialize counted bytes */
114 xdrrx_putbytes, /* serialize counted bytes */
115 0, /* get offset in the stream: not supported. */
116 0, /* set offset in the stream: not supported. */
117 xdrrx_inline, /* prime stream for inline macros */
118 0, /* destroy stream */
119 #if defined(KERNEL) && defined(AFS_SUN57_ENV)
121 xdrrx_getint32, /* deserialize an afs_int32 */
122 xdrrx_putint32, /* serialize an afs_int32 */
127 * Initialize an rx xdr handle, for a given rx call. op must be XDR_ENCODE or XDR_DECODE.
128 * Call must have been returned by rx_MakeCall or rx_GetCall. Stream should be a pointer to a local rx_stream structure.
131 xdrrx_create(xdrs, call, op)
133 register struct rx_call *call;
134 register enum xdr_op op;
137 xdrs->x_ops = &xdrrx_ops;
138 xdrs->x_private = (caddr_t) call;
141 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
142 #define STACK_TO_PIN 2*PAGESIZE /* 8K */
143 int rx_pin_failed = 0;
146 #if (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV)
148 xdrrx_getint64(XDR *xdrs, long *lp)
150 register struct rx_call *call = ((struct rx_call *) (xdrs)->x_private);
153 if (rx_Read32(call, &i) == sizeof(i)) {
161 xdrrx_putint64(XDR *xdrs, long *lp)
163 afs_int32 code, i = htonl(*lp);
164 register struct rx_call *call = ((struct rx_call *) (xdrs)->x_private);
166 code = (rx_Write32(call, &i) == sizeof(i));
169 #endif /* (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV) */
172 xdrrx_getint32(xdrs, lp)
174 register afs_int32 *lp;
177 register struct rx_call *call = ((struct rx_call *) (xdrs)->x_private);
178 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
179 char *saddr = (char *)&l;
180 saddr -= STACK_TO_PIN;
182 * Hack of hacks: Aix3.2 only guarantees that the next 2K of stack in pinned. Under
183 * splnet (disables interrupts), which is set throughout rx, we can't swap in stack
184 * pages if we need so we panic. Since sometimes, under splnet, we'll use more than
185 * 2K stack we could try to bring the next few stack pages in here before we call the rx
186 * layer. Of course this doesn't guarantee that those stack pages won't be swapped
187 * out between here and calling splnet. So we now pin (and unpin) them instead to
188 * guarantee that they remain there.
190 if (pin(saddr, STACK_TO_PIN)) {
191 /* XXX There's little we can do by continue XXX */
196 if (rx_Read32(call, &l) == sizeof(l)) {
198 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
199 if (saddr) unpin(saddr, STACK_TO_PIN);
203 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
204 if (saddr) unpin(saddr, STACK_TO_PIN);
210 xdrrx_putint32(xdrs, lp)
212 register afs_int32 *lp;
214 afs_int32 code, l = htonl(*lp);
215 register struct rx_call *call = ((struct rx_call *) (xdrs)->x_private);
216 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
217 char *saddr = (char *)&code;
218 saddr -= STACK_TO_PIN;
220 * Hack of hacks: Aix3.2 only guarantees that the next 2K of stack in pinned. Under
221 * splnet (disables interrupts), which is set throughout rx, we can't swap in stack
222 * pages if we need so we panic. Since sometimes, under splnet, we'll use more than
223 * 2K stack we could try to bring the next few stack pages in here before we call the rx
224 * layer. Of course this doesn't guarantee that those stack pages won't be swapped
225 * out between here and calling splnet. So we now pin (and unpin) them instead to
226 * guarantee that they remain there.
228 if (pin(saddr, STACK_TO_PIN)) {
233 code = (rx_Write32(call, &l) == sizeof(l));
234 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
235 if (saddr) unpin(saddr, STACK_TO_PIN);
241 xdrrx_getbytes(xdrs, addr, len)
243 register caddr_t addr;
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)
268 if (saddr) unpin(saddr, STACK_TO_PIN);
274 xdrrx_putbytes(xdrs, addr, len)
276 register caddr_t addr;
280 register struct rx_call *call = ((struct rx_call *) (xdrs)->x_private);
281 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
282 char *saddr = (char *)&code;
283 saddr -= STACK_TO_PIN;
285 * Hack of hacks: Aix3.2 only guarantees that the next 2K of stack in pinned. Under
286 * splnet (disables interrupts), which is set throughout rx, we can't swap in stack
287 * pages if we need so we panic. Since sometimes, under splnet, we'll use more than
288 * 2K stack we could try to bring the next few stack pages in here before we call the rx
289 * layer. Of course this doesn't guarantee that those stack pages won't be swapped
290 * out between here and calling splnet. So we now pin (and unpin) them instead to
291 * guarantee that they remain there.
293 if (pin(saddr, STACK_TO_PIN)) {
294 /* XXX There's little we can do by continue XXX */
299 code = (rx_Write(call, addr, len) == len);
300 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
301 if (saddr) unpin(saddr, STACK_TO_PIN);
306 #ifdef undef /* not used */
311 /* Not supported. What error code should we return? (It doesn't matter: it will never be called, anyway!) */
316 xdrrx_setpos(xdrs, pos)
325 static AFS_RPC_INLINE_T *
326 xdrrx_inline(xdrs, len)
330 /* I don't know what this routine is supposed to do, but the stdio module returns null, so we will, too */