X-Git-Url: https://gitweb.dragonflybsd.org/~lentferj/dragonfly.git/blobdiff_plain/a57065a884cd914933230ce9372594cedfc32e4e..ce0e08e21d42c06c0014fae6b9d27144aa5109b0:/lib/libc/rpc/pmap_getport.c diff --git a/lib/libc/rpc/pmap_getport.c b/lib/libc/rpc/pmap_getport.c index 71346db902..e6aa9bfdd3 100644 --- a/lib/libc/rpc/pmap_getport.c +++ b/lib/libc/rpc/pmap_getport.c @@ -28,7 +28,8 @@ * * @(#)pmap_getport.c 1.9 87/08/11 Copyr 1984 Sun Micro * @(#)pmap_getport.c 2.2 88/08/01 4.0 RPCSRC - * $FreeBSD: src/lib/libc/rpc/pmap_getport.c,v 1.10 2000/01/27 23:06:40 jasone Exp $ + * $NetBSD: pmap_getport.c,v 1.16 2000/07/06 03:10:34 christos Exp $ + * $FreeBSD: src/lib/libc/rpc/pmap_getport.c,v 1.15 2004/10/16 06:11:35 obrien Exp $ * $DragonFly: src/lib/libc/rpc/pmap_getport.c,v 1.6 2005/11/13 12:27:04 swildner Exp $ */ @@ -40,28 +41,22 @@ */ #include "namespace.h" -#include -#include -#include +#include #include + +#include #include + +#include #include -#include "un-namespace.h" -static struct timeval timeout = { 5, 0 }; -static struct timeval tottimeout = { 60, 0 }; +#include +#include +#include +#include "un-namespace.h" -/* - * Change the primary pmap_getport() timeout - */ -void -pmap_getport_timeout(struct timeval *otv, struct timeval *ntv) -{ - if (otv) - *otv = tottimeout; - if (ntv) - tottimeout = *ntv; -} +static const struct timeval timeout = { 5, 0 }; +static const struct timeval tottimeout = { 60, 0 }; /* * Find the mapped port for program,version. @@ -73,20 +68,24 @@ pmap_getport(struct sockaddr_in *address, u_long program, u_long version, u_int protocol) { u_short port = 0; - int socket = -1; + int sock = -1; CLIENT *client; struct pmap parms; + assert(address != NULL); + address->sin_port = htons(PMAPPORT); client = clntudp_bufcreate(address, PMAPPROG, - PMAPVERS, timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); - if (client != (CLIENT *)NULL) { + PMAPVERS, timeout, &sock, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); + if (client != NULL) { parms.pm_prog = program; parms.pm_vers = version; parms.pm_prot = protocol; parms.pm_port = 0; /* not needed or used */ - if (CLNT_CALL(client, PMAPPROC_GETPORT, xdr_pmap, &parms, - xdr_u_short, &port, tottimeout) != RPC_SUCCESS){ + if (CLNT_CALL(client, (rpcproc_t)PMAPPROC_GETPORT, + (xdrproc_t)xdr_pmap, + &parms, (xdrproc_t)xdr_u_short, &port, tottimeout) != + RPC_SUCCESS){ rpc_createerr.cf_stat = RPC_PMAPFAILURE; clnt_geterr(client, &rpc_createerr.cf_error); } else if (port == 0) { @@ -94,8 +93,6 @@ pmap_getport(struct sockaddr_in *address, u_long program, u_long version, } CLNT_DESTROY(client); } - if (socket != -1) - _close(socket); address->sin_port = 0; return (port); }