14890 unix: dboot should use efi memory map if present
[illumos-gate.git] / usr / src / uts / common / rpc / rpcb_prot.c
blob90a711c19365e4780c0f47bb10fb991447eb3299
1 /*
2 * CDDL HEADER START
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
7 * with the License.
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]
20 * CDDL HEADER END
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.
36 * rpcb_prot.c
37 * XDR routines for the rpcbinder version 3.
40 #include <rpc/rpc.h>
41 #include <rpc/types.h>
42 #include <rpc/xdr.h>
43 #include <rpc/rpcb_prot.h>
46 bool_t
47 xdr_rpcb(XDR *xdrs, RPCB *objp)
49 if (!xdr_rpcprog(xdrs, &objp->r_prog))
50 return (FALSE);
51 if (!xdr_rpcvers(xdrs, &objp->r_vers))
52 return (FALSE);
53 if (!xdr_string(xdrs, &objp->r_netid, ~0))
54 return (FALSE);
55 if (!xdr_string(xdrs, &objp->r_addr, ~0))
56 return (FALSE);
57 if (!xdr_string(xdrs, &objp->r_owner, ~0))
58 return (FALSE);
59 return (TRUE);
63 * XDR remote call arguments
64 * written for XDR_ENCODE direction only
66 bool_t
67 xdr_rpcb_rmtcallargs(XDR *xdrs, struct rpcb_rmtcallargs *objp)
69 uint_t lenposition, argposition, position;
71 if (!xdr_rpcprog(xdrs, &objp->prog))
72 return (FALSE);
73 if (!xdr_rpcvers(xdrs, &objp->vers))
74 return (FALSE);
75 if (!xdr_rpcproc(xdrs, &objp->proc))
76 return (FALSE);
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)))
82 return (FALSE);
83 argposition = XDR_GETPOS(xdrs);
84 if (!(*(objp->xdr_args))(xdrs, objp->args_ptr))
85 return (FALSE);
86 position = XDR_GETPOS(xdrs);
87 objp->arglen = position - argposition;
88 XDR_SETPOS(xdrs, lenposition);
89 if (!xdr_u_int(xdrs, &(objp->arglen)))
90 return (FALSE);
91 XDR_SETPOS(xdrs, position);
92 return (TRUE);
96 * XDR remote call results
97 * written for XDR_DECODE direction only
99 bool_t
100 xdr_rpcb_rmtcallres(XDR *xdrs, struct rpcb_rmtcallres *objp)
102 if (!xdr_string(xdrs, &objp->addr_ptr, ~0))
103 return (FALSE);
104 if (!xdr_u_int(xdrs, &objp->resultslen))
105 return (FALSE);
106 return ((*(objp->xdr_results))(xdrs, objp->results_ptr));
109 bool_t
110 xdr_netbuf(XDR *xdrs, struct netbuf *objp)
112 bool_t res;
115 * Save the passed in maxlen value and buf pointer. We might
116 * need them later.
118 uint_t maxlen_save = objp->maxlen;
119 void *buf_save = objp->buf;
121 if (!xdr_u_int(xdrs, &objp->maxlen))
122 return (FALSE);
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,
129 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;
150 return (res);