public final class ProtocolDataUnit extends Object
This class encapsulates a Protocol Data Unit (PDU), which is defined in the iSCSI Standard (RFC 3720).
| Constructor and Description |
|---|
ProtocolDataUnit(IDigest initHeaderDigest,
IDigest initDataDigest)
Default constructor, creates a new, empty ProtcolDataUnit object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears all stored content of this ProtocolDataUnit object.
|
int |
deserialize(ByteBuffer pdu)
Deserializes (parses) a given byte representation of a PDU to an PDU
object.
|
boolean |
equals(Object o) |
Iterator<org.jscsi.parser.AdditionalHeaderSegment> |
getAdditionalHeaderSegments()
Returns an iterator to all contained Additional Header Segment in this
PDU.
|
BasicHeaderSegment |
getBasicHeaderSegment()
Returns the Basic Header Segment contained in this PDU.
|
IDigest |
getDataDigest()
Returns the instance of the used digest algorithm for the data segment.
|
ByteBuffer |
getDataSegment()
Gets the data segment in this PDU.
|
IDigest |
getHeaderDigest()
Returns the instance of the used digest algorithm for the header.
|
int |
read(SocketChannel sChannel)
Reads from the given
SocketChannel all the neccassary bytes
to fill this PDU. |
ByteBuffer |
serialize()
Serialize all informations of this PDU object to its byte representation.
|
int |
serializeDataSegment(ByteBuffer dst,
int offset)
Serializes the data segment (binary or key-value pairs) to a destination
array, staring from offset to write.
|
void |
setDataDigest(IDigest newDataDigest)
Sets the digest of the data segment to use for data integrity.
|
void |
setDataSegment(ByteBuffer dataSegment) |
void |
setDataSegment(IDataSegmentIterator.IDataSegmentChunk chunk)
Sets a new data segment in this PDU.
|
void |
setHeaderDigest(IDigest newHeaderDigest)
Sets the digest of the header to use for data integrity.
|
String |
toString() |
int |
write(SocketChannel sChannel)
Writes this
ProtocolDataUnit object to the given SocketChannel. |
public ProtocolDataUnit(IDigest initHeaderDigest, IDigest initDataDigest)
initHeaderDigest - The instance of the digest to use for the Basic Header Segment
protection.initDataDigest - The instance of the digest to use for the Data Segment
protection.public final ByteBuffer serialize() throws InternetSCSIException, IOException
InternetSCSIException - If any violation of the iSCSI-Standard emerge.IOException - if an I/O error occurs.public final int deserialize(ByteBuffer pdu) throws InternetSCSIException, IOException, DigestException
pdu - The byte representation of an PDU to parse.InternetSCSIException - If any violation of the iSCSI-Standard emerge.IOException - if an I/O error occurs.DigestException - There is a mismatch of the digest.public final int serializeDataSegment(ByteBuffer dst, int offset) throws InternetSCSIException
dst - The array to write in.offset - The start offset to start from in dst.InternetSCSIException - If any violation of the iSCSI-Standard emerge.public final int write(SocketChannel sChannel) throws InternetSCSIException, IOException
ProtocolDataUnit object to the given SocketChannel.sChannel - SocketChannel to write to.InternetSCSIException - if any violation of the iSCSI-Standard emerge.IOException - if an I/O error occurs.public final int read(SocketChannel sChannel) throws InternetSCSIException, IOException, DigestException
SocketChannel all the neccassary bytes
to fill this PDU.sChannel - SocketChannel to read from.-1 if the
channel has reached end-of-streamIOException - if an I/O error occurs.InternetSCSIException - if any violation of the iSCSI-Standard emerge.DigestException - if a mismatch of the digest exists.public final void clear()
public final Iterator<org.jscsi.parser.AdditionalHeaderSegment> getAdditionalHeaderSegments()
AdditionalHeaderSegmentpublic final BasicHeaderSegment getBasicHeaderSegment()
BasicHeaderSegmentpublic final ByteBuffer getDataSegment()
ProtocolDataUnit object.public final void setDataSegment(ByteBuffer dataSegment)
public final void setDataSegment(IDataSegmentIterator.IDataSegmentChunk chunk)
chunk - The new data segment of this ProtocolDataUnit object.public final IDigest getHeaderDigest()
public final void setHeaderDigest(IDigest newHeaderDigest)
newHeaderDigest - An instance of the new header digest.public final IDigest getDataDigest()
public final void setDataDigest(IDigest newDataDigest)
newDataDigest - An instance of the new data segment digest.Copyright © 2013 University of Konstanz, Distributed Systems Group. All Rights Reserved.