|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.neeve.util.UtlListElement
com.neeve.pkt.PktSerializable
com.neeve.pkt.PktHeader
public final class PktHeader
Represents the header portion of a packet.
A packet consists of a header, body and tags. This class represents the header portion of the packet. The header consists of a fixed portion and a variable portion. The variable portion is in the form of subheaders.
The packet header is a versioned entity. The header version defines the format of the header i.e. what fields comprise the header and their relative locations when serialized. A crucial aspect of header versioning is that a version N header will always be a subset of a version M header where N < M i.e. all fields in version N of a header will be present and in the same position as fields in version M of the header. i.e. a header never shrinks or moves fields around. With time, the header can only grow. See the setter/getter method documentation for information on which header version the fields that they affect belong to.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.neeve.pkt.PktSerializable |
---|
PktSerializable.DeserializeContext, PktSerializable.SerializeContext |
Field Summary | |
---|---|
static int |
MAGIC
|
static int |
MAGIC_SIZE
|
static short |
MAX_HTL
|
static int |
STATIC_HEADER_LENGTH
|
Fields inherited from class com.neeve.util.UtlListElement |
---|
count, head, next, prev |
Method Summary | |
---|---|
PktSubheaderFMC |
activateFMCSubheader(boolean reset)
Activate the fabric multicast subheader. |
PktSubheaderFUC |
activateFUCSubheader(boolean reset)
Activate the fabric unicast subheader. |
PktSubheaderODS |
activateODSSubheader(boolean reset)
Activate the ODS subheader. |
PktSubheaderRR |
activateRRSubheader(boolean reset)
Activate the request-reply subheader. |
PktSubheaderSMA |
activateSMASubheader(boolean reset)
Activate the SMA subheader. |
static void |
clearMagic(ByteBuffer buffer,
int offset)
Clear the magic number from a serialized header |
static void |
clearMagic(PktBuffer buffer,
int offset)
Clear the magic number from a serialized header |
static PktHeader |
create(PktBody body,
Properties props)
Create a packet header |
void |
deactivateFMCSubheader()
Deactivate the fabric multicast subheader. |
void |
deactivateFUCSubheader()
Deactivate the fabric unicast subheader. |
void |
deactivateODSSubheader()
Deactivate the ODS subheader. |
void |
deactivateRRSubheader()
Deactivate the request-reply subheader. |
void |
deactivateSMASubheader()
Deactivate the SMA subheader. |
int |
deserialize(ByteBuffer buf,
int bufOffset)
Deserialize a packet header from a byte buffer |
int |
deserialize(com.neeve.io.IOBuffer iobuf,
int iobufOffset,
boolean wrap)
Deserialize a packet header from an IO buffer |
void |
deserialize(PktSerializable.DeserializeContext context,
int headerSerializedLength,
Tracer tracer)
Implementation of PktSerializable.deserialize(com.neeve.pkt.PktSerializable.DeserializeContext, int, com.neeve.trace.Tracer) . |
PktBody |
getBody()
Get the body associated with this header |
int |
getBodyType()
Get the packet body type (V1 Header Field). |
static int |
getBodyType(ByteBuffer buffer,
int offset)
Get the body type from a serialized header. |
static int |
getBodyType(PktBuffer buffer,
int offset)
Get the body type from a serialized header. |
PktBuffer |
getBuffer()
Get the internal header buffer. |
short |
getClazz()
Get the packet class (V1 Header Field). |
int |
getDest()
Get the packet destination fabric address (V1 Header Field). |
short |
getDestPort()
Get the packet destination port (V1 Header Field). |
int |
getFlow()
Get the packet flow (V1 Header Field). |
PktSubheaderFMC |
getFMCSubheader()
Get the packet fabric multicast subheader. |
PktSubheaderFUC |
getFUCSubheader()
Get the packet fabric unicast subheader. |
short |
getHtl()
Get the packet 'hops to live' (V1 Header Field). |
int |
getInitialBufferLength()
Implementation of IOElasticBuffer.Sizer.getInitialBufferLength() |
static short |
getLatestVersion()
Get the latest header version. |
int |
getLength()
Get the packet length (V1 Header Field). |
boolean |
getNoBuffering()
Get the 'no buffering' flag (V1 Header Field). |
short |
getNumSubheaders()
Get the number of attached subheaders (V1 Header Field). |
PktSubheaderODS |
getODSSubheader()
Get the packet ODS subheader. |
boolean |
getReplyExpected()
Get the 'reply expected' flag (V1 Header Field). |
PktSubheaderRR |
getRRSubheader()
Get the request-reply subheader. |
int |
getSerializedLength()
Implementation of PktSerializable.getSerializedLength()
This method returns the serialized length of the static header plus
the serialized length of all attached subheaders. |
PktSubheaderSMA |
getSMASubheader()
Get the packet SMA subheader. |
int |
getSrc()
Get the packet source fabric address (V1 Header Field). |
short |
getSrcPort()
Get the packet source port (V1 Header Field). |
int |
getStaticSerializedLength()
Get the serialized length of the only the static portion of the header. |
short |
getVersion()
Get the header format version (V1 Header Field). |
static boolean |
hasMagic(ByteBuffer buffer,
int offset)
Check if a serialized buffer is start of a packet |
void |
initializeBuffer()
Implementation of IOElasticBuffer.Initializer.initializeBuffer() |
static int |
preDeserialize(ByteBuffer buf,
int bufOffset,
int length)
Parse and return length of a serialized packet in a byte buffer |
static int |
preDeserialize(com.neeve.io.IOBuffer iobuf,
int iobufOffset,
int length)
Parse and return length of a serialized packet in an IO buffer |
static boolean |
preDeserialize(PktSerializable.DeserializeContext context)
Perform pre-deserialization checks. |
void |
reset()
Reset the contents of a packet header. |
static void |
restoreClearedMagic(ByteBuffer buffer,
int offset)
Restore the magic number cleared from a serialized header using clearMagic(java.nio.ByteBuffer, int) |
static void |
restoreClearedMagic(PktBuffer buffer,
int offset)
Restore the magic number cleared from a serialized header using clearMagic(java.nio.ByteBuffer, int) |
int |
serialize(byte[] array,
int arrayOffset)
Serialize a packet header to a byte array |
int |
serialize(ByteBuffer buf)
Serialize a packet header to a byte buffer |
int |
serialize(ByteBuffer buf,
int bufOffset)
Serialize a packet header to a byte buffer |
int |
serialize(com.neeve.io.IOBuffer iobuf,
int iobufOffset)
Serialize a packet header to an IO buffer |
int |
serialize(com.neeve.io.IOElasticBuffer iobuf,
int iobufOffset)
Serialize a packet header to an elastic IO buffer |
int |
serialize(long address,
int addressOffset)
Serialize a packet header to a native memory region |
void |
serialize(PktSerializable.SerializeContext context,
Tracer tracer)
Implementation of PktSerializable.serialize(com.neeve.pkt.PktSerializable.SerializeContext, com.neeve.trace.Tracer) . |
void |
setClazz(short clazz)
Set the packet class (V1 Header Field). |
void |
setDeserializationPolicy(int policy)
Implementation of PktSerializable.setDeserializationPolicy(int) . |
void |
setDest(int addr)
Set the packet destination fabric address (V1 Header Field). |
void |
setDestPort(short port)
Set the packet destination port (V1 Header Field). |
void |
setFlow(int flow)
Set the packet flow (V1 Header Field). |
void |
setHtl(short htl)
Set the packet 'hops to live' (V1 Header Field). |
void |
setNoBuffering(boolean val)
Set the 'no buffering' flag (V1 Header Field). |
void |
setReplyExpected(boolean val)
Set the 'reply expected' flag (V1 Header Field). |
void |
setSerializationPolicy(int policy)
Implementation of PktSerializable.setSerializationPolicy(int) . |
void |
setSrc(int addr)
Set the packet source fabric address (V1 Header Field). |
void |
setSrcPort(short port)
Set the packet source port(V1 Header Field). |
String |
toString()
Return a string representation of the object. |
Methods inherited from class com.neeve.pkt.PktSerializable |
---|
deserialize, getDeserializationPolicy, getSerializationPolicy, isValidDeserializationPolicy, isValidSerializationPolicy, serialize |
Methods inherited from class com.neeve.util.UtlListElement |
---|
count, insertAfter, insertBefore, isLinked, next, previous, unlink, wipe |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int STATIC_HEADER_LENGTH
public static final int MAGIC_SIZE
public static final int MAGIC
public static final short MAX_HTL
Method Detail |
---|
public static PktHeader create(PktBody body, Properties props)
body
- The associated bodyprops
- Property set to use in the creation of the packet header.
Currently, the header does not support any creation or operational
properties. This is present for future compatibility.
This method creates a packet header. The created header has all header elements initialized to their default values. The type and length elements are initialized as 0 upon return from this method. The type element is initialized when a packet body is associated with the header. The length field is initialized when the header is serialized. or initialized through deserialization.
Note that this method creates a standalone header that is not associated
with a packet body. A public user should only use this method in case
that is what is desired i.e. a standalone header with no associated
body. To create a packet header asociated with a body, the user should
not use this method directly. The PktFactory
packet creation
methods should be used which create and associate packet headers and
bodies.
public static final int preDeserialize(ByteBuffer buf, int bufOffset, int length)
buf
- The buffer containing the packetbufOffset
- The offset into the buffer where the packet startslength
- The number of valid bytes starting from the offset
This method parses the supplied buffer and attempts to return the length of the serialized packet starting at the supplied offset. It only considers the supplied length. If the supplied length is not enough to determine the serialized length, then this method returns 0. Otherwise, it checks the integrity of the packet by validating the magic and version and then returns the length of the packet. Note that the returned length may be more than the supplied length in which case the full packet is not present in the buffer.
EPktCorruptException
- Thrown if a valid packet does not start at
the specified offset in he buffer
EPktVersionInvalidException
- Thrown in case the buffer contains
a serialized packet with an invalid header format versionpublic static final int preDeserialize(com.neeve.io.IOBuffer iobuf, int iobufOffset, int length)
iobuf
- The buffer containing the packetiobufOffset
- The offset into the buffer where the packet startslength
- The number of valid bytes starting from the offset
This method parses the supplied buffer and attempts to return the length of the serialized packet starting at the supplied offset. It only considers the supplied length. If the supplied length is not enough to determine the serialized length, then this method returns 0. Otherwise, it checks the integrity of the packet by validating the magic and version and then returns the length of the packet. Note that the returned length may be more than the supplied length in which case the full packet is not present in the buffer.
EPktCorruptException
- Thrown if a valid packet does not start at
the specified offset in he buffer
EPktVersionInvalidException
- Thrown in case the buffer contains
a serialized packet with an invalid header format versionpublic static final boolean preDeserialize(PktSerializable.DeserializeContext context) throws EPktCorruptException, EPktVersionInvalidException
context
- The context to use for the predeserialization process.
See PktSerializable.DeserializeContext
for more information.
This method validates that the remaining data in the provided byte
buffer contains a valid and full serialized packet. If not valid, a
EPktCorruptException
is thrown. If valid but the header
format version is incorrect, a EPktVersionInvalidException
is
thrown. If valid but not complete, the method returns false and provides
information in the context parameter as to how much additional data is
needed to oomplete the packet. If the byte buffer contains a valid and
complete packet, the context parameter is unchanged.
This method does not actually initialize the header from the
provided buffer. It just serves as a deserialization prologue to
check the integrity of the header and whether enough data is present
to deserialize a complete packet. The markers of the provided buffer
are not modified by this method. The user should call this
method and, in case this method returns successfully, instantiate a
packet header and initialize it using the deserialize(com.neeve.pkt.PktSerializable.DeserializeContext, int, com.neeve.trace.Tracer)
method.
EPktCorruptException
- Thrown if the provided byte buffer does not
contain a valid serialized packet.
EPktVersionInvalidException
- Thrown in case the serialized buffer
contains an invalid header format versionpublic static final void clearMagic(ByteBuffer buffer, int offset)
public static final void clearMagic(PktBuffer buffer, int offset)
public static final void restoreClearedMagic(ByteBuffer buffer, int offset)
clearMagic(java.nio.ByteBuffer, int)
public static final void restoreClearedMagic(PktBuffer buffer, int offset)
clearMagic(java.nio.ByteBuffer, int)
public static final boolean hasMagic(ByteBuffer buffer, int offset)
public static final short getLatestVersion()
This method returns the latest header version i.e. the version used when headers are created explicitly i.e. not through deserialization
public final short getVersion()
public final int getLength()
This method returns the packet length set in the packet header. This
field is set by the serialize(com.neeve.pkt.PktSerializable.SerializeContext, com.neeve.trace.Tracer)
method and can be used by
the user after a call to serialize(com.neeve.pkt.PktSerializable.SerializeContext, com.neeve.trace.Tracer)
to check the length of the
serialized packet. Note that although this field contains the length
of the full packet, the serialize(com.neeve.pkt.PktSerializable.SerializeContext, com.neeve.trace.Tracer)
method does not serialize
the attached body (if present). That is the responsibility of the user.
public final void setSrc(int addr)
addr
- The fabric address to setpublic final int getSrc()
public final void setDest(int addr)
addr
- The fabric address to setpublic final int getDest()
public final void setSrcPort(short port)
port
- The port to setpublic final short getSrcPort()
public final void setDestPort(short port)
port
- The port to setpublic final short getDestPort()
public final void setFlow(int flow)
flow
- The packet flow to setpublic final int getFlow()
public final void setNoBuffering(boolean val)
This method is used to specify that the packet should be delivered to the intended destination with as little latency as possible. This flag is used by intermediate network links as a directive to not buffer the packet but to flush it through the network ASAP.
public final boolean getNoBuffering()
public final void setReplyExpected(boolean val)
This method is used to specify that the packet is the request in a request-reply exchange.
public final boolean getReplyExpected()
public final void setHtl(short htl)
htl
- The htl to set. Although the type of this parameter
is short, it is encoded on the wire as a single byte. Thus, only the
lower byte is used from this parameter. The reason for this is that we
want to treat htl as an 'unsigned byte'public final short getHtl()
public final void setClazz(short clazz)
clazz
- The packet class to set. Although the type of this
parameter is short, it is encoded on the wire as a single byte.
Thus, only the lower byte is used from this parameter. The reason
for this is that we want to treat clazz as an 'unsigned byte'public final short getClazz()
public final int getBodyType()
public static final int getBodyType(PktBuffer buffer, int offset)
This method returns the body type encoded in a serialized packet header. If the header was serialized without an attached body, then the type field will be zero in the serialized header.
The body type field is only guaranteed to be set during header serialization time into the serialization buffer which may be different from the header buffer depending on the serialization policy used. Thus, even if the body is set in a header, it is not guaranteed that the header buffer will contain the serialized body type prior to serialization or even after serialization in case the header was copied into a separate buffer during serialization. Therefore, this method is only reliable for use to get the body type from a serialized header.
public static final int getBodyType(ByteBuffer buffer, int offset)
getBodyType(PktBuffer, int)
public final short getNumSubheaders()
public final PktBuffer getBuffer()
This method returns the internal buffer used to store elements of the static portion of the header. Each subheader maintains its own buffer. The user must not modify the contents of this buffer. Use the header element setter/getter methods to modify the contents of the buffer.
public final PktSubheaderRR activateRRSubheader(boolean reset)
reset
- Indicates whether the subheader should be reset after
activation. This flag is only present for those situations where
the user deactivates a subheader and then reactivates for use but
only partially re-populates the header after re-activation.It is safe to activate an already active sub-header.
public final void deactivateRRSubheader()
It is safe to deactivate an already inactive sub-header.
public final PktSubheaderRR getRRSubheader()
public final PktSubheaderFMC activateFMCSubheader(boolean reset)
reset
- Indicates whether the subheader should be reset after
activation. This flag is only present for those situations where
the user deactivates a subheader and then reactivates for use but
only partially re-populates the header after re-activation.It is safe to activate an already active sub-header.
public final void deactivateFMCSubheader()
It is safe to deactivate an already inactive sub-header.
public final PktSubheaderFMC getFMCSubheader()
public final PktSubheaderFUC activateFUCSubheader(boolean reset)
reset
- Indicates whether the subheader should be reset after
activation. This flag is only present for those situations where
the user deactivates a subheader and then reactivates for use but
only partially re-populates the header after re-activation.It is safe to activate an already active sub-header.
public final void deactivateFUCSubheader()
It is safe to deactivate an already inactive sub-header.
public final PktSubheaderFUC getFUCSubheader()
public final PktSubheaderSMA activateSMASubheader(boolean reset)
reset
- Indicates whether the subheader should be reset after
activation. This flag is only present for those situations where
the user deactivates a subheader and then reactivates for use but
only partially re-populates the header after re-activation.It is safe to activate an already active sub-header.
public final void deactivateSMASubheader()
It is safe to deactivate an already inactive sub-header.
public final PktSubheaderSMA getSMASubheader()
public final PktSubheaderODS activateODSSubheader(boolean reset)
reset
- Indicates whether the subheader should be reset after
activation. This flag is only present for those situations where
the user deactivates a subheader and then reactivates for use but
only partially re-populates the header after re-activation.It is safe to activate an already active sub-header.
public final void deactivateODSSubheader()
It is safe to deactivate an already inactive sub-header.
public final PktSubheaderODS getODSSubheader()
public final PktBody getBody()
public final void reset()
This method resets the contents of a header. Upon return from this method, the contents of the header are the same as a freshly created header of the latest header version.
This method retains its reference to it container packet (if any).
This method is intended for use with object pools through which packet header objects can be recycled rather than created fresh every time.
public final void setSerializationPolicy(int policy)
PktSerializable.setSerializationPolicy(int)
.
setSerializationPolicy
in class PktSerializable
policy
- The serialization policy to use for this entity. The
following are the permissible serialization policies:PktConstants.SERIALIZE_POLICY_HEADER_COPY_BODY_COPY
PktConstants.SERIALIZE_POLICY_HEADER_COPY_BODY_ATTACH
PktConstants.SERIALIZE_POLICY_HEADER_ATTACH_BODY_ATTACH
public final void serialize(PktSerializable.SerializeContext context, Tracer tracer) throws EPktSerializeException
PktSerializable.serialize(com.neeve.pkt.PktSerializable.SerializeContext, com.neeve.trace.Tracer)
.
This method serializes the packet header into the buffer list
in the specified serialization context. This method invokes
PktSerializable.resolveSerializationPolicy(int)
using the
policy in the specified context to resolve the serialization
policy to use. The default serialization policy set in this
entity is determined using the configuration information for
the type of the packet being serialized.
The user should note that this method only serializes the packet header. The user is responsible for serializing the packet body separately.
serialize
in class PktSerializable
context
- The context to be used by the serialization process. See
PktSerializable.SerializeContext
for more information.tracer
- Tracer used to output serialization related trace. Can be
null in which case no trace is output.
EPktSerializeException
- Thrown in case an error is encountered
during the serialization process.
This method serializes a serialiable entity into a byte array presented as a set of byte buffers. As input, this method accepts a serialization context that, among other fields, contains a list of buffers of type {link java.nio.ByteBuffer} into which the entity is to serialize itself. The serialization operation is policy driven and the policy determines whether the header is copied into space remaining in the provided buffers or whether the internal entity buffers are just appended to the provided buffer list. In case the decision is made to copy the serialized data into the provided buffers, the data is always copied into the last buffer in the list. In case the last buffer does not contain enough remaining space to accomodate all the serialized data, this method will allocate and append a new buffer that will be of the same type and capacity as the last buffer in the provided list. Read the documentation of the policy constants to understand which policies cause the header to be copied as opposed to appended (the policy constant names are also self descriptive)
public final int serialize(ByteBuffer buf)
buf
- The byte buffer to serialize to
This method serialized the contents of a packet header by copying the contents of the packet header's buffer to a byte buffer. This method copies the contents to the target buffer starting at the target buffer's position. This method does not change any of the markers of the target byte buffer.
Note:Since this method does not change any markers of the target buffer, the caller needs to ensure the buffer limit is set correctly to accommodate the header's contents. The caller can invokegetSerializedLength()
to get
the length of the header's contents and use that to set the target buffer's
limit before invoking this method.
public final int serialize(ByteBuffer buf, int bufOffset)
buf
- The byte buffer to serialize tobufOffset
- The offset into the buffer where the serialized contents
of the packet header needs to be serialized (copied)
This method serialized the contents of a packet header by copying the contents of the packet header's buffer to a byte buffer. This method copies the contents to the target buffer starting at the supplied buffer offset. This method does not change any of the markers of the target byte buffer.
Note:Since this method does not change any markers of the target buffer, the caller needs to ensure the buffer limit is set correctly to accommodate the header's contents. The caller can invokegetSerializedLength()
to get
the length of the header's contents and use that to set the target buffer's
limit before invoking this method.
public final int serialize(byte[] array, int arrayOffset)
array
- The byte array to serialize toarrayOffset
- The offset into the array where the serialized contents
of the packet header needs to be serialized (copied)
This method serialized the contents of a packet header by copying the contents of the packet header's buffer to a byte array.
public final int serialize(com.neeve.io.IOBuffer iobuf, int iobufOffset)
iobuf
- The IO buffer to serialize toiobufOffset
- The offset into the IO buffer where the serialized contents
of the packet header needs to be serialized (copied)
This method serialized the contents of a packet header by copying the contents of the packet header's buffer to a IO buffer.
public final int serialize(com.neeve.io.IOElasticBuffer iobuf, int iobufOffset)
iobuf
- The IO buffer to serialize toiobufOffset
- The offset into the IO buffer where the serialized contents
of the packet header needs to be serialized (copied)
This method serialized the contents of a packet header by copying the contents of the packet header's buffer to an elastic IO buffer.
public final int serialize(long address, int addressOffset)
address
- The address of the native memory region to serialize toaddressOffset
- The offset into the memory region where the serialized
contents of the packet header should be serialized to.
This method serialized the contents of a packet header by copying the contents of the packet header's buffer to a native memory region.
public final void setDeserializationPolicy(int policy)
PktSerializable.setDeserializationPolicy(int)
.
setDeserializationPolicy
in class PktSerializable
policy
- The deserialization policy to use for this entity. The
following are the permissible serialization policies:PktConstants.DESERIALIZE_POLICY_HEADER_COPY_BODY_COPY
PktConstants.DESERIALIZE_POLICY_HEADER_COPY_BODY_SLICE
PktConstants.DESERIALIZE_POLICY_HEADER_SLICE_BODY_SLICE
public final void deserialize(PktSerializable.DeserializeContext context, int headerSerializedLength, Tracer tracer) throws EPktDeserializeException
PktSerializable.deserialize(com.neeve.pkt.PktSerializable.DeserializeContext, int, com.neeve.trace.Tracer)
.
This method does not does not check for packet integrity or
whether the buffer contains a full packet header or not. The user
should call preDeserialize(java.nio.ByteBuffer, int, int)
before invoking this method to
check for packet integrity and whether the buffer contains a full
packet before calling this method. This method should only be
subsequently called in case the preDeserialize(java.nio.ByteBuffer, int, int)
method
returns successfully i.e. the serialized packet has correct integrity
and the full packet is contained in the buffer. Calling this method
using a corrupt or incomplete buffer has undefined results.
This method invokes PktSerializable.deserialize(com.neeve.pkt.PktSerializable.DeserializeContext, int, com.neeve.trace.Tracer)
using the
policy in the specified context to reolve the deserialization policy
to use. The default deserialization policy set in this entity is
determined using the configuration information for the type of the
packet being deserialized.
deserialize
in class PktSerializable
context
- The context to be used by the deserialization process.
See PktSerializable.DeserializeContext
for more information.headerSerializedLength
- This parameter is present for entities
whose serialized form does not contain the serialized length of the
entity. For such entities, the caller needs to pass in the serialized
length to the entity during deserialize time. For other entities, this
value will be ignored and should be set to -1 (some entities that
pull the length from the serialized form may indeed validate that
the passed in value is -1)tracer
- Tracer used to output deserialization related trace. Can be
null in which case no trace is output.
EPktDeserializeException
- Thrown in case an error is encountered
during the deserialization process.
This method initializes a serializable entity from a byte buffer. As
input, this method accepts a deserialization context that contains, in
addition to other fields, a ByteBuffer
from where
the entity is to be initialized. It is assumed that the caller has
validated (using some other means) that the buffer contains enough data
to initialize the entity. Upon successful return, the context is
updated with information relating to the deserialization e.g. how
many bytes were consumed from the buffer to initialize the entity
and whether a reference to the buffer is being retained by the entity
subsequent to returning from this method. Refer to the context
documentation for detailed information on how and when the fields
are updated.
Before returning from this method, the implementation must replace the buffer in the context with a sliced version of the provided buffer so that the next entity in the deserialization chain can operate out of the buffer provided to it using absolute indices i.e. relative to the beginning of the buffer rather than relative to the current buffer position.
public final int deserialize(ByteBuffer buf, int bufOffset)
buf
- The byte buffer to deserialize frombufOffset
- The offset into the buffer where the serialized contents
of the packet header begins.
This method deserializes the contents of a packet header by copying contents from a byte buffer to the packet header's buffer. This method copies the content starting from the supplied offset. It does not change any of the markers of the source byte buffer
This method does not does not check for packet integrity or whether the buffer
contains a full packet header or not. The user should call preDeserialize(java.nio.ByteBuffer, int, int)
before
invoking this method to check for packet integrity and whether the buffer contains a full
packet before calling this method. This method should only be subsequently called in case
the preDeserialize(java.nio.ByteBuffer, int, int)
method returns successfully i.e. the serialized packet has
correct integrity and the full packet is contained in the buffer. Calling this method
using a corrupt or incomplete buffer has undefined results.
public final int deserialize(com.neeve.io.IOBuffer iobuf, int iobufOffset, boolean wrap)
iobuf
- The IO buffer to deserialize fromiobufOffset
- The offset into the IO buffer where the serialized contents
of the packet header begins.wrap
- Indicates whether the deserialization process should copy the
contents of the IO buffer to the packet header or wrap the packet header and
subheader's buffers around the supplied IO buffer
This method deserializes the contents of a packet header by wrapping or copying contents from a byte buffer to the packet header's buffer.
This method does not does not check for packet integrity or whether the IO
buffer contains a full packet header or not. The user should call preDeserialize(java.nio.ByteBuffer, int, int)
before invoking this method to check for packet integrity and whether the buffer contains
a full packet before calling this method. This method should only be subsequently called
in case the preDeserialize(java.nio.ByteBuffer, int, int)
method returns successfully i.e. the serialized packet
has correct integrity and the full packet is contained in the buffer. Calling this method
using a corrupt or incomplete buffer has undefined results.
public final int getStaticSerializedLength()
This method returns the serialized length of only the static portion of the header. This length is governed by the header version. /P>
public final int getSerializedLength()
PktSerializable.getSerializedLength()
This method returns the serialized length of the static header plus the serialized length of all attached subheaders.
getSerializedLength
in class PktSerializable
public final int getInitialBufferLength()
IOElasticBuffer.Sizer.getInitialBufferLength()
getInitialBufferLength
in interface com.neeve.io.IOElasticBuffer.Sizer
public final void initializeBuffer()
IOElasticBuffer.Initializer.initializeBuffer()
initializeBuffer
in interface com.neeve.io.IOElasticBuffer.Initializer
public final String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |