/*
* 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 (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5.2.1 */
#include "mt.h"
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <stropts.h>
#include <xti.h>
#include <signal.h>
#include <syslog.h>
#include <assert.h>
#include "tx.h"
int
int fd,
int resfd,
int api_semantics
)
{
int didalloc;
return (-1);
return (-1);
/*
* We need to block signals to perform the I_FDINSERT operation
* (sending T_CONN_RES downstream) which is non-idempotent.
* Note that sig_mutex_lock() only defers signals, it does not
* block them, so interruptible syscalls could still get EINTR.
*/
return (-1);
}
if (_T_IS_XTI(api_semantics)) {
/*
* User level state verification only done for XTI
* because doing for TLI may break existing applications
*
* For fd == resfd, state should be T_INCON
* For fd != resfd,
* fd state should be T_INCON
* resfd state should be T_IDLE (bound endpoint) or
* it can be T_UNBND. The T_UNBND case is not (yet?)
* allowed in the published XTI spec but fixed by the
* corrigenda.
*/
return (-1);
}
/*
* XTI says:
* If fd != resfd, and a resfd bound to a protocol address is
* passed, then it better not have a qlen > 0.
* That is, an endpoint bound as if it will be a listener
* cannot be used as an acceptor.
*/
return (-1);
}
return (-1);
}
/*
* Note: TRESADDR error is specified by XTI. It happens
* when resfd is bound and fd and resfd are not BOUND to
* the same protocol address. TCP obviously does allow
* two endpoints to bind to the same address. Why is the
* need for this error considering there is an address switch
* that can be done for the endpoint at accept time ? Go
* figure and ask the XTI folks.
* We interpret this to be a transport specific error condition
* to be be coveyed by the transport provider in T_ERROR_ACK
* to T_CONN_RES on transports that allow two endpoints to
* be bound to the same address and have trouble with the
* idea of accepting connections on a resfd that has a qlen > 0
*/
}
return (-1);
}
if (retval > 0) {
return (-1);
}
}
/*
* of the message.
*/
return (-1);
}
/*
* In Unix98 t_accept() need not return [TLOOK] if connect/disconnect
* indications are present. TLI and Unix95 need to return error.
*/
goto err_out;
}
/* LINTED pointer cast */
cres->OPT_offset = 0;
} else {
/* I_FDINSERT should use O_T_CONN_RES. */
cres->ACCEPTOR_id = 0;
}
size = (int)sizeof (struct T_conn_res);
/*
* Aligned copy will overflow buffer allocated based
* transport maximum options length.
* return error.
*/
goto err_out;
}
}
/*
* user data not valid with connect or it
* exceeds the limits specified by the transport
* provider
*/
goto err_out;
}
}
/*
* Assumes signals are blocked so putmsg() will not block
* indefinitely
*/
/*
* Assumes signals are blocked so putmsg() will not block
* indefinitely
*/
0) {
else
goto err_out;
}
} else {
else
goto err_out;
}
}
/*
* At the TPI level, the error returned in a T_ERROR_ACK
* received in response to a T_CONN_RES for a listener and
* acceptor endpoints not being the same kind of endpoints
* has changed to a new t_errno code introduced with
* XTI (TPROVMISMATCH). We need to adjust TLI error code
* to be same as before.
*/
/* TLI only */
}
goto err_out;
}
"t_accept: invalid state event T_ACCEPT1");
} else {
"t_accept: invalid state event T_ACCEPT2");
/*
* XXX Here we lock the resfd lock also. This
* is an instance of holding two locks without
* any enforcement of a locking hiararchy.
* There is potential for deadlock in incorrect
* or buggy programs here but this is the safer
* choice in this case. Correct programs will not
* deadlock.
*/
"t_accept: invalid state event T_PASSCON");
}
} else {
"t_accept: invalid state event T_ACCEPT3");
"t_accept: invalid state event T_PASSCON");
}
/*
* Update attributes which may have been negotiated during
* connection establishment for protocols where we suspect
* such negotiation is likely (e.g. OSI). We do not do it for
* all endpoints for performance reasons. Also, this code is
* deliberately done after user level state changes so even
* the (unlikely) failure case reflects a connected endpoint.
*/
if (restiptr->ti_tsdusize != 0) {
goto err_out;
}
if (didalloc)
else
return (0);
/* NOTREACHED */
if (didalloc)
else
return (-1);
}