clnt_udp.c 16 KB

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