Added an replacement for callrpc that uses tcp as primary transport method.

This enables larger reply messages.
This commit is contained in:
Tor Egge 1997-09-04 21:21:56 +00:00
parent c12fbac488
commit 5ab88c4102
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=29117

View File

@ -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);
@ -207,6 +211,71 @@ main(argc, argv)
exit(0);
}
/*
* 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
*/