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 "../h/types.h"
20 #include <net/net_globals.h>
21 #endif /* AFS_OSF_ENV */
22 #ifdef AFS_LINUX20_ENV
23 #include "../h/socket.h"
25 #include "../rpc/types.h"
33 #endif /* AFS_ALPHA_ENV */
34 #ifdef AFS_LINUX22_ENV
36 #define quad_t __quad_t
37 #define u_quad_t __u_quad_t
40 #include "../rpc/xdr.h"
41 #include "../netinet/in.h"
43 #include "../afs/sysincludes.h"
44 #include "../rpc/types.h"
45 #include "../rpc/xdr.h"
49 #include "../afs/longc_procs.h"
52 #include "afs/param.h"
53 #include <sys/types.h>
56 #include <netinet/in.h>
63 * This section should really go in the param.*.h files.
67 * kernel version needs to agree with <rpc/xdr.h>
69 # if defined(AFS_SUN57_ENV)
70 # define AFS_RPC_INLINE_T rpc_inline_t
71 # elif defined(AFS_DUX40_ENV)
72 # define AFS_RPC_INLINE_T int
74 # define AFS_RPC_INLINE_T long
78 * user version needs to agree with "xdr.h", i.e. <rx/xdr.h>
80 # define AFS_RPC_INLINE_T afs_int32
83 #if (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV)
84 static bool_t xdrrx_getint64();
85 static bool_t xdrrx_putint64();
86 #endif /* defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT) || defined(AFS_HPUX_64BIT_ENV) */
87 static bool_t xdrrx_getint32();
88 static bool_t xdrrx_putint32();
89 static bool_t xdrrx_getbytes();
90 static bool_t xdrrx_putbytes();
91 static AFS_RPC_INLINE_T * xdrrx_inline();
95 * Ops vector for stdio type XDR
97 static struct xdr_ops xdrrx_ops = {
98 #if (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV)
101 #endif /* (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV) */
102 #if !(defined(KERNEL) && defined(AFS_SUN57_ENV)) && !defined(AFS_HPUX_64BIT_ENV)
103 xdrrx_getint32, /* deserialize an afs_int32 */
104 xdrrx_putint32, /* serialize an afs_int32 */
106 xdrrx_getbytes, /* deserialize counted bytes */
107 xdrrx_putbytes, /* serialize counted bytes */
108 0, /* get offset in the stream: not supported. */
109 0, /* set offset in the stream: not supported. */
110 xdrrx_inline, /* prime stream for inline macros */
111 0, /* destroy stream */
112 #if defined(KERNEL) && defined(AFS_SUN57_ENV)
114 xdrrx_getint32, /* deserialize an afs_int32 */
115 xdrrx_putint32, /* serialize an afs_int32 */
120 * Initialize an rx xdr handle, for a given rx call. op must be XDR_ENCODE or XDR_DECODE.
121 * Call must have been returned by rx_MakeCall or rx_GetCall. Stream should be a pointer to a local rx_stream structure.
124 xdrrx_create(xdrs, call, op)
126 register struct rx_call *call;
127 register enum xdr_op op;
130 xdrs->x_ops = &xdrrx_ops;
131 xdrs->x_private = (caddr_t) call;
134 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
135 #define STACK_TO_PIN 2*PAGESIZE /* 8K */
136 int rx_pin_failed = 0;
139 #if (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV)
141 xdrrx_getint64(XDR *xdrs, long *lp)
143 register struct rx_call *call = ((struct rx_call *) (xdrs)->x_private);
146 if (rx_Read32(call, &i) == sizeof(i)) {
154 xdrrx_putint64(XDR *xdrs, long *lp)
156 afs_int32 code, i = htonl(*lp);
157 register struct rx_call *call = ((struct rx_call *) (xdrs)->x_private);
159 code = (rx_Write32(call, &i) == sizeof(i));
162 #endif /* (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV) */
165 xdrrx_getint32(xdrs, lp)
167 register afs_int32 *lp;
170 register struct rx_call *call = ((struct rx_call *) (xdrs)->x_private);
171 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
172 char *saddr = (char *)&l;
173 saddr -= STACK_TO_PIN;
175 * Hack of hacks: Aix3.2 only guarantees that the next 2K of stack in pinned. Under
176 * splnet (disables interrupts), which is set throughout rx, we can't swap in stack
177 * pages if we need so we panic. Since sometimes, under splnet, we'll use more than
178 * 2K stack we could try to bring the next few stack pages in here before we call the rx
179 * layer. Of course this doesn't guarantee that those stack pages won't be swapped
180 * out between here and calling splnet. So we now pin (and unpin) them instead to
181 * guarantee that they remain there.
183 if (pin(saddr, STACK_TO_PIN)) {
184 /* XXX There's little we can do by continue XXX */
189 if (rx_Read32(call, &l) == sizeof(l)) {
191 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
192 if (saddr) unpin(saddr, STACK_TO_PIN);
196 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
197 if (saddr) unpin(saddr, STACK_TO_PIN);
203 xdrrx_putint32(xdrs, lp)
205 register afs_int32 *lp;
207 afs_int32 code, l = htonl(*lp);
208 register struct rx_call *call = ((struct rx_call *) (xdrs)->x_private);
209 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
210 char *saddr = (char *)&code;
211 saddr -= STACK_TO_PIN;
213 * Hack of hacks: Aix3.2 only guarantees that the next 2K of stack in pinned. Under
214 * splnet (disables interrupts), which is set throughout rx, we can't swap in stack
215 * pages if we need so we panic. Since sometimes, under splnet, we'll use more than
216 * 2K stack we could try to bring the next few stack pages in here before we call the rx
217 * layer. Of course this doesn't guarantee that those stack pages won't be swapped
218 * out between here and calling splnet. So we now pin (and unpin) them instead to
219 * guarantee that they remain there.
221 if (pin(saddr, STACK_TO_PIN)) {
226 code = (rx_Write32(call, &l) == sizeof(l));
227 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
228 if (saddr) unpin(saddr, STACK_TO_PIN);
234 xdrrx_getbytes(xdrs, addr, len)
236 register caddr_t addr;
240 register struct rx_call *call = ((struct rx_call *) (xdrs)->x_private);
241 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
242 char *saddr = (char *)&code;
243 saddr -= STACK_TO_PIN;
245 * Hack of hacks: Aix3.2 only guarantees that the next 2K of stack in pinned. Under
246 * splnet (disables interrupts), which is set throughout rx, we can't swap in stack
247 * pages if we need so we panic. Since sometimes, under splnet, we'll use more than
248 * 2K stack we could try to bring the next few stack pages in here before we call the rx
249 * layer. Of course this doesn't guarantee that those stack pages won't be swapped
250 * out between here and calling splnet. So we now pin (and unpin) them instead to
251 * guarantee that they remain there.
253 if (pin(saddr, STACK_TO_PIN)) {
254 /* XXX There's little we can do by continue XXX */
259 code = (rx_Read(call, addr, len) == len);
260 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
261 if (saddr) unpin(saddr, STACK_TO_PIN);
267 xdrrx_putbytes(xdrs, addr, len)
269 register caddr_t addr;
273 register struct rx_call *call = ((struct rx_call *) (xdrs)->x_private);
274 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
275 char *saddr = (char *)&code;
276 saddr -= STACK_TO_PIN;
278 * Hack of hacks: Aix3.2 only guarantees that the next 2K of stack in pinned. Under
279 * splnet (disables interrupts), which is set throughout rx, we can't swap in stack
280 * pages if we need so we panic. Since sometimes, under splnet, we'll use more than
281 * 2K stack we could try to bring the next few stack pages in here before we call the rx
282 * layer. Of course this doesn't guarantee that those stack pages won't be swapped
283 * out between here and calling splnet. So we now pin (and unpin) them instead to
284 * guarantee that they remain there.
286 if (pin(saddr, STACK_TO_PIN)) {
287 /* XXX There's little we can do by continue XXX */
292 code = (rx_Write(call, addr, len) == len);
293 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
294 if (saddr) unpin(saddr, STACK_TO_PIN);
303 /* Not supported. What error code should we return? (It doesn't matter: it will never be called, anyway!) */
308 xdrrx_setpos(xdrs, pos)
316 static AFS_RPC_INLINE_T *
317 xdrrx_inline(xdrs, len)
321 /* I don't know what this routine is supposed to do, but the stdio module returns null, so we will, too */