2 static char sfs_clnt_id[] = "@(#)pmap_getport.c 2.1 97/10/23";
4 /* @(#)pmap_getport.c 2.2 88/08/01 4.0 RPCSRC */
6 * Copyright (c) 1992-1997,2001 by Standard Performance Evaluation Corporation
8 * Standard Performance Evaluation Corporation (SPEC)
9 * 6585 Merchant Place, Suite 100
12 * This product contains benchmarks acquired from several sources who
13 * understand and agree with SPEC's goal of creating fair and objective
14 * benchmarks to measure computer performance.
16 * This copyright notice is placed here only to protect SPEC in the
17 * event the source is misused in any manner that is contrary to the
18 * spirit, the goals and the intent of SPEC.
20 * The source code is provided to the user or company under the license
21 * agreement for the SPEC Benchmark Suite for this product.
24 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
25 * unrestricted use provided that this legend is included on all tape
26 * media and as a part of the software program in whole or part. Users
27 * may copy or modify Sun RPC without charge, but are not authorized
28 * to license or distribute it to anyone else except as part of a product or
29 * program developed by the user.
31 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
32 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
33 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
35 * Sun RPC is provided with no support and without any obligation on the
36 * part of Sun Microsystems, Inc. to assist in its use, correction,
37 * modification or enhancement.
39 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
40 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
41 * OR ANY PART THEREOF.
43 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
44 * or profits or other special, indirect and consequential damages, even if
45 * Sun has been advised of the possibility of such damages.
47 * Sun Microsystems, Inc.
49 * Mountain View, California 94043
51 #if !defined(lint) && defined(SCCSIDS)
52 static char sccsid[] = "@(#)pmap_getport.c 1.9 87/08/11 Copyr 1984 Sun Micro";
57 * Client interface to pmap rpc service.
59 * Copyright (C) 1984, Sun Microsystems, Inc.
66 #include "rpc/pmap_prot.h"
67 #include "rpc/pmap_clnt.h"
68 #include "rpc/osdep.h"
70 static struct timeval timeout = { 5, 0 };
71 static struct timeval tottimeout = { 60, 0 };
74 * Find the mapped port for program,version.
75 * Calls the pmap service remotely to do the lookup.
76 * Returns 0 if no map exists.
80 struct sockaddr_in *address,
87 register CLIENT *client;
90 address->sin_port = htons(PMAPPORT);
91 client = clntudp_bufcreate(address, PMAPPROG,
92 PMAPVERS, timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
93 if (client != (CLIENT *)NULL) {
94 parms.pm_prog = program;
95 parms.pm_vers = version;
96 parms.pm_prot = protocol;
97 parms.pm_port = 0; /* not needed or used */
98 if (CLNT_CALL(client, PMAPPROC_GETPORT, xdr_pmap, &parms,
99 xdr_uint16_t, &port, tottimeout) != RPC_SUCCESS){
100 rpc_createerr.cf_stat = RPC_PMAPFAILURE;
101 clnt_geterr(client, &rpc_createerr.cf_error);
102 } else if (port == 0) {
103 rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED;
105 CLNT_DESTROY(client);
108 address->sin_port = 0;