1 /*********************************************************************
2 * RPC for the Windows NT Operating System
3 * 1993 by Martin F. Gergeleit
4 * Users may use, copy or modify Sun RPC for the Windows NT Operating
5 * System according to the Sun copyright below.
7 * RPC for the Windows NT Operating System COMES WITH ABSOLUTELY NO
8 * WARRANTY, NOR WILL I BE LIABLE FOR ANY DAMAGES INCURRED FROM THE
9 * USE OF. USE ENTIRELY AT YOUR OWN RISK!!!
10 *********************************************************************/
11 /* @(#)rpc_callmsg.c 2.1 88/07/29 4.0 RPCSRC */
13 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
14 * unrestricted use provided that this legend is included on all tape
15 * media and as a part of the software program in whole or part. Users
16 * may copy or modify Sun RPC without charge, but are not authorized
17 * to license or distribute it to anyone else except as part of a product or
18 * program developed by the user.
20 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
21 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
24 * Sun RPC is provided with no support and without any obligation on the
25 * part of Sun Microsystems, Inc. to assist in its use, correction,
26 * modification or enhancement.
28 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
29 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
30 * OR ANY PART THEREOF.
32 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
33 * or profits or other special, indirect and consequential damages, even if
34 * Sun has been advised of the possibility of such damages.
36 * Sun Microsystems, Inc.
38 * Mountain View, California 94043
40 #if !defined(lint) && defined(SCCSIDS)
41 static char sccsid[] = "@(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro";
47 * Copyright (C) 1984, Sun Microsystems, Inc.
52 #include <sys/param.h>
60 xdr_callmsg(xdrs, cmsg)
62 register struct rpc_msg *cmsg;
65 register struct opaque_auth *oa;
67 if (xdrs->x_op == XDR_ENCODE) {
68 if (cmsg->rm_call.cb_cred.oa_length > MAX_AUTH_BYTES) {
71 if (cmsg->rm_call.cb_verf.oa_length > MAX_AUTH_BYTES) {
74 buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT
75 + RNDUP(cmsg->rm_call.cb_cred.oa_length)
76 + 2 * BYTES_PER_XDR_UNIT
77 + RNDUP(cmsg->rm_call.cb_verf.oa_length));
79 IXDR_PUT_LONG(buf, cmsg->rm_xid);
80 IXDR_PUT_ENUM(buf, cmsg->rm_direction);
81 if (cmsg->rm_direction != CALL) {
84 IXDR_PUT_LONG(buf, cmsg->rm_call.cb_rpcvers);
85 if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) {
88 IXDR_PUT_LONG(buf, cmsg->rm_call.cb_prog);
89 IXDR_PUT_LONG(buf, cmsg->rm_call.cb_vers);
90 IXDR_PUT_LONG(buf, cmsg->rm_call.cb_proc);
91 oa = &cmsg->rm_call.cb_cred;
92 IXDR_PUT_ENUM(buf, oa->oa_flavor);
93 IXDR_PUT_LONG(buf, oa->oa_length);
95 bcopy(oa->oa_base, (caddr_t)buf, oa->oa_length);
96 buf += RNDUP(oa->oa_length) / sizeof (long);
98 oa = &cmsg->rm_call.cb_verf;
99 IXDR_PUT_ENUM(buf, oa->oa_flavor);
100 IXDR_PUT_LONG(buf, oa->oa_length);
102 bcopy(oa->oa_base, (caddr_t)buf, oa->oa_length);
104 buf += RNDUP(oa->oa_length) / sizeof (long);
110 if (xdrs->x_op == XDR_DECODE) {
111 buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT);
113 cmsg->rm_xid = IXDR_GET_LONG(buf);
114 cmsg->rm_direction = IXDR_GET_ENUM(buf, enum msg_type);
115 if (cmsg->rm_direction != CALL) {
118 cmsg->rm_call.cb_rpcvers = IXDR_GET_LONG(buf);
119 if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) {
122 cmsg->rm_call.cb_prog = IXDR_GET_LONG(buf);
123 cmsg->rm_call.cb_vers = IXDR_GET_LONG(buf);
124 cmsg->rm_call.cb_proc = IXDR_GET_LONG(buf);
125 oa = &cmsg->rm_call.cb_cred;
126 oa->oa_flavor = IXDR_GET_ENUM(buf, enum_t);
127 oa->oa_length = IXDR_GET_LONG(buf);
129 if (oa->oa_length > MAX_AUTH_BYTES) {
132 if (oa->oa_base == NULL) {
133 oa->oa_base = (caddr_t)
134 mem_alloc(oa->oa_length);
136 buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length));
138 if (xdr_opaque(xdrs, oa->oa_base,
139 oa->oa_length) == FALSE) {
143 bcopy((caddr_t)buf, oa->oa_base,
146 buf += RNDUP(oa->oa_length) /
151 oa = &cmsg->rm_call.cb_verf;
152 buf = XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT);
154 if (xdr_enum(xdrs, &oa->oa_flavor) == FALSE ||
155 xdr_u_int(xdrs, &oa->oa_length) == FALSE) {
159 oa->oa_flavor = IXDR_GET_ENUM(buf, enum_t);
160 oa->oa_length = IXDR_GET_LONG(buf);
163 if (oa->oa_length > MAX_AUTH_BYTES) {
166 if (oa->oa_base == NULL) {
167 oa->oa_base = (caddr_t)
168 mem_alloc(oa->oa_length);
170 buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length));
172 if (xdr_opaque(xdrs, oa->oa_base,
173 oa->oa_length) == FALSE) {
177 bcopy((caddr_t)buf, oa->oa_base,
180 buf += RNDUP(oa->oa_length) /
189 xdr_u_long(xdrs, &(cmsg->rm_xid)) &&
190 xdr_enum(xdrs, (enum_t *)&(cmsg->rm_direction)) &&
191 (cmsg->rm_direction == CALL) &&
192 xdr_u_long(xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
193 (cmsg->rm_call.cb_rpcvers == RPC_MSG_VERSION) &&
194 xdr_u_long(xdrs, &(cmsg->rm_call.cb_prog)) &&
195 xdr_u_long(xdrs, &(cmsg->rm_call.cb_vers)) &&
196 xdr_u_long(xdrs, &(cmsg->rm_call.cb_proc)) &&
197 xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_cred)) )
198 return (xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_verf)));