Back to index

glibc  2.9
Functions
clnt.h File Reference
#include <sunrpc/rpc/clnt.h>

Go to the source code of this file.

Functions

int _openchild (const char *command, FILE **fto, FILE **ffrom)
CLIENTclnt_create_internal (__const char *__host, __const u_long __prog, __const u_long __vers, __const char *__prot) attribute_hidden
CLIENTclnttcp_create_internal (struct sockaddr_in *__raddr, u_long __prog, u_long __version, int *__sockp, u_int __sendsz, u_int __recvsz) attribute_hidden
CLIENTclntudp_create_internal (struct sockaddr_in *__raddr, u_long __program, u_long __version, struct timeval __wait_resend, int *__sockp) attribute_hidden
CLIENTclntudp_bufcreate_internal (struct sockaddr_in *__raddr, u_long __program, u_long __version, struct timeval __wait_resend, int *__sockp, u_int __sendsz, u_int __recvsz) attribute_hidden
CLIENT__libc_clntudp_bufcreate (struct sockaddr_in *__raddr, u_long __program, u_long __version, struct timeval __wait_resend, int *__sockp, u_int __sendsz, u_int __recvsz, int __flags)
CLIENT__libc_clntudp_bufcreate_internal (struct sockaddr_in *__raddr, u_long __program, u_long __version, struct timeval __wait_resend, int *__sockp, u_int __sendsz, u_int __recvsz, int __flags) attribute_hidden
CLIENTclntunix_create_internal (struct sockaddr_un *__raddr, u_long __program, u_long __version, int *__sockp, u_int __sendsz, u_int __recvsz) attribute_hidden

Function Documentation

CLIENT* __libc_clntudp_bufcreate ( struct sockaddr_in __raddr,
u_long  __program,
u_long  __version,
struct timeval  __wait_resend,
int __sockp,
u_int  __sendsz,
u_int  __recvsz,
int  __flags 
)

Definition at line 127 of file clnt_udp.c.

