| 1 | |
package org.jscsi.target.connection.stage.fullfeature; |
| 2 | |
|
| 3 | |
|
| 4 | |
import java.io.IOException; |
| 5 | |
import java.security.DigestException; |
| 6 | |
|
| 7 | |
import org.jscsi.exception.InternetSCSIException; |
| 8 | |
import org.jscsi.parser.BasicHeaderSegment; |
| 9 | |
import org.jscsi.parser.ProtocolDataUnit; |
| 10 | |
import org.jscsi.parser.logout.LogoutResponse; |
| 11 | |
import org.jscsi.target.connection.TargetPduFactory; |
| 12 | |
import org.jscsi.target.connection.phase.TargetFullFeaturePhase; |
| 13 | |
import org.jscsi.target.settings.SettingsException; |
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
public final class LogoutStage extends TargetFullFeatureStage { |
| 25 | |
|
| 26 | |
public LogoutStage (TargetFullFeaturePhase targetFullFeaturePhase) { |
| 27 | 0 | super(targetFullFeaturePhase); |
| 28 | 0 | } |
| 29 | |
|
| 30 | |
@Override |
| 31 | |
public void execute (ProtocolDataUnit pdu) throws IOException , InterruptedException , InternetSCSIException , DigestException , SettingsException { |
| 32 | |
|
| 33 | 0 | final BasicHeaderSegment bhs = pdu.getBasicHeaderSegment(); |
| 34 | 0 | final int initiatorTaskTag = bhs.getInitiatorTaskTag(); |
| 35 | |
|
| 36 | 0 | final ProtocolDataUnit responsePDU = TargetPduFactory.createLogoutResponsePdu(LogoutResponse.CONNECTION_CLOSED_SUCCESSFULLY, initiatorTaskTag, (short) settings.getDefaultTime2Wait(), |
| 37 | |
(short) settings.getDefaultTime2Retain()); |
| 38 | |
|
| 39 | 0 | connection.sendPdu(responsePDU); |
| 40 | 0 | } |
| 41 | |
|
| 42 | |
} |