home *** CD-ROM | disk | FTP | other *** search
- /*
- * $Id: pmap_clnt.c,v 4.2 1994/09/29 23:48:50 jraja Exp $
- *
- * Client interface to pmap rpc service.
- *
- * Copyright © 1994 AmiTCP/IP Group,
- * Network Solutions Development Inc.
- * All rights reserved.
- */
-
- /* @(#)pmap_clnt.c 2.2 88/08/01 4.0 RPCSRC */
- #if !defined(lint) && defined(SCCSIDS)
- static char sccsid[] = "@(#)pmap_clnt.c 1.37 87/08/11 Copyr 1984 Sun Micro";
- #endif
-
- /*
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
- #include <sys/param.h>
- #include <rpc/rpc.h>
- #include <rpc/pmap_prot.h>
- #include <rpc/pmap_clnt.h>
- #include <sys/socket.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) {
- clnt_perror(client, "Cannot register service");
- return (FALSE);
- }
- CLNT_DESTROY(client);
- #ifdef AMITCP
- (void)CloseSocket(socket);
- #else
- (void)close(socket);
- #endif
- 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);
- #ifdef AMITCP
- (void)CloseSocket(socket);
- #else
- (void)close(socket);
- #endif
- return (rslt);
- }
-