| 1 | |
package org.jscsi.target.connection.stage; |
| 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.tmf.TaskManagementFunctionRequestParser; |
| 11 | |
import org.jscsi.parser.tmf.TaskManagementFunctionResponseParser; |
| 12 | |
import org.jscsi.parser.tmf.TaskManagementFunctionResponseParser.ResponseCode; |
| 13 | |
import org.jscsi.target.connection.TargetPduFactory; |
| 14 | |
import org.jscsi.target.connection.phase.TargetFullFeaturePhase; |
| 15 | |
import org.jscsi.target.connection.stage.fullfeature.TargetFullFeatureStage; |
| 16 | |
import org.jscsi.target.settings.SettingsException; |
| 17 | |
import org.slf4j.Logger; |
| 18 | |
import org.slf4j.LoggerFactory; |
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
public class TMStage extends TargetFullFeatureStage { |
| 29 | |
|
| 30 | 0 | private static final Logger LOGGER = LoggerFactory.getLogger(TMStage.class); |
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
public TMStage (TargetFullFeaturePhase targetFullFeaturePhase) { |
| 36 | 0 | super(targetFullFeaturePhase); |
| 37 | 0 | } |
| 38 | |
|
| 39 | |
@Override |
| 40 | |
public void execute (ProtocolDataUnit pdu) throws IOException , InterruptedException , InternetSCSIException , DigestException , SettingsException { |
| 41 | |
|
| 42 | 0 | final BasicHeaderSegment bhs = pdu.getBasicHeaderSegment(); |
| 43 | 0 | final TaskManagementFunctionRequestParser parser = (TaskManagementFunctionRequestParser) bhs.getParser(); |
| 44 | 0 | final int initiatorTaskTag = bhs.getInitiatorTaskTag(); |
| 45 | |
|
| 46 | 0 | TaskManagementFunctionResponseParser.ResponseCode responseCode = ResponseCode.TASK_DOES_NOT_EXIST; |
| 47 | |
|
| 48 | 0 | switch (parser.getFunction()) { |
| 49 | |
case ABORT_TASK : |
| 50 | 0 | LOGGER.error("ABORT_TASK"); |
| 51 | 0 | break; |
| 52 | |
case ABORT_TASK_SET : |
| 53 | 0 | LOGGER.error("ABORT_TASK_SET"); |
| 54 | 0 | break; |
| 55 | |
case CLEAR_ACA : |
| 56 | 0 | responseCode = ResponseCode.FUNCTION_COMPLETE; |
| 57 | 0 | break; |
| 58 | |
case CLEAR_TASK_SET : |
| 59 | 0 | responseCode = ResponseCode.FUNCTION_COMPLETE; |
| 60 | 0 | break; |
| 61 | |
case LUN_RESET : |
| 62 | 0 | LOGGER.error("LUN_RESET"); |
| 63 | 0 | break; |
| 64 | |
case TARGET_WARM_RESET : |
| 65 | 0 | LOGGER.error("TARGET_WARM_RESET"); |
| 66 | 0 | break; |
| 67 | |
case TARGET_COLD_RESET : |
| 68 | 0 | LOGGER.error("TARGET_COLD_RESET"); |
| 69 | 0 | break; |
| 70 | |
case TASK_REASSIGN : |
| 71 | 0 | LOGGER.error("TASK_REASSIGN"); |
| 72 | 0 | break; |
| 73 | |
default : |
| 74 | |
break; |
| 75 | |
} |
| 76 | |
|
| 77 | 0 | final ProtocolDataUnit responsePDU = TargetPduFactory.createTMResponsePdu(responseCode, initiatorTaskTag); |
| 78 | 0 | connection.sendPdu(responsePDU); |
| 79 | |
|
| 80 | 0 | } |
| 81 | |
|
| 82 | |
} |