Back to index

glibc  2.9
Functions | Variables
pmap_clnt.c File Reference
#include <stdio.h>
#include <unistd.h>
#include <libintl.h>
#include <net/if.h>
#include <ifaddrs.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <rpc/rpc.h>
#include <rpc/pmap_prot.h>
#include <rpc/pmap_clnt.h>

Go to the source code of this file.

Functions

static bool_t __get_myaddress (struct sockaddr_in *addr)
bool_t pmap_set (u_long program, u_long version, int protocol, u_short port)
 libc_hidden_def (pmap_set)

Variables

static struct timeval = {5, 0}

Function Documentation

static bool_t __get_myaddress ( struct sockaddr_in addr) [static]

Definition at line 56 of file pmap_clnt.c.

{
  struct ifaddrs *ifa;

  if (getifaddrs (&ifa) != 0)
    {
      perror ("get_myaddress: getifaddrs");
      exit (1);
    }

  int loopback = 1;
  struct ifaddrs *run;

 again:
  run = ifa;
  while (run != NULL)
    {
      if ((run->ifa_flags & IFF_UP)
         && run->ifa_addr != NULL
         && run->ifa_addr->sa_family == AF_INET
         && ((run->ifa_flags & IFF_LOOPBACK) || loopback == 0))
       {
         *addr = *((struct sockaddr_in *) run->ifa_addr);
         addr->sin_port = htons (PMAPPORT);
         goto out;
       }

      run = run->ifa_next;
    }

  if (loopback == 1)
    {
      loopback = 0;
      goto again;
    }
 out:
  freeifaddrs (ifa);

  return run == NULL ? FALSE : TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 136 of file pmap_clnt.c.

{
  struct sockaddr_in myaddress;
  int socket = -1;
  CLIENT *client;
  struct pmap parms;
  bool_t rslt;

  if (!__get_myaddress (&myaddress))
    return FALSE;
  client = INTUSE(clntudp_bufcreate) (&myaddress, PMAPPROG, PMAPVERS,
                                  timeout, &socket, RPCSMALLMSGSIZE,
                                  RPCSMALLMSGSIZE);
  if (client == (CLIENT *) NULL)
    return FALSE;
  parms.pm_prog = program;
  parms.pm_vers = version;
  parms.pm_port = parms.pm_prot = 0;
  CLNT_CALL (client, PMAPPROC_UNSET, (xdrproc_t)INTUSE(xdr_pmap),
            (caddr_t)&parms, (xdrproc_t)INTUSE(xdr_bool), (caddr_t)&rslt,
            tottimeout);
  CLNT_DESTROY (client);
  /* (void)close(socket); CLNT_DESTROY already closed it */
  return rslt;
}

Here is the call graph for this function:

bool_t pmap_set ( u_long  program,
u_long  version,
int  protocol,
u_short  port 
)

Definition at line 106 of file pmap_clnt.c.

{
  struct sockaddr_in myaddress;
  int socket = -1;
  CLIENT *client;
  struct pmap parms;
  bool_t rslt;

  if (!__get_myaddress (&myaddress))
    return FALSE;
  client = INTUSE(clntudp_bufcreate) (&myaddress, PMAPPROG, PMAPVERS,
                                  timeout, &socket, RPCSMALLMSGSIZE,
                                  RPCSMALLMSGSIZE);
  if (client == (CLIENT *) NULL)
    return (FALSE);
  parms.pm_prog = program;
  parms.pm_vers = version;
  parms.pm_prot = protocol;
  parms.pm_port = port;
  if (CLNT_CALL (client, PMAPPROC_SET, (xdrproc_t)INTUSE(xdr_pmap),
               (caddr_t)&parms, (xdrproc_t)INTUSE(xdr_bool), (caddr_t)&rslt,
               tottimeout) != RPC_SUCCESS)
    {
      clnt_perror (client, _("Cannot register service"));
      rslt = FALSE;
    }
  CLNT_DESTROY (client);
  /* (void)close(socket); CLNT_DESTROY closes it */
  return rslt;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

static struct timeval = {5, 0} [static]

Definition at line 98 of file pmap_clnt.c.