pmap_getmaps Subroutine

Important: The subroutine is exported from both the libc and the libnsl libraries.

pmap_getmaps Subroutine Exported from the libc Library

Purpose

Returns a list of the current Remote Procedure Call (RPC) program-to-port mappings on the host.

Library

C Library (libc.a)

Syntax

#include <rpc/rpc.h>

struct pmaplist *pmap_getmaps ( addr)
struct sockaddr_in *addr;

Description

The pmap_getmaps subroutine acts as a user interface to the portmap daemon. The subroutine returns a list of the current RPC program-to-port mappings on the host located at the Internet Protocol (IP) address pointed to by the addr parameter.

Note: The rpcinfo -p command calls this subroutine.

Parameters

Item Description
addr Specifies the address where the machine's IP address is placed.

Return Values

If there is no list of current RPC programs, this procedure returns a value of null.

pmap_getmaps Subroutine Exported from the libnsl Library

Purpose

Returns a list of the current Remote Procedure Call (RPC) program-to-port mappings on the host.

Library

C Library (libnsl.a)

Syntax

#include <rpc/rpc.h>
struct pmaplist *pmap_getmaps(addr)
struct sockaddr_in *addr;

Description

The pmap_getmaps subroutine acts as a user interface to the portmap daemon. The subroutine returns a list of the current RPC program-to-port mappings on the host located at the Internet Protocol (IP) address pointed to by the addr parameter.

Note: The rpcinfo -p command calls this subroutine.

Parameters

Item Description
addr Specifies the address where the machine's IP address is placed.

Return Values

Item Description
a pointer to the first element of the list successful
a null value unsuccessful

Examples

In the following example, the pmap_getmaps subroutine obtains a list of the current RPC program-to-port mappings on the host.

#include <rpc/rpc.h>
#include <stdio.h>

int main()
{
  rpcprog_t PROGNUM = 0x3fffffffL ;
  rpcvers_t PROGVER = 0x1L ;
  struct hostent *hp;
  struct sockaddr_in addr;
  struct pmaplist *plist = NULL;

  /* Obtain the host information */
  hp = (struct hostent *) gethostbyname(hostname);
  if (hp == NULL) {
    printf("host information not found\n");
    exit(2);
  }

  addr.sin_family = hp->h_addrtype;
  memcpy(&addr.sin_addr.s_addr, hp->h_addr_list[0], hp->h_length);

  plist = (struct pmaplist *) pmap_getmaps(&addr);
  if(plist==NULL)
  {
    fprintf(stderr,"pmap_getmaps() failed");
    exit(1);
  }

return 0;
}