/* * clnt_udp.c, Implements a UDP/IP based, client side RPC. * * Copyright (C) 1984, Sun Microsystems, Inc. */ #include #include #include #include #include #include #include #include static enum clnt_stat ClntUdp_send(cu, proc, xargs, argsp) struct cu_data *cu; u_long proc; /* procedure number */ xdrproc_t xargs; /* xdr routine for args */ caddr_t argsp; /* pointer to args */ { register XDR *xdrs; register int outlen; register int inlen; int Proc = proc; enum clnt_stat res; xdrs = &(cu->cu_outxdrs); xdrs->x_op = XDR_ENCODE; /* We place the encoding pointer after the constant buffer */ XDR_SETPOS(xdrs, cu->cu_xdrpos); /* * the transaction is the first thing in the out buffer */ (*(short *)(cu->cu_outbuf))++; if /* Then, we encode the procedure number */ ((! XDR_PUTLONG(xdrs, (long *)&Proc)) || /* now we encode parameters */ (! (*xargs)(xdrs, argsp)) ) { res = (cu->cu_error.re_status = RPC_CANTENCODEARGS); return res; } outlen = (int)XDR_GETPOS(xdrs); /* OS call for sending marshalled data */ if (sendto(cu->cu_sock, cu->cu_outbuf, outlen, 0, (struct sockaddr *)&(cu->cu_raddr), cu->cu_rlen) != outlen) { cu->cu_error.re_errno = errno; res = (cu->cu_error.re_status = RPC_CANTSEND); return res; } res = (cu->cu_error.re_status = RPC_SUCCESS); return res; }