clnt_udp.c 16 KB

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