diff options
Diffstat (limited to 'libc/inet/rpc/pm_getport.c')
| -rw-r--r-- | libc/inet/rpc/pm_getport.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/libc/inet/rpc/pm_getport.c b/libc/inet/rpc/pm_getport.c index 327fb9101..9a0e79178 100644 --- a/libc/inet/rpc/pm_getport.c +++ b/libc/inet/rpc/pm_getport.c @@ -44,10 +44,6 @@ static char sccsid[] = "@(#)pmap_getport.c 1.9 87/08/11 Copyr 1984 Sun Micro"; #include <rpc/pmap_prot.h> #include <rpc/pmap_clnt.h> -libc_hidden_proto(clntudp_bufcreate) -libc_hidden_proto(__rpc_thread_createerr) -libc_hidden_proto(xdr_u_short) -libc_hidden_proto(xdr_pmap) static const struct timeval timeout = {5, 0}; @@ -59,13 +55,9 @@ static const struct timeval tottimeout = * Calls the pmap service remotely to do the lookup. * Returns 0 if no map exists. */ -libc_hidden_proto(pmap_getport) u_short -pmap_getport (address, program, version, protocol) - struct sockaddr_in *address; - u_long program; - u_long version; - u_int protocol; +pmap_getport (struct sockaddr_in *address, u_long program, u_long version, + u_int protocol) { u_short port = 0; int _socket = -1; @@ -73,7 +65,19 @@ pmap_getport (address, program, version, protocol) struct pmap parms; address->sin_port = htons (PMAPPORT); - client = clntudp_bufcreate (address, PMAPPROG, + if (protocol == IPPROTO_TCP) + { + // glibc does this: + ///* Don't need a reserved port to get ports from the portmapper. */ + //socket = __get_socket(address); // does socket(TCP),bind(),connect(address) + //if (_socket != -1) + // closeit = true; + // do we need/want to do the same? + client = clnttcp_create (address, PMAPPROG, + PMAPVERS, &_socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); + } + else + client = clntudp_bufcreate (address, PMAPPROG, PMAPVERS, timeout, &_socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); if (client != (CLIENT *) NULL) { @@ -95,7 +99,7 @@ pmap_getport (address, program, version, protocol) } CLNT_DESTROY (client); } - /* (void)__close(_socket); CLNT_DESTROY already closed it */ + /* (void)close(_socket); CLNT_DESTROY already closed it */ address->sin_port = 0; return port; } |
