diff options
author | alfred <alfred@FreeBSD.org> | 2001-03-19 12:50:13 +0000 |
---|---|---|
committer | alfred <alfred@FreeBSD.org> | 2001-03-19 12:50:13 +0000 |
commit | f67e4a8fc7fc95c74bd6c09d3453200de47faea5 (patch) | |
tree | 98b613188d263fdcef5f2d020e5e8c374db1f5b6 /lib/libc/xdr/xdr_mem.c | |
parent | 6f24d923a7fa9d1679753d77cc982ec72c22a197 (diff) | |
download | FreeBSD-src-f67e4a8fc7fc95c74bd6c09d3453200de47faea5.zip FreeBSD-src-f67e4a8fc7fc95c74bd6c09d3453200de47faea5.tar.gz |
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
Diffstat (limited to 'lib/libc/xdr/xdr_mem.c')
-rw-r--r-- | lib/libc/xdr/xdr_mem.c | 136 |
1 files changed, 74 insertions, 62 deletions
diff --git a/lib/libc/xdr/xdr_mem.c b/lib/libc/xdr/xdr_mem.c index 3193e64..b54fc59 100644 --- a/lib/libc/xdr/xdr_mem.c +++ b/lib/libc/xdr/xdr_mem.c @@ -1,3 +1,5 @@ +/* $NetBSD: xdr_mem.c,v 1.15 2000/01/22 22:19:18 mycroft Exp $ */ + /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -27,6 +29,7 @@ * Mountain View, California 94043 */ +#include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)xdr_mem.c 1.19 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)xdr_mem.c 2.1 88/07/29 4.0 RPCSRC";*/ @@ -44,24 +47,31 @@ static char *rcsid = "$FreeBSD$"; * */ +#include "namespace.h" +#include <sys/types.h> + +#include <netinet/in.h> + #include <string.h> + #include <rpc/types.h> #include <rpc/xdr.h> -#include <netinet/in.h> - -static bool_t xdrmem_getlong_aligned(); -static bool_t xdrmem_putlong_aligned(); -static bool_t xdrmem_getlong_unaligned(); -static bool_t xdrmem_putlong_unaligned(); -static bool_t xdrmem_getbytes(); -static bool_t xdrmem_putbytes(); -static u_int xdrmem_getpos(); /* XXX w/64-bit pointers, u_int not enough! */ -static bool_t xdrmem_setpos(); -static int32_t *xdrmem_inline_aligned(); -static int32_t *xdrmem_inline_unaligned(); -static void xdrmem_destroy(); - -static struct xdr_ops xdrmem_ops_aligned = { +#include "un-namespace.h" + +static void xdrmem_destroy __P((XDR *)); +static bool_t xdrmem_getlong_aligned __P((XDR *, long *)); +static bool_t xdrmem_putlong_aligned __P((XDR *, const long *)); +static bool_t xdrmem_getlong_unaligned __P((XDR *, long *)); +static bool_t xdrmem_putlong_unaligned __P((XDR *, const long *)); +static bool_t xdrmem_getbytes __P((XDR *, char *, u_int)); +static bool_t xdrmem_putbytes __P((XDR *, const char *, u_int)); +/* XXX: w/64-bit pointers, u_int not enough! */ +static u_int xdrmem_getpos __P((XDR *)); +static bool_t xdrmem_setpos __P((XDR *, u_int)); +static int32_t *xdrmem_inline_aligned __P((XDR *, u_int)); +static int32_t *xdrmem_inline_unaligned __P((XDR *, u_int)); + +static const struct xdr_ops xdrmem_ops_aligned = { xdrmem_getlong_aligned, xdrmem_putlong_aligned, xdrmem_getbytes, @@ -72,7 +82,7 @@ static struct xdr_ops xdrmem_ops_aligned = { xdrmem_destroy }; -static struct xdr_ops xdrmem_ops_unaligned = { +static const struct xdr_ops xdrmem_ops_unaligned = { xdrmem_getlong_unaligned, xdrmem_putlong_unaligned, xdrmem_getbytes, @@ -89,154 +99,156 @@ static struct xdr_ops xdrmem_ops_unaligned = { */ void xdrmem_create(xdrs, addr, size, op) - register XDR *xdrs; - caddr_t addr; + XDR *xdrs; + char *addr; u_int size; enum xdr_op op; { xdrs->x_op = op; - xdrs->x_ops = ((size_t)addr & (sizeof(int32_t) - 1)) - ? &xdrmem_ops_unaligned : &xdrmem_ops_aligned; + xdrs->x_ops = ((unsigned long)addr & (sizeof(int32_t) - 1)) + ? &xdrmem_ops_unaligned : &xdrmem_ops_aligned; xdrs->x_private = xdrs->x_base = addr; xdrs->x_handy = size; } +/*ARGSUSED*/ static void -xdrmem_destroy(/*xdrs*/) - /*XDR *xdrs;*/ +xdrmem_destroy(xdrs) + XDR *xdrs; { } static bool_t xdrmem_getlong_aligned(xdrs, lp) - register XDR *xdrs; + XDR *xdrs; long *lp; { if ((xdrs->x_handy -= sizeof(int32_t)) < 0) return (FALSE); - *lp = ntohl(*(int32_t *)(xdrs->x_private)); - xdrs->x_private += sizeof(int32_t); + *lp = ntohl(*(u_int32_t *)xdrs->x_private); + xdrs->x_private = (char *)xdrs->x_private + sizeof(int32_t); return (TRUE); } static bool_t xdrmem_putlong_aligned(xdrs, lp) - register XDR *xdrs; - long *lp; + XDR *xdrs; + const long *lp; { if ((xdrs->x_handy -= sizeof(int32_t)) < 0) return (FALSE); - *(int32_t *)xdrs->x_private = htonl(*lp); - xdrs->x_private += sizeof(int32_t); + *(u_int32_t *)xdrs->x_private = htonl((u_int32_t)*lp); + xdrs->x_private = (char *)xdrs->x_private + sizeof(int32_t); return (TRUE); } static bool_t xdrmem_getlong_unaligned(xdrs, lp) - register XDR *xdrs; + XDR *xdrs; long *lp; { - int32_t l; + u_int32_t l; if ((xdrs->x_handy -= sizeof(int32_t)) < 0) return (FALSE); - memcpy(&l, xdrs->x_private, sizeof(int32_t)); + memmove(&l, xdrs->x_private, sizeof(int32_t)); *lp = ntohl(l); - xdrs->x_private += sizeof(int32_t); + xdrs->x_private = (char *)xdrs->x_private + sizeof(int32_t); return (TRUE); } static bool_t xdrmem_putlong_unaligned(xdrs, lp) - register XDR *xdrs; - long *lp; + XDR *xdrs; + const long *lp; { - int32_t l; + u_int32_t l; if ((xdrs->x_handy -= sizeof(int32_t)) < 0) return (FALSE); - l = htonl(*lp); - memcpy(xdrs->x_private, &l, sizeof(int32_t)); - xdrs->x_private += sizeof(int32_t); + l = htonl((u_int32_t)*lp); + memmove(xdrs->x_private, &l, sizeof(int32_t)); + xdrs->x_private = (char *)xdrs->x_private + sizeof(int32_t); return (TRUE); } static bool_t xdrmem_getbytes(xdrs, addr, len) - register XDR *xdrs; - caddr_t addr; - register u_int len; + XDR *xdrs; + char *addr; + u_int len; { if ((xdrs->x_handy -= len) < 0) return (FALSE); - memcpy(addr, xdrs->x_private, len); - xdrs->x_private += len; + memmove(addr, xdrs->x_private, len); + xdrs->x_private = (char *)xdrs->x_private + len; return (TRUE); } static bool_t xdrmem_putbytes(xdrs, addr, len) - register XDR *xdrs; - caddr_t addr; - register u_int len; + XDR *xdrs; + const char *addr; + u_int len; { if ((xdrs->x_handy -= len) < 0) return (FALSE); - memcpy(xdrs->x_private, addr, len); - xdrs->x_private += len; + memmove(xdrs->x_private, addr, len); + xdrs->x_private = (char *)xdrs->x_private + len; return (TRUE); } static u_int xdrmem_getpos(xdrs) - register XDR *xdrs; + XDR *xdrs; { /* XXX w/64-bit pointers, u_int not enough! */ - return ((u_long)xdrs->x_private - (u_long)xdrs->x_base); + return (u_int)((u_long)xdrs->x_private - (u_long)xdrs->x_base); } static bool_t xdrmem_setpos(xdrs, pos) - register XDR *xdrs; + XDR *xdrs; u_int pos; { - register caddr_t newaddr = xdrs->x_base + pos; - register caddr_t lastaddr = xdrs->x_private + xdrs->x_handy; + char *newaddr = xdrs->x_base + pos; + char *lastaddr = (char *)xdrs->x_private + xdrs->x_handy; if ((long)newaddr > (long)lastaddr) return (FALSE); xdrs->x_private = newaddr; - xdrs->x_handy = (long)lastaddr - (long)newaddr; + xdrs->x_handy = (int)((long)lastaddr - (long)newaddr); return (TRUE); } static int32_t * xdrmem_inline_aligned(xdrs, len) - register XDR *xdrs; - int len; + XDR *xdrs; + u_int len; { int32_t *buf = 0; if (xdrs->x_handy >= len) { xdrs->x_handy -= len; - buf = (int32_t *) xdrs->x_private; - xdrs->x_private += len; + buf = (int32_t *)xdrs->x_private; + xdrs->x_private = (char *)xdrs->x_private + len; } return (buf); } +/* ARGSUSED */ static int32_t * xdrmem_inline_unaligned(xdrs, len) - register XDR *xdrs; - int len; + XDR *xdrs; + u_int len; { - + return (0); } |