summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authortegge <tegge@FreeBSD.org>1997-09-04 21:21:56 +0000
committertegge <tegge@FreeBSD.org>1997-09-04 21:21:56 +0000
commitcca2f92f76a20573f6e82aa3f5ca311c2160169a (patch)
treea220f4e2059b0a66339c104bc381696be158823a /usr.bin
parente84e12e485a102d810a9544ce159eeb48d4d51cc (diff)
downloadFreeBSD-src-cca2f92f76a20573f6e82aa3f5ca311c2160169a.zip
FreeBSD-src-cca2f92f76a20573f6e82aa3f5ca311c2160169a.tar.gz
Added an replacement for callrpc that uses tcp as primary transport method.
This enables larger reply messages.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/showmount/showmount.c75
1 files changed, 72 insertions, 3 deletions
diff --git a/usr.bin/showmount/showmount.c b/usr.bin/showmount/showmount.c
index f6c116f..08d7d50 100644
--- a/usr.bin/showmount/showmount.c
+++ b/usr.bin/showmount/showmount.c
@@ -45,7 +45,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)showmount.c 8.3 (Berkeley) 3/29/95";
#endif
static const char rcsid[] =
- "$Id$";
+ "$Id: showmount.c,v 1.6 1997/08/11 07:27:27 charnier Exp $";
#endif not lint
#include <sys/types.h>
@@ -99,6 +99,10 @@ void print_dump __P((struct mountlist *));
static void usage __P((void));
int xdr_mntdump __P((XDR *, struct mountlist **));
int xdr_exports __P((XDR *, struct exportslist **));
+int tcp_callrpc __P((char *host,
+ int prognum, int versnum, int procnum,
+ xdrproc_t inproc, char *in,
+ xdrproc_t outproc, char *out));
/*
* This command queries the NFS mount daemon for it's mount list and/or
@@ -157,14 +161,14 @@ main(argc, argv)
rpcs = DODUMP;
if (rpcs & DODUMP)
- if ((estat = callrpc(host, RPCPROG_MNT, mntvers,
+ if ((estat = tcp_callrpc(host, RPCPROG_MNT, mntvers,
RPCMNT_DUMP, xdr_void, (char *)0,
xdr_mntdump, (char *)&mntdump)) != 0) {
clnt_perrno(estat);
errx(1, "can't do mountdump rpc");
}
if (rpcs & DOEXPORTS)
- if ((estat = callrpc(host, RPCPROG_MNT, mntvers,
+ if ((estat = tcp_callrpc(host, RPCPROG_MNT, mntvers,
RPCMNT_EXPORT, xdr_void, (char *)0,
xdr_exports, (char *)&exports)) != 0) {
clnt_perrno(estat);
@@ -208,6 +212,71 @@ main(argc, argv)
}
/*
+ * tcp_callrpc has the same interface as callrpc, but tries to
+ * use tcp as transport method in order to handle large replies.
+ */
+
+int
+tcp_callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
+ char *host;
+ int prognum;
+ int versnum;
+ int procnum;
+ xdrproc_t inproc;
+ char *in;
+ xdrproc_t outproc;
+ char *out;
+{
+ struct hostent *hp;
+ struct sockaddr_in server_addr;
+ CLIENT *client;
+ int sock;
+ struct timeval timeout;
+ int rval;
+
+ hp = gethostbyname(host);
+
+ if (!hp)
+ return ((int) RPC_UNKNOWNHOST);
+
+ memset(&server_addr,0,sizeof(server_addr));
+ memcpy((char *) &server_addr.sin_addr,
+ hp->h_addr,
+ hp->h_length);
+ server_addr.sin_len = sizeof(struct sockaddr_in);
+ server_addr.sin_family =AF_INET;
+ server_addr.sin_port = 0;
+
+ sock = RPC_ANYSOCK;
+
+ client = clnttcp_create(&server_addr,
+ (u_long) prognum,
+ (u_long) versnum, &sock, 0, 0);
+ if (!client) {
+ timeout.tv_sec = 5;
+ timeout.tv_usec = 0;
+ server_addr.sin_port = 0;
+ sock = RPC_ANYSOCK;
+ client = clntudp_create(&server_addr,
+ (u_long) prognum,
+ (u_long) versnum,
+ timeout,
+ &sock);
+ }
+ if (!client)
+ return ((int) rpc_createerr.cf_stat);
+
+ timeout.tv_sec = 25;
+ timeout.tv_usec = 0;
+ rval = (int) clnt_call(client, procnum,
+ inproc, in,
+ outproc, out,
+ timeout);
+ clnt_destroy(client);
+ return rval;
+}
+
+/*
* Xdr routine for retrieving the mount dump list
*/
int
OpenPOWER on IntegriCloud