📄 scs_conn.c
字号:
#ifndef lintstatic char *sccsid = "@(#)scs_conn.c 4.1 (ULTRIX) 7/2/90";#endif lint/************************************************************************ * * * Copyright (c) 1988 - 1989 by * * Digital Equipment Corporation, Maynard, MA * * All rights reserved. * * * * This software is furnished under a license and may be used and * * copied only in accordance with the terms of such license and * * with the inclusion of the above copyright notice. This * * software or any other copies thereof may not be provided or * * otherwise made available to any other person. No title to and * * ownership of the software is hereby transferred. * * * * The information in this software is subject to change without * * notice and should not be construed as a commitment by Digital * * Equipment Corporation. * * * * Digital assumes no responsibility for the use or reliability * * of its software on equipment which is not supplied by Digital. * * * ************************************************************************ * * * Facility: Systems Communication Architecture * Systems Communication Services * * Abstract: This module contains Systems Communication Services( SCS ) * connection management service functions. * * Creator: Todd M. Katz Creation Date: May 27, 1985 * * Function/Routines: * * scs_listen Listen for SCS Connection Requests * scs_connect Request Logical SCS Connection * scs_accept Accept Logical SCS Connection Request * scs_reject Reject Logical SCS Connection Request * scs_disconnect Disconnect SCS Connection * * Modification History: * * 06-Apr-1989 Pete Keilty * Added include file smp_lock.h, external lk_scadb * * 11-Feb-1989 Todd M. Katz TMK0004 * 1. Add support for SCS event logging. Log establishments and * terminations of SCS listening connections and disconnects of fully * established SCS connections terminated by path failure. * 2. Include header file ../vaxmsi/msisysap.h. * * 13-Sep-1988 Todd M. Katz TMK0003 * Return an error( RET_NORESOURCES ) from scs_listen() if SCS has never * been initialized. * * 12-Jul-1988 Todd M. Katz TMK0002 * Macros Copy_name() and Copy_data() have been renamed to Move_name() and * Move_data() respectively. * * 02-Jun-1988 Ricky S. Palmer * Removed inclusion of header file ../vaxmsi/msisysap.h * * 08-Jan-1988 Todd M. Katz TMK0001 * Formated module, revised comments, increased robustness, restructured * code paths, and added SMP support. *//* Libraries and Include Files. */#include "../h/types.h"#include "../h/param.h"#include "../h/ksched.h"#include "../h/time.h"#ifdef mips#include "../h/systm.h"#include "../h/vmmac.h"#endif mips#include "../h/errlog.h"#include "../h/smp_lock.h"#include "../io/scs/sca.h"#include "../io/scs/scaparam.h"#include "../io/ci/cippdsysap.h"#include "../io/ci/cisysap.h"#include "../io/msi/msisysap.h"#include "../io/bi/bvpsysap.h"#include "../io/gvp/gvpsysap.h"#include "../io/uba/uqsysap.h"#include "../io/sysap/sysap.h"#include "../io/ci/cippdscs.h"#include "../io/ci/ciscs.h"#include "../io/msi/msiscs.h"#include "../io/bi/bvpscs.h"#include "../io/gvp/gvpscs.h"#include "../io/uba/uqscs.h"#include "../io/scs/scs.h"/* External Variables and Routines. */extern SCSIB lscs;extern CBVTDB *scs_cbvtdb;extern struct lock_t lk_scadb;extern sbq scs_config_db;extern cbq scs_listeners;extern CB *scs_alloc_cb();extern PB *scs_choose_path();extern void ksched(), scs_abort_conn(), scs_dealloc_cb(), scs_log_event(), scs_request();/* Name: scs_listen - Listen for SCS Connection Requests * * Abstract: This function initiates passive listening for SCS connection * requests. The SYSAP receives requests for connection * establishment and notification of the existence of new paths * through asynchronous invocations of the listening connection's * control event routine. * * The SYSAP's name and optionally supplied connection data is * passed to any curious SYSAP requesting such information from * the local directory SYSAP. * * A CB is allocated for the new listening SCS connection. A * CBVTE is allocated to reference the new CB. *. * Inputs: * * IPL_SCS - Interrupt processor level * cmsb - Connection Management Service Block pointer * aux - Address of auxiliary structure( OPTIONAL ) * conn_data - Connection data( OPTIONAL ) * control - Address of connection control event routine * lproc_name - Local SYSAP name( blank filled ) * lk_scadb - SCA database lock structure * scs_listeners - Listening SYSAP queue head * * Outputs: * * IPL_SCS - Interrupt processor level * cmsb - Connection Management Service Block pointer * connid - Identification of listening SCS connection * * Return Values: * * RET_SUCCESS - SYSAP is passively listening for requests * RET_ALLOCFAIL - Failed to allocate a CB * RET_NORESOURCES - SCS has never been initialized * * SMP: The SCA database is locked for CBVTE allocation and for CB * insertion into the queue of listening SYSAPs. * * There is no need to lock the new CB. It can not be accessed * through its CBVTE until used and is otherwise inaccessible * until the SCA database lock is released. */u_longscs_listen( cmsb ) CMSB *cmsb;{ register cbq *cb, *ptr; register u_long status = RET_SUCCESS; /* Passive listening for SCS connection requests is initiated as follows: * * 1. Lock the SCA database. * 2. Allocate and initialize a CB. * 3. Insert the CB into the first available slot within the queue of * listening SYSAPs. * 4. Log establishment of the new listening SCS connection. * 5. Unlock the SCA database. * 6. Return an appropriate status. * * The CB is assigned a directory identification number based upon its slot * assignment. If the queue was previously empty the CB is assigned a * directory identification number of 1. */ Lock_scadb() if( lscs.system.swtype == 0 ) { status = RET_NORESOURCES; } else if(( cb = ( cbq * )scs_alloc_cb( CS_LISTEN, cmsb, NULL ))) { Move_connid( Cb->cinfo.lconnid, cmsb->connid ) for( Cb->cinfo.Dirid = 1, ptr = scs_listeners.flink; ptr != &scs_listeners; ++Cb->cinfo.Dirid, ptr = ptr->flink ) { if( Cb->cinfo.Dirid < (( CB * )ptr )->cinfo.Dirid ) { break; } } ( void )scs_log_event( Cb, I_NEW_LISTENER, LSYSAP_EVENT ); Insert_entry( cb->flink, ( *ptr )) } else { status = RET_ALLOCFAIL; } Unlock_scadb() return( status );}/* Name: scs_connect - Request Logical SCS Connection * * Abstract: This function initiates establishment of a logical SCS * connection to a SYSAP passively listening for such connection * requests. The SYSAP is notified of the outcome of its * connection request through asynchronous invocation of the * connection's control event routine. * * While the ultimate outcome of a connection request is either * success or failure, there are numerous reasons why failure to * establish a connection may occur. Some of these reasons are * SYSAP protocol specific. In other situations SCS itself aborts * connection establishment with one of the following reasons: * * NOLISTENER - Target SYSAP does not exist on remote system. * NORESOURCE - Insufficient resources on remote system for * connection establishment. * NOSUPPORT - Target SYSAP is not supported on remote system. * BUSY - Target SYSAP only supports one simultaneous * connection on remote system and such a * connection already exists. * DISCONN - Target SYSAP rejected connection without * specifying a reason or initiating SYSAP * unilaterally aborted connection establishment. * PATH_FAILURE - Path failed before connection was established. * * A CB and associated resources are allocated for the new logical * SCS connection. A CBVTE is allocated to reference the new CB. * * Inputs: * * IPL_SCS - Interrupt processor level * cmsb - Connection Management Service Block pointer * aux - Address of auxiliary structure( OPTIONAL ) * conn_data - Connection data( OPTIONAL ) * control - Address of connection control event routine * dg_event - Address of dg event routine( OPTIONAL ) * init_dg_credit - Initial datagram credit( OPTIONAL ) * init_rec_credit - Initial message credit( OPTIONAL ) * lport_name - Name of local port( OPTIONAL ) * ( 0 -> Choice of path left to SCS ) * lproc_name - Local SYSAP name( blank filled ) * min_snd_credit - Minimum send credit requirement( OPTIONAL ) * msg_event - Address of msg event routine( OPTIONAL ) * rport_addr - Remote port station address( OPTIONAL ) * rproc_name - Remote SYSAP name * sysid - Identification of target system * lk_scadb - SCA database lock structure * scs_config_db - System-wide configuration database queue head * * Outputs: * * IPL_SCS - Interrupt processor level * cmsb - Connection Management Service Block pointer * connid - Identification of logical SCS connection * pb - Path Block pointer * pinfo.nconns - Number of connections * * Return Values: * * RET_SUCCESS - Initiated SCS connection establishment * RET_ALLOCFAIL - Failed to allocate a CB * Failed to allocate receive datagram buffers * Failed to allocate receive message buffers * RET_INVPSTATE - Target path in invalid state * RET_NOSYSTEM - Target system does not exist * RET_NOPATH - Requested path does not exist * No paths exist * * SMP: The SCA database is locked for CBVTE allocation, CB insertion * into the system-wide configuration database, and for requesting * a new connection to the target SYSAP. It also prevents PB * deletion. * * The new CB is locked prior to insertion into the system-wide * configuration database even though there is no real need to do * so. It can not be accessed through its CBVTE until its * connection request has been processed and is otherwise * inaccessible until the SCA database lock is released. However, * locking it simplifies the interface to scs_request() and this * is why it is done. It is indirectly locked through its CBVTE. */u_longscs_connect( cmsb ) register CMSB *cmsb;{ register CB *cb; register sbq *sb; register pbq *pb; register CBVTE *cbvte; register u_long status = RET_NOSYSTEM; /* Initiation of logical SCS connection establishment proceeds as follows: * * 1. Lock the SCA database. * 2. Search the system-wide configuration database for the target system. * 3. Choose an open path to the target system for the new connection if * the choice of path was left up to SCS; otherwise, continue searching * the system-wide configuration database for the target path. * 4. Allocate and initialize a CB. * 5. Lock the CB. * 6. Insert the CB into the system-wide configuration database. * 7. Request establishment of a new connection to the target SYSAP * provided a suitable path to the target system exists. * 8. Unlock the CB and SCA database. * 9. Return an appropriate status. */ Lock_scadb() for( sb = scs_config_db.flink; sb != &scs_config_db; sb = sb->flink ) { if( Comp_scaaddr( cmsb->sysid, Sb->sinfo.sysid )) { if( cmsb->lport_name == 0 ) { if(( pb = ( pbq * )scs_choose_path( Sb )) == NULL ) { status = RET_NOPATH; break; } } else { for( pb = Sb->pbs.flink; pb != &Sb->pbs && ( cmsb->lport_name != Pb->pinfo.lport_name || !Comp_scaaddr( cmsb->rport_addr, Pb->pinfo.rport_addr )); pb = pb->flink ) {} if( pb == &Sb-> pbs ) { status = RET_NOPATH; } else if( Pb->pinfo.state != PS_OPEN ) { status = RET_INVPSTATE; } if( status != RET_NOSYSTEM ) { break; } } if(( cb = scs_alloc_cb( CS_CONN_SNT, cmsb, Pb ))) { status = RET_SUCCESS; Move_connid( cb->cinfo.lconnid, cmsb->connid ) cbvte = Get_cbvte( cb->cinfo.lconnid ); Lock_cbvte( cbvte ) Insert_cb( cb, Pb ) ( void )scs_request( CB_CONN_PEND, cb, Pb, NULL ); Unlock_cbvte( cbvte ) } else { status = RET_ALLOCFAIL; } break; } } Unlock_scadb() return( status );}/* Name: scs_accept - Accept Logical SCS Connection Request * * Abstract: This function establishes a logical SCS connection by accepting * a connection request. The SYSAP is notified of the outcome of * its acceptance request through asynchronous invocation of the * connection's control event routine. * * There are several reasons why unsuccessful outcomes to * acceptances can occur. These reasons are listed below: * * DISCONN - The connection initiating SYSAP unilaterally * aborted connection establishment. * PATH_FAILURE - Path failed before connection established. * * Resources are allocated for the new logical SCS connection. * * Inputs: * * IPL_SCS - Interrupt processor level * cmsb - Connection Management Service Block pointer * aux - Address of auxiliary structure( OPTIONAL ) * conn_data - Connection data( OPTIONAL ) * connid - Identification of accepted SCS connection * control - Address of connection control event routine * dg_event - Address of dg event routine( OPTIONAL ) * init_dg_credit - Initial datagram credit( OPTIONAL ) * init_rec_credit - Initial message credit( OPTIONAL ) * min_snd_credit - Minimum send credit requirement( OPTIONAL ) * msg_event - Address of msg event routine( OPTIONAL ) * lscs - Local system permanent information * lk_scadb - SCA database lock structure * scs_cbvtdb - CB vector table database pointer * * Outputs: * * IPL_SCS - Interrupt processor level * * Return Values: * * RET_SUCCESS - Initiated acceptance of connection request * RET_ALLOCFAIL - Failed to allocate receive datagram buffers * Failed to allocate receive message buffers * RET_INVCONNID - Invalid connection identification number
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -