# DL_BIND_REQ and DL_UNBIND_REQ tests
# Tested:
# DL_BIND_REQ
#	OK
#	DL_OUTSTATE
#	DL_UNSUPPORTED
#	DL_BADADDR (zero SAP, odd SAP)
#	DL_BOUND (two LLC1 streams to same SAP, two LLC2 streams
#	    w/ max_conind > 0 to same SAP, attempt to bind two
#	    conn mgmt streams)
#	(XXX should test: DL_BIND when have to register w/ Ethernet driver)
# DL_UNBIND_REQ
#	OK
#	DL_OUTSTATE

open 1

# Attempt to bind when out of state (not attached)
bind $1 40 2 0 0	0	dl_error_ack dl_outstate

attach $1 43

# Attempt to bind w/ invalid service mode
bind $1 40 3 0 0 0	dl_error_ack dl_unsupported

# Attempt to bind to SAP 0
bind $1 0 2 0 0 0	dl_error_ack dl_badaddr
 
# attempt to bind to odd SAP
bind $1 41 2 0 0 0	dl_error_ack dl_badaddr

check_state $1		dl_unbound

# Valid LLC2 bind request
bind $1 40 2 0 0 0

check_state $1		dl_idle

# Another attempt to bind when out of state (already bound)
bind $1 40 2 0 0 0	dl_error_ack dl_outstate

check_state $1		dl_idle

open 2
attach $2 43

# Bind a second LLC2 stream to the same SAP (is OK)
bind $2 40 2 0 0 0

open 3
attach $3 43

# Bind an LLC1 stream to a SAP already bound to an LLC2 stream (is OK)
bind $3 40 1 0 0 0

open 4
attach $4 43

# Attempt to bind a second LLC1 stream to the same SAP
bind $4 40 1 0 0	0	dl_error_ack dl_bound

# Bind an LLC2 stream w/ max_conind > 0
bind $4 40 2 5 0 0

open 5
attach $5 43

# Attempt to bind a second LLC2 stream w/ max_conind > 0
bind $5 40 2 5 0	0	dl_error_ack dl_bound

# Bind a connection management stream
bind $5 40 2 5 1 0

open 6
attach $6 43

# Attempt to bind a second connection management stream
bind $6 38 2 5 1 0	dl_error_ack dl_bound

check_state $4		dl_idle

# Successfull unbind (should be able to re-bind afterwards)
unbind $4

check_state $4		dl_unbound

bind $4 40 2 5 0 0

check_state $4		dl_idle

unbind $4

# Attempt to unbind when out of state (not bound)
unbind $4		dl_error_ack dl_outstate

detach $4

# Another attempt to unbind when out of state (not attached)
unbind $4		dl_error_ack dl_outstate
