Back to index

glibc  2.9
clnt_udp.c
Go to the documentation of this file.
00001 /* @(#)clnt_udp.c    2.2 88/08/01 4.0 RPCSRC */
00002 /*
00003  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
00004  * unrestricted use provided that this legend is included on all tape
00005  * media and as a part of the software program in whole or part.  Users
00006  * may copy or modify Sun RPC without charge, but are not authorized
00007  * to license or distribute it to anyone else except as part of a product or
00008  * program developed by the user.
00009  *
00010  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
00011  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
00012  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
00013  *
00014  * Sun RPC is provided with no support and without any obligation on the
00015  * part of Sun Microsystems, Inc. to assist in its use, correction,
00016  * modification or enhancement.
00017  *
00018  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
00019  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
00020  * OR ANY PART THEREOF.
00021  *
00022  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
00023  * or profits or other special, indirect and consequential damages, even if
00024  * Sun has been advised of the possibility of such damages.
00025  *
00026  * Sun Microsystems, Inc.
00027  * 2550 Garcia Avenue
00028  * Mountain View, California  94043
00029  */
00030 #if !defined(lint) && defined(SCCSIDS)
00031 static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro";
00032 #endif
00033 
00034 /*
00035  * clnt_udp.c, Implements a UDP/IP based, client side RPC.
00036  *
00037  * Copyright (C) 1984, Sun Microsystems, Inc.
00038  */
00039 
00040 #include <stdio.h>
00041 #include <unistd.h>
00042 #include <libintl.h>
00043 #include <rpc/rpc.h>
00044 #include <rpc/xdr.h>
00045 #include <rpc/clnt.h>
00046 #include <sys/poll.h>
00047 #include <sys/socket.h>
00048 #include <sys/ioctl.h>
00049 #include <netdb.h>
00050 #include <errno.h>
00051 #include <rpc/pmap_clnt.h>
00052 #include <net/if.h>
00053 #include <ifaddrs.h>
00054 #ifdef USE_IN_LIBIO
00055 # include <wchar.h>
00056 #endif
00057 #include <fcntl.h>
00058 
00059 #ifdef IP_RECVERR
00060 #include <errqueue.h>
00061 #include <sys/uio.h>
00062 #endif
00063 
00064 #include <kernel-features.h>
00065 
00066 extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *);
00067 extern u_long _create_xid (void);
00068 
00069 /*
00070  * UDP bases client side rpc operations
00071  */
00072 static enum clnt_stat clntudp_call (CLIENT *, u_long, xdrproc_t, caddr_t,
00073                                 xdrproc_t, caddr_t, struct timeval);
00074 static void clntudp_abort (void);
00075 static void clntudp_geterr (CLIENT *, struct rpc_err *);
00076 static bool_t clntudp_freeres (CLIENT *, xdrproc_t, caddr_t);
00077 static bool_t clntudp_control (CLIENT *, int, char *);
00078 static void clntudp_destroy (CLIENT *);
00079 
00080 static const struct clnt_ops udp_ops =
00081 {
00082   clntudp_call,
00083   clntudp_abort,
00084   clntudp_geterr,
00085   clntudp_freeres,
00086   clntudp_destroy,
00087   clntudp_control
00088 };
00089 
00090 /*
00091  * Private data kept per client handle
00092  */
00093 struct cu_data
00094   {
00095     int cu_sock;
00096     bool_t cu_closeit;
00097     struct sockaddr_in cu_raddr;
00098     int cu_rlen;
00099     struct timeval cu_wait;
00100     struct timeval cu_total;
00101     struct rpc_err cu_error;
00102     XDR cu_outxdrs;
00103     u_int cu_xdrpos;
00104     u_int cu_sendsz;
00105     char *cu_outbuf;
00106     u_int cu_recvsz;
00107     char cu_inbuf[1];
00108   };
00109 
00110 /*
00111  * Create a UDP based client handle.
00112  * If *sockp<0, *sockp is set to a newly created UPD socket.
00113  * If raddr->sin_port is 0 a binder on the remote machine
00114  * is consulted for the correct port number.
00115  * NB: It is the clients responsibility to close *sockp.
00116  * NB: The rpch->cl_auth is initialized to null authentication.
00117  *     Caller may wish to set this something more useful.
00118  *
00119  * wait is the amount of time used between retransmitting a call if
00120  * no response has been heard; retransmission occurs until the actual
00121  * rpc call times out.
00122  *
00123  * sendsz and recvsz are the maximum allowable packet sizes that can be
00124  * sent and received.
00125  */
00126 CLIENT *
00127 __libc_clntudp_bufcreate (struct sockaddr_in *raddr, u_long program,
00128                        u_long version, struct timeval wait, int *sockp,
00129                        u_int sendsz, u_int recvsz, int flags)
00130 {
00131   CLIENT *cl;
00132   struct cu_data *cu = NULL;
00133   struct rpc_msg call_msg;
00134 
00135   cl = (CLIENT *) mem_alloc (sizeof (CLIENT));
00136   sendsz = ((sendsz + 3) / 4) * 4;
00137   recvsz = ((recvsz + 3) / 4) * 4;
00138   cu = (struct cu_data *) mem_alloc (sizeof (*cu) + sendsz + recvsz);
00139   if (cl == NULL || cu == NULL)
00140     {
00141       struct rpc_createerr *ce = &get_rpc_createerr ();
00142       (void) __fxprintf (NULL, "%s: %s",
00143                       "clntudp_create", _("out of memory\n"));
00144       ce->cf_stat = RPC_SYSTEMERROR;
00145       ce->cf_error.re_errno = ENOMEM;
00146       goto fooy;
00147     }
00148   cu->cu_outbuf = &cu->cu_inbuf[recvsz];
00149 
00150   if (raddr->sin_port == 0)
00151     {
00152       u_short port;
00153       if ((port =
00154           pmap_getport (raddr, program, version, IPPROTO_UDP)) == 0)
00155        {
00156          goto fooy;
00157        }
00158       raddr->sin_port = htons (port);
00159     }
00160   cl->cl_ops = (struct clnt_ops *) &udp_ops;
00161   cl->cl_private = (caddr_t) cu;
00162   cu->cu_raddr = *raddr;
00163   cu->cu_rlen = sizeof (cu->cu_raddr);
00164   cu->cu_wait = wait;
00165   cu->cu_total.tv_sec = -1;
00166   cu->cu_total.tv_usec = -1;
00167   cu->cu_sendsz = sendsz;
00168   cu->cu_recvsz = recvsz;
00169   call_msg.rm_xid = _create_xid ();
00170   call_msg.rm_direction = CALL;
00171   call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
00172   call_msg.rm_call.cb_prog = program;
00173   call_msg.rm_call.cb_vers = version;
00174   INTUSE(xdrmem_create) (&(cu->cu_outxdrs), cu->cu_outbuf, sendsz, XDR_ENCODE);
00175   if (!INTUSE(xdr_callhdr) (&(cu->cu_outxdrs), &call_msg))
00176     {
00177       goto fooy;
00178     }
00179   cu->cu_xdrpos = XDR_GETPOS (&(cu->cu_outxdrs));
00180   if (*sockp < 0)
00181     {
00182       int dontblock = 1;
00183 
00184 #ifdef SOCK_NONBLOCK
00185 # ifndef __ASSUME_SOCK_CLOEXEC
00186       if (__have_sock_cloexec >= 0)
00187 # endif
00188        {
00189          *sockp = __socket (AF_INET, SOCK_DGRAM|SOCK_NONBLOCK|flags,
00190                           IPPROTO_UDP);
00191 # ifndef __ASSUME_SOCK_CLOEXEC
00192          if (__have_sock_cloexec == 0)
00193            __have_sock_cloexec = *sockp >= 0 || errno != EINVAL ? 1 : -1;
00194 # endif
00195        }
00196 #endif
00197 #ifndef __ASSUME_SOCK_CLOEXEC
00198 # ifdef SOCK_CLOEXEC
00199       if (__have_sock_cloexec < 0)
00200 # endif
00201        {
00202          *sockp = __socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
00203 # ifdef SOCK_CLOEXEC
00204          if (flags & SOCK_CLOEXEC)
00205            __fcntl (*sockp, F_SETFD, FD_CLOEXEC);
00206 # endif
00207        }
00208 #endif
00209       if (__builtin_expect (*sockp < 0, 0))
00210        {
00211          struct rpc_createerr *ce = &get_rpc_createerr ();
00212          ce->cf_stat = RPC_SYSTEMERROR;
00213          ce->cf_error.re_errno = errno;
00214          goto fooy;
00215        }
00216       /* attempt to bind to prov port */
00217       (void) bindresvport (*sockp, (struct sockaddr_in *) 0);
00218 #ifndef __ASSUME_SOCK_CLOEXEC
00219 # ifdef SOCK_CLOEXEC
00220       if (__have_sock_cloexec < 0)
00221 # endif
00222        /* the sockets rpc controls are non-blocking */
00223        (void) __ioctl (*sockp, FIONBIO, (char *) &dontblock);
00224 #endif
00225 #ifdef IP_RECVERR
00226       {
00227        int on = 1;
00228        __setsockopt (*sockp, SOL_IP, IP_RECVERR, &on, sizeof(on));
00229       }
00230 #endif
00231       cu->cu_closeit = TRUE;
00232     }
00233   else
00234     {
00235       cu->cu_closeit = FALSE;
00236     }
00237   cu->cu_sock = *sockp;
00238   cl->cl_auth = INTUSE(authnone_create) ();
00239   return cl;
00240 fooy:
00241   if (cu)
00242     mem_free ((caddr_t) cu, sizeof (*cu) + sendsz + recvsz);
00243   if (cl)
00244     mem_free ((caddr_t) cl, sizeof (CLIENT));
00245   return (CLIENT *) NULL;
00246 }
00247 INTDEF (__libc_clntudp_bufcreate)
00248 
00249 CLIENT *
00250 clntudp_bufcreate (struct sockaddr_in *raddr, u_long program, u_long version,
00251                  struct timeval wait, int *sockp, u_int sendsz,
00252                  u_int recvsz)
00253 {
00254   return INTUSE(__libc_clntudp_bufcreate) (raddr, program, version, wait,
00255                                       sockp, sendsz, recvsz, 0);
00256 }
00257 INTDEF (clntudp_bufcreate)
00258 
00259 CLIENT *
00260 clntudp_create (raddr, program, version, wait, sockp)
00261      struct sockaddr_in *raddr;
00262      u_long program;
00263      u_long version;
00264      struct timeval wait;
00265      int *sockp;
00266 {
00267   return INTUSE(__libc_clntudp_bufcreate) (raddr, program, version, wait,
00268                                       sockp, UDPMSGSIZE, UDPMSGSIZE, 0);
00269 }
00270 INTDEF (clntudp_create)
00271 
00272 static int
00273 is_network_up (int sock)
00274 {
00275   struct ifaddrs *ifa;
00276 
00277   if (getifaddrs (&ifa) != 0)
00278     return 0;
00279 
00280   struct ifaddrs *run = ifa;
00281   while (run != NULL)
00282     {
00283       if ((run->ifa_flags & IFF_UP) != 0
00284          && run->ifa_addr != NULL
00285          && run->ifa_addr->sa_family == AF_INET)
00286        break;
00287 
00288       run = run->ifa_next;
00289     }
00290 
00291   freeifaddrs (ifa);
00292 
00293   return run != NULL;
00294 }
00295 
00296 static enum clnt_stat
00297 clntudp_call (cl, proc, xargs, argsp, xresults, resultsp, utimeout)
00298      CLIENT *cl;     /* client handle */
00299      u_long proc;           /* procedure number */
00300      xdrproc_t xargs;              /* xdr routine for args */
00301      caddr_t argsp;         /* pointer to args */
00302      xdrproc_t xresults;    /* xdr routine for results */
00303      caddr_t resultsp;             /* pointer to results */
00304      struct timeval utimeout;      /* seconds to wait before giving up */
00305 {
00306   struct cu_data *cu = (struct cu_data *) cl->cl_private;
00307   XDR *xdrs;
00308   int outlen = 0;
00309   int inlen;
00310   socklen_t fromlen;
00311   struct pollfd fd;
00312   int milliseconds = (cu->cu_wait.tv_sec * 1000) +
00313     (cu->cu_wait.tv_usec / 1000);
00314   struct sockaddr_in from;
00315   struct rpc_msg reply_msg;
00316   XDR reply_xdrs;
00317   struct timeval time_waited;
00318   bool_t ok;
00319   int nrefreshes = 2;              /* number of times to refresh cred */
00320   struct timeval timeout;
00321   int anyup;                /* any network interface up */
00322 
00323   if (cu->cu_total.tv_usec == -1)
00324     {
00325       timeout = utimeout;   /* use supplied timeout */
00326     }
00327   else
00328     {
00329       timeout = cu->cu_total;      /* use default timeout */
00330     }
00331 
00332   time_waited.tv_sec = 0;
00333   time_waited.tv_usec = 0;
00334 call_again:
00335   xdrs = &(cu->cu_outxdrs);
00336   if (xargs == NULL)
00337     goto get_reply;
00338   xdrs->x_op = XDR_ENCODE;
00339   XDR_SETPOS (xdrs, cu->cu_xdrpos);
00340   /*
00341    * the transaction is the first thing in the out buffer
00342    */
00343   (*(uint32_t *) (cu->cu_outbuf))++;
00344   if ((!XDR_PUTLONG (xdrs, (long *) &proc)) ||
00345       (!AUTH_MARSHALL (cl->cl_auth, xdrs)) ||
00346       (!(*xargs) (xdrs, argsp)))
00347     return (cu->cu_error.re_status = RPC_CANTENCODEARGS);
00348   outlen = (int) XDR_GETPOS (xdrs);
00349 
00350 send_again:
00351   if (__sendto (cu->cu_sock, cu->cu_outbuf, outlen, 0,
00352               (struct sockaddr *) &(cu->cu_raddr), cu->cu_rlen)
00353       != outlen)
00354     {
00355       cu->cu_error.re_errno = errno;
00356       return (cu->cu_error.re_status = RPC_CANTSEND);
00357     }
00358 
00359   /*
00360    * Hack to provide rpc-based message passing
00361    */
00362   if (timeout.tv_sec == 0 && timeout.tv_usec == 0)
00363     {
00364       return (cu->cu_error.re_status = RPC_TIMEDOUT);
00365     }
00366  get_reply:
00367   /*
00368    * sub-optimal code appears here because we have
00369    * some clock time to spare while the packets are in flight.
00370    * (We assume that this is actually only executed once.)
00371    */
00372   reply_msg.acpted_rply.ar_verf = _null_auth;
00373   reply_msg.acpted_rply.ar_results.where = resultsp;
00374   reply_msg.acpted_rply.ar_results.proc = xresults;
00375   fd.fd = cu->cu_sock;
00376   fd.events = POLLIN;
00377   anyup = 0;
00378   for (;;)
00379     {
00380       switch (__poll (&fd, 1, milliseconds))
00381        {
00382 
00383        case 0:
00384          if (anyup == 0)
00385            {
00386              anyup = is_network_up (cu->cu_sock);
00387              if (!anyup)
00388               return (cu->cu_error.re_status = RPC_CANTRECV);
00389            }
00390 
00391          time_waited.tv_sec += cu->cu_wait.tv_sec;
00392          time_waited.tv_usec += cu->cu_wait.tv_usec;
00393          while (time_waited.tv_usec >= 1000000)
00394            {
00395              time_waited.tv_sec++;
00396              time_waited.tv_usec -= 1000000;
00397            }
00398          if ((time_waited.tv_sec < timeout.tv_sec) ||
00399              ((time_waited.tv_sec == timeout.tv_sec) &&
00400               (time_waited.tv_usec < timeout.tv_usec)))
00401            goto send_again;
00402          return (cu->cu_error.re_status = RPC_TIMEDOUT);
00403 
00404          /*
00405           * buggy in other cases because time_waited is not being
00406           * updated.
00407           */
00408        case -1:
00409          if (errno == EINTR)
00410            continue;
00411          cu->cu_error.re_errno = errno;
00412          return (cu->cu_error.re_status = RPC_CANTRECV);
00413        }
00414 #ifdef IP_RECVERR
00415       if (fd.revents & POLLERR)
00416        {
00417          struct msghdr msg;
00418          struct cmsghdr *cmsg;
00419          struct sock_extended_err *e;
00420          struct sockaddr_in err_addr;
00421          struct iovec iov;
00422          char *cbuf = (char *) alloca (outlen + 256);
00423          int ret;
00424 
00425          iov.iov_base = cbuf + 256;
00426          iov.iov_len = outlen;
00427          msg.msg_name = (void *) &err_addr;
00428          msg.msg_namelen = sizeof (err_addr);
00429          msg.msg_iov = &iov;
00430          msg.msg_iovlen = 1;
00431          msg.msg_flags = 0;
00432          msg.msg_control = cbuf;
00433          msg.msg_controllen = 256;
00434          ret = __recvmsg (cu->cu_sock, &msg, MSG_ERRQUEUE);
00435          if (ret >= 0
00436              && memcmp (cbuf + 256, cu->cu_outbuf, ret) == 0
00437              && (msg.msg_flags & MSG_ERRQUEUE)
00438              && ((msg.msg_namelen == 0
00439                  && ret >= 12)
00440                 || (msg.msg_namelen == sizeof (err_addr)
00441                     && err_addr.sin_family == AF_INET
00442                     && memcmp (&err_addr.sin_addr, &cu->cu_raddr.sin_addr,
00443                              sizeof (err_addr.sin_addr)) == 0
00444                     && err_addr.sin_port == cu->cu_raddr.sin_port)))
00445            for (cmsg = CMSG_FIRSTHDR (&msg); cmsg;
00446                cmsg = CMSG_NXTHDR (&msg, cmsg))
00447              if (cmsg->cmsg_level == SOL_IP && cmsg->cmsg_type == IP_RECVERR)
00448               {
00449                 e = (struct sock_extended_err *) CMSG_DATA(cmsg);
00450                 cu->cu_error.re_errno = e->ee_errno;
00451                 return (cu->cu_error.re_status = RPC_CANTRECV);
00452               }
00453        }
00454 #endif
00455       do
00456        {
00457          fromlen = sizeof (struct sockaddr);
00458          inlen = __recvfrom (cu->cu_sock, cu->cu_inbuf,
00459                            (int) cu->cu_recvsz, MSG_DONTWAIT,
00460                            (struct sockaddr *) &from, &fromlen);
00461        }
00462       while (inlen < 0 && errno == EINTR);
00463       if (inlen < 0)
00464        {
00465          if (errno == EWOULDBLOCK)
00466            continue;
00467          cu->cu_error.re_errno = errno;
00468          return (cu->cu_error.re_status = RPC_CANTRECV);
00469        }
00470       if (inlen < 4)
00471        continue;
00472 
00473       /* see if reply transaction id matches sent id.
00474         Don't do this if we only wait for a replay */
00475       if (xargs != NULL
00476          && (*((u_int32_t *) (cu->cu_inbuf))
00477              != *((u_int32_t *) (cu->cu_outbuf))))
00478        continue;
00479       /* we now assume we have the proper reply */
00480       break;
00481     }
00482 
00483   /*
00484    * now decode and validate the response
00485    */
00486   INTUSE(xdrmem_create) (&reply_xdrs, cu->cu_inbuf, (u_int) inlen, XDR_DECODE);
00487   ok = INTUSE(xdr_replymsg) (&reply_xdrs, &reply_msg);
00488   /* XDR_DESTROY(&reply_xdrs);  save a few cycles on noop destroy */
00489   if (ok)
00490     {
00491       _seterr_reply (&reply_msg, &(cu->cu_error));
00492       if (cu->cu_error.re_status == RPC_SUCCESS)
00493        {
00494          if (!AUTH_VALIDATE (cl->cl_auth,
00495                            &reply_msg.acpted_rply.ar_verf))
00496            {
00497              cu->cu_error.re_status = RPC_AUTHERROR;
00498              cu->cu_error.re_why = AUTH_INVALIDRESP;
00499            }
00500          if (reply_msg.acpted_rply.ar_verf.oa_base != NULL)
00501            {
00502              xdrs->x_op = XDR_FREE;
00503              (void) INTUSE(xdr_opaque_auth) (xdrs,
00504                                          &(reply_msg.acpted_rply.ar_verf));
00505            }
00506        }                    /* end successful completion */
00507       else
00508        {
00509          /* maybe our credentials need to be refreshed ... */
00510          if (nrefreshes > 0 && AUTH_REFRESH (cl->cl_auth))
00511            {
00512              nrefreshes--;
00513              goto call_again;
00514            }
00515        }                    /* end of unsuccessful completion */
00516     }                       /* end of valid reply message */
00517   else
00518     {
00519       cu->cu_error.re_status = RPC_CANTDECODERES;
00520     }
00521   return cu->cu_error.re_status;
00522 }
00523 
00524 static void
00525 clntudp_geterr (CLIENT *cl, struct rpc_err *errp)
00526 {
00527   struct cu_data *cu = (struct cu_data *) cl->cl_private;
00528 
00529   *errp = cu->cu_error;
00530 }
00531 
00532 
00533 static bool_t
00534 clntudp_freeres (CLIENT *cl, xdrproc_t xdr_res, caddr_t res_ptr)
00535 {
00536   struct cu_data *cu = (struct cu_data *) cl->cl_private;
00537   XDR *xdrs = &(cu->cu_outxdrs);
00538 
00539   xdrs->x_op = XDR_FREE;
00540   return (*xdr_res) (xdrs, res_ptr);
00541 }
00542 
00543 static void
00544 clntudp_abort (void)
00545 {
00546 }
00547 
00548 static bool_t
00549 clntudp_control (CLIENT *cl, int request, char *info)
00550 {
00551   struct cu_data *cu = (struct cu_data *) cl->cl_private;
00552 
00553   switch (request)
00554     {
00555     case CLSET_FD_CLOSE:
00556       cu->cu_closeit = TRUE;
00557       break;
00558     case CLSET_FD_NCLOSE:
00559       cu->cu_closeit = FALSE;
00560       break;
00561     case CLSET_TIMEOUT:
00562       cu->cu_total = *(struct timeval *) info;
00563       break;
00564     case CLGET_TIMEOUT:
00565       *(struct timeval *) info = cu->cu_total;
00566       break;
00567     case CLSET_RETRY_TIMEOUT:
00568       cu->cu_wait = *(struct timeval *) info;
00569       break;
00570     case CLGET_RETRY_TIMEOUT:
00571       *(struct timeval *) info = cu->cu_wait;
00572       break;
00573     case CLGET_SERVER_ADDR:
00574       *(struct sockaddr_in *) info = cu->cu_raddr;
00575       break;
00576     case CLGET_FD:
00577       *(int *)info = cu->cu_sock;
00578       break;
00579     case CLGET_XID:
00580       /*
00581        * use the knowledge that xid is the
00582        * first element in the call structure *.
00583        * This will get the xid of the PREVIOUS call
00584        */
00585       *(u_long *)info = ntohl(*(u_long *)cu->cu_outbuf);
00586       break;
00587     case CLSET_XID:
00588       /* This will set the xid of the NEXT call */
00589       *(u_long *)cu->cu_outbuf =  htonl(*(u_long *)info - 1);
00590       /* decrement by 1 as clntudp_call() increments once */
00591     case CLGET_VERS:
00592       /*
00593        * This RELIES on the information that, in the call body,
00594        * the version number field is the fifth field from the
00595        * begining of the RPC header. MUST be changed if the
00596        * call_struct is changed
00597        */
00598       *(u_long *)info = ntohl(*(u_long *)(cu->cu_outbuf +
00599                                      4 * BYTES_PER_XDR_UNIT));
00600       break;
00601     case CLSET_VERS:
00602       *(u_long *)(cu->cu_outbuf + 4 * BYTES_PER_XDR_UNIT)
00603        = htonl(*(u_long *)info);
00604       break;
00605     case CLGET_PROG:
00606       /*
00607        * This RELIES on the information that, in the call body,
00608        * the program number field is the  field from the
00609        * begining of the RPC header. MUST be changed if the
00610        * call_struct is changed
00611        */
00612       *(u_long *)info = ntohl(*(u_long *)(cu->cu_outbuf +
00613                                      3 * BYTES_PER_XDR_UNIT));
00614       break;
00615     case CLSET_PROG:
00616       *(u_long *)(cu->cu_outbuf + 3 * BYTES_PER_XDR_UNIT)
00617        = htonl(*(u_long *)info);
00618       break;
00619     /* The following are only possible with TI-RPC */
00620     case CLGET_SVC_ADDR:
00621     case CLSET_SVC_ADDR:
00622     case CLSET_PUSH_TIMOD:
00623     case CLSET_POP_TIMOD:
00624     default:
00625       return FALSE;
00626     }
00627   return TRUE;
00628 }
00629 
00630 static void
00631 clntudp_destroy (CLIENT *cl)
00632 {
00633   struct cu_data *cu = (struct cu_data *) cl->cl_private;
00634 
00635   if (cu->cu_closeit)
00636     {
00637       (void) __close (cu->cu_sock);
00638     }
00639   XDR_DESTROY (&(cu->cu_outxdrs));
00640   mem_free ((caddr_t) cu, (sizeof (*cu) + cu->cu_sendsz + cu->cu_recvsz));
00641   mem_free ((caddr_t) cl, sizeof (CLIENT));
00642 }