summaryrefslogtreecommitdiffstats
path: root/lib/libc/rpc/svc_raw.c
diff options
context:
space:
mode:
authoralfred <alfred@FreeBSD.org>2001-03-19 12:50:13 +0000
committeralfred <alfred@FreeBSD.org>2001-03-19 12:50:13 +0000
commitf67e4a8fc7fc95c74bd6c09d3453200de47faea5 (patch)
tree98b613188d263fdcef5f2d020e5e8c374db1f5b6 /lib/libc/rpc/svc_raw.c
parent6f24d923a7fa9d1679753d77cc982ec72c22a197 (diff)
downloadFreeBSD-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/rpc/svc_raw.c')
-rw-r--r--lib/libc/rpc/svc_raw.c212
1 files changed, 152 insertions, 60 deletions
diff --git a/lib/libc/rpc/svc_raw.c b/lib/libc/rpc/svc_raw.c
index 4726152..5ab10f8 100644
--- a/lib/libc/rpc/svc_raw.c
+++ b/lib/libc/rpc/svc_raw.c
@@ -1,3 +1,5 @@
+/* $NetBSD: svc_raw.c,v 1.14 2000/07/06 03:10:35 christos 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
@@ -26,12 +28,18 @@
* 2550 Garcia Avenue
* Mountain View, California 94043
*/
+/*
+ * Copyright (c) 1986-1991 by Sun Microsystems Inc.
+ */
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)svc_raw.c 1.15 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)svc_raw.c 2.1 88/07/29 4.0 RPCSRC";*/
+/* #ident "@(#)svc_raw.c 1.16 94/04/24 SMI" */
+
+#if 0
+#if defined(SCCSIDS) && !defined(lint)
+static char sccsid[] = "@(#)svc_raw.c 1.25 89/01/31 Copyr 1984 Sun Micro";
static char *rcsid = "$FreeBSD$";
#endif
+#endif
/*
* svc_raw.c, This a toy for simple testing and timing.
@@ -39,130 +47,214 @@ static char *rcsid = "$FreeBSD$";
* This lets us similate rpc and get rpc (round trip) overhead, without
* any interference from the kernal.
*
- * Copyright (C) 1984, Sun Microsystems, Inc.
*/
+#include "reentrant.h"
+#include "namespace.h"
#include <rpc/rpc.h>
+#include <sys/types.h>
+#include <rpc/raw.h>
#include <stdlib.h>
+#include "un-namespace.h"
+
+#ifndef UDPMSGSIZE
+#define UDPMSGSIZE 8800
+#endif
/*
* This is the "network" that we will be moving data over
*/
-static struct svcraw_private {
- char _raw_buf[UDPMSGSIZE];
+static struct svc_raw_private {
+ char *raw_buf; /* should be shared with the cl handle */
SVCXPRT server;
XDR xdr_stream;
char verf_body[MAX_AUTH_BYTES];
-} *svcraw_private;
-
-static bool_t svcraw_recv();
-static enum xprt_stat svcraw_stat();
-static bool_t svcraw_getargs();
-static bool_t svcraw_reply();
-static bool_t svcraw_freeargs();
-static void svcraw_destroy();
-
-static struct xp_ops server_ops = {
- svcraw_recv,
- svcraw_stat,
- svcraw_getargs,
- svcraw_reply,
- svcraw_freeargs,
- svcraw_destroy
-};
+} *svc_raw_private;
+
+extern mutex_t svcraw_lock;
+
+static enum xprt_stat svc_raw_stat __P((SVCXPRT *));
+static bool_t svc_raw_recv __P((SVCXPRT *, struct rpc_msg *));
+static bool_t svc_raw_reply __P((SVCXPRT *, struct rpc_msg *));
+static bool_t svc_raw_getargs __P((SVCXPRT *, xdrproc_t, caddr_t));
+static bool_t svc_raw_freeargs __P((SVCXPRT *, xdrproc_t, caddr_t));
+static void svc_raw_destroy __P((SVCXPRT *));
+static void svc_raw_ops __P((SVCXPRT *));
+static bool_t svc_raw_control __P((SVCXPRT *, const u_int, void *));
+
+char *__rpc_rawcombuf = NULL;
SVCXPRT *
-svcraw_create()
+svc_raw_create()
{
- register struct svcraw_private *srp = svcraw_private;
+ struct svc_raw_private *srp;
+/* VARIABLES PROTECTED BY svcraw_lock: svc_raw_private, srp */
- if (srp == 0) {
- srp = (struct svcraw_private *)calloc(1, sizeof (*srp));
- if (srp == 0)
- return (0);
+ mutex_lock(&svcraw_lock);
+ srp = svc_raw_private;
+ if (srp == NULL) {
+ srp = (struct svc_raw_private *)calloc(1, sizeof (*srp));
+ if (srp == NULL) {
+ mutex_unlock(&svcraw_lock);
+ return (NULL);
+ }
+ if (__rpc_rawcombuf == NULL)
+ __rpc_rawcombuf = calloc(UDPMSGSIZE, sizeof (char));
+ srp->raw_buf = __rpc_rawcombuf; /* Share it with the client */
+ svc_raw_private = srp;
}
- srp->server.xp_sock = 0;
+ srp->server.xp_fd = FD_SETSIZE;
srp->server.xp_port = 0;
- srp->server.xp_ops = &server_ops;
+ srp->server.xp_p3 = NULL;
+ svc_raw_ops(&srp->server);
srp->server.xp_verf.oa_base = srp->verf_body;
- xdrmem_create(&srp->xdr_stream, srp->_raw_buf, UDPMSGSIZE, XDR_FREE);
+ xdrmem_create(&srp->xdr_stream, srp->raw_buf, UDPMSGSIZE, XDR_DECODE);
+ xprt_register(&srp->server);
+ mutex_unlock(&svcraw_lock);
return (&srp->server);
}
+/*ARGSUSED*/
static enum xprt_stat
-svcraw_stat()
+svc_raw_stat(xprt)
+SVCXPRT *xprt; /* args needed to satisfy ANSI-C typechecking */
{
-
return (XPRT_IDLE);
}
+/*ARGSUSED*/
static bool_t
-svcraw_recv(xprt, msg)
+svc_raw_recv(xprt, msg)
SVCXPRT *xprt;
struct rpc_msg *msg;
{
- register struct svcraw_private *srp = svcraw_private;
- register XDR *xdrs;
+ struct svc_raw_private *srp;
+ XDR *xdrs;
+
+ mutex_lock(&svcraw_lock);
+ srp = svc_raw_private;
+ if (srp == NULL) {
+ mutex_unlock(&svcraw_lock);
+ return (FALSE);
+ }
+ mutex_unlock(&svcraw_lock);
- if (srp == 0)
- return (0);
xdrs = &srp->xdr_stream;
xdrs->x_op = XDR_DECODE;
- XDR_SETPOS(xdrs, 0);
- if (! xdr_callmsg(xdrs, msg))
- return (FALSE);
+ (void) XDR_SETPOS(xdrs, 0);
+ if (! xdr_callmsg(xdrs, msg)) {
+ return (FALSE);
+ }
return (TRUE);
}
+/*ARGSUSED*/
static bool_t
-svcraw_reply(xprt, msg)
+svc_raw_reply(xprt, msg)
SVCXPRT *xprt;
struct rpc_msg *msg;
{
- register struct svcraw_private *srp = svcraw_private;
- register XDR *xdrs;
+ struct svc_raw_private *srp;
+ XDR *xdrs;
- if (srp == 0)
+ mutex_lock(&svcraw_lock);
+ srp = svc_raw_private;
+ if (srp == NULL) {
+ mutex_unlock(&svcraw_lock);
return (FALSE);
+ }
+ mutex_unlock(&svcraw_lock);
+
xdrs = &srp->xdr_stream;
xdrs->x_op = XDR_ENCODE;
- XDR_SETPOS(xdrs, 0);
- if (! xdr_replymsg(xdrs, msg))
- return (FALSE);
- (void)XDR_GETPOS(xdrs); /* called just for overhead */
+ (void) XDR_SETPOS(xdrs, 0);
+ if (! xdr_replymsg(xdrs, msg)) {
+ return (FALSE);
+ }
+ (void) XDR_GETPOS(xdrs); /* called just for overhead */
return (TRUE);
}
+/*ARGSUSED*/
static bool_t
-svcraw_getargs(xprt, xdr_args, args_ptr)
+svc_raw_getargs(xprt, xdr_args, args_ptr)
SVCXPRT *xprt;
xdrproc_t xdr_args;
caddr_t args_ptr;
{
- register struct svcraw_private *srp = svcraw_private;
+ struct svc_raw_private *srp;
- if (srp == 0)
+ mutex_lock(&svcraw_lock);
+ srp = svc_raw_private;
+ if (srp == NULL) {
+ mutex_unlock(&svcraw_lock);
return (FALSE);
- return ((*xdr_args)(&srp->xdr_stream, args_ptr));
+ }
+ mutex_unlock(&svcraw_lock);
+ return (*xdr_args)(&srp->xdr_stream, args_ptr);
}
+/*ARGSUSED*/
static bool_t
-svcraw_freeargs(xprt, xdr_args, args_ptr)
+svc_raw_freeargs(xprt, xdr_args, args_ptr)
SVCXPRT *xprt;
xdrproc_t xdr_args;
caddr_t args_ptr;
{
- register struct svcraw_private *srp = svcraw_private;
- register XDR *xdrs;
+ struct svc_raw_private *srp;
+ XDR *xdrs;
- if (srp == 0)
+ mutex_lock(&svcraw_lock);
+ srp = svc_raw_private;
+ if (srp == NULL) {
+ mutex_unlock(&svcraw_lock);
return (FALSE);
+ }
+ mutex_unlock(&svcraw_lock);
+
xdrs = &srp->xdr_stream;
xdrs->x_op = XDR_FREE;
- return ((*xdr_args)(xdrs, args_ptr));
+ return (*xdr_args)(xdrs, args_ptr);
+}
+
+/*ARGSUSED*/
+static void
+svc_raw_destroy(xprt)
+SVCXPRT *xprt;
+{
+}
+
+/*ARGSUSED*/
+static bool_t
+svc_raw_control(xprt, rq, in)
+ SVCXPRT *xprt;
+ const u_int rq;
+ void *in;
+{
+ return (FALSE);
}
static void
-svcraw_destroy()
+svc_raw_ops(xprt)
+ SVCXPRT *xprt;
{
+ static struct xp_ops ops;
+ static struct xp_ops2 ops2;
+ extern mutex_t ops_lock;
+
+/* VARIABLES PROTECTED BY ops_lock: ops */
+
+ mutex_lock(&ops_lock);
+ if (ops.xp_recv == NULL) {
+ ops.xp_recv = svc_raw_recv;
+ ops.xp_stat = svc_raw_stat;
+ ops.xp_getargs = svc_raw_getargs;
+ ops.xp_reply = svc_raw_reply;
+ ops.xp_freeargs = svc_raw_freeargs;
+ ops.xp_destroy = svc_raw_destroy;
+ ops2.xp_control = svc_raw_control;
+ }
+ xprt->xp_ops = &ops;
+ xprt->xp_ops2 = &ops2;
+ mutex_unlock(&ops_lock);
}
OpenPOWER on IntegriCloud