dapl_rsp_create.c revision 9e39c5ba00a55fa05777cc94b148296af305e135
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * CDDL HEADER START
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The contents of this file are subject to the terms of the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Common Development and Distribution License (the "License").
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * You may not use this file except in compliance with the License.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * See the License for the specific language governing permissions
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and limitations under the License.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * When distributing Covered Code, include this CDDL HEADER in each
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If applicable, add the following below this CDDL HEADER, with the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * fields enclosed by brackets "[]" replaced with your own identifying
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * information: Portions Copyright [yyyy] [name of copyright owner]
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * CDDL HEADER END
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Copyright (c) 2002-2003, Network Appliance, Inc. All rights reserved.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Use is subject to license terms.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * PURPOSE: Connection management
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Description: Interfaces in this file are completely described in
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the DAPL 1.1 API, Chapter 6, section 4
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * $Id: dapl_rsp_create.c,v 1.14 2003/07/25 19:24:11 sjs2 Exp $
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * dapl_rsp_create
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * uDAPL: User Direct Access Program Library Version 1.1, 6.4.3.4.1
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Create a Resereved Service Point with the specified Endpoint
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * that generates at most one Connection Request that is
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * delivered to the specified Event Dispatcher in a notification
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * evd_handle
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * rsp_handle
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * DAT_SUCCESS
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * DAT_INSUFFICIENT_RESOURCES
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * DAT_INVALID_PARAMETER
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * DAT_INVALID_STATE
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * DAT_CONN_QUAL_IN_USE
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ">>> dapl_rsp_free conn_qual: %x EP: %p\n",
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (DAPL_BAD_HANDLE(ep_handle, DAPL_MAGIC_EP)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (DAPL_BAD_HANDLE(evd_handle, DAPL_MAGIC_EVD)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG5);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (ep_ptr->param.ep_state != DAT_EP_STATE_UNCONNECTED) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor sp_ptr = dapls_ia_sp_search(ia_ptr, conn_qual, DAT_FALSE);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Allocate RSP */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor dat_status = DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Fill out the RSP args
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Take a reference on the EVD handle
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor (void) dapl_os_atomic_inc(&((DAPL_EVD *)evd_handle)->evd_ref_count);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Update the EP state indicating the provider now owns it
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Set up a listener for a connection. Connections can arrive
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * even before this call returns!
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Link it onto the IA */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor dat_status = dapls_ib_setup_conn_listener(ia_ptr, conn_qual,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Have a problem setting up the connection, something
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * rsp_free will decrement the EVD refcount. Set
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * listening to * false to avoid tearing down the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * conn_listener which didn't * get set up.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor "--> dapl_rsp_create setup_conn_listener failed: "
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Return handle to the user