]>
git.saurik.com Git - apple/libinfo.git/blob - rpc.subproj/rpc_callmsg.c
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
27 * unrestricted use provided that this legend is included on all tape
28 * media and as a part of the software program in whole or part. Users
29 * may copy or modify Sun RPC without charge, but are not authorized
30 * to license or distribute it to anyone else except as part of a product or
31 * program developed by the user.
33 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
34 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
35 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
37 * Sun RPC is provided with no support and without any obligation on the
38 * part of Sun Microsystems, Inc. to assist in its use, correction,
39 * modification or enhancement.
41 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
42 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
43 * OR ANY PART THEREOF.
45 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
46 * or profits or other special, indirect and consequential damages, even if
47 * Sun has been advised of the possibility of such damages.
49 * Sun Microsystems, Inc.
51 * Mountain View, California 94043
54 #if defined(LIBC_SCCS) && !defined(lint)
55 /*static char *sccsid = "from: @(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro";*/
56 /*static char *sccsid = "from: @(#)rpc_callmsg.c 2.1 88/07/29 4.0 RPCSRC";*/
57 static char *rcsid
= "$Id: rpc_callmsg.c,v 1.4 2003/06/23 17:24:59 majka Exp $";
63 * Copyright (C) 1984, Sun Microsystems, Inc.
69 #include <sys/param.h>
73 extern bool_t
xdr_opaque_auth();
79 xdr_callmsg(xdrs
, cmsg
)
81 register struct rpc_msg
*cmsg
;
84 register struct opaque_auth
*oa
;
86 if (xdrs
->x_op
== XDR_ENCODE
) {
87 if (cmsg
->rm_call
.cb_cred
.oa_length
> MAX_AUTH_BYTES
) {
90 if (cmsg
->rm_call
.cb_verf
.oa_length
> MAX_AUTH_BYTES
) {
93 buf
= (long *)XDR_INLINE(xdrs
, 8 * BYTES_PER_XDR_UNIT
94 + RNDUP(cmsg
->rm_call
.cb_cred
.oa_length
)
95 + 2 * BYTES_PER_XDR_UNIT
96 + RNDUP(cmsg
->rm_call
.cb_verf
.oa_length
));
98 IXDR_PUT_LONG(buf
, cmsg
->rm_xid
);
99 IXDR_PUT_ENUM(buf
, cmsg
->rm_direction
);
100 if (cmsg
->rm_direction
!= CALL
) {
103 IXDR_PUT_LONG(buf
, cmsg
->rm_call
.cb_rpcvers
);
104 if (cmsg
->rm_call
.cb_rpcvers
!= RPC_MSG_VERSION
) {
107 IXDR_PUT_LONG(buf
, cmsg
->rm_call
.cb_prog
);
108 IXDR_PUT_LONG(buf
, cmsg
->rm_call
.cb_vers
);
109 IXDR_PUT_LONG(buf
, cmsg
->rm_call
.cb_proc
);
110 oa
= &cmsg
->rm_call
.cb_cred
;
111 IXDR_PUT_ENUM(buf
, oa
->oa_flavor
);
112 IXDR_PUT_LONG(buf
, oa
->oa_length
);
114 bcopy(oa
->oa_base
, (caddr_t
)buf
, oa
->oa_length
);
115 buf
+= RNDUP(oa
->oa_length
) / sizeof (long);
117 oa
= &cmsg
->rm_call
.cb_verf
;
118 IXDR_PUT_ENUM(buf
, oa
->oa_flavor
);
119 IXDR_PUT_LONG(buf
, oa
->oa_length
);
121 bcopy(oa
->oa_base
, (caddr_t
)buf
, oa
->oa_length
);
123 buf += RNDUP(oa->oa_length) / sizeof (long);
129 if (xdrs
->x_op
== XDR_DECODE
) {
130 buf
= (long *)XDR_INLINE(xdrs
, 8 * BYTES_PER_XDR_UNIT
);
132 cmsg
->rm_xid
= IXDR_GET_LONG(buf
);
133 cmsg
->rm_direction
= IXDR_GET_ENUM(buf
, enum msg_type
);
134 if (cmsg
->rm_direction
!= CALL
) {
137 cmsg
->rm_call
.cb_rpcvers
= IXDR_GET_LONG(buf
);
138 if (cmsg
->rm_call
.cb_rpcvers
!= RPC_MSG_VERSION
) {
141 cmsg
->rm_call
.cb_prog
= IXDR_GET_LONG(buf
);
142 cmsg
->rm_call
.cb_vers
= IXDR_GET_LONG(buf
);
143 cmsg
->rm_call
.cb_proc
= IXDR_GET_LONG(buf
);
144 oa
= &cmsg
->rm_call
.cb_cred
;
145 oa
->oa_flavor
= IXDR_GET_ENUM(buf
, enum_t
);
146 oa
->oa_length
= IXDR_GET_LONG(buf
);
148 if (oa
->oa_length
> MAX_AUTH_BYTES
) {
151 if (oa
->oa_base
== NULL
) {
152 oa
->oa_base
= (caddr_t
)
153 mem_alloc(oa
->oa_length
);
155 buf
= (long *)XDR_INLINE(xdrs
, RNDUP(oa
->oa_length
));
157 if (xdr_opaque(xdrs
, oa
->oa_base
,
158 oa
->oa_length
) == FALSE
) {
162 bcopy((caddr_t
)buf
, oa
->oa_base
,
165 buf += RNDUP(oa->oa_length) /
170 oa
= &cmsg
->rm_call
.cb_verf
;
171 buf
= (long *)XDR_INLINE(xdrs
, 2 * BYTES_PER_XDR_UNIT
);
173 if (xdr_enum(xdrs
, &oa
->oa_flavor
) == FALSE
||
174 xdr_u_int(xdrs
, &oa
->oa_length
) == FALSE
) {
178 oa
->oa_flavor
= IXDR_GET_ENUM(buf
, enum_t
);
179 oa
->oa_length
= IXDR_GET_LONG(buf
);
182 if (oa
->oa_length
> MAX_AUTH_BYTES
) {
185 if (oa
->oa_base
== NULL
) {
186 oa
->oa_base
= (caddr_t
)
187 mem_alloc(oa
->oa_length
);
189 buf
= (long *)XDR_INLINE(xdrs
, RNDUP(oa
->oa_length
));
191 if (xdr_opaque(xdrs
, oa
->oa_base
,
192 oa
->oa_length
) == FALSE
) {
196 bcopy((caddr_t
)buf
, oa
->oa_base
,
199 buf += RNDUP(oa->oa_length) /
208 xdr_u_long(xdrs
, &(cmsg
->rm_xid
)) &&
209 xdr_enum(xdrs
, (enum_t
*)&(cmsg
->rm_direction
)) &&
210 (cmsg
->rm_direction
== CALL
) &&
211 xdr_u_long(xdrs
, &(cmsg
->rm_call
.cb_rpcvers
)) &&
212 (cmsg
->rm_call
.cb_rpcvers
== RPC_MSG_VERSION
) &&
213 xdr_u_long(xdrs
, &(cmsg
->rm_call
.cb_prog
)) &&
214 xdr_u_long(xdrs
, &(cmsg
->rm_call
.cb_vers
)) &&
215 xdr_u_long(xdrs
, &(cmsg
->rm_call
.cb_proc
)) &&
216 xdr_opaque_auth(xdrs
, &(cmsg
->rm_call
.cb_cred
)) )
217 return (xdr_opaque_auth(xdrs
, &(cmsg
->rm_call
.cb_verf
)));