|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.voytechs.jnetstream.codec.PacketImpl
public class PacketImpl
Note: The PacketImpl class * is usually hidden from the user and the default public JNetStream access interfaces.
Default implementation class of the Packet interface. A packet contains a list of headers that make up the packet. The last header is usually a data header containing user data in the packet.
This packet object is made up of two sets of property tables. Properties are user definable information objects that can be attached to packets. First set of tables is shared by all PacketImpl objects so there is only a single instance accross all packets. This is useful where information such as protocol/header description, RFC references are stored.
The second property table is private and is unique to each packet object. The properties are also user definable as well as some properties are automatically exported into the PacketImpl property table. Such properties as capture time, packet length and others. Users can define their own properties using the NPL statement "property local" in a NPL definition for the protocol.
| Field Summary |
|---|
| Fields inherited from interface com.voytechs.jnetstream.codec.Packet |
|---|
CAPTURE_DEVICE_ARCH, CAPTURE_DEVICE_FILENAME, CAPTURE_DEVICE_IP, CAPTURE_DEVICE_OS, CAPTURE_TIMESTAMP, DADDR, FIRST_HEADER, FLOWKEY, INDEX, PACKET_END, PACKET_LENGTH, PACKET_REMAINING, PACKET_SNAPLEN, PACKET_START, POST_NOTE, PRE_NOTE, SADDR, SUMMARY |
| Constructor Summary | |
|---|---|
PacketImpl(java.util.Map permProperties,
PacketInputStream in)
Initialize the PacketImpl object from the packet stream. |
|
| Method Summary | |
|---|---|
void |
addHeader(Header header)
Adds a new header to the packet. |
Header |
getDataHeader()
Returns the data header in the packet. |
byte[] |
getDataValue()
Retries the byte[] value from the Data header. |
Header |
getHeader(int index)
Returns the indexed header from the packet. |
Header |
getHeader(java.lang.String name)
Returns the named header from the packet. |
Header |
getHeader(java.lang.String name,
int index)
Finds all instances of the named header if more than one, and returns the index header from the headers found. |
int |
getHeaderCount()
Returns the size of this packet. |
Header |
getLastHeader()
Returns the last header in the packet excluding the Data header if its the last header. |
java.util.Map |
getPermProperties()
|
Primitive |
getProperty(java.lang.String name)
Retrieve a named property from either the permanent or temporary properties tables. |
java.lang.String |
getSummary()
Returns a 1 line summary of the packet content. |
java.util.Map |
getTempProperties()
|
java.lang.Object |
getValue(int headerIndex,
java.lang.String fieldName)
Conveniece method to retrieve a value of a field directly from a header. |
java.lang.Object |
getValue(java.lang.String propertyName)
Conveniece method to retrieve a value of a property directly from the Packet. |
java.lang.Object |
getValue(java.lang.String headerName,
java.lang.String fieldName)
Conveniece method to retrieve a value of a field directly from a header. |
boolean |
hasDataHeader()
Check for presence of the Data header. |
boolean |
hasHeader(java.lang.String name)
Checks to if the specified header exists in the packet. |
boolean |
hasHeader(java.lang.String name,
int index)
Checks if the specified index header exists. |
boolean |
hasLastHeader()
Checks to see if there is atleast 1 header in the packet. |
boolean |
hasProperty(java.lang.String name)
Checks if the specified property exists. |
boolean |
isReassembled()
If true, this packet is based on a reassembled buffer of other packets. |
protected void |
setPacketPropertiesFromStream(PacketInputStream in)
Extract some properties fromt the input stream and export them into the temporary properties tables. |
void |
setProperty(java.lang.String name,
Primitive property)
Set a property in the temporary properties table. |
void |
setReassembled(boolean reassembled)
|
java.lang.String |
toString()
Convert the PacketImpl object to pretty text for display back to user. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public PacketImpl(java.util.Map permProperties,
PacketInputStream in)
permProperties - permProperties hashtable is the shared
properties table for all PacketImpl objects.in - Initialize the PacketImpl object from the given InputStream.
Main purpose of this is to extract Stream specific properties and
export them into the PacketImpl temporary properties table. Such as
capture time, packet length, etc...| Method Detail |
|---|
protected void setPacketPropertiesFromStream(PacketInputStream in)
in - Input stream to extract properties from. The stream has
to follow the PacketInputStream interface.
public void setProperty(java.lang.String name,
Primitive property)
setProperty in interface MutablePacketname - Name of the property.property - Property value.public Primitive getProperty(java.lang.String name)
getProperty in interface Packetpublic void addHeader(Header header)
addHeader in interface MutablePacketheader - A reference to a header to be added to the list of header
within this PacketImpl object.public Header getHeader(java.lang.String name)
getHeader in interface Packetname - Name of the header to retrieve from the PacketImpl list
of headers it has.
public boolean hasHeader(java.lang.String name,
int index)
Packet
hasHeader in interface Packetname - name of the indexed header.index - index of the header with the above name
public Header getHeader(java.lang.String name,
int index)
getHeader in interface Packetpublic Header getHeader(int index)
getHeader in interface Packetindex - Index of the header to return from the list of headers.
public Header getLastHeader()
Returns the last header in the packet excluding the Data header if its the last header. Use getDataHeader() to retrieve the data header.
Packet is made up of a number of headers that the decoder was able to
decode from the capture file or stream. To find out how many headers
use the getHeaderCount() method call.
getLastHeader in interface Packetpublic Header getDataHeader()
Returns the data header in the packet. If present.
Packet is made up of a number of headers that the decoder was able to
decode from the capture file or stream. To find out how many headers
use the getHeaderCount() method call. Usually there is a catch all
header that captures the remainder of the data in the packet. This header
is called the Data header. If all available data is retrieved
then there could be an empty Data header or none at all.
getDataHeader in interface Packetpublic int getHeaderCount()
getHeaderCount in interface Packet
public java.lang.Object getValue(java.lang.String headerName,
java.lang.String fieldName)
getValue in interface PacketheaderName - Header name to lookup the field.fieldName - Field name to retrieve the value from.
public java.lang.Object getValue(int headerIndex,
java.lang.String fieldName)
getValue in interface PacketheaderIndex - Header index to lookup the field.fieldName - Field name to retrieve the value from.
public java.lang.Object getValue(java.lang.String propertyName)
getValue in interface PacketpopertyName - property name to retrieve the value from.
public java.lang.String toString()
toString in class java.lang.Objectpublic java.util.Map getPermProperties()
public java.util.Map getTempProperties()
public boolean hasHeader(java.lang.String name)
Packet
hasHeader in interface Packetname - name of the header to check for.
public boolean hasLastHeader()
Packet
hasLastHeader in interface Packetpublic boolean hasDataHeader()
Packet
hasDataHeader in interface Packetpublic byte[] getDataValue()
Packet
getDataValue in interface Packetpublic boolean hasProperty(java.lang.String name)
Packet
hasProperty in interface Packetname - Name of the property to check for.
public java.lang.String getSummary()
Packet
getSummary in interface Packetpublic void setReassembled(boolean reassembled)
b - public boolean isReassembled()
Packet
isReassembled in interface Packet
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||