2 * Copyright (c) 2009, Sun Microsystems, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * - Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.
9 * - Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12 * - Neither the name of Sun Microsystems, Inc. nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
32 * Copyright (C) 1984, Sun Microsystems, Inc.
44 //#include <sys/select.h>
50 xdr_callmsg(xdrs
, cmsg
)
55 struct opaque_auth
*oa
;
60 if (xdrs
->x_op
== XDR_ENCODE
) {
61 if (cmsg
->rm_call
.cb_cred
.oa_length
> MAX_AUTH_BYTES
) {
64 if (cmsg
->rm_call
.cb_verf
.oa_length
> MAX_AUTH_BYTES
) {
67 buf
= XDR_INLINE(xdrs
, 8 * BYTES_PER_XDR_UNIT
68 + RNDUP(cmsg
->rm_call
.cb_cred
.oa_length
)
69 + 2 * BYTES_PER_XDR_UNIT
70 + RNDUP(cmsg
->rm_call
.cb_verf
.oa_length
));
72 IXDR_PUT_INT32(buf
, cmsg
->rm_xid
);
73 IXDR_PUT_ENUM(buf
, cmsg
->rm_direction
);
74 if (cmsg
->rm_direction
!= CALL
) {
77 IXDR_PUT_INT32(buf
, cmsg
->rm_call
.cb_rpcvers
);
78 if (cmsg
->rm_call
.cb_rpcvers
!= RPC_MSG_VERSION
) {
81 IXDR_PUT_INT32(buf
, cmsg
->rm_call
.cb_prog
);
82 IXDR_PUT_INT32(buf
, cmsg
->rm_call
.cb_vers
);
83 IXDR_PUT_INT32(buf
, cmsg
->rm_call
.cb_proc
);
84 oa
= &cmsg
->rm_call
.cb_cred
;
85 IXDR_PUT_ENUM(buf
, oa
->oa_flavor
);
86 IXDR_PUT_INT32(buf
, oa
->oa_length
);
88 memmove(buf
, oa
->oa_base
, oa
->oa_length
);
89 buf
+= RNDUP(oa
->oa_length
) / sizeof (int32_t);
91 oa
= &cmsg
->rm_call
.cb_verf
;
92 IXDR_PUT_ENUM(buf
, oa
->oa_flavor
);
93 IXDR_PUT_INT32(buf
, oa
->oa_length
);
95 memmove(buf
, oa
->oa_base
, oa
->oa_length
);
97 buf += RNDUP(oa->oa_length) / sizeof (int32_t);
103 if (xdrs
->x_op
== XDR_DECODE
) {
104 buf
= XDR_INLINE(xdrs
, 8 * BYTES_PER_XDR_UNIT
);
106 cmsg
->rm_xid
= IXDR_GET_U_INT32(buf
);
107 cmsg
->rm_direction
= IXDR_GET_ENUM(buf
, enum msg_type
);
108 if (cmsg
->rm_direction
!= CALL
) {
111 cmsg
->rm_call
.cb_rpcvers
= IXDR_GET_U_INT32(buf
);
112 if (cmsg
->rm_call
.cb_rpcvers
!= RPC_MSG_VERSION
) {
115 cmsg
->rm_call
.cb_prog
= IXDR_GET_U_INT32(buf
);
116 cmsg
->rm_call
.cb_vers
= IXDR_GET_U_INT32(buf
);
117 cmsg
->rm_call
.cb_proc
= IXDR_GET_U_INT32(buf
);
118 oa
= &cmsg
->rm_call
.cb_cred
;
119 oa
->oa_flavor
= IXDR_GET_ENUM(buf
, enum_t
);
120 oa
->oa_length
= (u_int
)IXDR_GET_U_INT32(buf
);
122 if (oa
->oa_length
> MAX_AUTH_BYTES
) {
125 if (oa
->oa_base
== NULL
) {
126 oa
->oa_base
= (caddr_t
)
127 mem_alloc(oa
->oa_length
);
128 if (oa
->oa_base
== NULL
)
131 buf
= XDR_INLINE(xdrs
, RNDUP(oa
->oa_length
));
133 if (xdr_opaque(xdrs
, oa
->oa_base
,
134 oa
->oa_length
) == FALSE
) {
138 memmove(oa
->oa_base
, buf
,
141 buf += RNDUP(oa->oa_length) /
146 oa
= &cmsg
->rm_call
.cb_verf
;
147 buf
= XDR_INLINE(xdrs
, 2 * BYTES_PER_XDR_UNIT
);
149 if (xdr_enum(xdrs
, &oa
->oa_flavor
) == FALSE
||
150 xdr_u_int(xdrs
, &oa
->oa_length
) == FALSE
) {
154 oa
->oa_flavor
= IXDR_GET_ENUM(buf
, enum_t
);
155 oa
->oa_length
= (u_int
)IXDR_GET_U_INT32(buf
);
158 if (oa
->oa_length
> MAX_AUTH_BYTES
) {
161 if (oa
->oa_base
== NULL
) {
162 oa
->oa_base
= (caddr_t
)
163 mem_alloc(oa
->oa_length
);
164 if (oa
->oa_base
== NULL
)
167 buf
= XDR_INLINE(xdrs
, RNDUP(oa
->oa_length
));
169 if (xdr_opaque(xdrs
, oa
->oa_base
,
170 oa
->oa_length
) == FALSE
) {
174 memmove(oa
->oa_base
, buf
,
177 buf += RNDUP(oa->oa_length) /
186 xdr_u_int32_t(xdrs
, &(cmsg
->rm_xid
)) &&
187 xdr_enum(xdrs
, (enum_t
*)&(cmsg
->rm_direction
)) &&
188 (cmsg
->rm_direction
== CALL
) &&
189 xdr_u_int32_t(xdrs
, &(cmsg
->rm_call
.cb_rpcvers
)) &&
190 (cmsg
->rm_call
.cb_rpcvers
== RPC_MSG_VERSION
) &&
191 xdr_u_int32_t(xdrs
, &(cmsg
->rm_call
.cb_prog
)) &&
192 xdr_u_int32_t(xdrs
, &(cmsg
->rm_call
.cb_vers
)) &&
193 xdr_u_int32_t(xdrs
, &(cmsg
->rm_call
.cb_proc
)) &&
194 xdr_opaque_auth(xdrs
, &(cmsg
->rm_call
.cb_cred
)) )
195 return (xdr_opaque_auth(xdrs
, &(cmsg
->rm_call
.cb_verf
)));