87 lines
2.0 KiB
C
87 lines
2.0 KiB
C
#if !defined(lint) && defined(SCCSIDS)
|
|
static char sccsid[] = "@(#)pmap_clnt.c 1.1 94/10/31 Copyr 1984 Sun Micro";
|
|
#endif
|
|
|
|
/*
|
|
* pmap_clnt.c
|
|
* Client interface to pmap rpc service.
|
|
*
|
|
* Copyright (C) 1984, Sun Microsystems, Inc.
|
|
*/
|
|
|
|
#include <rpc/rpc.h>
|
|
#include <rpc/pmap_prot.h>
|
|
#include <rpc/pmap_clnt.h>
|
|
#include <sys/time.h>
|
|
#include <sys/syslog.h>
|
|
|
|
static struct timeval timeout = { 5, 0 };
|
|
static struct timeval tottimeout = { 60, 0 };
|
|
|
|
/*
|
|
* Set a mapping between program, version and port.
|
|
* Calls the pmap service remotely to do the mapping.
|
|
*/
|
|
bool_t
|
|
pmap_set(program, version, protocol, port)
|
|
u_long program;
|
|
u_long version;
|
|
int protocol;
|
|
u_short port;
|
|
{
|
|
struct sockaddr_in myaddress;
|
|
int socket = -1;
|
|
register CLIENT *client;
|
|
struct pmap parms;
|
|
bool_t rslt;
|
|
|
|
get_myaddress(&myaddress);
|
|
client = clntudp_bufcreate(&myaddress, PMAPPROG, PMAPVERS,
|
|
timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
|
|
if (client == (CLIENT *)NULL)
|
|
return (FALSE);
|
|
parms.pm_prog = program;
|
|
parms.pm_vers = version;
|
|
parms.pm_prot = protocol;
|
|
parms.pm_port = port;
|
|
if (CLNT_CALL(client, PMAPPROC_SET, xdr_pmap, &parms, xdr_bool, &rslt,
|
|
tottimeout) != RPC_SUCCESS) {
|
|
(void) syslog(LOG_ERR, clnt_sperror(client,
|
|
"Cannot register service"));
|
|
return (FALSE);
|
|
}
|
|
CLNT_DESTROY(client);
|
|
(void)close(socket);
|
|
return (rslt);
|
|
}
|
|
|
|
/*
|
|
* Remove the mapping between program, version and port.
|
|
* Calls the pmap service remotely to do the un-mapping.
|
|
*/
|
|
bool_t
|
|
pmap_unset(program, version)
|
|
u_long program;
|
|
u_long version;
|
|
{
|
|
struct sockaddr_in myaddress;
|
|
int socket = -1;
|
|
register CLIENT *client;
|
|
struct pmap parms;
|
|
bool_t rslt;
|
|
|
|
get_myaddress(&myaddress);
|
|
client = clntudp_bufcreate(&myaddress, PMAPPROG, PMAPVERS,
|
|
timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
|
|
if (client == (CLIENT *)NULL)
|
|
return (FALSE);
|
|
parms.pm_prog = program;
|
|
parms.pm_vers = version;
|
|
parms.pm_port = parms.pm_prot = 0;
|
|
CLNT_CALL(client, PMAPPROC_UNSET, xdr_pmap, &parms, xdr_bool, &rslt,
|
|
tottimeout);
|
|
CLNT_DESTROY(client);
|
|
(void)close(socket);
|
|
return (rslt);
|
|
}
|