clnt_udp.c 17 KB

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