182 lines
4.9 KiB
C
182 lines
4.9 KiB
C
/*
|
|
* COMPONENT_NAME: LIBCRPC
|
|
*
|
|
* FUNCTIONS: xdr_callmsg
|
|
*
|
|
* ORIGINS: 24,27
|
|
*
|
|
* This module contains IBM CONFIDENTIAL code. -- (IBM
|
|
* Confidential Restricted when combined with the aggregated
|
|
* modules for this product)
|
|
* SOURCE MATERIALS
|
|
*
|
|
* (C) COPYRIGHT International Business Machines Corp. 1989,1993
|
|
* All Rights Reserved
|
|
* US Government Users Restricted Rights - Use, duplication or
|
|
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
*/
|
|
static char sccsid[] = "@(#)17 1.1 src/bos/usr/ccs/lib/libc/rpc_callmsg.c, libcrpc, bos411, 9428A410j 10/25/93 20:53:46";
|
|
|
|
/*
|
|
#if defined(LIBC_SCCS) && !defined(lint)
|
|
static char sccsid[] = "@(#)rpc_callmsg.c 1.5 90/07/19 4.1NFSSRC Copyr 1990 Sun Micro";
|
|
#endif
|
|
*
|
|
* Copyright (c) 1988 by Sun Microsystems, Inc.
|
|
* 1.6 88/02/08
|
|
*/
|
|
|
|
|
|
/*
|
|
* rpc_callmsg.c
|
|
*/
|
|
|
|
#ifdef _KERNEL
|
|
#include <sys/param.h>
|
|
#include <rpc/types.h> /* spell 'em out for make depend */
|
|
#include <rpc/xdr.h>
|
|
#include <rpc/auth.h>
|
|
#include <rpc/clnt.h>
|
|
#include <rpc/rpc_msg.h>
|
|
#include <netinet/in.h>
|
|
#else
|
|
#include <sys/param.h>
|
|
#include <rpc/rpc.h>
|
|
#endif
|
|
|
|
/*
|
|
* XDR a call message
|
|
*/
|
|
bool_t
|
|
xdr_callmsg(xdrs, cmsg)
|
|
register XDR *xdrs;
|
|
register struct rpc_msg *cmsg;
|
|
{
|
|
register long *buf;
|
|
register struct opaque_auth *oa;
|
|
|
|
if (xdrs->x_op == XDR_ENCODE) {
|
|
if (cmsg->rm_call.cb_cred.oa_length > MAX_AUTH_BYTES) {
|
|
return (FALSE);
|
|
}
|
|
if (cmsg->rm_call.cb_verf.oa_length > MAX_AUTH_BYTES) {
|
|
return (FALSE);
|
|
}
|
|
buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT
|
|
+ RNDUP(cmsg->rm_call.cb_cred.oa_length)
|
|
+ 2 * BYTES_PER_XDR_UNIT
|
|
+ RNDUP(cmsg->rm_call.cb_verf.oa_length));
|
|
if (buf != NULL) {
|
|
IXDR_PUT_LONG(buf, cmsg->rm_xid);
|
|
IXDR_PUT_ENUM(buf, cmsg->rm_direction);
|
|
if (cmsg->rm_direction != CALL) {
|
|
return (FALSE);
|
|
}
|
|
IXDR_PUT_LONG(buf, cmsg->rm_call.cb_rpcvers);
|
|
if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) {
|
|
return (FALSE);
|
|
}
|
|
IXDR_PUT_LONG(buf, cmsg->rm_call.cb_prog);
|
|
IXDR_PUT_LONG(buf, cmsg->rm_call.cb_vers);
|
|
IXDR_PUT_LONG(buf, cmsg->rm_call.cb_proc);
|
|
oa = &cmsg->rm_call.cb_cred;
|
|
IXDR_PUT_ENUM(buf, oa->oa_flavor);
|
|
IXDR_PUT_LONG(buf, oa->oa_length);
|
|
if (oa->oa_length) {
|
|
bcopy(oa->oa_base, (caddr_t)buf, oa->oa_length);
|
|
buf += RNDUP(oa->oa_length) / sizeof (long);
|
|
}
|
|
oa = &cmsg->rm_call.cb_verf;
|
|
IXDR_PUT_ENUM(buf, oa->oa_flavor);
|
|
IXDR_PUT_LONG(buf, oa->oa_length);
|
|
if (oa->oa_length) {
|
|
bcopy(oa->oa_base, (caddr_t)buf, oa->oa_length);
|
|
}
|
|
return (TRUE);
|
|
}
|
|
}
|
|
if (xdrs->x_op == XDR_DECODE) {
|
|
buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT);
|
|
if (buf != NULL) {
|
|
cmsg->rm_xid = IXDR_GET_LONG(buf);
|
|
cmsg->rm_direction = IXDR_GET_ENUM(buf, enum msg_type);
|
|
if (cmsg->rm_direction != CALL) {
|
|
return (FALSE);
|
|
}
|
|
cmsg->rm_call.cb_rpcvers = IXDR_GET_LONG(buf);
|
|
if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) {
|
|
return (FALSE);
|
|
}
|
|
cmsg->rm_call.cb_prog = IXDR_GET_LONG(buf);
|
|
cmsg->rm_call.cb_vers = IXDR_GET_LONG(buf);
|
|
cmsg->rm_call.cb_proc = IXDR_GET_LONG(buf);
|
|
oa = &cmsg->rm_call.cb_cred;
|
|
oa->oa_flavor = IXDR_GET_ENUM(buf, enum_t);
|
|
oa->oa_length = IXDR_GET_LONG(buf);
|
|
if (oa->oa_length) {
|
|
if (oa->oa_length > MAX_AUTH_BYTES) {
|
|
return (FALSE);
|
|
}
|
|
if (oa->oa_base == NULL) {
|
|
oa->oa_base = (caddr_t)
|
|
mem_alloc(oa->oa_length);
|
|
}
|
|
buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length));
|
|
if (buf == NULL) {
|
|
if (xdr_opaque(xdrs, oa->oa_base,
|
|
oa->oa_length) == FALSE) {
|
|
return (FALSE);
|
|
}
|
|
} else {
|
|
bcopy((caddr_t)buf, oa->oa_base,
|
|
oa->oa_length);
|
|
}
|
|
}
|
|
oa = &cmsg->rm_call.cb_verf;
|
|
buf = XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT);
|
|
if (buf == NULL) {
|
|
if (xdr_enum(xdrs, &oa->oa_flavor) == FALSE ||
|
|
xdr_u_int(xdrs, &oa->oa_length) == FALSE) {
|
|
return (FALSE);
|
|
}
|
|
} else {
|
|
oa->oa_flavor = IXDR_GET_ENUM(buf, enum_t);
|
|
oa->oa_length = IXDR_GET_LONG(buf);
|
|
}
|
|
if (oa->oa_length) {
|
|
if (oa->oa_length > MAX_AUTH_BYTES) {
|
|
return (FALSE);
|
|
}
|
|
if (oa->oa_base == NULL) {
|
|
oa->oa_base = (caddr_t)
|
|
mem_alloc(oa->oa_length);
|
|
}
|
|
buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length));
|
|
if (buf == NULL) {
|
|
if (xdr_opaque(xdrs, oa->oa_base,
|
|
oa->oa_length) == FALSE) {
|
|
return (FALSE);
|
|
}
|
|
} else {
|
|
bcopy((caddr_t)buf, oa->oa_base,
|
|
oa->oa_length);
|
|
}
|
|
}
|
|
return (TRUE);
|
|
}
|
|
}
|
|
if (
|
|
xdr_u_long(xdrs, &(cmsg->rm_xid)) &&
|
|
xdr_enum(xdrs, (enum_t *)&(cmsg->rm_direction)) &&
|
|
(cmsg->rm_direction == CALL) &&
|
|
xdr_u_long(xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
|
|
(cmsg->rm_call.cb_rpcvers == RPC_MSG_VERSION) &&
|
|
xdr_u_long(xdrs, &(cmsg->rm_call.cb_prog)) &&
|
|
xdr_u_long(xdrs, &(cmsg->rm_call.cb_vers)) &&
|
|
xdr_u_long(xdrs, &(cmsg->rm_call.cb_proc)) &&
|
|
xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_cred)) )
|
|
return (xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_verf)));
|
|
return (FALSE);
|
|
}
|
|
|