Files
seta75D 2e8a93c394 Init
2021-10-11 18:20:23 -03:00

60 lines
1.4 KiB
C

#if !defined(lint) && defined(SCCSIDS)
static char sccsid[] = "@(#)pmap_getmaps.c 1.1 92/07/30 Copyr 1984 Sun Micro";
#endif
/*
* pmap_getmap.c
* Client interface to pmap rpc service.
* contains pmap_getmaps, which is only tcp service involved
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
#include <rpc/rpc.h>
#include <rpc/pmap_prot.h>
#include <rpc/pmap_clnt.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netdb.h>
#include <stdio.h>
#include <errno.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <sys/syslog.h>
#define NAMELEN 255
#define MAX_BROADCAST_SIZE 1400
extern int errno;
/*
* Get a copy of the current port maps.
* Calls the pmap service remotely to do get the maps.
*/
struct pmaplist *
pmap_getmaps(address)
struct sockaddr_in *address;
{
struct pmaplist *head = (struct pmaplist *)NULL;
int socket = -1;
struct timeval minutetimeout;
register CLIENT *client;
minutetimeout.tv_sec = 60;
minutetimeout.tv_usec = 0;
address->sin_port = htons(PMAPPORT);
client = clnttcp_create(address, PMAPPROG,
PMAPVERS, &socket, 50, 500);
if (client != (CLIENT *)NULL) {
if (CLNT_CALL(client, PMAPPROC_DUMP, xdr_void,
NULL, xdr_pmaplist,
&head, minutetimeout) != RPC_SUCCESS) {
(void) syslog(LOG_ERR, clnt_sperror(client,
"pmap_getmaps rpc problem"));
}
CLNT_DESTROY(client);
}
(void)close(socket);
address->sin_port = 0;
return (head);
}