~ubuntu-branches/ubuntu/precise/eglibc/precise-201308281639

« back to all changes in this revision

Viewing changes to sunrpc/clnt_udp.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-02-08 01:58:09 UTC
  • mfrom: (1.5.3) (288.1.12 precise)
  • Revision ID: package-import@ubuntu.com-20120208015809-ulscst7uteq3e22z
Tags: 2.15~pre6-0ubuntu10
Merge from Debian (r5151, 2.13-26).

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
#include <rpc/pmap_clnt.h>
46
46
#include <net/if.h>
47
47
#include <ifaddrs.h>
48
 
#ifdef USE_IN_LIBIO
49
 
# include <wchar.h>
50
 
#endif
 
48
#include <wchar.h>
51
49
#include <fcntl.h>
52
50
 
53
51
#ifdef IP_RECVERR
57
55
 
58
56
#include <kernel-features.h>
59
57
 
60
 
extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *);
61
58
extern u_long _create_xid (void);
62
59
 
63
60
/*
165
162
  call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
166
163
  call_msg.rm_call.cb_prog = program;
167
164
  call_msg.rm_call.cb_vers = version;
168
 
  INTUSE(xdrmem_create) (&(cu->cu_outxdrs), cu->cu_outbuf, sendsz, XDR_ENCODE);
169
 
  if (!INTUSE(xdr_callhdr) (&(cu->cu_outxdrs), &call_msg))
 
165
  xdrmem_create (&(cu->cu_outxdrs), cu->cu_outbuf, sendsz, XDR_ENCODE);
 
166
  if (!xdr_callhdr (&(cu->cu_outxdrs), &call_msg))
170
167
    {
171
168
      goto fooy;
172
169
    }
173
170
  cu->cu_xdrpos = XDR_GETPOS (&(cu->cu_outxdrs));
174
171
  if (*sockp < 0)
175
172
    {
176
 
      int dontblock = 1;
177
 
 
178
173
#ifdef SOCK_NONBLOCK
179
174
# ifndef __ASSUME_SOCK_CLOEXEC
180
175
      if (__have_sock_cloexec >= 0)
213
208
# ifdef SOCK_CLOEXEC
214
209
      if (__have_sock_cloexec < 0)
215
210
# endif
216
 
        /* the sockets rpc controls are non-blocking */
217
 
        (void) __ioctl (*sockp, FIONBIO, (char *) &dontblock);
 
211
        {
 
212
          /* the sockets rpc controls are non-blocking */
 
213
          int dontblock = 1;
 
214
          (void) __ioctl (*sockp, FIONBIO, (char *) &dontblock);
 
215
        }
218
216
#endif
219
217
#ifdef IP_RECVERR
220
218
      {
229
227
      cu->cu_closeit = FALSE;
230
228
    }
231
229
  cu->cu_sock = *sockp;
232
 
  cl->cl_auth = INTUSE(authnone_create) ();
 
230
  cl->cl_auth = authnone_create ();
233
231
  return cl;
234
232
fooy:
235
233
  if (cu)
238
236
    mem_free ((caddr_t) cl, sizeof (CLIENT));
239
237
  return (CLIENT *) NULL;
240
238
}
241
 
INTDEF (__libc_clntudp_bufcreate)
 
239
#ifdef EXPORT_RPC_SYMBOLS
 
240
libc_hidden_def (__libc_clntudp_bufcreate)
 
241
#else
 
242
libc_hidden_nolink (__libc_clntudp_bufcreate, GLIBC_PRIVATE)
 
243
#endif
242
244
 
243
245
CLIENT *
244
246
clntudp_bufcreate (struct sockaddr_in *raddr, u_long program, u_long version,
245
247
                   struct timeval wait, int *sockp, u_int sendsz,
246
248
                   u_int recvsz)
247
249
{
248
 
  return INTUSE(__libc_clntudp_bufcreate) (raddr, program, version, wait,
249
 
                                           sockp, sendsz, recvsz, 0);
 
250
  return __libc_clntudp_bufcreate (raddr, program, version, wait,
 
251
                                   sockp, sendsz, recvsz, 0);
250
252
}
251
 
INTDEF (clntudp_bufcreate)
 
253
libc_hidden_nolink (clntudp_bufcreate, GLIBC_2_0)
252
254
 
253
255
CLIENT *
254
256
clntudp_create (raddr, program, version, wait, sockp)
258
260
     struct timeval wait;
259
261
     int *sockp;
260
262
{
261
 
  return INTUSE(__libc_clntudp_bufcreate) (raddr, program, version, wait,
262
 
                                           sockp, UDPMSGSIZE, UDPMSGSIZE, 0);
 
263
  return __libc_clntudp_bufcreate (raddr, program, version, wait,
 
264
                                   sockp, UDPMSGSIZE, UDPMSGSIZE, 0);
263
265
}
264
 
INTDEF (clntudp_create)
 
266
#ifdef EXPORT_RPC_SYMBOLS
 
267
libc_hidden_def (clntudp_create)
 
268
#else
 
269
libc_hidden_nolink (clntudp_create, GLIBC_2_0)
 
270
#endif
265
271
 
266
272
static int
267
273
is_network_up (int sock)
465
471
        continue;
466
472
 
467
473
      /* see if reply transaction id matches sent id.
468
 
        Don't do this if we only wait for a replay */
 
474
        Don't do this if we only wait for a replay */
469
475
      if (xargs != NULL
470
 
          && (*((u_int32_t *) (cu->cu_inbuf))
471
 
              != *((u_int32_t *) (cu->cu_outbuf))))
 
476
          && memcmp (cu->cu_inbuf, cu->cu_outbuf, sizeof (u_int32_t)) != 0)
472
477
        continue;
473
478
      /* we now assume we have the proper reply */
474
479
      break;
477
482
  /*
478
483
   * now decode and validate the response
479
484
   */
480
 
  INTUSE(xdrmem_create) (&reply_xdrs, cu->cu_inbuf, (u_int) inlen, XDR_DECODE);
481
 
  ok = INTUSE(xdr_replymsg) (&reply_xdrs, &reply_msg);
 
485
  xdrmem_create (&reply_xdrs, cu->cu_inbuf, (u_int) inlen, XDR_DECODE);
 
486
  ok = xdr_replymsg (&reply_xdrs, &reply_msg);
482
487
  /* XDR_DESTROY(&reply_xdrs);  save a few cycles on noop destroy */
483
488
  if (ok)
484
489
    {
494
499
          if (reply_msg.acpted_rply.ar_verf.oa_base != NULL)
495
500
            {
496
501
              xdrs->x_op = XDR_FREE;
497
 
              (void) INTUSE(xdr_opaque_auth) (xdrs,
498
 
                                              &(reply_msg.acpted_rply.ar_verf));
 
502
              (void) xdr_opaque_auth (xdrs, &(reply_msg.acpted_rply.ar_verf));
499
503
            }
500
504
        }                       /* end successful completion */
501
505
      else