1*45083Smckusick /* @(#)pmap_getmaps.c 2.2 88/08/01 4.0 RPCSRC */
2*45083Smckusick /*
3*45083Smckusick * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
4*45083Smckusick * unrestricted use provided that this legend is included on all tape
5*45083Smckusick * media and as a part of the software program in whole or part. Users
6*45083Smckusick * may copy or modify Sun RPC without charge, but are not authorized
7*45083Smckusick * to license or distribute it to anyone else except as part of a product or
8*45083Smckusick * program developed by the user.
9*45083Smckusick *
10*45083Smckusick * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
11*45083Smckusick * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
12*45083Smckusick * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
13*45083Smckusick *
14*45083Smckusick * Sun RPC is provided with no support and without any obligation on the
15*45083Smckusick * part of Sun Microsystems, Inc. to assist in its use, correction,
16*45083Smckusick * modification or enhancement.
17*45083Smckusick *
18*45083Smckusick * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
19*45083Smckusick * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
20*45083Smckusick * OR ANY PART THEREOF.
21*45083Smckusick *
22*45083Smckusick * In no event will Sun Microsystems, Inc. be liable for any lost revenue
23*45083Smckusick * or profits or other special, indirect and consequential damages, even if
24*45083Smckusick * Sun has been advised of the possibility of such damages.
25*45083Smckusick *
26*45083Smckusick * Sun Microsystems, Inc.
27*45083Smckusick * 2550 Garcia Avenue
28*45083Smckusick * Mountain View, California 94043
29*45083Smckusick */
30*45083Smckusick #if !defined(lint) && defined(SCCSIDS)
31*45083Smckusick static char sccsid[] = "@(#)pmap_getmaps.c 1.10 87/08/11 Copyr 1984 Sun Micro";
32*45083Smckusick #endif
33*45083Smckusick
34*45083Smckusick /*
35*45083Smckusick * pmap_getmap.c
36*45083Smckusick * Client interface to pmap rpc service.
37*45083Smckusick * contains pmap_getmaps, which is only tcp service involved
38*45083Smckusick *
39*45083Smckusick * Copyright (C) 1984, Sun Microsystems, Inc.
40*45083Smckusick */
41*45083Smckusick
42*45083Smckusick #include <rpc/rpc.h>
43*45083Smckusick #include <rpc/pmap_prot.h>
44*45083Smckusick #include <rpc/pmap_clnt.h>
45*45083Smckusick #include <sys/socket.h>
46*45083Smckusick #include <netdb.h>
47*45083Smckusick #include <stdio.h>
48*45083Smckusick #include <errno.h>
49*45083Smckusick #include <net/if.h>
50*45083Smckusick #include <sys/ioctl.h>
51*45083Smckusick #define NAMELEN 255
52*45083Smckusick #define MAX_BROADCAST_SIZE 1400
53*45083Smckusick
54*45083Smckusick extern int errno;
55*45083Smckusick
56*45083Smckusick /*
57*45083Smckusick * Get a copy of the current port maps.
58*45083Smckusick * Calls the pmap service remotely to do get the maps.
59*45083Smckusick */
60*45083Smckusick struct pmaplist *
pmap_getmaps(address)61*45083Smckusick pmap_getmaps(address)
62*45083Smckusick struct sockaddr_in *address;
63*45083Smckusick {
64*45083Smckusick struct pmaplist *head = (struct pmaplist *)NULL;
65*45083Smckusick int socket = -1;
66*45083Smckusick struct timeval minutetimeout;
67*45083Smckusick register CLIENT *client;
68*45083Smckusick
69*45083Smckusick minutetimeout.tv_sec = 60;
70*45083Smckusick minutetimeout.tv_usec = 0;
71*45083Smckusick address->sin_port = htons(PMAPPORT);
72*45083Smckusick client = clnttcp_create(address, PMAPPROG,
73*45083Smckusick PMAPVERS, &socket, 50, 500);
74*45083Smckusick if (client != (CLIENT *)NULL) {
75*45083Smckusick if (CLNT_CALL(client, PMAPPROC_DUMP, xdr_void, NULL, xdr_pmaplist,
76*45083Smckusick &head, minutetimeout) != RPC_SUCCESS) {
77*45083Smckusick clnt_perror(client, "pmap_getmaps rpc problem");
78*45083Smckusick }
79*45083Smckusick CLNT_DESTROY(client);
80*45083Smckusick }
81*45083Smckusick (void)close(socket);
82*45083Smckusick address->sin_port = 0;
83*45083Smckusick return (head);
84*45083Smckusick }
85