clnt_udp.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. /* @(#)clnt_udp.c 2.2 88/08/01 4.0 RPCSRC */
  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. #if 0
  31. static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro";
  32. #endif
  33. /*
  34. * clnt_udp.c, Implements a UDP/IP based, client side RPC.
  35. *
  36. * Copyright (C) 1984, Sun Microsystems, Inc.
  37. */
  38. #include <stdio.h>
  39. #include <unistd.h>
  40. #include "rpc_private.h"
  41. #include <rpc/xdr.h>
  42. #include <rpc/clnt.h>
  43. #include <sys/poll.h>
  44. #include <sys/socket.h>
  45. #include <sys/ioctl.h>
  46. #include <netdb.h>
  47. #include <errno.h>
  48. #include <rpc/pmap_clnt.h>
  49. #include <net/if.h>
  50. #ifdef USE_IN_LIBIO
  51. # include <wchar.h>
  52. #endif
  53. #ifdef IP_RECVERR
  54. #include "errqueue.h"
  55. #include <sys/uio.h>
  56. #endif
  57. /*
  58. * UDP bases client side rpc operations
  59. */
  60. static enum clnt_stat clntudp_call (CLIENT *, u_long, xdrproc_t, caddr_t,
  61. xdrproc_t, caddr_t, struct timeval);
  62. static void clntudp_abort (void);
  63. static void clntudp_geterr (CLIENT *, struct rpc_err *);
  64. static bool_t clntudp_freeres (CLIENT *, xdrproc_t, caddr_t);
  65. static bool_t clntudp_control (CLIENT *, int, char *);
  66. static void clntudp_destroy (CLIENT *);
  67. static const struct clnt_ops udp_ops =
  68. {
  69. clntudp_call,
  70. clntudp_abort,
  71. clntudp_geterr,
  72. clntudp_freeres,
  73. clntudp_destroy,
  74. clntudp_control
  75. };
  76. /*
  77. * Private data kept per client handle
  78. */
  79. struct cu_data
  80. {
  81. int cu_sock;
  82. bool_t cu_closeit;
  83. struct sockaddr_in cu_raddr;
  84. int cu_rlen;
  85. struct timeval cu_wait;
  86. struct timeval cu_total;
  87. struct rpc_err cu_error;
  88. XDR cu_outxdrs;
  89. u_int cu_xdrpos;
  90. u_int cu_sendsz;
  91. char *cu_outbuf;
  92. u_int cu_recvsz;
  93. char cu_inbuf[1];
  94. };
  95. /*
  96. * Create a UDP based client handle.
  97. * If *sockp<0, *sockp is set to a newly created UPD socket.
  98. * If raddr->sin_port is 0 a binder on the remote machine
  99. * is consulted for the correct port number.
  100. * NB: It is the clients responsibility to close *sockp.
  101. * NB: The rpch->cl_auth is initialized to null authentication.
  102. * Caller may wish to set this something more useful.
  103. *
  104. * wait is the amount of time used between retransmitting a call if
  105. * no response has been heard; retransmission occurs until the actual
  106. * rpc call times out.
  107. *
  108. * sendsz and recvsz are the maximum allowable packet sizes that can be
  109. * sent and received.
  110. */
  111. CLIENT *
  112. clntudp_bufcreate (struct sockaddr_in *raddr, u_long program, u_long version,
  113. struct timeval wait, int *sockp, u_int sendsz,
  114. u_int recvsz)
  115. {
  116. CLIENT *cl;
  117. struct cu_data *cu = NULL;
  118. struct rpc_msg call_msg;
  119. cl = (CLIENT *) mem_alloc (sizeof (CLIENT));
  120. sendsz = ((sendsz + 3) / 4) * 4;
  121. recvsz = ((recvsz + 3) / 4) * 4;
  122. cu = (struct cu_data *) mem_alloc (sizeof (*cu) + sendsz + recvsz);
  123. if (cl == NULL || cu == NULL)
  124. {
  125. struct rpc_createerr *ce = &get_rpc_createerr ();
  126. #ifdef USE_IN_LIBIO
  127. if (_IO_fwide (stderr, 0) > 0)
  128. (void) fwprintf (stderr, L"%s",
  129. _("clntudp_create: out of memory\n"));
  130. else
  131. #endif
  132. (void) fputs (_("clntudp_create: out of memory\n"), stderr);
  133. ce->cf_stat = RPC_SYSTEMERROR;
  134. ce->cf_error.re_errno = ENOMEM;
  135. goto fooy;
  136. }
  137. cu->cu_outbuf = &cu->cu_inbuf[recvsz];
  138. if (raddr->sin_port == 0)
  139. {
  140. u_short port;
  141. if ((port =
  142. pmap_getport (raddr, program, version, IPPROTO_UDP)) == 0)
  143. {
  144. goto fooy;
  145. }
  146. raddr->sin_port = htons (port);
  147. }
  148. cl->cl_ops = &udp_ops;
  149. cl->cl_private = (caddr_t) cu;
  150. cu->cu_raddr = *raddr;
  151. cu->cu_rlen = sizeof (cu->cu_raddr);
  152. cu->cu_wait = wait;
  153. cu->cu_total.tv_sec = -1;
  154. cu->cu_total.tv_usec = -1;
  155. cu->cu_sendsz = sendsz;
  156. cu->cu_recvsz = recvsz;
  157. call_msg.rm_xid = _create_xid ();
  158. call_msg.rm_direction = CALL;
  159. call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
  160. call_msg.rm_call.cb_prog = program;
  161. call_msg.rm_call.cb_vers = version;
  162. xdrmem_create (&(cu->cu_outxdrs), cu->cu_outbuf,
  163. sendsz, XDR_ENCODE);
  164. if (!xdr_callhdr (&(cu->cu_outxdrs), &call_msg))
  165. {
  166. goto fooy;
  167. }
  168. cu->cu_xdrpos = XDR_GETPOS (&(cu->cu_outxdrs));
  169. if (*sockp < 0)
  170. {
  171. int dontblock = 1;
  172. *sockp = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
  173. if (*sockp < 0)
  174. {
  175. struct rpc_createerr *ce = &get_rpc_createerr ();
  176. ce->cf_stat = RPC_SYSTEMERROR;
  177. ce->cf_error.re_errno = errno;
  178. goto fooy;
  179. }
  180. /* attempt to bind to prov port */
  181. (void) bindresvport (*sockp, (struct sockaddr_in *) 0);
  182. /* the sockets rpc controls are non-blocking */
  183. (void) ioctl (*sockp, FIONBIO, (char *) &dontblock);
  184. #ifdef IP_RECVERR
  185. {
  186. int on = 1;
  187. setsockopt(*sockp, SOL_IP, IP_RECVERR, &on, sizeof(on));
  188. }
  189. #endif
  190. cu->cu_closeit = TRUE;
  191. }
  192. else
  193. {
  194. cu->cu_closeit = FALSE;
  195. }
  196. cu->cu_sock = *sockp;
  197. cl->cl_auth = authnone_create ();
  198. return cl;
  199. fooy:
  200. if (cu)
  201. mem_free ((caddr_t) cu, sizeof (*cu) + sendsz + recvsz);
  202. if (cl)
  203. mem_free ((caddr_t) cl, sizeof (CLIENT));
  204. return (CLIENT *) NULL;
  205. }
  206. libc_hidden_def(clntudp_bufcreate)
  207. CLIENT *
  208. clntudp_create (struct sockaddr_in *raddr, u_long program, u_long version, struct timeval wait, int *sockp)
  209. {
  210. return clntudp_bufcreate (raddr, program, version, wait, sockp,
  211. UDPMSGSIZE, UDPMSGSIZE);
  212. }
  213. libc_hidden_def(clntudp_create)
  214. static int
  215. is_network_up (int sock)
  216. {
  217. struct ifconf ifc;
  218. char buf[UDPMSGSIZE];
  219. struct ifreq ifreq, *ifr;
  220. int n;
  221. ifc.ifc_len = sizeof (buf);
  222. ifc.ifc_buf = buf;
  223. if (ioctl(sock, SIOCGIFCONF, (char *) &ifc) == 0)
  224. {
  225. ifr = ifc.ifc_req;
  226. for (n = ifc.ifc_len / sizeof (struct ifreq); n > 0; n--, ifr++)
  227. {
  228. ifreq = *ifr;
  229. if (ioctl (sock, SIOCGIFFLAGS, (char *) &ifreq) < 0)
  230. break;
  231. if ((ifreq.ifr_flags & IFF_UP)
  232. && ifr->ifr_addr.sa_family == AF_INET)
  233. return 1;
  234. }
  235. }
  236. return 0;
  237. }
  238. static enum clnt_stat
  239. clntudp_call (
  240. CLIENT *cl, /* client handle */
  241. u_long proc, /* procedure number */
  242. xdrproc_t xargs, /* xdr routine for args */
  243. caddr_t argsp, /* pointer to args */
  244. xdrproc_t xresults, /* xdr routine for results */
  245. caddr_t resultsp, /* pointer to results */
  246. struct timeval utimeout /* seconds to wait before giving up */)
  247. {
  248. struct cu_data *cu = (struct cu_data *) cl->cl_private;
  249. XDR *xdrs;
  250. int outlen = 0;
  251. int inlen;
  252. socklen_t fromlen;
  253. struct pollfd fd;
  254. int milliseconds = (cu->cu_wait.tv_sec * 1000) +
  255. (cu->cu_wait.tv_usec / 1000);
  256. struct sockaddr_in from;
  257. struct rpc_msg reply_msg;
  258. XDR reply_xdrs;
  259. struct timeval time_waited;
  260. bool_t ok;
  261. int nrefreshes = 2; /* number of times to refresh cred */
  262. struct timeval timeout;
  263. int anyup; /* any network interface up */
  264. if (cu->cu_total.tv_usec == -1)
  265. {
  266. timeout = utimeout; /* use supplied timeout */
  267. }
  268. else
  269. {
  270. timeout = cu->cu_total; /* use default timeout */
  271. }
  272. time_waited.tv_sec = 0;
  273. time_waited.tv_usec = 0;
  274. call_again:
  275. xdrs = &(cu->cu_outxdrs);
  276. if (xargs == NULL)
  277. goto get_reply;
  278. xdrs->x_op = XDR_ENCODE;
  279. XDR_SETPOS (xdrs, cu->cu_xdrpos);
  280. /*
  281. * the transaction is the first thing in the out buffer
  282. */
  283. (*(uint32_t *) (cu->cu_outbuf))++;
  284. if ((!XDR_PUTLONG (xdrs, (long *) &proc)) ||
  285. (!AUTH_MARSHALL (cl->cl_auth, xdrs)) ||
  286. (!(*xargs) (xdrs, argsp)))
  287. return (cu->cu_error.re_status = RPC_CANTENCODEARGS);
  288. outlen = (int) XDR_GETPOS (xdrs);
  289. send_again:
  290. if (sendto (cu->cu_sock, cu->cu_outbuf, outlen, 0,
  291. (struct sockaddr *) &(cu->cu_raddr), cu->cu_rlen)
  292. != outlen)
  293. {
  294. cu->cu_error.re_errno = errno;
  295. return (cu->cu_error.re_status = RPC_CANTSEND);
  296. }
  297. /*
  298. * Hack to provide rpc-based message passing
  299. */
  300. if (timeout.tv_sec == 0 && timeout.tv_usec == 0)
  301. {
  302. return (cu->cu_error.re_status = RPC_TIMEDOUT);
  303. }
  304. get_reply:
  305. /*
  306. * sub-optimal code appears here because we have
  307. * some clock time to spare while the packets are in flight.
  308. * (We assume that this is actually only executed once.)
  309. */
  310. reply_msg.acpted_rply.ar_verf = _null_auth;
  311. reply_msg.acpted_rply.ar_results.where = resultsp;
  312. reply_msg.acpted_rply.ar_results.proc = xresults;
  313. fd.fd = cu->cu_sock;
  314. fd.events = POLLIN;
  315. anyup = 0;
  316. for (;;)
  317. {
  318. switch (poll (&fd, 1, milliseconds))
  319. {
  320. case 0:
  321. if (anyup == 0)
  322. {
  323. anyup = is_network_up (cu->cu_sock);
  324. if (!anyup)
  325. return (cu->cu_error.re_status = RPC_CANTRECV);
  326. }
  327. time_waited.tv_sec += cu->cu_wait.tv_sec;
  328. time_waited.tv_usec += cu->cu_wait.tv_usec;
  329. while (time_waited.tv_usec >= 1000000)
  330. {
  331. time_waited.tv_sec++;
  332. time_waited.tv_usec -= 1000000;
  333. }
  334. if ((time_waited.tv_sec < timeout.tv_sec) ||
  335. ((time_waited.tv_sec == timeout.tv_sec) &&
  336. (time_waited.tv_usec < timeout.tv_usec)))
  337. goto send_again;
  338. return (cu->cu_error.re_status = RPC_TIMEDOUT);
  339. /*
  340. * buggy in other cases because time_waited is not being
  341. * updated.
  342. */
  343. case -1:
  344. if (errno == EINTR)
  345. continue;
  346. cu->cu_error.re_errno = errno;
  347. return (cu->cu_error.re_status = RPC_CANTRECV);
  348. }
  349. #ifdef IP_RECVERR
  350. if (fd.revents & POLLERR)
  351. {
  352. struct msghdr msg;
  353. struct cmsghdr *cmsg;
  354. struct sock_extended_err *e;
  355. struct sockaddr_in err_addr;
  356. struct iovec iov;
  357. char *cbuf = (char *) alloca (outlen + 256);
  358. int ret;
  359. iov.iov_base = cbuf + 256;
  360. iov.iov_len = outlen;
  361. msg.msg_name = (void *) &err_addr;
  362. msg.msg_namelen = sizeof (err_addr);
  363. msg.msg_iov = &iov;
  364. msg.msg_iovlen = 1;
  365. msg.msg_flags = 0;
  366. msg.msg_control = cbuf;
  367. msg.msg_controllen = 256;
  368. ret = recvmsg (cu->cu_sock, &msg, MSG_ERRQUEUE);
  369. if (ret >= 0
  370. && memcmp (cbuf + 256, cu->cu_outbuf, ret) == 0
  371. && (msg.msg_flags & MSG_ERRQUEUE)
  372. && ((msg.msg_namelen == 0
  373. && ret >= 12)
  374. || (msg.msg_namelen == sizeof (err_addr)
  375. && err_addr.sin_family == AF_INET
  376. && memcmp (&err_addr.sin_addr, &cu->cu_raddr.sin_addr,
  377. sizeof (err_addr.sin_addr)) == 0
  378. && err_addr.sin_port == cu->cu_raddr.sin_port)))
  379. for (cmsg = CMSG_FIRSTHDR (&msg); cmsg;
  380. cmsg = CMSG_NXTHDR (&msg, cmsg))
  381. if (cmsg->cmsg_level == SOL_IP && cmsg->cmsg_type == IP_RECVERR)
  382. {
  383. e = (struct sock_extended_err *) CMSG_DATA(cmsg);
  384. cu->cu_error.re_errno = e->ee_errno;
  385. return (cu->cu_error.re_status = RPC_CANTRECV);
  386. }
  387. }
  388. #endif
  389. do
  390. {
  391. fromlen = sizeof (struct sockaddr);
  392. inlen = recvfrom (cu->cu_sock, cu->cu_inbuf,
  393. (int) cu->cu_recvsz, 0,
  394. (struct sockaddr *) &from, &fromlen);
  395. }
  396. while (inlen < 0 && errno == EINTR);
  397. if (inlen < 0)
  398. {
  399. if (errno == EWOULDBLOCK)
  400. continue;
  401. cu->cu_error.re_errno = errno;
  402. return (cu->cu_error.re_status = RPC_CANTRECV);
  403. }
  404. if (inlen < 4)
  405. continue;
  406. /* see if reply transaction id matches sent id.
  407. Don't do this if we only wait for a replay */
  408. if (xargs != NULL
  409. && (*((u_int32_t *) (cu->cu_inbuf))
  410. != *((u_int32_t *) (cu->cu_outbuf))))
  411. continue;
  412. /* we now assume we have the proper reply */
  413. break;
  414. }
  415. /*
  416. * now decode and validate the response
  417. */
  418. xdrmem_create (&reply_xdrs, cu->cu_inbuf, (u_int) inlen, XDR_DECODE);
  419. ok = xdr_replymsg (&reply_xdrs, &reply_msg);
  420. /* XDR_DESTROY(&reply_xdrs); save a few cycles on noop destroy */
  421. if (ok)
  422. {
  423. _seterr_reply (&reply_msg, &(cu->cu_error));
  424. if (cu->cu_error.re_status == RPC_SUCCESS)
  425. {
  426. if (!AUTH_VALIDATE (cl->cl_auth,
  427. &reply_msg.acpted_rply.ar_verf))
  428. {
  429. cu->cu_error.re_status = RPC_AUTHERROR;
  430. cu->cu_error.re_why = AUTH_INVALIDRESP;
  431. }
  432. if (reply_msg.acpted_rply.ar_verf.oa_base != NULL)
  433. {
  434. xdrs->x_op = XDR_FREE;
  435. (void) xdr_opaque_auth (xdrs,
  436. &(reply_msg.acpted_rply.ar_verf));
  437. }
  438. } /* end successful completion */
  439. else
  440. {
  441. /* maybe our credentials need to be refreshed ... */
  442. if (nrefreshes > 0 && AUTH_REFRESH (cl->cl_auth))
  443. {
  444. nrefreshes--;
  445. goto call_again;
  446. }
  447. } /* end of unsuccessful completion */
  448. } /* end of valid reply message */
  449. else
  450. {
  451. cu->cu_error.re_status = RPC_CANTDECODERES;
  452. }
  453. return cu->cu_error.re_status;
  454. }
  455. static void
  456. clntudp_geterr (CLIENT *cl, struct rpc_err *errp)
  457. {
  458. struct cu_data *cu = (struct cu_data *) cl->cl_private;
  459. *errp = cu->cu_error;
  460. }
  461. static bool_t
  462. clntudp_freeres (CLIENT *cl, xdrproc_t xdr_res, caddr_t res_ptr)
  463. {
  464. struct cu_data *cu = (struct cu_data *) cl->cl_private;
  465. XDR *xdrs = &(cu->cu_outxdrs);
  466. xdrs->x_op = XDR_FREE;
  467. return (*xdr_res) (xdrs, res_ptr);
  468. }
  469. static void
  470. clntudp_abort (void)
  471. {
  472. }
  473. static bool_t
  474. clntudp_control (CLIENT *cl, int request, char *info)
  475. {
  476. struct cu_data *cu = (struct cu_data *) cl->cl_private;
  477. switch (request)
  478. {
  479. case CLSET_FD_CLOSE:
  480. cu->cu_closeit = TRUE;
  481. break;
  482. case CLSET_FD_NCLOSE:
  483. cu->cu_closeit = FALSE;
  484. break;
  485. case CLSET_TIMEOUT:
  486. cu->cu_total = *(struct timeval *) info;
  487. break;
  488. case CLGET_TIMEOUT:
  489. *(struct timeval *) info = cu->cu_total;
  490. break;
  491. case CLSET_RETRY_TIMEOUT:
  492. cu->cu_wait = *(struct timeval *) info;
  493. break;
  494. case CLGET_RETRY_TIMEOUT:
  495. *(struct timeval *) info = cu->cu_wait;
  496. break;
  497. case CLGET_SERVER_ADDR:
  498. *(struct sockaddr_in *) info = cu->cu_raddr;
  499. break;
  500. case CLGET_FD:
  501. *(int *)info = cu->cu_sock;
  502. break;
  503. case CLGET_XID:
  504. /*
  505. * use the knowledge that xid is the
  506. * first element in the call structure *.
  507. * This will get the xid of the PREVIOUS call
  508. */
  509. *(u_long *)info = ntohl(*(u_long *)cu->cu_outbuf);
  510. break;
  511. case CLSET_XID:
  512. /* This will set the xid of the NEXT call */
  513. *(u_long *)cu->cu_outbuf = htonl(*(u_long *)info - 1);
  514. /* decrement by 1 as clntudp_call() increments once */
  515. break;
  516. case CLGET_VERS:
  517. /*
  518. * This RELIES on the information that, in the call body,
  519. * the version number field is the fifth field from the
  520. * begining of the RPC header. MUST be changed if the
  521. * call_struct is changed
  522. */
  523. *(u_long *)info = ntohl(*(u_long *)(cu->cu_outbuf +
  524. 4 * BYTES_PER_XDR_UNIT));
  525. break;
  526. case CLSET_VERS:
  527. *(u_long *)(cu->cu_outbuf + 4 * BYTES_PER_XDR_UNIT)
  528. = htonl(*(u_long *)info);
  529. break;
  530. case CLGET_PROG:
  531. /*
  532. * This RELIES on the information that, in the call body,
  533. * the program number field is the field from the
  534. * begining of the RPC header. MUST be changed if the
  535. * call_struct is changed
  536. */
  537. *(u_long *)info = ntohl(*(u_long *)(cu->cu_outbuf +
  538. 3 * BYTES_PER_XDR_UNIT));
  539. break;
  540. case CLSET_PROG:
  541. *(u_long *)(cu->cu_outbuf + 3 * BYTES_PER_XDR_UNIT)
  542. = htonl(*(u_long *)info);
  543. break;
  544. /* The following are only possible with TI-RPC */
  545. case CLGET_SVC_ADDR:
  546. case CLSET_SVC_ADDR:
  547. case CLSET_PUSH_TIMOD:
  548. case CLSET_POP_TIMOD:
  549. default:
  550. return FALSE;
  551. }
  552. return TRUE;
  553. }
  554. static void
  555. clntudp_destroy (CLIENT *cl)
  556. {
  557. struct cu_data *cu = (struct cu_data *) cl->cl_private;
  558. if (cu->cu_closeit)
  559. {
  560. (void) close (cu->cu_sock);
  561. }
  562. XDR_DESTROY (&(cu->cu_outxdrs));
  563. mem_free ((caddr_t) cu, (sizeof (*cu) + cu->cu_sendsz + cu->cu_recvsz));
  564. mem_free ((caddr_t) cl, sizeof (CLIENT));
  565. }