/** * Returns the one and only {@link StandardInquiryData} object. * * @return the one and only {@link StandardInquiryData} object */ public static StandardInquiryData getInstance () { if (instance == null) instance = new StandardInquiryData(); return instance; }
/** * Returns the combined length of all contained IDENTIFICATION DESCRIPTORs. * * @return the combined length of all contained IDENTIFICATION DESCRIPTORs */ private short getPageLength () { short pageLength = 0; for (int i = 0; i < identificationDescriptors.length; ++i) { pageLength += identificationDescriptors[i].size(); } return pageLength; }
/** * Returns the singleton. * * @return the singleton */ public static SupportedVpdPages getInstance () { if (instance == null) instance = new SupportedVpdPages(); return instance; }
LOGGER.debug("cdb.isNormalACA() = " + cdb.isNormalACA()); LOGGER.debug("cdb.getPageCode() = " + cdb.getPageCode()); LOGGER.debug("cdb.getPageCode().getVitalProductDataPageName() = " + cdb.getPageCode().getVitalProductDataPageName()); responseData = StandardInquiryData.getInstance(); } else { final VitalProductDataPageName pageName = cdb.getPageCode().getVitalProductDataPageName(); responseData = SupportedVpdPages.getInstance(); break; case DEVICE_IDENTIFICATION :
public void serialize (ByteBuffer byteBuffer, int index) { // byte 0 byteBuffer.position(index); byte b = (byte) (((protocolIdentifier.getValue() & 15) << 4) | (codeSet.getValue() & 15)); byteBuffer.put(b); // byte 1 b = (byte) (((association.getValue() & 3) << 4) | (identifierType.getValue() & 15)); b = BitManip.getByteWithBitSet(b, 7, protocolIdentifierValid); byteBuffer.put(b); // byte 2 is reserved byteBuffer.put((byte) 0); // byte 3 byteBuffer.put((byte) identifier.size());// identifier length // identifier identifier.serialize(byteBuffer, index + HEADER_LENGTH); }
public InquiryCDB (ByteBuffer buffer) { super(buffer); // EVPD enableVitalProductData = BitManip.getBit(buffer.get(1),// byte 0);// bit number // page code pageCode = new PageCode(buffer.get(2)); // allocation length allocationLength = ReadWrite.readTwoByteInt(buffer, 3); final VitalProductDataPageName vpdpn = pageCode.getVitalProductDataPageName(); if (enableVitalProductData) { if (!SupportedVpdPages.vpdPageCodeSupported(vpdpn)) addIllegalFieldPointer(2);// page code not supported } else { /* * If the PAGE CODE field is not set to zero when the EVPD bit is set to zero, the command shall be * terminated with CHECK CONDITION status, with the sense key set to ILLEGAL REQUEST, and the additional * sense code set to INVALID FIELD IN CDB. */ if (vpdpn != VitalProductDataPageName.SUPPORTED_VPD_PAGES) addIllegalFieldPointer(2);// value should be 0x00 } }
/** * Returns <code>true</code> for those and only for those VPD Page Codes which are supported by the jSCSI Target. * * @param vitalProductDataPageName VPD Page Name whose support is inquired * @return <code>true</code> for those and only for those VPD Page Codes which are supported by the jSCSI Target */ public static boolean vpdPageCodeSupported (final VitalProductDataPageName vitalProductDataPageName) { for (int i = 0; i < SUPPORTED_VPD_PAGES.length; ++i) { PageCode pageCode = new PageCode(SUPPORTED_VPD_PAGES[i]); if (pageCode.getVitalProductDataPageName() == vitalProductDataPageName) return true; } return false; } }
public DeviceIdentificationVpdPage (TargetServer target) { /* * For each logical unit that is not a well known logical unit, the Device Identification VPD page shall include * at least one identification descriptor in which a logical unit name (see SAM-3) is indicated. */ final ProtocolIdentifier protocolIdentifier = ProtocolIdentifier.INTERNET_SCSI; final CodeSet codeSet = CodeSet.UTF8_CODES; final boolean protocolIdentifierValid = true; final Association association = Association.SCSI_TARGET_DEVICE; final IdentifierType identifierType = IdentifierType.SCSI_NAME_STRING; String[] targetNames = target.getTargetNames(); identificationDescriptors = new IdentificationDescriptor[targetNames.length]; for (int curTargetNum = 0; curTargetNum < targetNames.length; curTargetNum++) { final IdentificationDescriptor identDescriptor = new IdentificationDescriptor(protocolIdentifier, codeSet, protocolIdentifierValid, association, identifierType, new ScsiNameStringIdentifier(targetNames[curTargetNum])); identificationDescriptors[curTargetNum] = identDescriptor; } }
public int size () { return getPageLength() + HEADER_LENGTH; } }
public int size () { return identifier.size() + HEADER_LENGTH; } }
public int size () { return Math.min(nameString.length() + getNullTerminatedPaddingLength(), MAX_SIZE); }
public void serialize (ByteBuffer byteBuffer, int index) { byteBuffer.position(index); final int size = size();// this many bytes will be written int stringLength = Math.min(nameString.length(), MAX_SIZE); if (stringLength == MAX_SIZE) --stringLength;// at least one null character as padding // copy string characters for (int i = 0; i < stringLength; ++i) byteBuffer.put((byte) nameString.charAt(i)); // add padding for (int i = 0; i < size - stringLength; ++i) byteBuffer.put((byte) 0); }
putString(byteBuffer, VENDOR_ID, index + VENDOR_ID_FIELD_POSITION, VENDOR_ID_FIELD_LENGTH); putString(byteBuffer, PRODUCT_ID, index + PRODUCT_ID_FIELD_POSITION, PRODUCT_ID_FIELD_LENGTH); putString(byteBuffer, PRODUCT_REVISION_LEVEL, index + PRODUCT_REVISION_LEVEL_FIELD_POSITION, PRODUCT_REVISION_LEVEL_FIELD_LENGTH);
public TargetServer (final Configuration conf) { this.config = conf; LOGGER.debug("Starting jSCSI-target: "); // read target settings from configuration file LOGGER.debug(" port: " + getConfig().getPort()); LOGGER.debug(" loading targets."); // open the storage medium List<Target> targetInfo = getConfig().getTargets(); for (Target curTargetInfo : targetInfo) { targets.put(curTargetInfo.getTargetName(), curTargetInfo); // print configuration and medium details LOGGER.debug(" target name: " + curTargetInfo.getTargetName() + " loaded."); } this.deviceIdentificationVpdPage = new DeviceIdentificationVpdPage(this); this.workerPool = Executors.newCachedThreadPool(); }
responseData = StandardInquiryData.getInstance(); } else { final VitalProductDataPageName pageName = cdb.getPageCode().getVitalProductDataPageName(); responseData = SupportedVpdPages.getInstance(); break; case DEVICE_IDENTIFICATION :
public void serialize (ByteBuffer byteBuffer, int index) { // serialize header byteBuffer.position(index); byteBuffer.put(peripheralQualifierAndPeripheralDeviceType); byteBuffer.put(pageCode); ReadWrite.writeTwoByteInt(byteBuffer,// buffer getPageLength(), index + PAGE_LENGTH_FIELD_INDEX);// index }