Skip to content

Commit

Permalink
Merge pull request #3 from ActiveVolcano/config
Browse files Browse the repository at this point in the history
Add listening address configuration in XML file
  • Loading branch information
ActiveVolcano committed Aug 5, 2022
2 parents cc69317 + df5bbec commit 74b0404
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 84 deletions.
40 changes: 21 additions & 19 deletions bundles/commons/src/main/java/org/jscsi/parser/login/ISID.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* Copyright (c) 2012, University of Konstanz, Distributed Systems Group All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation and/or other materials provided with the
* distribution. * Neither the name of the University of Konstanz nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
Expand Down Expand Up @@ -147,7 +147,7 @@
* it is installed (see Section 9.1.1 Conservative Reuse of ISIDs and Section 9.1.2 iSCSI Name, ISID, and TPGT Use). The
* resultant ISID MUST also be persistent over power cycles, reboot, card swap, etc. For details have a look in the
* [RFC3721].
*
*
* @author Volker Wildi
*/
public final class ISID {
Expand Down Expand Up @@ -186,7 +186,7 @@ private Format (final byte newValue) {

/**
* Returns the value of this enumeration.
*
*
* @return The value of this enumeration.
*/
public final byte value () {
Expand All @@ -196,7 +196,7 @@ public final byte value () {

/**
* Returns the constant defined for the given <code>value</code>.
*
*
* @param value The value to search for.
* @return The constant defined for the given <code>value</code>. Or <code>null</code>, if this value is not
* defined by this enumeration.
Expand All @@ -209,6 +209,7 @@ public static final Format valueOf (final byte value) {
}

/** Bit mask to extract the first int out from a long. */
@SuppressWarnings("unused")
private static final long FIRST_LINE_FLAG_MASK = 0xFFFFFFFF00000000L;

/** Bit flag mask to get the field <code>A</code> in this ISID. */
Expand Down Expand Up @@ -247,7 +248,7 @@ public ISID () {

/**
* This constructor creates a new ISID object with the given settings.
*
*
* @param initT The new T-Value.
* @param initA The new A-Value.
* @param initB The new B-Value.
Expand All @@ -266,7 +267,7 @@ public ISID (final Format initT, final byte initA, final short initB, final byte
/**
* This method creates an Initiator Session ID of the <code>Random</code> format defined in the iSCSI Standard
* (RFC3720).
*
*
* @param seed The initialization seed for random generator.
* @return A instance of an <code>ISID</code>.
*/
Expand All @@ -285,7 +286,7 @@ public static final ISID createRandom (final long seed) {

/**
* Serializes this ISID object ot its byte representation.
*
*
* @return The byte representation of this ISID object.
* @throws InternetSCSIException If any violation of the iSCSI-Standard emerge.
*/
Expand All @@ -300,7 +301,7 @@ public final long serialize () throws InternetSCSIException {
firstLine |= a << Constants.THREE_BYTES_SHIFT;
firstLine &= 0x00ffffff;
firstLine |= t.value() << T_FIELD_SHIFT;

isid = Utils.getUnsignedLong(firstLine) << Constants.FOUR_BYTES_SHIFT;
isid |= Utils.getUnsignedLong(d) << Constants.TWO_BYTES_SHIFT;

Expand All @@ -309,13 +310,13 @@ public final long serialize () throws InternetSCSIException {

/**
* Parses a given ISID in this ISID obejct.
*
*
* @param isid The byte representation of a ISID to parse.
* @throws InternetSCSIException If any violation of the iSCSI-Standard emerge.
*/
final void deserialize ( long isid) throws InternetSCSIException {
int line = (int) (isid >>> Constants.FOUR_BYTES_SHIFT);

t = Format.valueOf((byte) (line >>> T_FIELD_SHIFT));
a = (byte) ((line & A_FIELD_FLAG_MASK) >>> Constants.THREE_BYTES_SHIFT);
b = (short) ((line & Constants.MIDDLE_TWO_BYTES_SHIFT) >>> Constants.ONE_BYTE_SHIFT);
Expand All @@ -332,9 +333,10 @@ final void deserialize ( long isid) throws InternetSCSIException {

/**
* Creates a string with all fields of this ISID object.
*
*
* @return The string representation.
*/
@Override
public final String toString () {

final StringBuilder sb = new StringBuilder(Constants.LOG_INITIAL_SIZE);
Expand All @@ -351,7 +353,7 @@ public final String toString () {

/**
* This method compares a given ISID object with this object for value equality.
*
*
* @param isid The given ISID object to check.
* @return <code>True</code>, if the values of the two ISID objects are equal. Else <code>false</code>.
*/
Expand Down Expand Up @@ -408,7 +410,7 @@ public final void clear () {

/**
* Returns the value of the field <code>A</code>.
*
*
* @return The value of the field <code>A</code>.
*/
public final byte getA () {
Expand All @@ -418,7 +420,7 @@ public final byte getA () {

/**
* Returns the value of the field <code>B</code>.
*
*
* @return The value of the field <code>B</code>.
*/
public final short getB () {
Expand All @@ -428,7 +430,7 @@ public final short getB () {

/**
* Returns the value of the field <code>C</code>.
*
*
* @return The value of the field <code>C</code>.
*/
public final byte getC () {
Expand All @@ -438,7 +440,7 @@ public final byte getC () {

/**
* Returns the value of the field <code>D</code>.
*
*
* @return The value of the field <code>D</code>.
*/
public final short getD () {
Expand All @@ -448,7 +450,7 @@ public final short getD () {

/**
* Returns the value of the field <code>T</code>.
*
*
* @return The value of the field <code>T</code>.
*/
public final Format getT () {
Expand All @@ -461,7 +463,7 @@ public final Format getT () {

/**
* This method checks, if all fields are valid. In these cases an exception will be thrown.
*
*
* @throws InternetSCSIException If the integrity is violated.
*/
protected final void checkIntegrity () throws InternetSCSIException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* Copyright (c) 2012, University of Konstanz, Distributed Systems Group All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation and/or other materials provided with the
* distribution. * Neither the name of the University of Konstanz nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
Expand All @@ -28,7 +28,6 @@
import org.jscsi.parser.ProtocolDataUnit;
import org.jscsi.parser.TargetMessageParser;
import org.jscsi.parser.datasegment.DataSegmentFactory.DataSegmentFormat;
import org.jscsi.parser.logout.LogoutResponse;
import org.jscsi.utils.Utils;


Expand Down Expand Up @@ -63,14 +62,14 @@
* <p>
* <h4>TotalAHSLength and DataSegmentLength</h4> For this PDU TotalAHSLength and DataSegmentLength MUST be
* <code>0</code>.
*
*
* @author Volker Wildi
*/
public final class TaskManagementFunctionResponseParser extends TargetMessageParser {

/**
* This enumeration defines all valid response code, which are defined in the iSCSI Standard (RFC 3720).
*
*
* @author Volker Wildi
*/
public static enum ResponseCode {
Expand Down Expand Up @@ -110,7 +109,7 @@ private ResponseCode (final byte newValue) {

/**
* Returns the value of this enumeration.
*
*
* @return The value of this enumeration.
*/
public final byte value () {
Expand All @@ -120,7 +119,7 @@ public final byte value () {

/**
* Returns the constant defined for the given <code>value</code>.
*
*
* @param value The value to search for.
* @return The constant defined for the given <code>value</code>. Or <code>null</code>, if this value is not
* defined by this enumeration.
Expand All @@ -142,7 +141,7 @@ public static final ResponseCode valueOf (final byte value) {

/**
* Default constructor, creates a new, empty <code>TaskManagementFunctionResponseParser</code> object.
*
*
* @param initProtocolDataUnit The reference <code>ProtocolDataUnit</code> instance, which contains this
* <code>TaskManagementFunctionResponseParser</code> subclass object.
*/
Expand Down Expand Up @@ -260,7 +259,7 @@ public final void clear () {
* field in the Task Management function request is outside the valid CmdSN window, then targets must return the
* "Task does not exist" response.</li>
* </ol>
*
*
* @return The response code of this <code>TaskManagementFunctionResponseParser</code> object.
*/
public final ResponseCode getResponse () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* Copyright (c) 2012, University of Konstanz, Distributed Systems Group All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation and/or other materials provided with the
* distribution. * Neither the name of the University of Konstanz nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
Expand All @@ -23,7 +23,7 @@
* <p/>
* This class encapsulate the behavior of how to compare and increment a number in Serial Number Arithmetic, which is
* defined in [RFC1982].
*
*
* @author Volker Wildi, University of Konstanz
*/
public final class SerialArithmeticNumber implements Comparable<Integer> {
Expand Down Expand Up @@ -57,7 +57,7 @@ public SerialArithmeticNumber () {
/**
* Constructor to create a new <code>SerialArithmeticNumber</code> instance, which is initialized to
* <code>startValue</code>.
*
*
* @param startValue The start value.
*/
public SerialArithmeticNumber (final int startValue) {
Expand All @@ -72,17 +72,17 @@ public SerialArithmeticNumber (final int startValue) {

/**
* Same as the <code>compareTo</code> method only with the exception of another parameter type.
*
*
* @param anotherSerialNumber The number to compare with.
* @return a negative integer, zero, or a positive integer as this <code>SerialArithmeticNumber</code> is less than,
* equal to, or greater than the given number.
*/
public final int compareTo (final int anotherSerialNumber) {

return compareTo(new Integer(anotherSerialNumber));
return compareTo(anotherSerialNumber);
}

/** {@inheritDoc} */
@Override
public final synchronized int compareTo (final Integer anotherSerialNumber) {

long diff = serialNumber - Utils.getUnsignedLong(anotherSerialNumber.intValue());
Expand All @@ -99,7 +99,7 @@ public final synchronized int compareTo (final Integer anotherSerialNumber) {

/**
* Returns the current value of this <code>SerialArithmeticNumber</code> instance.
*
*
* @return The current value of this <code>SerialArithmeticNumber</code> instance.
*/
public final synchronized int getValue () {
Expand All @@ -121,7 +121,7 @@ public final synchronized void increment () {

/**
* Updates the value of this <code>SerialArithmeticNumber</code> instance to the given one.
*
*
* @param newValue The new value.
*/
public final synchronized void setValue (final int newValue) {
Expand Down
Loading

0 comments on commit 74b0404

Please sign in to comment.