#!/bin/tcsh
#
#	ini-conn-up
#
#	vi: set autoindent tabstop=4 shiftwidth=4 :
#
#	bring up additional connection in an initiator session
#
#
#	this command file can be run on a platform whose initiator loads as
#	host 0-9 (i.e., 1 digit)
#
if ( ! -e /proc/scsi/iscsi_initiator ) then
	echo "/proc/scsi/iscsi_initiator does not exist"
	echo "load the initiator module with ini-install"
	exit 1
endif
#
set hostno = /proc/scsi/iscsi_initiator/?
set hostno = $hostno:t
#
#	set the target's ip address or DNS name to connect to
set ip = 127.0.0.1
#
#	set the port number on the target to connect to
set portno = 3260
#
#	set the lun, which must be the same as an already existing lun
set lun = 0
#
#	set the connection id to bring up, which must differ from all others
set cid = 2
#
#	set this to determine initiator's local target slot to use
set localtargetno = 0
#
#	if connecting to the unh reference target emulator, set its target number
set remotetargetno = 1
#
echo "local initiator host" $hostno "initiator's target slot" $localtargetno
echo lun $lun "connection id" $cid
echo "remote target number for UNH target" $remotetargetno
#
#
./iscsi_manage init restore host=$hostno target=$localtargetno
./iscsi_manage init set TargetName=iqn.1992-08.com.netapp:sn.50403788 host=$hostno target=$localtargetno
#./iscsi_manage init set TargetName=iqn.2002-10.edu.unh.iol.iscsi.draft20-target:$remotetargetno host=$hostno target=$localtargetno
./iscsi_manage init set InitiatorName=iqn.1999-11.edu.unh.iol.iscsi.draft20-initiator host=$hostno target=$localtargetno
#
#	Can only negotiate a limited number of parameters on a second connection
#
# force initiator to offer security stage, even if it has no keys to send
#./iscsi_manage init force s host=$hostno target=$localtargetno
#
# to turn on CHAP Authentication -- also need to define names and secrets (next)
#./iscsi_manage init set AuthMethod=CHAP,None host=$hostno target=$localtargetno
#
# for the UNH reference target CHAP Authentication
#./iscsi_manage init force b t cl=256 lx="wild_cat_and_dog" ln=UNH-reference-Target px="UNH cowhampshire" pn=anonymous-user-of-UNH-reference-Target host=$hostno target=$localtargetno
#
# for the UNH TARGET target.t script CHAP Authentication in both directions
#./iscsi_manage init force b t cl=256 lx="When will it begin?" ln=UNH-TESTOR-Target px="This should work now!" pn=anonymous-user-of-UNH-TESTOR-Target host=$hostno target=$localtargetno
#
# for the UNH TARGET target.t script CHAP Authentication initiator only
#./iscsi_manage init force b cl=256 px="This should work now!" pn=anonymous-user-of-UNH-TESTOR-Target host=$hostno target=$localtargetno
#
# to turn on SRP Authentication -- also need to define names and secrets (next)
#./iscsi_manage init set AuthMethod=SRP,None host=$hostno target=$localtargetno
#
#./iscsi_manage init force b t host=$hostno target=$localtargetno
#./iscsi_manage init force sx="old_man_of_the_mountain" host=$hostno target=$localtargetno
#./iscsi_manage init force sn=UNH-IOL-user-name host=$hostno target=$localtargetno
#
# uncomment only 1 of the following 5 lines to configure the SRP group
# larger groups take correspondingly longer to compute
#./iscsi_manage init force sg=SRP-768 host=$hostno target=$localtargetno
#./iscsi_manage init force sg=SRP-1024 host=$hostno target=$localtargetno
#./iscsi_manage init force sg=SRP-1280 host=$hostno target=$localtargetno
#./iscsi_manage init force sg=SRP-1536 host=$hostno target=$localtargetno
#./iscsi_manage init force sg=SRP-2048 host=$hostno target=$localtargetno
#
#./iscsi_manage init set HeaderDigest=CRC32C,None host=$hostno target=$localtargetno
#./iscsi_manage init set DataDigest=CRC32C,None host=$hostno target=$localtargetno
#./iscsi_manage init set MaxRecvDataSegmentLength=16773120 host=$hostno target=$localtargetno
#./iscsi_manage init set MaxRecvDataSegmentLength=32768 host=$hostno target=$localtargetno
#
#	force nop pings to be sent to target every 8 seconds
./iscsi_manage init force n=4 host=$hostno target=$localtargetno
#
#	finally, bring up the new connection to the target
./iscsi_config up ip=$ip port=$portno host=$hostno cid=$cid lun=$lun target=$localtargetno
