4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 * Portions of this source code were derived from Berkeley 4.3 BSD
32 * under license from the Regents of the University of California.
37 * XDR routines for the rpcbinder version 3.
41 #include <rpc/types.h>
43 #include <rpc/rpcb_prot.h>
47 xdr_rpcb(XDR
*xdrs
, RPCB
*objp
)
49 if (!xdr_rpcprog(xdrs
, &objp
->r_prog
))
51 if (!xdr_rpcvers(xdrs
, &objp
->r_vers
))
53 if (!xdr_string(xdrs
, &objp
->r_netid
, ~0))
55 if (!xdr_string(xdrs
, &objp
->r_addr
, ~0))
57 if (!xdr_string(xdrs
, &objp
->r_owner
, ~0))
63 * XDR remote call arguments
64 * written for XDR_ENCODE direction only
67 xdr_rpcb_rmtcallargs(XDR
*xdrs
, struct rpcb_rmtcallargs
*objp
)
69 uint_t lenposition
, argposition
, position
;
71 if (!xdr_rpcprog(xdrs
, &objp
->prog
))
73 if (!xdr_rpcvers(xdrs
, &objp
->vers
))
75 if (!xdr_rpcproc(xdrs
, &objp
->proc
))
78 * All the jugglery for just getting the size of the arguments
80 lenposition
= XDR_GETPOS(xdrs
);
81 if (!xdr_u_int(xdrs
, &(objp
->arglen
)))
83 argposition
= XDR_GETPOS(xdrs
);
84 if (!(*(objp
->xdr_args
))(xdrs
, objp
->args_ptr
))
86 position
= XDR_GETPOS(xdrs
);
87 objp
->arglen
= position
- argposition
;
88 XDR_SETPOS(xdrs
, lenposition
);
89 if (!xdr_u_int(xdrs
, &(objp
->arglen
)))
91 XDR_SETPOS(xdrs
, position
);
96 * XDR remote call results
97 * written for XDR_DECODE direction only
100 xdr_rpcb_rmtcallres(XDR
*xdrs
, struct rpcb_rmtcallres
*objp
)
102 if (!xdr_string(xdrs
, &objp
->addr_ptr
, ~0))
104 if (!xdr_u_int(xdrs
, &objp
->resultslen
))
106 return ((*(objp
->xdr_results
))(xdrs
, objp
->results_ptr
));
110 xdr_netbuf(XDR
*xdrs
, struct netbuf
*objp
)
115 * Save the passed in maxlen value and buf pointer. We might
118 uint_t maxlen_save
= objp
->maxlen
;
119 void *buf_save
= objp
->buf
;
121 if (!xdr_u_int(xdrs
, &objp
->maxlen
))
125 * We need to free maxlen, not len, so do it explicitly now.
127 if (xdrs
->x_op
== XDR_FREE
)
128 return (xdr_bytes(xdrs
, &objp
->buf
, &objp
->maxlen
,
132 * If we're decoding and the caller has already allocated a
133 * buffer restore the maxlen value since the decoded value
134 * doesn't apply to the caller's buffer. xdr_bytes() will
135 * return an error if the buffer isn't big enough.
137 if (xdrs
->x_op
== XDR_DECODE
&& objp
->buf
!= NULL
)
138 objp
->maxlen
= maxlen_save
;
140 res
= xdr_bytes(xdrs
, &objp
->buf
, &objp
->len
, objp
->maxlen
);
143 * If we are decoding and the buffer was allocated in the
144 * xdr_bytes() function we need to set maxlen properly to
145 * follow the netbuf semantics.
147 if (xdrs
->x_op
== XDR_DECODE
&& objp
->buf
!= buf_save
)
148 objp
->maxlen
= objp
->len
;