123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- #define __FORCE_GLIBC__
- #include <features.h>
- #include <rpc/rpc.h>
- #include <rpc/pmap_prot.h>
- #include <rpc/pmap_clnt.h>
- #include <unistd.h>
- static struct timeval timeout = { 5, 0 };
- static struct timeval tottimeout = { 60, 0 };
- void clnt_perror();
- 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, (xdrproc_t) xdr_pmap, (caddr_t) &parms,
- (xdrproc_t) xdr_bool, (caddr_t) &rslt,
- tottimeout) != RPC_SUCCESS) {
- clnt_perror(client, "Cannot register service");
- return (FALSE);
- }
- CLNT_DESTROY(client);
- (void) close(socket);
- return (rslt);
- }
- 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, (xdrproc_t) xdr_pmap, (caddr_t) &parms,
- (xdrproc_t) xdr_bool, (caddr_t) &rslt, tottimeout);
- CLNT_DESTROY(client);
- (void) close(socket);
- return (rslt);
- }
|