clnt_tcp.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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 1990 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_tcp.c, Implements a TCP/IP based, client side RPC.
*
* TCP based RPC supports 'batched calls'.
* A sequence of calls may be batched-up in a send buffer. The rpc call
* return immediately to the client even though the call was not necessarily
* sent. The batching occurs if the results' xdr routine is NULL (0) AND
* the rpc timeout value is zero (see clnt.h, rpc).
*
* Clients should NOT casually batch calls that in fact return results; that is,
* the server side should be aware that a call is batched and not produce any
* return message. Batched calls that produce many result messages can
* deadlock (netlock) the client and the server....
*
* Now go hang yourself.
*/
#include <netdb.h>
#include <errno.h>
#include <rpc/pmap_clnt.h>
#include <syslog.h>
#include <malloc.h>
#include <stdio.h>
#define MCALL_MSG_SIZE 24
extern int errno;
static int readtcp();
static int writetcp();
extern int _socket(int, int, int);
extern int bindresvport(int, struct sockaddr_in *);
static struct clnt_ops *clnttcp_ops();
struct ct_data {
int ct_sock;
struct sockaddr_in ct_addr;
};
/*
* If *sockp<0, *sockp is set to a newly created TCP socket and it is
* connected to raddr. If *sockp non-negative then
* similar to stdio, so the client must pick send and receive buffer sizes
* 0 => use the default.
* If raddr->sin_port is 0, then a binder on the remote machine is
* consulted for the right port number.
* NB: *sockp is copied into a private area.
* NB: It is the clients responsibility to close *sockp.
* NB: The rpch->cl_auth is set null authentication. Caller may wish to
* set this something more useful.
*/
CLIENT *
struct sockaddr_in *raddr;
register int *sockp;
{
CLIENT *h;
int i;
if (h == NULL) {
goto fooy;
}
goto fooy;
}
/*
* If no port number given ask the pmap for one
*/
== 0) {
}
}
/*
* If no socket given, open one
*/
if (*sockp < 0) {
if ((*sockp < 0)||
sizeof (*raddr)) < 0)) {
goto fooy;
}
} else {
}
/*
* Set up private data struct
*/
/*
* Initialize call message
*/
/*
* pre-serialize the staic part of the call msg and stash it away
*/
if (ct->ct_closeit) {
}
goto fooy;
}
/*
* Create a client handle which uses xdrrec for serialization
* and authnone for authentication.
*/
h->cl_ops = clnttcp_ops();
h->cl_auth = authnone_create();
return (h);
fooy:
/*
* Something goofed, free stuff and barf
*/
}
static enum clnt_stat
register CLIENT *h;
{
int refreshes = 2;
if (!ct->ct_waitset) {
}
shipnow =
}
if (! shipnow)
return (RPC_SUCCESS);
/*
* Hack to provide rpc-based message passing
*/
}
/*
* Keep receiving until we get a valid transaction id
*/
while (TRUE) {
if (! xdrrec_skiprecord(xdrs))
/* now decode and validate the response header */
continue;
}
break;
}
/*
* process header
*/
if (! AUTH_VALIDATE(h->cl_auth,
}
/* free verifier ... */
(void) xdr_opaque_auth(xdrs,
}
} /* end successful completion */
else {
/* maybe our credentials need to be refreshed ... */
goto call_again;
} /* end of unsuccessful completion */
}
static void
clnttcp_geterr(h, errp)
CLIENT *h;
{
(struct ct_data *) h->cl_private;
}
static bool_t
{
}
static void
{
}
static bool_t
int request;
char *info;
{
switch (request) {
case CLSET_TIMEOUT:
break;
case CLGET_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
CLIENT *h;
{
(struct ct_data *) h->cl_private;
if (ct->ct_closeit) {
}
}
/*
* Interface between xdr serializer and tcp connection.
* Behaves like the system calls, read & write, but keeps some error state
* around for the rpc level.
*/
static int
register int len;
{
if (len == 0)
return (0);
while (TRUE) {
switch (select(__rpc_dtbsize(),
case 0:
return (-1);
case -1:
continue;
return (-1);
}
break;
}
case 0:
/* premature eof */
break;
case -1:
break;
}
return (len);
}
static int
int len;
{
register int i, cnt;
return (-1);
}
}
return (len);
}
static struct clnt_ops *
{
}
return (&ops);
}