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