# Tests of DL_CONNECT_REQ
# Tested:
#	1) Error conditions:
#	    DL_OUTSTATE (bad state, connect on an LLC1 stream)
#	    DL_BADADDR (zero SAP, odd SAP, loopback w/ same SAP)
#	2) Valid connection setup
#	3) Error: DL_ACCESS (connect to MAC/SAP already in use)

###### Test case #1 ######
open 1

# Attempt to connect when out of state (not attached)
connect $1 0:0:0:0:0:0,40 1	dl_error_ack dl_outstate

attach $1 43

# Another attempt to connect when out of state (not bound)
connect $1 0:0:0:0:0:0,40 1	dl_error_ack dl_outstate

bind $1 40 2 0 0 1

# Attempt to connect to zero SAP
connect $1 0:0:0:0:0:0,0 1	dl_error_ack dl_badaddr

# Attempt to connect to odd SAP
connect $1 0:0:0:0:0:0,41 1	dl_error_ack dl_badaddr

# Attempt to loopback to same SAP
connect $1 0:0:0:0:0:0,40 1	dl_error_ack dl_badaddr

open 2
attach $2 43
bind $2 44 1 0 0 0

# Attempt to connect on an LLC1 stream
connect $2 0:0:0:0:0:0,46 1	dl_error_ack dl_outstate

###### Test case #2 ######
# Open a stream to listen on
open 3
attach $3 43
bind $3 48 2 2 0 1

check_state $1		dl_idle

# Valid connect request
connect $1 0:0:0:0:0:0,48 0

check_state $1		dl_outcon_pending

# Should see event on stream $3 (the listen stream)
poll $1 $3 $3

connect_ind $3 1 -

check_state $3		dl_dataxfer

# Should see event on stream $1 (the connecting stream)
poll $1 $3 $1
connect_con $1

check_state $1		dl_dataxfer

###### Test case #3 ######
# Attempt to connect to the same MAC/SAP
open 4
attach $4 43
bind $4 40 2 0 0 0

connect $4 0:0:0:0:0:0,48 1	dl_error_ack dl_access
