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>
15 #include <afs/param.h>
18 # include "afs/sysincludes.h"
22 # ifdef AFS_LINUX20_ENV
23 # include "h/socket.h"
25 # ifdef AFS_LINUX22_ENV
27 # define quad_t __quad_t
28 # define u_quad_t __u_quad_t
31 # include "netinet/in.h"
32 # endif /* !UKERNEL */
40 /* Static prototypes */
41 static bool_t xdrrx_getint32(XDR *axdrs, afs_int32 * lp);
42 static bool_t xdrrx_putint32(XDR *axdrs, afs_int32 * lp);
43 static bool_t xdrrx_getbytes(XDR *axdrs, caddr_t addr,
45 static bool_t xdrrx_putbytes(XDR *axdrs, caddr_t addr,
47 static afs_int32 *xdrrx_inline(XDR *axdrs, u_int len);
51 * Ops vector for stdio type XDR
53 static struct xdr_ops xdrrx_ops = {
54 #ifndef HAVE_STRUCT_LABEL_SUPPORT
55 /* Windows does not support labeled assigments */
56 xdrrx_getint32, /* deserialize an afs_int32 */
57 xdrrx_putint32, /* serialize an afs_int32 */
58 xdrrx_getbytes, /* deserialize counted bytes */
59 xdrrx_putbytes, /* serialize counted bytes */
60 NULL, /* get offset in the stream: not supported. */
61 NULL, /* set offset in the stream: not supported. */
62 xdrrx_inline, /* prime stream for inline macros */
63 NULL, /* destroy stream */
65 .x_getint32 = xdrrx_getint32, /* deserialize an afs_int32 */
66 .x_putint32 = xdrrx_putint32, /* serialize an afs_int32 */
67 .x_getbytes = xdrrx_getbytes, /* deserialize counted bytes */
68 .x_putbytes = xdrrx_putbytes, /* serialize counted bytes */
69 .x_getpostn = NULL, /* get offset in the stream: not supported. */
70 .x_setpostn = NULL, /* set offset in the stream: not supported. */
71 .x_inline = xdrrx_inline, /* prime stream for inline macros */
72 .x_destroy = NULL, /* destroy stream */
77 * Initialize an rx xdr handle, for a given rx call. op must be XDR_ENCODE or XDR_DECODE.
78 * Call must have been returned by rx_MakeCall or rx_GetCall.
81 xdrrx_create(XDR * xdrs, struct rx_call *call,
85 xdrs->x_ops = &xdrrx_ops;
86 xdrs->x_private = (caddr_t) call;
89 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
90 #define STACK_TO_PIN 2*PAGESIZE /* 8K */
91 int rx_pin_failed = 0;
95 xdrrx_getint32(XDR *axdrs, afs_int32 * lp)
98 XDR * xdrs = (XDR *)axdrs;
99 struct rx_call *call = ((struct rx_call *)(xdrs)->x_private);
100 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
101 char *saddr = (char *)&l;
102 saddr -= STACK_TO_PIN;
104 * Hack of hacks: Aix3.2 only guarantees that the next 2K of stack in pinned. Under
105 * splnet (disables interrupts), which is set throughout rx, we can't swap in stack
106 * pages if we need so we panic. Since sometimes, under splnet, we'll use more than
107 * 2K stack we could try to bring the next few stack pages in here before we call the rx
108 * layer. Of course this doesn't guarantee that those stack pages won't be swapped
109 * out between here and calling splnet. So we now pin (and unpin) them instead to
110 * guarantee that they remain there.
112 if (pin(saddr, STACK_TO_PIN)) {
113 /* XXX There's little we can do by continue XXX */
118 if (rx_Read32(call, &l) == sizeof(l)) {
120 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
122 unpin(saddr, STACK_TO_PIN);
126 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
128 unpin(saddr, STACK_TO_PIN);
134 xdrrx_putint32(XDR *axdrs, afs_int32 * lp)
136 afs_int32 code, l = htonl(*lp);
137 XDR * xdrs = (XDR *)axdrs;
138 struct rx_call *call = ((struct rx_call *)(xdrs)->x_private);
139 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
140 char *saddr = (char *)&code;
141 saddr -= STACK_TO_PIN;
143 * Hack of hacks: Aix3.2 only guarantees that the next 2K of stack in pinned. Under
144 * splnet (disables interrupts), which is set throughout rx, we can't swap in stack
145 * pages if we need so we panic. Since sometimes, under splnet, we'll use more than
146 * 2K stack we could try to bring the next few stack pages in here before we call the rx
147 * layer. Of course this doesn't guarantee that those stack pages won't be swapped
148 * out between here and calling splnet. So we now pin (and unpin) them instead to
149 * guarantee that they remain there.
151 if (pin(saddr, STACK_TO_PIN)) {
156 code = (rx_Write32(call, &l) == sizeof(l));
157 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
159 unpin(saddr, STACK_TO_PIN);
165 xdrrx_getbytes(XDR *axdrs, caddr_t addr, u_int len)
168 XDR * xdrs = (XDR *)axdrs;
169 struct rx_call *call = ((struct rx_call *)(xdrs)->x_private);
170 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
171 char *saddr = (char *)&code;
172 saddr -= STACK_TO_PIN;
174 * Hack of hacks: Aix3.2 only guarantees that the next 2K of stack in pinned. Under
175 * splnet (disables interrupts), which is set throughout rx, we can't swap in stack
176 * pages if we need so we panic. Since sometimes, under splnet, we'll use more than
177 * 2K stack we could try to bring the next few stack pages in here before we call the rx
178 * layer. Of course this doesn't guarantee that those stack pages won't be swapped
179 * out between here and calling splnet. So we now pin (and unpin) them instead to
180 * guarantee that they remain there.
182 if (pin(saddr, STACK_TO_PIN)) {
183 /* XXX There's little we can do by continue XXX */
188 code = (rx_Read(call, addr, len) == len);
189 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
191 unpin(saddr, STACK_TO_PIN);
197 xdrrx_putbytes(XDR *axdrs, caddr_t addr, u_int len)
200 XDR * xdrs = (XDR *)axdrs;
201 struct rx_call *call = ((struct rx_call *)(xdrs)->x_private);
202 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
203 char *saddr = (char *)&code;
204 saddr -= STACK_TO_PIN;
206 * Hack of hacks: Aix3.2 only guarantees that the next 2K of stack in pinned. Under
207 * splnet (disables interrupts), which is set throughout rx, we can't swap in stack
208 * pages if we need so we panic. Since sometimes, under splnet, we'll use more than
209 * 2K stack we could try to bring the next few stack pages in here before we call the rx
210 * layer. Of course this doesn't guarantee that those stack pages won't be swapped
211 * out between here and calling splnet. So we now pin (and unpin) them instead to
212 * guarantee that they remain there.
214 if (pin(saddr, STACK_TO_PIN)) {
215 /* XXX There's little we can do by continue XXX */
220 code = (rx_Write(call, addr, len) == len);
221 #if defined(KERNEL) && defined(AFS_AIX32_ENV)
223 unpin(saddr, STACK_TO_PIN);
228 #ifdef undef /* not used */
230 xdrrx_getpos(XDR * xdrs)
232 /* Not supported. What error code should we return? (It doesn't matter: it will never be called, anyway!) */
237 xdrrx_setpos(XDR * xdrs, u_int pos)
245 xdrrx_inline(XDR *axdrs, u_int len)
247 /* I don't know what this routine is supposed to do, but the stdio module returns null, so we will, too */