Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/fs/common/nfsrpc Add libc rpc bits modified to be suit...
details: https://anonhg.NetBSD.org/src/rev/4a07784af24f
branches: trunk
changeset: 756622:4a07784af24f
user: pooka <pooka%NetBSD.org@localhost>
date: Mon Jul 26 15:56:45 2010 +0000
description:
Add libc rpc bits modified to be suitable for testing the nfs
server & client.
diffstat:
tests/fs/common/nfsrpc/Makefile.inc | 12 +
tests/fs/common/nfsrpc/bindresvport.c | 163 ++++
tests/fs/common/nfsrpc/clnt_bcast.c | 683 +++++++++++++++++
tests/fs/common/nfsrpc/clnt_dg.c | 773 +++++++++++++++++++
tests/fs/common/nfsrpc/clnt_generic.c | 375 +++++++++
tests/fs/common/nfsrpc/clnt_vc.c | 784 ++++++++++++++++++++
tests/fs/common/nfsrpc/namespace.h | 55 +
tests/fs/common/nfsrpc/reentrant.h | 264 ++++++
tests/fs/common/nfsrpc/rpc_generic.c | 897 ++++++++++++++++++++++
tests/fs/common/nfsrpc/rpc_internal.h | 69 +
tests/fs/common/nfsrpc/rpc_soc.c | 449 +++++++++++
tests/fs/common/nfsrpc/rpcb_clnt.c | 1292 +++++++++++++++++++++++++++++++++
tests/fs/common/nfsrpc/svc.c | 836 +++++++++++++++++++++
tests/fs/common/nfsrpc/svc_dg.c | 652 ++++++++++++++++
tests/fs/common/nfsrpc/svc_dg.h | 49 +
tests/fs/common/nfsrpc/svc_fdset.h | 6 +
tests/fs/common/nfsrpc/svc_generic.c | 317 ++++++++
tests/fs/common/nfsrpc/svc_run.c | 116 ++
tests/fs/common/nfsrpc/svc_vc.c | 838 +++++++++++++++++++++
19 files changed, 8630 insertions(+), 0 deletions(-)
diffs (truncated from 8706 to 300 lines):
diff -r 5034d932f4a4 -r 4a07784af24f tests/fs/common/nfsrpc/Makefile.inc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fs/common/nfsrpc/Makefile.inc Mon Jul 26 15:56:45 2010 +0000
@@ -0,0 +1,12 @@
+# $NetBSD: Makefile.inc,v 1.1 2010/07/26 15:56:45 pooka Exp $
+#
+
+.PATH: ${.PARSEDIR}
+
+# libc rpc using rump syscalls
+SRCS+= bindresvport.c clnt_bcast.c clnt_dg.c clnt_generic.c clnt_vc.c \
+ rpc_generic.c rpc_soc.c rpcb_clnt.c \
+ svc.c svc_dg.c svc_generic.c svc_run.c svc_vc.c
+
+CPPFLAGS+= -DPORTMAP -D_REENTRANT -DRUMP_SYS_NETWORKING
+CPPFLAGS+= -DDEBUG -DLIBWRAP
diff -r 5034d932f4a4 -r 4a07784af24f tests/fs/common/nfsrpc/bindresvport.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fs/common/nfsrpc/bindresvport.c Mon Jul 26 15:56:45 2010 +0000
@@ -0,0 +1,163 @@
+/* $NetBSD: bindresvport.c,v 1.1 2010/07/26 15:56:45 pooka 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
+ * 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
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char *sccsid = "@(#)bindresvport.c 1.8 88/02/08 SMI";
+static char *sccsid = "@(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC";
+#else
+__RCSID("$NetBSD: bindresvport.c,v 1.1 2010/07/26 15:56:45 pooka Exp $");
+#endif
+#endif
+
+/*
+ * Copyright (c) 1987 by Sun Microsystems, Inc.
+ */
+
+#include "namespace.h"
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <netinet/in.h>
+
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <rpc/rpc.h>
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+
+/*
+ * Bind a socket to a privileged IP port
+ */
+int
+bindresvport(sd, brsin)
+ int sd;
+ struct sockaddr_in *brsin;
+{
+ return bindresvport_sa(sd, (struct sockaddr *)(void *)brsin);
+}
+
+#include <stdio.h>
+/*
+ * Bind a socket to a privileged IP port
+ */
+int
+bindresvport_sa(sd, sa)
+ int sd;
+ struct sockaddr *sa;
+{
+ int error, old;
+ struct sockaddr_storage myaddr;
+ struct sockaddr_in *brsin;
+#ifdef INET6
+ struct sockaddr_in6 *brsin6;
+#endif
+ int proto, portrange, portlow;
+ u_int16_t *portp;
+ socklen_t salen;
+ int af;
+
+ if (sa == NULL) {
+ salen = sizeof(myaddr);
+ sa = (struct sockaddr *)(void *)&myaddr;
+
+ if (getsockname(sd, sa, &salen) == -1)
+ return -1; /* errno is correctly set */
+
+ af = sa->sa_family;
+ memset(sa, 0, salen);
+ } else
+ af = sa->sa_family;
+
+ switch (af) {
+ case AF_INET:
+ proto = IPPROTO_IP;
+ portrange = IP_PORTRANGE;
+ portlow = IP_PORTRANGE_LOW;
+ brsin = (struct sockaddr_in *)(void *)sa;
+ salen = sizeof(struct sockaddr_in);
+ portp = &brsin->sin_port;
+ break;
+#ifdef INET6
+ case AF_INET6:
+ proto = IPPROTO_IPV6;
+ portrange = IPV6_PORTRANGE;
+ portlow = IPV6_PORTRANGE_LOW;
+ brsin6 = (struct sockaddr_in6 *)(void *)sa;
+ salen = sizeof(struct sockaddr_in6);
+ portp = &brsin6->sin6_port;
+ break;
+#endif
+ default:
+ errno = EPFNOSUPPORT;
+ return (-1);
+ }
+ sa->sa_family = af;
+ sa->sa_len = salen;
+
+ if (*portp == 0) {
+ socklen_t oldlen = sizeof(old);
+
+ error = getsockopt(sd, proto, portrange, &old, &oldlen);
+ if (error < 0)
+ return (error);
+ error = setsockopt(sd, proto, portrange, &portlow,
+ sizeof(portlow));
+ if (error < 0)
+ return (error);
+ }
+
+ error = bind(sd, sa, salen);
+
+ if (*portp == 0) {
+ int saved_errno = errno;
+
+ if (error < 0) {
+ if (setsockopt(sd, proto, portrange, &old,
+ sizeof(old)) < 0)
+ errno = saved_errno;
+ return (error);
+ }
+
+ if (sa != (struct sockaddr *)(void *)&myaddr) {
+ /* What did the kernel assign? */
+ if (getsockname(sd, sa, &salen) < 0)
+ errno = saved_errno;
+ return (error);
+ }
+ }
+ return (error);
+}
diff -r 5034d932f4a4 -r 4a07784af24f tests/fs/common/nfsrpc/clnt_bcast.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fs/common/nfsrpc/clnt_bcast.c Mon Jul 26 15:56:45 2010 +0000
@@ -0,0 +1,683 @@
+/* $NetBSD: clnt_bcast.c,v 1.1 2010/07/26 15:56:45 pooka 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
+ * 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
+ */
+/*
+ * Copyright (c) 1986-1991 by Sun Microsystems Inc.
+ */
+
+/* #ident "@(#)clnt_bcast.c 1.18 94/05/03 SMI" */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)clnt_bcast.c 1.15 89/04/21 Copyr 1988 Sun Micro";
+#else
+__RCSID("$NetBSD: clnt_bcast.c,v 1.1 2010/07/26 15:56:45 pooka Exp $");
+#endif
+#endif
+
+/*
+ * clnt_bcast.c
+ * Client interface to broadcast service.
+ *
+ * Copyright (C) 1988, Sun Microsystems, Inc.
+ *
+ * The following is kludged-up support for simple rpc broadcasts.
+ * Someday a large, complicated system will replace these routines.
+ */
+
+#include "namespace.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/queue.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <ifaddrs.h>
+#include <sys/poll.h>
+#include <rpc/rpc.h>
+#ifdef PORTMAP
+#include <rpc/pmap_prot.h>
+#include <rpc/pmap_clnt.h>
+#include <rpc/pmap_rmt.h>
+#endif
+#include <rpc/nettype.h>
+#include <arpa/inet.h>
+#ifdef RPC_DEBUG
+#include <stdio.h>
+#endif
+#include <assert.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <netdb.h>
+#include <err.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+
+#include "rpc_internal.h"
+
+#define MAXBCAST 20 /* Max no of broadcasting transports */
+#define INITTIME 4000 /* Time to wait initially */
+#define WAITTIME 8000 /* Maximum time to wait */
+
+/*
+ * If nettype is NULL, it broadcasts on all the available
+ * datagram_n transports. May potentially lead to broadacst storms
+ * and hence should be used with caution, care and courage.
+ *
+ * The current parameter xdr packet size is limited by the max tsdu
+ * size of the transport. If the max tsdu size of any transport is
+ * smaller than the parameter xdr packet, then broadcast is not
+ * sent on that transport.
+ *
+ * Also, the packet size should be less the packet size of
+ * the data link layer (for ethernet it is 1400 bytes). There is
+ * no easy way to find out the max size of the data link layer and
+ * we are assuming that the args would be smaller than that.
+ *
+ * The result size has to be smaller than the transport tsdu size.
+ *
+ * If PORTMAP has been defined, we send two packets for UDP, one for
+ * rpcbind and one for portmap. For those machines which support
+ * both rpcbind and portmap, it will cause them to reply twice, and
+ * also here it will get two responses ... inefficient and clumsy.
Home |
Main Index |
Thread Index |
Old Index