{
  CLIENT *cl;
  struct cu_data *cu = NULL;
  struct rpc_msg call_msg;

  cl = (CLIENT *) mem_alloc (sizeof (CLIENT));
  sendsz = ((sendsz + 3) / 4) * 4;
  recvsz = ((recvsz + 3) / 4) * 4;
  cu = (struct cu_data *) mem_alloc (sizeof (*cu) + sendsz + recvsz);
  if (cl == NULL || cu == NULL)
    {
      struct rpc_createerr *ce = &get_rpc_createerr ();
      (void) __fxprintf (NULL, "%s: %s",
                      "clntudp_create", _("out of memory\n"));
      ce->cf_stat = RPC_SYSTEMERROR;
      ce->cf_error.re_errno = ENOMEM;
      goto fooy;
    }
  cu->cu_outbuf = &cu->cu_inbuf[recvsz];

  if (raddr->sin_port == 0)
    {
      u_short port;
      if ((port =
          pmap_getport (raddr, program, version, IPPROTO_UDP)) == 0)
       {
         goto fooy;
       }
      raddr->sin_port = htons (port);
    }
  cl->cl_ops = (struct clnt_ops *) &udp_ops;
  cl->cl_private = (caddr_t) cu;
  cu->cu_raddr = *raddr;
  cu->cu_rlen = sizeof (cu->cu_raddr);
  cu->cu_wait = wait;
  cu->cu_total.tv_sec = -1;
  cu->cu_total.tv_usec = -1;
  cu->cu_sendsz = sendsz;
  cu->cu_recvsz = recvsz;
  call_msg.rm_xid = _create_xid ();
  call_msg.rm_direction = CALL;
  call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
  call_msg.rm_call.cb_prog = program;
  call_msg.rm_call.cb_vers = version;
  INTUSE(xdrmem_create) (&(cu->cu_outxdrs), cu->cu_outbuf, sendsz, XDR_ENCODE);
  if (!INTUSE(xdr_callhdr) (&(cu->cu_outxdrs), &call_msg))
    {
      goto fooy;
    }
  cu->cu_xdrpos = XDR_GETPOS (&(cu->cu_outxdrs));
  if (*sockp < 0)
    {
      int dontblock = 1;

#ifdef SOCK_NONBLOCK
# ifndef __ASSUME_SOCK_CLOEXEC
      if (__have_sock_cloexec >= 0)
# endif
       {
         *sockp = __socket (AF_INET, SOCK_DGRAM|SOCK_NONBLOCK|flags,
                          IPPROTO_UDP);
# ifndef __ASSUME_SOCK_CLOEXEC
         if (__have_sock_cloexec == 0)
           __have_sock_cloexec = *sockp >= 0 || errno != EINVAL ? 1 : -1;
# endif
       }
#endif
#ifndef __ASSUME_SOCK_CLOEXEC
# ifdef SOCK_CLOEXEC
      if (__have_sock_cloexec < 0)
# endif
       {
         *sockp = __socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
# ifdef SOCK_CLOEXEC
         if (flags & SOCK_CLOEXEC)
           __fcntl (*sockp, F_SETFD, FD_CLOEXEC);
# endif
       }
#endif
      if (__builtin_expect (*sockp < 0, 0))
       {
         struct rpc_createerr *ce = &get_rpc_createerr ();
         ce->cf_stat = RPC_SYSTEMERROR;
         ce->cf_error.re_errno = errno;
         goto fooy;
       }
      /* attempt to bind to prov port */
      (void) bindresvport (*sockp, (struct sockaddr_in *) 0);
#ifndef __ASSUME_SOCK_CLOEXEC
# ifdef SOCK_CLOEXEC
      if (__have_sock_cloexec < 0)
# endif
       /* the sockets rpc controls are non-blocking */
       (void) __ioctl (*sockp, FIONBIO, (char *) &dontblock);
#endif
#ifdef IP_RECVERR
      {
       int on = 1;
       __setsockopt (*sockp, SOL_IP, IP_RECVERR, &on, sizeof(on));
      }
#endif
      cu->cu_closeit = TRUE;
    }
  else
    {
      cu->cu_closeit = FALSE;
    }
  cu->cu_sock = *sockp;
  cl->cl_auth = INTUSE(authnone_create) ();
  return cl;
fooy:
  if (cu)
    mem_free ((caddr_t) cu, sizeof (*cu) + sendsz + recvsz);
  if (cl)
    mem_free ((caddr_t) cl, sizeof (CLIENT));
  return (CLIENT *) NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

CLIENT* __libc_clntudp_bufcreate_internal ( struct sockaddr_in __raddr,
u_long  __program,
u_long  __version,
struct timeval  __wait_resend,
int __sockp,
u_int  __sendsz,
u_int  __recvsz,
int  __flags 
)
int _openchild ( const char *  command,
FILE **  fto,
FILE **  ffrom 
)

Definition at line 56 of file openchild.c.

{
  int i;
  int pid;
  int pdto[2];
  int pdfrom[2];

  if (__pipe (pdto) < 0)
    goto error1;
  if (__pipe (pdfrom) < 0)
    goto error2;
  switch (pid = __fork ())
    {
    case -1:
      goto error3;

    case 0:
      /*
       * child: read from pdto[0], write into pdfrom[1]
       */
      __close (0);
      __dup (pdto[0]);
      __close (1);
      __dup (pdfrom[1]);
      fflush (stderr);
      for (i = _rpc_dtablesize () - 1; i >= 3; i--)
       __close (i);
      fflush (stderr);
      execlp (command, command, NULL);
      perror ("exec");
      _exit (~0);

    default:
      /*
       * parent: write into pdto[1], read from pdfrom[0]
       */
      *fto = __fdopen (pdto[1], "w");
      __close (pdto[0]);
      *ffrom = __fdopen (pdfrom[0], "r");
      __close (pdfrom[1]);
      break;
    }
  return pid;

  /*
   * error cleanup and return
   */
error3:
  __close (pdfrom[0]);
  __close (pdfrom[1]);
error2:
  __close (pdto[0]);
  __close (pdto[1]);
error1:
  return -1;
}

Here is the caller graph for this function:

CLIENT* clnt_create_internal ( __const char *  __host,
__const u_long  __prog,
__const u_long  __vers,
__const char *  __prot 
)
CLIENT* clnttcp_create_internal ( struct sockaddr_in __raddr,
u_long  __prog,
u_long  __version,
int __sockp,
u_int  __sendsz,
u_int  __recvsz 
)
CLIENT* clntudp_bufcreate_internal ( struct sockaddr_in __raddr,
u_long  __program,
u_long  __version,
struct timeval  __wait_resend,
int __sockp,
u_int  __sendsz,
u_int  __recvsz 
)
CLIENT* clntudp_create_internal ( struct sockaddr_in __raddr,
u_long  __program,
u_long  __version,
struct timeval  __wait_resend,
int __sockp 
)
CLIENT* clntunix_create_internal ( struct sockaddr_un __raddr,
u_long  __program,
u_long  __version,
int __sockp,
u_int  __sendsz,
u_int  __recvsz 
)