FreeBSD/usr.sbin/ypbind/yp_ping.c
/*
 * Find the mapped port for program,version.
 * Calls the pmap service remotely to do the lookup.
 * Returns 0 if no map exists.
 */
Find the mapped port for program,version.
Calls the pmap service remotely to do the lookup.
Returns 0 if no map exists.
Find the mapped port for program version . Calls the pmap service remotely to do the lookup . Returns 0 if no map exists .
static u_short
__pmap_getport(struct sockaddr_in *address, u_long program, u_long version,
    u_int protocol)
{
	u_short port = 0;
	int sock = -1;
	register CLIENT *client;
	struct pmap parms;
	address->sin_port = htons(PMAPPORT);
	client = clntudp_bufcreate(address, PMAPPROG,
	    PMAPVERS, timeout, &sock, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
	if (client != (CLIENT *)NULL) {
		parms.pm_prog = program;
		parms.pm_vers = version;
		parms.pm_prot = protocol;
		parms.pm_port = 0;  
		if (CLNT_CALL(client, 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) {
			rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED;
		}
		CLNT_DESTROY(client);
	}
	if (sock != -1)
		(void)close(sock);
	address->sin_port = 0;
	return (port);
}
static u_short __pmap_getport ( struct sockaddr_in * address , u_long program , u_long version , u_int protocol ) { u_short port = 0 ; int sock = -1 ; register CLIENT * client ; struct pmap parms ; address -> sin_port = htons ( PMAPPORT ) ; client = clntudp_bufcreate ( address , PMAPPROG , PMAPVERS , timeout , & sock , RPCSMALLMSGSIZE , RPCSMALLMSGSIZE ) ; if ( client != ( CLIENT * ) NULL ) { parms . pm_prog = program ; parms . pm_vers = version ; parms . pm_prot = protocol ; parms . pm_port = 0 ; if ( CLNT_CALL ( client , 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 ) { rpc_createerr . cf_stat = RPC_PROGNOTREGISTERED ; } CLNT_DESTROY ( client ) ; } if ( sock != -1 ) ( void ) close ( sock ) ; address -> sin_port = 0 ; return ( port ) ; }
Find the mapped port for program,version.
Find the mapped port for program version .
/* not needed or used */