summaryrefslogtreecommitdiffstats
path: root/c/src/librpc
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2000-04-29 19:09:48 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2000-04-29 19:09:48 +0000
commitb797468c04288ea990d7e49e9b296d010f12c2c8 (patch)
tree6189996c2166d0ac0a330f645b2d920d6e0ca4f7 /c/src/librpc
parentremoved unused variables. (diff)
downloadrtems-b797468c04288ea990d7e49e9b296d010f12c2c8.tar.bz2
Removed as part of merging RPC/XDR upgrade from Eric Norum.
Diffstat (limited to 'c/src/librpc')
-rw-r--r--c/src/librpc/src/rpc_callmsg.c191
-rw-r--r--c/src/librpc/src/rpc_prot.c271
-rw-r--r--c/src/librpc/src/svc.c259
-rw-r--r--c/src/librpc/src/svc_auth.c124
-rw-r--r--c/src/librpc/src/svc_udp.c476
-rw-r--r--c/src/librpc/src/xdr.c578
-rw-r--r--c/src/librpc/src/xdr_array.c157
-rw-r--r--c/src/librpc/src/xdr_mem.c185
8 files changed, 0 insertions, 2241 deletions
diff --git a/c/src/librpc/src/rpc_callmsg.c b/c/src/librpc/src/rpc_callmsg.c
deleted file mode 100644
index 4f95254e82..0000000000
--- a/c/src/librpc/src/rpc_callmsg.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/* @(#)rpc_callmsg.c 2.1 88/07/29 4.0 RPCSRC */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- */
-#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro";
-#endif
-
-/*
- * rpc_callmsg.c
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- *
- */
-
-#include <string.h> /* bcopy */
-#include <rpc/rpc.h>
-
-bool_t xdr_opaque_auth (register XDR *xdrs, register struct
- opaque_auth *ap);
-/*
- * 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);
- /* no real need....
- buf += RNDUP(oa->oa_length) / sizeof (long);
- */
- }
- 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);
- /* no real need....
- buf += RNDUP(oa->oa_length) /
- sizeof (long);
- */
- }
- }
- 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);
- /* no real need...
- buf += RNDUP(oa->oa_length) /
- sizeof (long);
- */
- }
- }
- 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);
-}
-
diff --git a/c/src/librpc/src/rpc_prot.c b/c/src/librpc/src/rpc_prot.c
deleted file mode 100644
index 8d2fde7116..0000000000
--- a/c/src/librpc/src/rpc_prot.c
+++ /dev/null
@@ -1,271 +0,0 @@
-/* @(#)rpc_prot.c 2.3 88/08/07 4.0 RPCSRC */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- */
-
-/*
- * rpc_prot.c
- */
-
-#include <rpc/rpc.h>
-
-/* * * * * * * * * * * * * * XDR Authentication * * * * * * * * * * * */
-
-struct opaque_auth _null_auth;
-
-/*
- * XDR an opaque authentication struct
- * (see auth.h)
- */
-bool_t
-xdr_opaque_auth(xdrs, ap)
- register XDR *xdrs;
- register struct opaque_auth *ap;
-{
-
- if (xdr_enum(xdrs, &(ap->oa_flavor)))
- return (xdr_bytes(xdrs, &ap->oa_base,
- &ap->oa_length, MAX_AUTH_BYTES));
- return (FALSE);
-}
-
-/*
- * XDR a DES block
- */
-bool_t
-xdr_des_block(xdrs, blkp)
- register XDR *xdrs;
- register des_block *blkp;
-{
- return (xdr_opaque(xdrs, (caddr_t)blkp, sizeof(des_block)));
-}
-
-/* * * * * * * * * * * * * * XDR RPC MESSAGE * * * * * * * * * * * * * * * */
-
-/*
- * XDR the MSG_ACCEPTED part of a reply message union
- */
-bool_t
-xdr_accepted_reply(xdrs, ar)
- register XDR *xdrs;
- register struct accepted_reply *ar;
-{
-
- /* personalized union, rather than calling xdr_union */
- if (! xdr_opaque_auth(xdrs, &(ar->ar_verf)))
- return (FALSE);
- if (! xdr_enum(xdrs, (enum_t *)&(ar->ar_stat)))
- return (FALSE);
- switch (ar->ar_stat) {
-
- case SUCCESS:
- return ((*(ar->ar_results.proc))(xdrs, ar->ar_results.where));
-
- case PROG_MISMATCH:
- if (! xdr_u_long(xdrs, &(ar->ar_vers.low)))
- return (FALSE);
- return (xdr_u_long(xdrs, &(ar->ar_vers.high)));
- default:
- break;
- }
- return (TRUE); /* TRUE => open ended set of problems */
-}
-
-/*
- * XDR the MSG_DENIED part of a reply message union
- */
-bool_t
-xdr_rejected_reply(xdrs, rr)
- register XDR *xdrs;
- register struct rejected_reply *rr;
-{
-
- /* personalized union, rather than calling xdr_union */
- if (! xdr_enum(xdrs, (enum_t *)&(rr->rj_stat)))
- return (FALSE);
- switch (rr->rj_stat) {
-
- case RPC_MISMATCH:
- if (! xdr_u_long(xdrs, &(rr->rj_vers.low)))
- return (FALSE);
- return (xdr_u_long(xdrs, &(rr->rj_vers.high)));
-
- case AUTH_ERROR:
- return (xdr_enum(xdrs, (enum_t *)&(rr->rj_why)));
- }
- return (FALSE);
-}
-
-static struct xdr_discrim reply_dscrm[3] = {
- { (int)MSG_ACCEPTED, xdr_accepted_reply },
- { (int)MSG_DENIED, xdr_rejected_reply },
- { __dontcare__, NULL_xdrproc_t } };
-
-/*
- * XDR a reply message
- */
-bool_t
-xdr_replymsg(xdrs, rmsg)
- register XDR *xdrs;
- register struct rpc_msg *rmsg;
-{
- if (
- xdr_u_long(xdrs, &(rmsg->rm_xid)) &&
- xdr_enum(xdrs, (enum_t *)&(rmsg->rm_direction)) &&
- (rmsg->rm_direction == REPLY) )
- return (xdr_union(xdrs, (enum_t *)&(rmsg->rm_reply.rp_stat),
- (caddr_t)&(rmsg->rm_reply.ru), reply_dscrm, NULL_xdrproc_t));
- return (FALSE);
-}
-
-
-/*
- * Serializes the "static part" of a call message header.
- * The fields include: rm_xid, rm_direction, rpcvers, prog, and vers.
- * The rm_xid is not really static, but the user can easily munge on the fly.
- */
-bool_t
-xdr_callhdr(xdrs, cmsg)
- register XDR *xdrs;
- register struct rpc_msg *cmsg;
-{
-
- cmsg->rm_direction = CALL;
- cmsg->rm_call.cb_rpcvers = RPC_MSG_VERSION;
- if (
- (xdrs->x_op == XDR_ENCODE) &&
- xdr_u_long(xdrs, &(cmsg->rm_xid)) &&
- xdr_enum(xdrs, (enum_t *)&(cmsg->rm_direction)) &&
- xdr_u_long(xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
- xdr_u_long(xdrs, &(cmsg->rm_call.cb_prog)) )
- return (xdr_u_long(xdrs, &(cmsg->rm_call.cb_vers)));
- return (FALSE);
-}
-
-/* ************************** Client utility routine ************* */
-
-static void
-accepted(acpt_stat, error)
- register enum accept_stat acpt_stat;
- register struct rpc_err *error;
-{
-
- switch (acpt_stat) {
-
- case PROG_UNAVAIL:
- error->re_status = RPC_PROGUNAVAIL;
- return;
-
- case PROG_MISMATCH:
- error->re_status = RPC_PROGVERSMISMATCH;
- return;
-
- case PROC_UNAVAIL:
- error->re_status = RPC_PROCUNAVAIL;
- return;
-
- case GARBAGE_ARGS:
- error->re_status = RPC_CANTDECODEARGS;
- return;
-
- case SYSTEM_ERR:
- error->re_status = RPC_SYSTEMERROR;
- return;
-
- case SUCCESS:
- error->re_status = RPC_SUCCESS;
- return;
- }
- /* something's wrong, but we don't know what ... */
- error->re_status = RPC_FAILED;
- error->re_lb.s1 = (long)MSG_ACCEPTED;
- error->re_lb.s2 = (long)acpt_stat;
-}
-
-static void
-rejected(rjct_stat, error)
- register enum reject_stat rjct_stat;
- register struct rpc_err *error;
-{
-
- switch (rjct_stat) {
-
- case RPC_VERSMISMATCH:
- error->re_status = RPC_VERSMISMATCH;
- return;
-
- case AUTH_ERROR:
- error->re_status = RPC_AUTHERROR;
- return;
-
- default:
- break;
- }
- /* something's wrong, but we don't know what ... */
- error->re_status = RPC_FAILED;
- error->re_lb.s1 = (long)MSG_DENIED;
- error->re_lb.s2 = (long)rjct_stat;
-}
-
-/*
- * given a reply message, fills in the error
- */
-void
-_seterr_reply(msg, error)
- register struct rpc_msg *msg;
- register struct rpc_err *error;
-{
-
- /* optimized for normal, SUCCESSful case */
- switch (msg->rm_reply.rp_stat) {
-
- case MSG_ACCEPTED:
- if (msg->acpted_rply.ar_stat == SUCCESS) {
- error->re_status = RPC_SUCCESS;
- return;
- };
- accepted(msg->acpted_rply.ar_stat, error);
- break;
-
- case MSG_DENIED:
- rejected(msg->rjcted_rply.rj_stat, error);
- break;
-
- default:
- error->re_status = RPC_FAILED;
- error->re_lb.s1 = (long)(msg->rm_reply.rp_stat);
- break;
- }
- switch (error->re_status) {
-
- case RPC_VERSMISMATCH:
- error->re_vers.low = msg->rjcted_rply.rj_vers.low;
- error->re_vers.high = msg->rjcted_rply.rj_vers.high;
- break;
-
- case RPC_AUTHERROR:
- error->re_why = msg->rjcted_rply.rj_why;
- break;
-
- case RPC_PROGVERSMISMATCH:
- error->re_vers.low = msg->acpted_rply.ar_vers.low;
- error->re_vers.high = msg->acpted_rply.ar_vers.high;
- break;
-
- default:
- break;
- }
-}
diff --git a/c/src/librpc/src/svc.c b/c/src/librpc/src/svc.c
deleted file mode 100644
index c4ccb46aa5..0000000000
--- a/c/src/librpc/src/svc.c
+++ /dev/null
@@ -1,259 +0,0 @@
-/* @(#)svc.c 2.4 88/08/11 4.0 RPCSRC; from 1.44 88/02/08 SMI */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- */
-#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)svc.c 1.41 87/10/13 Copyr 1984 Sun Micro";
-#endif
-
-/*
- * svc.c, Server-side remote procedure call interface.
- *
- * There are two sets of procedures here. The xprt routines are
- * for handling transport handles. The svc routines handle the
- * list of service routines.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
-#include <rpc/rpc.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#define RQCRED_SIZE 400 /* this size is excessive */
-
-/* ******************* REPLY GENERATION ROUTINES ************ */
-
-/*
- * Send a reply to an rpc request
- */
-bool_t
-svc_sendreply(xprt, xdr_results, xdr_location)
- register SVCXPRT *xprt;
- xdrproc_t xdr_results;
- caddr_t xdr_location;
-{
- struct rpc_msg rply;
-
- rply.rm_direction = REPLY;
- rply.rm_reply.rp_stat = MSG_ACCEPTED;
- rply.acpted_rply.ar_verf = xprt->xp_verf;
- rply.acpted_rply.ar_stat = SUCCESS;
- rply.acpted_rply.ar_results.where = xdr_location;
- rply.acpted_rply.ar_results.proc = xdr_results;
- return (SVC_REPLY(xprt, &rply));
-}
-
-/*
- * No procedure error reply
- */
-void
-svcerr_noproc(xprt)
- register SVCXPRT *xprt;
-{
- struct rpc_msg rply;
-
- rply.rm_direction = REPLY;
- rply.rm_reply.rp_stat = MSG_ACCEPTED;
- rply.acpted_rply.ar_verf = xprt->xp_verf;
- rply.acpted_rply.ar_stat = PROC_UNAVAIL;
- SVC_REPLY(xprt, &rply);
-}
-
-/*
- * Can't decode args error reply
- */
-void
-svcerr_decode(xprt)
- register SVCXPRT *xprt;
-{
- struct rpc_msg rply;
-
- rply.rm_direction = REPLY;
- rply.rm_reply.rp_stat = MSG_ACCEPTED;
- rply.acpted_rply.ar_verf = xprt->xp_verf;
- rply.acpted_rply.ar_stat = GARBAGE_ARGS;
- SVC_REPLY(xprt, &rply);
-}
-
-/*
- * Some system error
- */
-void
-svcerr_systemerr(xprt)
- register SVCXPRT *xprt;
-{
- struct rpc_msg rply;
-
- rply.rm_direction = REPLY;
- rply.rm_reply.rp_stat = MSG_ACCEPTED;
- rply.acpted_rply.ar_verf = xprt->xp_verf;
- rply.acpted_rply.ar_stat = SYSTEM_ERR;
- SVC_REPLY(xprt, &rply);
-}
-
-/*
- * Authentication error reply
- */
-void
-svcerr_auth(xprt, why)
- SVCXPRT *xprt;
- enum auth_stat why;
-{
- struct rpc_msg rply;
-
- rply.rm_direction = REPLY;
- rply.rm_reply.rp_stat = MSG_DENIED;
- rply.rjcted_rply.rj_stat = AUTH_ERROR;
- rply.rjcted_rply.rj_why = why;
- SVC_REPLY(xprt, &rply);
-}
-
-/*
- * Auth too weak error reply
- */
-void
-svcerr_weakauth(xprt)
- SVCXPRT *xprt;
-{
-
- svcerr_auth(xprt, AUTH_TOOWEAK);
-}
-
-/*
- * Program unavailable error reply
- */
-void
-svcerr_noprog(xprt)
- register SVCXPRT *xprt;
-{
- struct rpc_msg rply;
-
- rply.rm_direction = REPLY;
- rply.rm_reply.rp_stat = MSG_ACCEPTED;
- rply.acpted_rply.ar_verf = xprt->xp_verf;
- rply.acpted_rply.ar_stat = PROG_UNAVAIL;
- SVC_REPLY(xprt, &rply);
-}
-
-/*
- * Program version mismatch error reply
- */
-void
-svcerr_progvers(xprt, low_vers, high_vers)
- register SVCXPRT *xprt;
- u_long low_vers;
- u_long high_vers;
-{
- struct rpc_msg rply;
-
- rply.rm_direction = REPLY;
- rply.rm_reply.rp_stat = MSG_ACCEPTED;
- rply.acpted_rply.ar_verf = xprt->xp_verf;
- rply.acpted_rply.ar_stat = PROG_MISMATCH;
- rply.acpted_rply.ar_vers.low = low_vers;
- rply.acpted_rply.ar_vers.high = high_vers;
- SVC_REPLY(xprt, &rply);
-}
-
- void
-svc_processrequest(xprt, prog, vers, dispatch)
- SVCXPRT *xprt;
- u_long prog;
- u_long vers;
- void (*dispatch)();
-{
- struct rpc_msg msg;
- int prog_found = FALSE;
- u_long low_vers = 0; /* dummy init */
- u_long high_vers = 0; /* dummy init */
- struct svc_req r;
- /*static char cred_area[2*MAX_AUTH_BYTES + RQCRED_SIZE];*/
- char *cred_area;
-
- cred_area = (char *)malloc(2*MAX_AUTH_BYTES + RQCRED_SIZE);
- msg.rm_call.cb_cred.oa_base = cred_area;
- msg.rm_call.cb_verf.oa_base = &(cred_area[MAX_AUTH_BYTES]);
- r.rq_clntcred = &(cred_area[2*MAX_AUTH_BYTES]);
-
- if (SVC_RECV(xprt, &msg)) {
-
- /* now find the exported program and call it */
- /* register struct svc_callout *s; */
- enum auth_stat why;
-
- r.rq_xprt = xprt;
- r.rq_prog = msg.rm_call.cb_prog;
- r.rq_vers = msg.rm_call.cb_vers;
- r.rq_proc = msg.rm_call.cb_proc;
- r.rq_cred = msg.rm_call.cb_cred;
-
- /* first authenticate the message */
- if ((why= _authenticate(&r, &msg)) != AUTH_OK) {
- svcerr_auth(xprt, why);
- free(cred_area);
- return;
- }
-
- /* now match message with a registered service*/
- prog_found = FALSE;
- low_vers = 0 - 1;
- high_vers = 0;
- if (prog == r.rq_prog) {
- if (vers == r.rq_vers) {
- (*dispatch)(&r, xprt);
- free(cred_area);
- return;
- } /* found correct version */
- prog_found = TRUE;
- if (vers < low_vers)
- low_vers = vers;
- if (vers > high_vers)
- high_vers = vers;
- } /* found correct program */
- }
- /*
- * if we got here, the program or version
- * is not served ...
- */
- if (prog_found) {
- svcerr_progvers(xprt,
- low_vers, high_vers);
- } else {
- svcerr_noprog(xprt);
- }
-
- free(cred_area);
-
-}
-
-/* stubs for solaris rpcgen */
-/*int _rpcsvccount;
-int _rpcsvcstate;
-int _SERVED;
-*/
diff --git a/c/src/librpc/src/svc_auth.c b/c/src/librpc/src/svc_auth.c
deleted file mode 100644
index e1943ace8f..0000000000
--- a/c/src/librpc/src/svc_auth.c
+++ /dev/null
@@ -1,124 +0,0 @@
-
-#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)svc_auth.c 2.1 88/08/07 4.0 RPCSRC; from 1.19 87/08/11 Copyr 1984 Sun Micro";
-#endif
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- */
-
-/*
- * svc_auth_nodes.c, Server-side rpc authenticator interface,
- * *WITHOUT* DES authentication.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
-#include <rpc/rpc.h>
-
-/*
- * svcauthsw is the bdevsw of server side authentication.
- *
- * Server side authenticators are called from authenticate by
- * using the client auth struct flavor field to index into svcauthsw.
- * The server auth flavors must implement a routine that looks
- * like:
- *
- * enum auth_stat
- * flavorx_auth(rqst, msg)
- * register struct svc_req *rqst;
- * register struct rpc_msg *msg;
- *
- */
-
-enum auth_stat _svcauth_null(); /* no authentication */
-enum auth_stat _svcauth_unix(); /* unix style (uid, gids) */
-enum auth_stat _svcauth_short(); /* short hand unix style */
-
-static struct {
- enum auth_stat (*authenticator)();
-} svcauthsw[] = {
- {
- _svcauth_null, /* AUTH_NULL */
-#ifdef MR
- _svcauth_unix, /* AUTH_UNIX */
- _svcauth_short /* AUTH_SHORT */
-#endif
- }
-};
-
-#ifdef MR
-#define AUTH_MAX 2 /* HIGHEST AUTH NUMBER */
-#else
-#define AUTH_MAX 0 /* HIGHEST AUTH NUMBER */
-#endif
-
-
-/*
- * The call rpc message, msg has been obtained from the wire. The msg contains
- * the raw form of credentials and verifiers. authenticate returns AUTH_OK
- * if the msg is successfully authenticated. If AUTH_OK then the routine also
- * does the following things:
- * set rqst->rq_xprt->verf to the appropriate response verifier;
- * sets rqst->rq_client_cred to the "cooked" form of the credentials.
- *
- * NB: rqst->rq_cxprt->verf must be pre-alloctaed;
- * its length is set appropriately.
- *
- * The caller still owns and is responsible for msg->u.cmb.cred and
- * msg->u.cmb.verf. The authentication system retains ownership of
- * rqst->rq_client_cred, the cooked credentials.
- *
- * There is an assumption that any flavour less than AUTH_NULL is
- * invalid.
- */
-enum auth_stat
-_authenticate(rqst, msg)
- register struct svc_req *rqst;
- struct rpc_msg *msg;
-{
- register int cred_flavor;
-
- rqst->rq_cred = msg->rm_call.cb_cred;
- rqst->rq_xprt->xp_verf.oa_flavor = _null_auth.oa_flavor;
- rqst->rq_xprt->xp_verf.oa_length = 0;
- cred_flavor = rqst->rq_cred.oa_flavor;
- if ((cred_flavor <= AUTH_MAX) && (cred_flavor >= AUTH_NULL)) {
- return ((*(svcauthsw[cred_flavor].authenticator))(rqst, msg));
- }
-
- return (AUTH_REJECTEDCRED);
-}
-
-enum auth_stat
-_svcauth_null(/*rqst, msg*/)
- /*struct svc_req *rqst;
- struct rpc_msg *msg;*/
-{
-
- return (AUTH_OK);
-}
diff --git a/c/src/librpc/src/svc_udp.c b/c/src/librpc/src/svc_udp.c
deleted file mode 100644
index 70e874335b..0000000000
--- a/c/src/librpc/src/svc_udp.c
+++ /dev/null
@@ -1,476 +0,0 @@
-/* @(#)svc_udp.c 2.2 88/07/29 4.0 RPCSRC */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- */
-#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)svc_udp.c 1.24 87/08/11 Copyr 1984 Sun Micro";
-#endif
-
-/*
- * svc_udp.c,
- * Server side for UDP/IP based RPC. (Does some caching in the hopes of
- * achieving execute-at-most-once semantics.)
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
-/*
- * Adapted for rgdb specifi purposes.
- * Modifications are under #ifndef NO_RGDB.
- */
-
-#include <stdio.h> /* printf */
-#include <stdlib.h> /* free */
-#include <string.h> /* bzero, bcmp */
-#include <rpc/rpc.h>
-#include <sys/socket.h>
-
-#define rpc_buffer(xprt) ((xprt)->xp_p1)
-#define MAX(a, b) ((a > b) ? a : b)
-
-static bool_t svcudp_recv();
-static bool_t svcudp_reply();
-static enum xprt_stat svcudp_stat();
-static bool_t svcudp_getargs();
-static bool_t svcudp_freeargs();
-static void svcudp_destroy();
-static int cache_get();
-static void cache_set();
-
-static struct xp_ops svcudp_op = {
- svcudp_recv,
- svcudp_stat,
- svcudp_getargs,
- svcudp_reply,
- svcudp_freeargs,
- svcudp_destroy
-};
-
-extern int errno;
-
-/*
- * kept in xprt->xp_p2
- */
-struct svcudp_data {
- u_int su_iosz; /* byte size of send.recv buffer */
- u_long su_xid; /* transaction id */
- XDR su_xdrs; /* XDR handle */
- char su_verfbody[MAX_AUTH_BYTES]; /* verifier body */
- char * su_cache; /* cached data, NULL if no cache */
-};
-#define su_data(xprt) ((struct svcudp_data *)(xprt->xp_p2))
-
-/*
- * Usage:
- * xprt = svcudp_create(sock);
- *
- * If sock<0 then a socket is created, else sock is used.
- * If the socket, sock is not bound to a port then svcudp_create
- * binds it to an arbitrary port. In any (successful) case,
- * xprt->xp_sock is the registered socket number and xprt->xp_port is the
- * associated port number.
- * Once *xprt is initialized, it is registered as a transporter;
- * see (svc.h, xprt_register).
- * The routines returns NULL if a problem occurred.
- */
-SVCXPRT *
-svcudp_bufcreate(sock, sendsz, recvsz)
- register int sock;
- u_int sendsz, recvsz;
-{
- register SVCXPRT *xprt;
- register struct svcudp_data *su;
- struct sockaddr_in addr;
- int len = sizeof(struct sockaddr_in);
-
- if (sock == RPC_ANYSOCK) {
- (void)printf
- ("svcudp_create: socket should be created and bound\n");
- return ((SVCXPRT *) NULL);
- }
-
- if (getsockname(sock, (struct sockaddr *)&addr, &len) != 0) {
- (void)printf("svcudp_create - cannot getsockname");
- return ((SVCXPRT *)NULL);
- }
-
- xprt = (SVCXPRT *)mem_alloc(sizeof(SVCXPRT));
-
- if (xprt == NULL) {
- (void)printf("svcudp_create: out of memory\n");
- return (NULL);
- }
- su = (struct svcudp_data *)mem_alloc(sizeof(*su));
- if (su == NULL) {
- (void)printf("svcudp_create: out of memory\n");
- return (NULL);
- }
- su->su_iosz = ((MAX(sendsz, recvsz) + 3) / 4) * 4;
- if ((rpc_buffer(xprt) = (caddr_t) mem_alloc(su->su_iosz)) == NULL) {
- (void)printf("svcudp_create: out of memory\n");
- return (NULL);
- }
- xdrmem_create(
- &(su->su_xdrs), rpc_buffer(xprt), su->su_iosz, XDR_DECODE);
- su->su_cache = NULL;
- xprt->xp_p2 = (caddr_t)su;
- xprt->xp_verf.oa_base = su->su_verfbody;
- xprt->xp_ops = &svcudp_op;
- xprt->xp_port = ntohs(addr.sin_port);
- xprt->xp_sock = sock;
- return (xprt);
-}
-
-SVCXPRT *
-svcudp_create(sock)
- int sock;
-{
-
-/* return(svcudp_bufcreate(sock, UDPMSGSIZE, UDPMSGSIZE));*/
- return(svcudp_bufcreate(sock, 1500, 1500));
-}
-
-static enum xprt_stat
-svcudp_stat(xprt)
- SVCXPRT *xprt;
-{
-
- return (XPRT_IDLE);
-}
-
-static bool_t
-svcudp_recv(xprt, msg)
- register SVCXPRT *xprt;
- struct rpc_msg *msg;
-{
- register struct svcudp_data *su = su_data(xprt);
- register XDR *xdrs = &(su->su_xdrs);
- register int rlen;
- char *reply;
- u_long replylen;
-
- again:
- xprt->xp_addrlen = sizeof(struct sockaddr_in);
- rlen = recvfrom(xprt->xp_sock, rpc_buffer(xprt), (int) su->su_iosz,
- 0, (struct sockaddr *)&(xprt->xp_raddr), &(xprt->xp_addrlen));
- if (rlen == -1 /* && errno == EINTR */)
- goto again;
- if (rlen < 4*sizeof(u_long))
- return (FALSE);
- xdrs->x_op = XDR_DECODE;
- XDR_SETPOS(xdrs, 0);
- if (! xdr_callmsg(xdrs, msg))
- return (FALSE);
- su->su_xid = msg->rm_xid;
- if (su->su_cache != NULL) {
- if (cache_get(xprt, msg, &reply, &replylen)) {
- (void) sendto(xprt->xp_sock, reply, (int) replylen, 0,
- (struct sockaddr *) &xprt->xp_raddr, xprt->xp_addrlen);
- return (FALSE);
- }
- }
- return (TRUE);
-}
-
-static bool_t
-svcudp_reply(xprt, msg)
- register SVCXPRT *xprt;
- struct rpc_msg *msg;
-{
- register struct svcudp_data *su = su_data(xprt);
- register XDR *xdrs = &(su->su_xdrs);
- register int slen;
- register bool_t stat = FALSE;
-
- xdrs->x_op = XDR_ENCODE;
- XDR_SETPOS(xdrs, 0);
- msg->rm_xid = su->su_xid;
- if (xdr_replymsg(xdrs, msg)) {
- slen = (int)XDR_GETPOS(xdrs);
- if (sendto(xprt->xp_sock, rpc_buffer(xprt), slen, 0,
- (struct sockaddr *)&(xprt->xp_raddr), xprt->xp_addrlen)
- == slen) {
- stat = TRUE;
- if (su->su_cache && slen >= 0) {
- cache_set(xprt, (u_long) slen);
- }
- }
- }
- return (stat);
-}
-
-static bool_t
-svcudp_getargs(xprt, xdr_args, args_ptr)
- SVCXPRT *xprt;
- xdrproc_t xdr_args;
- caddr_t args_ptr;
-{
-
- return ((*xdr_args)(&(su_data(xprt)->su_xdrs), args_ptr));
-}
-
-static bool_t
-svcudp_freeargs(xprt, xdr_args, args_ptr)
- SVCXPRT *xprt;
- xdrproc_t xdr_args;
- caddr_t args_ptr;
-{
- register XDR *xdrs = &(su_data(xprt)->su_xdrs);
-
- xdrs->x_op = XDR_FREE;
- return ((*xdr_args)(xdrs, args_ptr));
-}
-
-static void
-svcudp_destroy(xprt)
- register SVCXPRT *xprt;
-{
- register struct svcudp_data *su = su_data(xprt);
-/*
- xprt_unregister(xprt);
- (void)close(xprt->xp_sock);
-*/
- XDR_DESTROY(&(su->su_xdrs));
- mem_free(rpc_buffer(xprt), su->su_iosz);
- mem_free((caddr_t)su, sizeof(struct svcudp_data));
- mem_free((caddr_t)xprt, sizeof(SVCXPRT));
-}
-
-
-/***********this could be a separate file*********************/
-
-/*
- * Fifo cache for udp server
- * Copies pointers to reply buffers into fifo cache
- * Buffers are sent again if retransmissions are detected.
- */
-
-#define SPARSENESS 4 /* 75% sparse */
-
-#define CACHE_PERROR(msg) \
- (void) printf("%s\n", msg)
-
-#define ALLOC(type, size) \
- (type *) mem_alloc((unsigned) (sizeof(type) * (size)))
-
-#define BZERO(addr, type, size) \
- bzero((char *) addr, sizeof(type) * (int) (size))
-
-/*
- * An entry in the cache
- */
-typedef struct cache_node *cache_ptr;
-struct cache_node {
- /*
- * Index into cache is xid, proc, vers, prog and address
- */
- u_long cache_xid;
- u_long cache_proc;
- u_long cache_vers;
- u_long cache_prog;
- struct sockaddr_in cache_addr;
- /*
- * The cached reply and length
- */
- char * cache_reply;
- u_long cache_replylen;
- /*
- * Next node on the list, if there is a collision
- */
- cache_ptr cache_next;
-};
-
-
-
-/*
- * The entire cache
- */
-struct udp_cache {
- u_long uc_size; /* size of cache */
- cache_ptr *uc_entries; /* hash table of entries in cache */
- cache_ptr *uc_fifo; /* fifo list of entries in cache */
- u_long uc_nextvictim; /* points to next victim in fifo list */
- u_long uc_prog; /* saved program number */
- u_long uc_vers; /* saved version number */
- u_long uc_proc; /* saved procedure number */
- struct sockaddr_in uc_addr; /* saved caller's address */
-};
-
-
-/*
- * the hashing function
- */
-#define CACHE_LOC(transp, xid) \
- (xid % (SPARSENESS*((struct udp_cache *) su_data(transp)->su_cache)->uc_size))
-
-
-/*
- * Enable use of the cache.
- * Note: there is no disable.
- */
- int
-svcudp_enablecache(transp, size)
- SVCXPRT *transp;
- u_long size;
-{
- struct svcudp_data *su = su_data(transp);
- struct udp_cache *uc;
-
- if (su->su_cache != NULL) {
- CACHE_PERROR("enablecache: cache already enabled");
- return(0);
- }
- uc = ALLOC(struct udp_cache, 1);
- if (uc == NULL) {
- CACHE_PERROR("enablecache: could not allocate cache");
- return(0);
- }
- uc->uc_size = size;
- uc->uc_nextvictim = 0;
- uc->uc_entries = ALLOC(cache_ptr, size * SPARSENESS);
- if (uc->uc_entries == NULL) {
- CACHE_PERROR("enablecache: could not allocate cache data");
- return(0);
- }
- BZERO(uc->uc_entries, cache_ptr, size * SPARSENESS);
- uc->uc_fifo = ALLOC(cache_ptr, size);
- if (uc->uc_fifo == NULL) {
- CACHE_PERROR("enablecache: could not allocate cache fifo");
- return(0);
- }
- BZERO(uc->uc_fifo, cache_ptr, size);
- su->su_cache = (char *) uc;
- return(1);
-}
-
-
-/*
- * Set an entry in the cache
- */
-static void
-cache_set(xprt, replylen)
- SVCXPRT *xprt;
- u_long replylen;
-{
- register cache_ptr victim;
- register cache_ptr *vicp;
- register struct svcudp_data *su = su_data(xprt);
- struct udp_cache *uc = (struct udp_cache *) su->su_cache;
- u_int loc;
- char *newbuf;
-
- /*
- * Find space for the new entry, either by
- * reusing an old entry, or by mallocing a new one
- */
- victim = uc->uc_fifo[uc->uc_nextvictim];
- if (victim != NULL) {
- loc = CACHE_LOC(xprt, victim->cache_xid);
- for (vicp = &uc->uc_entries[loc];
- *vicp != NULL && *vicp != victim;
- vicp = &(*vicp)->cache_next)
- ;
- if (*vicp == NULL) {
- CACHE_PERROR("cache_set: victim not found");
- return;
- }
- *vicp = victim->cache_next; /* remote from cache */
- newbuf = victim->cache_reply;
- } else {
- victim = ALLOC(struct cache_node, 1);
- if (victim == NULL) {
- CACHE_PERROR("cache_set: victim alloc failed");
- return;
- }
- newbuf = (char*) mem_alloc(su->su_iosz);
- if (newbuf == NULL) {
- CACHE_PERROR("cache_set: could not allocate new rpc_buffer");
- return;
- }
- }
-
- /*
- * Store it away
- */
- victim->cache_replylen = replylen;
- victim->cache_reply = rpc_buffer(xprt);
- rpc_buffer(xprt) = newbuf;
- xdrmem_create(&(su->su_xdrs), rpc_buffer(xprt), su->su_iosz, XDR_ENCODE);
- victim->cache_xid = su->su_xid;
- victim->cache_proc = uc->uc_proc;
- victim->cache_vers = uc->uc_vers;
- victim->cache_prog = uc->uc_prog;
- victim->cache_addr = uc->uc_addr;
- loc = CACHE_LOC(xprt, victim->cache_xid);
- victim->cache_next = uc->uc_entries[loc];
- uc->uc_entries[loc] = victim;
- uc->uc_fifo[uc->uc_nextvictim++] = victim;
- uc->uc_nextvictim %= uc->uc_size;
-}
-
-/*
- * Try to get an entry from the cache
- * return 1 if found, 0 if not found
- */
-static int
-cache_get(xprt, msg, replyp, replylenp)
- SVCXPRT *xprt;
- struct rpc_msg *msg;
- char **replyp;
- u_long *replylenp;
-{
- u_int loc;
- register cache_ptr ent;
- register struct svcudp_data *su = su_data(xprt);
- register struct udp_cache *uc = (struct udp_cache *) su->su_cache;
-
-# define EQADDR(a1, a2) (bcmp((char*)&a1, (char*)&a2, sizeof(a1)) == 0)
-
- loc = CACHE_LOC(xprt, su->su_xid);
- for (ent = uc->uc_entries[loc]; ent != NULL; ent = ent->cache_next) {
- if (ent->cache_xid == su->su_xid &&
- ent->cache_proc == uc->uc_proc &&
- ent->cache_vers == uc->uc_vers &&
- ent->cache_prog == uc->uc_prog &&
- EQADDR(ent->cache_addr, uc->uc_addr)) {
- *replyp = ent->cache_reply;
- *replylenp = ent->cache_replylen;
- return(1);
- }
- }
- /*
- * Failed to find entry
- * Remember a few things so we can do a set later
- */
- uc->uc_proc = msg->rm_call.cb_proc;
- uc->uc_vers = msg->rm_call.cb_vers;
- uc->uc_prog = msg->rm_call.cb_prog;
- uc->uc_addr = xprt->xp_raddr;
- return(0);
-}
-
diff --git a/c/src/librpc/src/xdr.c b/c/src/librpc/src/xdr.c
deleted file mode 100644
index cc8caf7785..0000000000
--- a/c/src/librpc/src/xdr.c
+++ /dev/null
@@ -1,578 +0,0 @@
-/* @(#)xdr.c 2.1 88/07/29 4.0 RPCSRC */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- */
-#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)xdr.c 1.35 87/08/12";
-#endif
-
-/*
- * xdr.c, Generic XDR routines implementation.
- *
- * Copyright (C) 1986, Sun Microsystems, Inc.
- *
- * These are the "generic" xdr routines used to serialize and de-serialize
- * most common data items. See xdr.h for more info on the interface to
- * xdr.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-
-/*
- * constants specific to the xdr "protocol"
- */
-#define XDR_FALSE ((long) 0)
-#define XDR_TRUE ((long) 1)
-#define LASTUNSIGNED ((u_int) 0-1)
-
-/*
- * for unit alignment
- */
-static char xdr_zero[BYTES_PER_XDR_UNIT] = { 0, 0, 0, 0 };
-
-/*
- * Free a data structure using XDR
- * Not a filter, but a convenient utility nonetheless
- */
-void
-xdr_free(proc, objp)
- xdrproc_t proc;
- char *objp;
-{
- XDR x;
-
- x.x_op = XDR_FREE;
- (*proc)(&x, objp);
-}
-
-/*
- * XDR nothing
- */
-bool_t
-xdr_void(/* xdrs, addr */)
- /* XDR *xdrs; */
- /* caddr_t addr; */
-{
-
- return (TRUE);
-}
-
-/*
- * XDR integers
- */
-bool_t
-xdr_int(xdrs, ip)
- XDR *xdrs;
- int *ip;
-{
-
-#ifdef lint
- (void) (xdr_short(xdrs, (short *)ip));
- return (xdr_long(xdrs, (long *)ip));
-#else
- if (sizeof (int) == sizeof (long)) {
- return (xdr_long(xdrs, (long *)ip));
- } else {
- return (xdr_short(xdrs, (short *)ip));
- }
-#endif
-}
-
-/*
- * XDR unsigned integers
- */
-bool_t
-xdr_u_int(xdrs, up)
- XDR *xdrs;
- u_int *up;
-{
-
-#ifdef lint
- (void) (xdr_short(xdrs, (short *)up));
- return (xdr_u_long(xdrs, (u_long *)up));
-#else
- if (sizeof (u_int) == sizeof (u_long)) {
- return (xdr_u_long(xdrs, (u_long *)up));
- } else {
- return (xdr_short(xdrs, (short *)up));
- }
-#endif
-}
-
-/*
- * XDR long integers
- * same as xdr_u_long - open coded to save a proc call!
- */
-bool_t
-xdr_long(xdrs, lp)
- register XDR *xdrs;
- long *lp;
-{
-
- if (xdrs->x_op == XDR_ENCODE)
- return (XDR_PUTLONG(xdrs, lp));
-
- if (xdrs->x_op == XDR_DECODE)
- return (XDR_GETLONG(xdrs, lp));
-
- if (xdrs->x_op == XDR_FREE)
- return (TRUE);
-
- return (FALSE);
-}
-
-/*
- * XDR unsigned long integers
- * same as xdr_long - open coded to save a proc call!
- */
-bool_t
-xdr_u_long(xdrs, ulp)
- register XDR *xdrs;
- u_long *ulp;
-{
-
- if (xdrs->x_op == XDR_DECODE)
- return (XDR_GETLONG(xdrs, (long *)ulp));
- if (xdrs->x_op == XDR_ENCODE)
- return (XDR_PUTLONG(xdrs, (long *)ulp));
- if (xdrs->x_op == XDR_FREE)
- return (TRUE);
- return (FALSE);
-}
-
-/*
- * XDR short integers
- */
-bool_t
-xdr_short(xdrs, sp)
- register XDR *xdrs;
- short *sp;
-{
- long l;
-
- switch (xdrs->x_op) {
-
- case XDR_ENCODE:
- l = (long) *sp;
- return (XDR_PUTLONG(xdrs, &l));
-
- case XDR_DECODE:
- if (!XDR_GETLONG(xdrs, &l)) {
- return (FALSE);
- }
- *sp = (short) l;
- return (TRUE);
-
- case XDR_FREE:
- return (TRUE);
- }
- return (FALSE);
-}
-
-/*
- * XDR unsigned short integers
- */
-bool_t
-xdr_u_short(xdrs, usp)
- register XDR *xdrs;
- u_short *usp;
-{
- u_long l;
-
- switch (xdrs->x_op) {
-
- case XDR_ENCODE:
- l = (u_long) *usp;
- return (XDR_PUTLONG(xdrs, &l));
-
- case XDR_DECODE:
- if (!XDR_GETLONG(xdrs, &l)) {
- return (FALSE);
- }
- *usp = (u_short) l;
- return (TRUE);
-
- case XDR_FREE:
- return (TRUE);
- }
- return (FALSE);
-}
-
-
-/*
- * XDR a char
- */
-bool_t
-xdr_char(xdrs, cp)
- XDR *xdrs;
- char *cp;
-{
- int i;
-
- i = (*cp);
- if (!xdr_int(xdrs, &i)) {
- return (FALSE);
- }
- *cp = i;
- return (TRUE);
-}
-
-/*
- * XDR an unsigned char
- */
-bool_t
-xdr_u_char(xdrs, cp)
- XDR *xdrs;
- char *cp;
-{
- u_int u;
-
- u = (*cp);
- if (!xdr_u_int(xdrs, &u)) {
- return (FALSE);
- }
- *cp = u;
- return (TRUE);
-}
-
-/*
- * XDR booleans
- */
-bool_t
-xdr_bool(xdrs, bp)
- register XDR *xdrs;
- bool_t *bp;
-{
- long lb;
-
- switch (xdrs->x_op) {
-
- case XDR_ENCODE:
- lb = *bp ? XDR_TRUE : XDR_FALSE;
- return (XDR_PUTLONG(xdrs, &lb));
-
- case XDR_DECODE:
- if (!XDR_GETLONG(xdrs, &lb)) {
- return (FALSE);
- }
- *bp = (lb == XDR_FALSE) ? FALSE : TRUE;
- return (TRUE);
-
- case XDR_FREE:
- return (TRUE);
- }
- return (FALSE);
-}
-
-/*
- * XDR enumerations
- */
-bool_t
-xdr_enum(xdrs, ep)
- XDR *xdrs;
- enum_t *ep;
-{
-#ifndef lint
- enum sizecheck { SIZEVAL }; /* used to find the size of an enum */
-
- /*
- * enums are treated as ints
- */
- if (sizeof (enum sizecheck) == sizeof (long)) {
- return (xdr_long(xdrs, (long *)ep));
- } else if (sizeof (enum sizecheck) == sizeof (short)) {
- return (xdr_short(xdrs, (short *)ep));
- } else {
- return (FALSE);
- }
-#else
- (void) (xdr_short(xdrs, (short *)ep));
- return (xdr_long(xdrs, (long *)ep));
-#endif
-}
-
-/*
- * XDR opaque data
- * Allows the specification of a fixed size sequence of opaque bytes.
- * cp points to the opaque object and cnt gives the byte length.
- */
-bool_t
-xdr_opaque(xdrs, cp, cnt)
- register XDR *xdrs;
- caddr_t cp;
- register u_int cnt;
-{
- register u_int rndup;
- static int crud[BYTES_PER_XDR_UNIT];
-
- /*
- * if no data we are done
- */
- if (cnt == 0)
- return (TRUE);
-
- /*
- * round byte count to full xdr units
- */
- rndup = cnt % BYTES_PER_XDR_UNIT;
- if (rndup > 0)
- rndup = BYTES_PER_XDR_UNIT - rndup;
-
- if (xdrs->x_op == XDR_DECODE) {
- if (!XDR_GETBYTES(xdrs, cp, cnt)) {
- return (FALSE);
- }
- if (rndup == 0)
- return (TRUE);
- return (XDR_GETBYTES(xdrs, crud, rndup));
- }
-
- if (xdrs->x_op == XDR_ENCODE) {
- if (!XDR_PUTBYTES(xdrs, cp, cnt)) {
- return (FALSE);
- }
- if (rndup == 0)
- return (TRUE);
- return (XDR_PUTBYTES(xdrs, xdr_zero, rndup));
- }
-
- if (xdrs->x_op == XDR_FREE) {
- return (TRUE);
- }
-
- return (FALSE);
-}
-
-/*
- * XDR counted bytes
- * *cpp is a pointer to the bytes, *sizep is the count.
- * If *cpp is NULL maxsize bytes are allocated
- */
-bool_t
-xdr_bytes(xdrs, cpp, sizep, maxsize)
- register XDR *xdrs;
- char **cpp;
- register u_int *sizep;
- u_int maxsize;
-{
- register char *sp = *cpp; /* sp is the actual string pointer */
- register u_int nodesize;
-
- /*
- * first deal with the length since xdr bytes are counted
- */
- if (! xdr_u_int(xdrs, sizep)) {
- return (FALSE);
- }
- nodesize = *sizep;
- if ((nodesize > maxsize) && (xdrs->x_op != XDR_FREE)) {
- return (FALSE);
- }
-
- /*
- * now deal with the actual bytes
- */
- switch (xdrs->x_op) {
-
- case XDR_DECODE:
- if (nodesize == 0) {
- return (TRUE);
- }
- if (sp == NULL) {
- *cpp = sp = (char *)mem_alloc(nodesize);
- }
- if (sp == NULL) {
- (void) printf("xdr_bytes: out of memory\n");
- return (FALSE);
- }
- /* fall into ... */
-
- case XDR_ENCODE:
- return (xdr_opaque(xdrs, sp, nodesize));
-
- case XDR_FREE:
- if (sp != NULL) {
- mem_free(sp, nodesize);
- *cpp = NULL;
- }
- return (TRUE);
- }
- return (FALSE);
-}
-
-/*
- * Implemented here due to commonality of the object.
- */
-bool_t
-xdr_netobj(xdrs, np)
- XDR *xdrs;
- struct netobj *np;
-{
-
- return (xdr_bytes(xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ));
-}
-
-/*
- * XDR a descriminated union
- * Support routine for discriminated unions.
- * You create an array of xdrdiscrim structures, terminated with
- * an entry with a null procedure pointer. The routine gets
- * the discriminant value and then searches the array of xdrdiscrims
- * looking for that value. It calls the procedure given in the xdrdiscrim
- * to handle the discriminant. If there is no specific routine a default
- * routine may be called.
- * If there is no specific or default routine an error is returned.
- */
-bool_t
-xdr_union(xdrs, dscmp, unp, choices, dfault)
- register XDR *xdrs;
- enum_t *dscmp; /* enum to decide which arm to work on */
- char *unp; /* the union itself */
- struct xdr_discrim *choices; /* [value, xdr proc] for each arm */
- xdrproc_t dfault; /* default xdr routine */
-{
- register enum_t dscm;
-
- /*
- * we deal with the discriminator; it's an enum
- */
- if (! xdr_enum(xdrs, dscmp)) {
- return (FALSE);
- }
- dscm = *dscmp;
-
- /*
- * search choices for a value that matches the discriminator.
- * if we find one, execute the xdr routine for that value.
- */
- for (; choices->proc != NULL_xdrproc_t; choices++) {
- if (choices->value == dscm)
- return ((*(choices->proc))(xdrs, unp, LASTUNSIGNED));
- }
-
- /*
- * no match - execute the default xdr routine if there is one
- */
- return ((dfault == NULL_xdrproc_t) ? FALSE :
- (*dfault)(xdrs, unp, LASTUNSIGNED));
-}
-
-
-/*
- * Non-portable xdr primitives.
- * Care should be taken when moving these routines to new architectures.
- */
-
-
-/*
- * XDR null terminated ASCII strings
- * xdr_string deals with "C strings" - arrays of bytes that are
- * terminated by a NULL character. The parameter cpp references a
- * pointer to storage; If the pointer is null, then the necessary
- * storage is allocated. The last parameter is the max allowed length
- * of the string as specified by a protocol.
- */
-bool_t
-xdr_string(xdrs, cpp, maxsize)
- register XDR *xdrs;
- char **cpp;
- u_int maxsize;
-{
- register char *sp = *cpp; /* sp is the actual string pointer */
- u_int size;
- u_int nodesize;
-
- /*
- * first deal with the length since xdr strings are counted-strings
- */
- switch (xdrs->x_op) {
- case XDR_FREE:
- if (sp == NULL) {
- return(TRUE); /* already free */
- }
- /* fall through... */
- case XDR_ENCODE:
- size = strlen(sp);
- break;
- default:
- break;
- }
- if (! xdr_u_int(xdrs, &size)) {
- return (FALSE);
- }
- if (size > maxsize) {
- return (FALSE);
- }
- nodesize = size + 1;
-
- /*
- * now deal with the actual bytes
- */
- switch (xdrs->x_op) {
-
- case XDR_DECODE:
- if (nodesize == 0) {
- return (TRUE);
- }
- if (sp == NULL)
- *cpp = sp = (char *)mem_alloc(nodesize);
- if (sp == NULL) {
- (void) printf("xdr_string: out of memory\n");
- return (FALSE);
- }
- sp[size] = 0;
- /* fall into ... */
-
- case XDR_ENCODE:
- return (xdr_opaque(xdrs, sp, size));
-
- case XDR_FREE:
- mem_free(sp, nodesize);
- *cpp = NULL;
- return (TRUE);
- }
- return (FALSE);
-}
-
-/*
- * Wrapper for xdr_string that can be called directly from
- * routines like clnt_call
- */
-bool_t
-xdr_wrapstring(xdrs, cpp)
- XDR *xdrs;
- char **cpp;
-{
- if (xdr_string(xdrs, cpp, LASTUNSIGNED)) {
- return (TRUE);
- }
- return (FALSE);
-}
diff --git a/c/src/librpc/src/xdr_array.c b/c/src/librpc/src/xdr_array.c
deleted file mode 100644
index b3cd21f2f4..0000000000
--- a/c/src/librpc/src/xdr_array.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/* @(#)xdr_array.c 2.1 88/07/29 4.0 RPCSRC */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- */
-#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro";
-#endif
-
-/*
- * xdr_array.c, Generic XDR routines impelmentation.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- *
- * These are the "non-trivial" xdr primitives used to serialize and de-serialize
- * arrays. See xdr.h for more info on the interface to xdr.
- */
-
-
-#include <stdio.h> /* printf */
-#include <string.h> /* bcmp */
-#include <stdlib.h> /* free */
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-
-#define LASTUNSIGNED ((u_int)0-1)
-
-
-/*
- * XDR an array of arbitrary elements
- * *addrp is a pointer to the array, *sizep is the number of elements.
- * If addrp is NULL (*sizep * elsize) bytes are allocated.
- * elsize is the size (in bytes) of each element, and elproc is the
- * xdr procedure to call to handle each element of the array.
- */
-bool_t
-xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc)
- register XDR *xdrs;
- caddr_t *addrp; /* array pointer */
- u_int *sizep; /* number of elements */
- u_int maxsize; /* max numberof elements */
- u_int elsize; /* size in bytes of each element */
- xdrproc_t elproc; /* xdr routine to handle each element */
-{
- register u_int i;
- register caddr_t target = *addrp;
- register u_int c; /* the actual element count */
- register bool_t stat = TRUE;
- register u_int nodesize;
-
- /* like strings, arrays are really counted arrays */
- if (! xdr_u_int(xdrs, sizep)) {
- return (FALSE);
- }
- c = *sizep;
- if ((c > maxsize) && (xdrs->x_op != XDR_FREE)) {
- return (FALSE);
- }
- nodesize = c * elsize;
-
- /*
- * if we are deserializing, we may need to allocate an array.
- * We also save time by checking for a null array if we are freeing.
- */
- if (target == NULL)
- switch (xdrs->x_op) {
- case XDR_DECODE:
- if (c == 0)
- return (TRUE);
- *addrp = target = mem_alloc(nodesize);
- if (target == NULL) {
- (void) printf(
- "xdr_array: out of memory\n");
- return (FALSE);
- }
- bzero(target, nodesize);
- break;
-
- case XDR_FREE:
- return (TRUE);
- default:
- break;
- }
-
- /*
- * now we xdr each element of array
- */
- for (i = 0; (i < c) && stat; i++) {
- stat = (*elproc)(xdrs, target, LASTUNSIGNED);
- target += elsize;
- }
-
- /*
- * the array may need freeing
- */
- if (xdrs->x_op == XDR_FREE) {
- mem_free(*addrp, nodesize);
- *addrp = NULL;
- }
- return (stat);
-}
-
-/*
- * xdr_vector():
- *
- * XDR a fixed length array. Unlike variable-length arrays,
- * the storage of fixed length arrays is static and unfreeable.
- * > basep: base of the array
- * > size: size of the array
- * > elemsize: size of each element
- * > xdr_elem: routine to XDR each element
- */
-bool_t
-xdr_vector(xdrs, basep, nelem, elemsize, xdr_elem)
- register XDR *xdrs;
- register char *basep;
- register u_int nelem;
- register u_int elemsize;
- register xdrproc_t xdr_elem;
-{
- register u_int i;
- register char *elptr;
-
- elptr = basep;
- for (i = 0; i < nelem; i++) {
- if (! (*xdr_elem)(xdrs, elptr, LASTUNSIGNED)) {
- return(FALSE);
- }
- elptr += elemsize;
- }
- return(TRUE);
-}
-
diff --git a/c/src/librpc/src/xdr_mem.c b/c/src/librpc/src/xdr_mem.c
deleted file mode 100644
index 280451a349..0000000000
--- a/c/src/librpc/src/xdr_mem.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/* @(#)xdr_mem.c 2.1 88/07/29 4.0 RPCSRC */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- */
-#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)xdr_mem.c 1.19 87/08/11 Copyr 1984 Sun Micro";
-#endif
-
-/*
- * xdr_mem.h, XDR implementation using memory buffers.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- *
- * If you have some data to be interpreted as external data representation
- * or to be converted to external data representation in a memory buffer,
- * then this is the package for you.
- *
- */
-
-
-#include <string.h> /* bcopy */
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-#include <netinet/in.h>
-
-static bool_t xdrmem_getlong();
-static bool_t xdrmem_putlong();
-static bool_t xdrmem_getbytes();
-static bool_t xdrmem_putbytes();
-static u_int xdrmem_getpos();
-static bool_t xdrmem_setpos();
-static long * xdrmem_inline();
-static void xdrmem_destroy();
-
-static struct xdr_ops xdrmem_ops = {
- xdrmem_getlong,
- xdrmem_putlong,
- xdrmem_getbytes,
- xdrmem_putbytes,
- xdrmem_getpos,
- xdrmem_setpos,
- xdrmem_inline,
- xdrmem_destroy
-};
-
-/*
- * The procedure xdrmem_create initializes a stream descriptor for a
- * memory buffer.
- */
-void
-xdrmem_create(xdrs, addr, size, op)
- register XDR *xdrs;
- caddr_t addr;
- u_int size;
- enum xdr_op op;
-{
-
- xdrs->x_op = op;
- xdrs->x_ops = &xdrmem_ops;
- xdrs->x_private = xdrs->x_base = addr;
- xdrs->x_handy = size;
-}
-
-static void
-xdrmem_destroy(/*xdrs*/)
- /*XDR *xdrs;*/
-{
-}
-
-static bool_t
-xdrmem_getlong(xdrs, lp)
- register XDR *xdrs;
- long *lp;
-{
-
- if ((xdrs->x_handy -= sizeof(long)) < 0)
- return (FALSE);
- *lp = (long)ntohl((u_long)(*((long *)(xdrs->x_private))));
- xdrs->x_private += sizeof(long);
- return (TRUE);
-}
-
-static bool_t
-xdrmem_putlong(xdrs, lp)
- register XDR *xdrs;
- long *lp;
-{
-
- if ((xdrs->x_handy -= sizeof(long)) < 0)
- return (FALSE);
- *(long *)xdrs->x_private = (long)htonl((u_long)(*lp));
- xdrs->x_private += sizeof(long);
- return (TRUE);
-}
-
-static bool_t
-xdrmem_getbytes(xdrs, addr, len)
- register XDR *xdrs;
- caddr_t addr;
- register u_int len;
-{
-
- if ((xdrs->x_handy -= len) < 0)
- return (FALSE);
- bcopy(xdrs->x_private, addr, len);
- xdrs->x_private += len;
- return (TRUE);
-}
-
-static bool_t
-xdrmem_putbytes(xdrs, addr, len)
- register XDR *xdrs;
- caddr_t addr;
- register u_int len;
-{
-
- if ((xdrs->x_handy -= len) < 0)
- return (FALSE);
- bcopy(addr, xdrs->x_private, len);
- xdrs->x_private += len;
- return (TRUE);
-}
-
-static u_int
-xdrmem_getpos(xdrs)
- register XDR *xdrs;
-{
-
- return ((u_int)xdrs->x_private - (u_int)xdrs->x_base);
-}
-
-static bool_t
-xdrmem_setpos(xdrs, pos)
- register XDR *xdrs;
- u_int pos;
-{
- register caddr_t newaddr = xdrs->x_base + pos;
- register caddr_t lastaddr = xdrs->x_private + xdrs->x_handy;
-
- if ((long)newaddr > (long)lastaddr)
- return (FALSE);
- xdrs->x_private = newaddr;
- xdrs->x_handy = (int)lastaddr - (int)newaddr;
- return (TRUE);
-}
-
-static long *
-xdrmem_inline(xdrs, len)
- register XDR *xdrs;
- int len;
-{
- long *buf = 0;
-
- if (xdrs->x_handy >= len) {
- xdrs->x_handy -= len;
- buf = (long *) xdrs->x_private;
- xdrs->x_private += len;
- }
- return (buf);
-}