PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

lib/libc/rpc/pmap_getmaps.c

http://www.minix3.org/
C | 106 lines | 53 code | 13 blank | 40 comment | 5 complexity | 47ffacfe8b74c65360647f627b958eb6 MD5 | raw file
Possible License(s): MIT, WTFPL, AGPL-1.0, BSD-3-Clause, GPL-3.0, LGPL-2.0, JSON, 0BSD
  1. /* $NetBSD: pmap_getmaps.c,v 1.16 2000/07/06 03:10:34 christos Exp $ */
  2. /*
  3. * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  4. * unrestricted use provided that this legend is included on all tape
  5. * media and as a part of the software program in whole or part. Users
  6. * may copy or modify Sun RPC without charge, but are not authorized
  7. * to license or distribute it to anyone else except as part of a product or
  8. * program developed by the user.
  9. *
  10. * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  11. * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  12. * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  13. *
  14. * Sun RPC is provided with no support and without any obligation on the
  15. * part of Sun Microsystems, Inc. to assist in its use, correction,
  16. * modification or enhancement.
  17. *
  18. * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  19. * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  20. * OR ANY PART THEREOF.
  21. *
  22. * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  23. * or profits or other special, indirect and consequential damages, even if
  24. * Sun has been advised of the possibility of such damages.
  25. *
  26. * Sun Microsystems, Inc.
  27. * 2550 Garcia Avenue
  28. * Mountain View, California 94043
  29. */
  30. #include <sys/cdefs.h>
  31. #if defined(LIBC_SCCS) && !defined(lint)
  32. #if 0
  33. static char *sccsid = "@(#)pmap_getmaps.c 1.10 87/08/11 Copyr 1984 Sun Micro";
  34. static char *sccsid = "@(#)pmap_getmaps.c 2.2 88/08/01 4.0 RPCSRC";
  35. #else
  36. __RCSID("$NetBSD: pmap_getmaps.c,v 1.16 2000/07/06 03:10:34 christos Exp $");
  37. #endif
  38. #endif
  39. /*
  40. * pmap_getmap.c
  41. * Client interface to pmap rpc service.
  42. * contains pmap_getmaps, which is only tcp service involved
  43. *
  44. * Copyright (C) 1984, Sun Microsystems, Inc.
  45. */
  46. #include "namespace.h"
  47. #include <sys/types.h>
  48. #include <sys/ioctl.h>
  49. #include <sys/socket.h>
  50. #include <net/if.h>
  51. #include <assert.h>
  52. #include <errno.h>
  53. #include <netdb.h>
  54. #include <stdio.h>
  55. #include <unistd.h>
  56. #include <rpc/rpc.h>
  57. #include <rpc/pmap_prot.h>
  58. #include <rpc/pmap_clnt.h>
  59. #ifdef __weak_alias
  60. __weak_alias(pmap_getmaps,_pmap_getmaps)
  61. #endif
  62. #define NAMELEN 255
  63. #define MAX_BROADCAST_SIZE 1400
  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 = NULL;
  73. int sock = -1;
  74. struct timeval minutetimeout;
  75. CLIENT *client;
  76. _DIAGASSERT(address != NULL);
  77. minutetimeout.tv_sec = 60;
  78. minutetimeout.tv_usec = 0;
  79. address->sin_port = htons(PMAPPORT);
  80. client = clnttcp_create(address, PMAPPROG,
  81. PMAPVERS, &sock, 50, 500);
  82. if (client != NULL) {
  83. if (CLNT_CALL(client, (rpcproc_t)PMAPPROC_DUMP,
  84. (xdrproc_t)xdr_void, NULL,
  85. (xdrproc_t)xdr_pmaplist, &head, minutetimeout) !=
  86. RPC_SUCCESS) {
  87. clnt_perror(client, "pmap_getmaps rpc problem");
  88. }
  89. CLNT_DESTROY(client);
  90. }
  91. address->sin_port = 0;
  92. return (head);
  93. }