home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / comm / tcp / amitcp / src / rpclib / pmap_getmaps.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-09  |  2.9 KB  |  97 lines

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