public ProtocolDataUnit check (final Connection pConnection) throws InterruptedException , IOException , InternetSCSIException {
ProtocolDataUnit responsePdu;
final BasicHeaderSegment bhs = new ProtocolDataUnitFactory().create(false, true, OperationCode.SCSI_COMMAND, "None", "None").getBasicHeaderSegment();
final SCSICommandParser parser = (SCSICommandParser) bhs.getParser();
final InquiryCDB cdb = new InquiryCDB(parser.getCDB());
IResponseData responseData = null;
if (!cdb.getEnableVitalProductData()) {
responseData = StandardInquiryData.getInstance();
} else {
final VitalProductDataPageName pageName = cdb.getPageCode().getVitalProductDataPageName();
switch (pageName) {// is never null
case SUPPORTED_VPD_PAGES :
responseData = SupportedVpdPages.getInstance();
break;
case DEVICE_IDENTIFICATION :
responseData = session.getTargetServer().getDeviceIdentificationVpdPage();
break;
default :
throw new InternetSCSIException();
}
}
// The part from the targetfullfeaturephase
final ByteBuffer fullBuffer = ByteBuffer.allocate(responseData.size());
responseData.serialize(fullBuffer, 0);
ByteBuffer trimmedBuffer;
if (fullBuffer.capacity() <= parser.getExpectedDataTransferLength()) {
trimmedBuffer = fullBuffer;
} else {