org.jnetstream.packet
Interface Header

All Superinterfaces:
HeaderElement, java.lang.Iterable<HeaderElement>, com.slytechs.utils.namespace.Named
All Known Subinterfaces:
FiniteHeader
All Known Implementing Classes:
DataHeader, NullHeader

public interface Header
extends HeaderElement, java.lang.Iterable<HeaderElement>

Super interface of all headers contained within a packet. Each packet contans 0 or more protocol specific headers that are typically daisy chained. The header are part of the packet data as returned by live packet capture or as read from a capture/trace file.

This header interface does not provide any mutable methods outside of returning a mutable ByteBuffer with the header's content. The reason for this is that the header structure is built based upon the contents of the buffer and the header's NPL definition. If the header's contents have been modified structurally the entire has to be redecoded again.

The interface does not provide any methods with dealing with fields within this header or sub headers if they exist. You use the type specific header interface to check for existance of fields and sub headers and then access those fields and sub headers.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Nested Class Summary
static class Header.DynamicProperty
          Common properties found in every header that are dynamic.
static class Header.StaticProperty
          Constants which define various automatic and user defined properties.
 
Nested classes/interfaces inherited from interface com.slytechs.utils.namespace.Named
com.slytechs.utils.namespace.Named.Util
 
Method Summary
 Field<?>[] getAllFields()
           
 Header[] getAllHeaders()
           
 com.slytechs.utils.memory.BitBuffer getBuffer()
          Returns buffer containing the header's data.
<T> Field<T>
getField(DataField field)
          Retrieves field's runtime environment.
 int getLength()
          Returns the length of this header in bytes.
 java.lang.String getName()
          Returns the NPL name of this header.
 int getOffset()
          Position or offset from the start of the packet buffer this buffer belongs to.
<T> T
getProperty(Header.DynamicProperty key)
           
<T> T
getProperty(Header.StaticProperty key)
           
<T> T
getProperty(java.lang.String name)
           
 Protocol getProtocol()
           
 java.lang.Class<? extends Header> getType()
           
 boolean isTruncated()
          Tells if this header has been truncated or if all of the headers contents are contained within the packet buffer.
 
Methods inherited from interface org.jnetstream.packet.HeaderElement
getFieldConstant
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

getName

java.lang.String getName()
Returns the NPL name of this header.

Specified by:
getName in interface com.slytechs.utils.namespace.Named
Returns:
name of this header

isTruncated

boolean isTruncated()
                    throws java.io.IOException
Tells if this header has been truncated or if all of the headers contents are contained within the packet buffer. Only what is considered as header content is included in this check as defined by the underlying NPL definition. Any data past the header content is not included in this check.

Returns:
true if header contents have been truncated and entire header could not be decoded, otherwise false
Throws:
java.io.IOException

getOffset

int getOffset()
Position or offset from the start of the packet buffer this buffer belongs to.

Returns:
0-based offset of the start of this header in octets from the beginning of the packet buffer

getLength

int getLength()
Returns the length of this header in bytes.

Returns:
number of octets this header occupies

getBuffer

com.slytechs.utils.memory.BitBuffer getBuffer()
                                              throws java.io.IOException
Returns buffer containing the header's data. The buffer is backed by the packet buffer which contains all of the contents of the packet. The returned buffer position, limit and capacity properties are set to getPosition(), getPosition() + getLength() and getPosition() + getLength() respectively. No new data is allocated and any changes to the returned header buffer are also reflected in the backing packet buffer.

Returns:
buffer which contains just the header data and is backed by the underlying packet buffer
Throws:
java.io.IOException

getField

<T> Field<T> getField(DataField field)
                  throws CodecException,
                         java.io.IOException
Retrieves field's runtime environment.

Type Parameters:
T - value type of the field
Parameters:
c - class of the field's runtime environment
Returns:
the runtime evironment of the field
Throws:
java.io.IOException
CodecException

getType

java.lang.Class<? extends Header> getType()
Returns:

getProperty

<T> T getProperty(Header.StaticProperty key)
Parameters:
key -
Returns:

getProperty

<T> T getProperty(Header.DynamicProperty key)
Parameters:
key -
Returns:

getProperty

<T> T getProperty(java.lang.String name)
Type Parameters:
T -
Parameters:
name -
Returns:

getProtocol

Protocol getProtocol()
Returns:

getAllFields

Field<?>[] getAllFields()
Returns:

getAllHeaders

Header[] getAllHeaders()
Returns: