clnt_udp.c 17 KB

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