/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1996 AT&T
* All Rights Reserved
*/
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* clnt_udp.c, Implements a UDP/IP based, client side RPC.
*/
#include <netdb.h>
#include <errno.h>
#include <rpc/pmap_clnt.h>
#include <rpc/clnt_soc.h>
#include <syslog.h>
#include <malloc.h>
#include <unistd.h>
#include <stropts.h>
#include <stdio.h>
extern int errno;
extern int _socket(int, int, int);
extern int bindresvport(int, struct sockaddr_in *);
extern int _sendto(int, const char *, int, int,
const struct sockaddr *, int);
extern int _recvfrom(int, char *, int, int,
struct sockaddr *, int *);
static struct clnt_ops *clntudp_ops();
/*
* Private data kept per client handle
*/
struct cu_data {
int cu_sock;
int cu_rlen;
char *cu_outbuf;
};
/*
* Create a UDP based client handle.
* If *sockp<0, *sockp is set to a newly created UPD socket.
* If raddr->sin_port is 0 a binder on the remote machine
* is consulted for the correct port number.
* NB: It is the clients responsibility to close *sockp.
* NB: The rpch->cl_auth is initialized to null authentication.
* Caller may wish to set this something more useful.
*
* wait is the amount of time used between retransmitting a call if
* no response has been heard; retransmition occurs until the actual
* rpc call times out.
*
* sendsz and recvsz are the maximum allowable packet sizes that can be
* sent and received.
*/
CLIENT *
struct sockaddr_in *raddr;
register int *sockp;
{
goto fooy;
}
goto fooy;
}
if ((port =
goto fooy;
}
}
sendsz, XDR_ENCODE);
goto fooy;
}
if (*sockp < 0) {
if (*sockp < 0) {
goto fooy;
}
/* attempt to bind to prov port */
/* the sockets rpc controls are non-blocking */
} else {
}
return (cl);
fooy:
if (cu)
if (cl)
}
CLIENT *
struct sockaddr_in *raddr;
register int *sockp;
{
UDPMSGSIZE, UDPMSGSIZE));
}
static enum clnt_stat
{
register int outlen;
register int inlen;
int fromlen;
} else {
}
time_waited.tv_sec = 0;
time_waited.tv_usec = 0;
/*
* the transaction is the first thing in the out buffer
*/
!= outlen) {
}
/*
* Hack to provide rpc-based message passing
*/
}
/*
* sub-optimal code appears here because we have
* some clock time to spare while the packets are in flight.
* (We assume that this is actually only executed once.)
*/
for (;;) {
NULL, &(retransmit_time))) {
case 0:
}
/* update retransmit_time */
}
}
goto send_again;
/*
* buggy in other cases because time_waited is not being
* updated.
*/
case -1:
}
/* interrupted by another signal, update time_waited */
if (firsttimeout) {
/*
* Could have done gettimeofday before clnt_call
* but that means 1 more system call per each
* clnt_call, so do it after first time out
*/
if (gettimeofday(&startime,
errno = 0;
continue;
}
firsttimeout = 0;
errno = 0;
continue;
};
if (gettimeofday(&curtime,
errno = 0;
continue;
};
while (time_waited.tv_usec < 0) {
};
}
}
errno = 0; /* reset it */
continue;
}
do {
if (inlen < 0) {
if (errno == EWOULDBLOCK)
continue;
}
continue;
/* see if reply transaction id matches sent id */
continue;
/* we now assume we have the proper reply */
break;
}
/*
* now decode and validate the response
*/
/* XDR_DESTROY(&reply_xdrs); save a few cycles on noop destroy */
if (ok) {
}
(void) xdr_opaque_auth(xdrs,
}
} /* end successful completion */
else {
/* maybe our credentials need to be refreshed ... */
if (nrefreshes > 0 &&
nrefreshes--;
goto call_again;
}
} /* end of unsuccessful completion */
} /* end of valid reply message */
else {
}
}
static void
{
}
static bool_t
{
}
static void
/* CLIENT *h; */
{
}
static bool_t
int request;
char *info;
{
switch (request) {
case CLSET_TIMEOUT:
break;
case CLGET_TIMEOUT:
break;
case CLSET_RETRY_TIMEOUT:
break;
case CLGET_RETRY_TIMEOUT:
break;
case CLGET_SERVER_ADDR:
break;
case CLGET_FD:
break;
case CLSET_FD_CLOSE:
break;
case CLSET_FD_NCLOSE:
break;
default:
return (FALSE);
}
return (TRUE);
}
static void
{
if (cu->cu_closeit) {
}
}
static struct clnt_ops *
{
}
return (&ops);
}