|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.InputStream
com.voytechs.jnetstream.io.ProtocolDataInputStream
com.voytechs.jnetstream.io.PacketInputStream
public abstract class PacketInputStream
Stream object that reads either an InputStream of bytes and allows
access to the byte stream with the following features:
1) data can be read in either bytes or individual bits.
2) position within the stream can be pushed on to a stack
3) position can be poped off of the stack.
4) a packet structure is imposed on the stream so that you can query or
be notified when the end of an individual packet byte stream is over
and when the next packet byte stream is beginning.
5) data can be read in any binary format (Big Endian or Little Endian)
6) Packet capture information is accessable, such as:
a) IP address of the capture device.
b) interface or filename the packet was captured on.
c) capture time of the packet
d) length of the entire packet in bytes
e) OS name of the capture device
d) OS version of the capture device
| Nested Class Summary | |
|---|---|
static class |
PacketInputStream.BufferedHeader
Debug class which returns byte buffer of the headers mainly for debug purposes. |
| Field Summary | |
|---|---|
protected java.lang.String |
captureDeviceArch
Capture device hardware architecture. |
protected java.lang.String |
captureDeviceFilename
Name of the file or interface the capture occured. |
protected IpAddress |
captureDeviceIp
Capture device IP address. |
protected java.lang.String |
captureDeviceOS
Capture device OS. |
protected boolean |
captureLive
Flag indicating if the stream is comming from a live capture or a pre-captured file. |
protected boolean |
debugHeaders
|
protected PacketInputStream.BufferedHeader |
fileHeader
|
protected java.lang.String |
linkType
|
protected java.sql.Timestamp |
packetCaptureTimestamp
Capture time of the packet. |
protected long |
packetEnd
|
protected long |
packetLength
Length of the captured packet. |
protected long |
packetSnaplen
|
protected long |
packetStart
|
protected long |
recordEnd
|
protected PacketInputStream.BufferedHeader |
recordHeader
|
protected long |
recordLength
|
protected long |
recordStart
|
BitStackInputStream |
stackIn
Reference to stack input so we can push() and pop() positions witin. |
| Fields inherited from class com.voytechs.jnetstream.io.ProtocolDataInputStream |
|---|
bitsLeft, in |
| Constructor Summary | |
|---|---|
PacketInputStream(BitStackInputStream inputStream)
|
|
| Method Summary | |
|---|---|
int |
bitsLeft()
|
void |
clear()
Clears previously pushed position off of a stack and without rewinding the stream. |
IpAddress |
getCaptureDeviceAddress()
Return IP address of the device the stream originated on or if known where the capture occured. |
java.lang.String |
getCaptureDeviceArch()
Return OS name of the device the stream originated or if know where the capture occured. |
java.lang.String |
getCaptureDeviceFilename()
Return filename name or interface name of the source of this data. |
IpAddress |
getCaptureDeviceIp()
Return Ip address of the source of this data. |
java.lang.String |
getCaptureDeviceOS()
Return OS name of the device the stream originated or if know where the capture occured. |
java.sql.Timestamp |
getCaptureTimestamp()
returns the time the packet was captured. |
java.lang.String |
getFileFormatName()
|
PacketInputStream.BufferedHeader |
getFileHeader()
|
java.lang.String |
getLinkType()
Returns the name of the first header in the packet. |
long |
getPacketEnd()
Returns the ending position of the packet in bytes. |
long |
getPacketLength()
Returns the length of the packet in bytes as seen on the wire. |
int |
getPacketLengthRemaining()
Returns the length of the packet in bytes. |
long |
getPacketSnaplen()
Returns the length of the packet in bytes. |
long |
getPacketStart()
Returns the beginning position of the packet in bytes. |
int |
getPaddingLength()
Returns the length of padding at the end of the record. |
long |
getRecordEnd()
Returns the position of the record end in the stream. |
PacketInputStream.BufferedHeader |
getRecordHeader()
|
protected long |
getRecordHeaderLength()
Returns the length of the record header excluding the rest of the packet. |
long |
getRecordLength()
Returns the length of the packet in bytes. |
protected long |
getRecordStart()
Returns the start of the packet record in the stream including all the headers. |
protected void |
goToEndOfRecord()
A special method that forwards the current position in the stream to the end of the packet. |
boolean |
gotoMark(java.lang.String markName)
|
protected boolean |
hasForceRead()
Indicates the state of the forceRead flag. |
static java.lang.String |
hex(int b)
A little internal conversion utility function to print int in hex. |
protected void |
initPacketStream()
Read stream ID data. |
protected void |
initRecordHeader()
Read pre-packet header from stream. |
boolean |
isCaptureLive()
Idicates wheather this capture stream is from a live source or offline or file data. |
boolean |
isCompressed()
|
boolean |
isDebugHeaders()
|
boolean |
isPacketReady()
Returns a flag indicating if stream is ready for packet processing. |
protected boolean |
isReady()
Returns a flag indicating if stream is ready for packet processing. |
protected boolean |
isReady(int len)
Returns a flag indicating if stream is ready for packet processing. |
static void |
main(java.lang.String[] args)
Test function for PacketInputStream |
void |
nextPacket()
Prepares the stream for the next packet in the stream. |
void |
pop()
Pops previously pushed position off of a stack and rewids the stream. |
long |
position()
protected accessible method that reports the position within the overall stream. |
static void |
printStream(java.io.InputStream in,
int printCount)
Dumps the contents of InputStream in hex. |
void |
push()
Pushes the current position in the stream onto a stack. |
void |
push(java.lang.String markName)
Pushes the current position in the stream onto a stack and mark's it with a name. |
int |
read()
Read packet data from the stream. |
protected void |
setCaptureTimestamp(java.sql.Timestamp captureTimestamp)
Sets the current capture timestamp. |
void |
setCompressed(boolean compressed)
|
void |
setDebugHeaders(boolean debugHeaders)
|
protected void |
setForceRead(boolean status)
Allow reads by force. |
void |
setIncludePadding(boolean includePaddingFlag)
Makes the stream also return any padding as packet data. |
protected void |
setLinkType(java.lang.String linkType)
Sets the First Header in the packet, usually a Data link layer, but not neccessarily. |
protected void |
setPacketLength(long length)
Sets the original packet length as seen on the network wire. |
protected void |
setPacketSnaplen(long length)
Sets the trunkated packet length during the capture. |
void |
setPacketStart(long start)
Sets the start of the packet in the stream. |
protected void |
setRecordLength(long length)
Sets the trunkated packet length during the capture. |
protected void |
setRecordStart(long start)
This is an unusual call, since record start and record end are normally computed by call to nextPacket() method which advances the stream to the beginning of the next record and after reading of the pre-header to the beginning of the packet in the stream. |
long |
skip(long bytes)
Skip ahead. |
| Methods inherited from class com.voytechs.jnetstream.io.ProtocolDataInputStream |
|---|
readBits, readBitsLong, readBoolean, readByte, readerUnsignedLongLittleEndian, readFromPacket, readFromPacket, readInt, readIntLittleEndian, readLong, readLongLittleEndian, readShort, readShortLittleEndian, readUnsignedByte, readUnsignedInt, readUnsignedIntLittleEndian, readUnsignedLong, readUnsignedShort, readUnsignedShortLittleEndian, reThrow |
| Methods inherited from class java.io.InputStream |
|---|
available, close, mark, markSupported, read, read, reset |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public BitStackInputStream stackIn
protected long packetLength
protected long packetSnaplen
protected long packetStart
protected long packetEnd
protected long recordLength
protected long recordStart
protected long recordEnd
protected boolean debugHeaders
protected PacketInputStream.BufferedHeader fileHeader
protected PacketInputStream.BufferedHeader recordHeader
protected java.sql.Timestamp packetCaptureTimestamp
protected IpAddress captureDeviceIp
protected java.lang.String captureDeviceOS
protected java.lang.String captureDeviceArch
protected java.lang.String captureDeviceFilename
protected boolean captureLive
protected java.lang.String linkType
| Constructor Detail |
|---|
public PacketInputStream(BitStackInputStream inputStream)
throws java.io.IOException,
EOPacketStream,
StreamFormatException
-
java.io.IOException
EOPacketStream
StreamFormatException| Method Detail |
|---|
public java.lang.String getLinkType()
protected void setLinkType(java.lang.String linkType)
linkType - First Header in the packet, usually a Data Link frame type.protected long getRecordStart()
protected void setRecordStart(long start)
start - start position in the stream.public long getRecordLength()
public long getRecordEnd()
protected void setRecordLength(long length)
protected long getRecordHeaderLength()
public long getPacketLength()
protected void setPacketLength(long length)
length - length in bytes of packet as seen on the wire.public long getPacketSnaplen()
protected void setPacketSnaplen(long length)
length - length of the packet record in the capture file or stream.public long getPacketStart()
public void setPacketStart(long start)
public long getPacketEnd()
public int getPacketLengthRemaining()
public java.sql.Timestamp getCaptureTimestamp()
protected void setCaptureTimestamp(java.sql.Timestamp captureTimestamp)
public IpAddress getCaptureDeviceAddress()
public java.lang.String getCaptureDeviceOS()
public java.lang.String getCaptureDeviceArch()
public java.lang.String getCaptureDeviceFilename()
public IpAddress getCaptureDeviceIp()
public boolean isCaptureLive()
protected void initPacketStream()
throws java.io.IOException,
EOPacketStream,
StreamFormatException
java.io.IOException
EOPacketStream
StreamFormatException
protected void initRecordHeader()
throws java.io.IOException,
EOPacketStream,
StreamFormatException
java.io.IOException
EOPacketStream
StreamFormatExceptionpublic void push()
public void push(java.lang.String markName)
public boolean gotoMark(java.lang.String markName)
public void pop()
public void clear()
protected void setForceRead(boolean status)
protected boolean hasForceRead()
setForceRead(boolean status)
public int read()
throws java.io.IOException
read in class ProtocolDataInputStreamjava.io.IOException - Any problems with the stream IO.
public void nextPacket()
throws java.io.IOException,
EOPacketStream,
StreamFormatException
java.io.IOException
EOPacketStream
StreamFormatException
protected void goToEndOfRecord()
throws java.io.IOException,
StreamFormatException
java.io.IOException
StreamFormatException
public long skip(long bytes)
throws java.io.IOException
skip in class java.io.InputStreamjava.io.IOExceptionpublic long position()
public int bitsLeft()
public boolean isPacketReady()
public void setIncludePadding(boolean includePaddingFlag)
includePaddingFlag - If true, padding will be included when reading from the stream.
If false, padding will not be included and skipped during the next nextPacket() call.public int getPaddingLength()
protected boolean isReady()
throws EOPacket
isReady in class ProtocolDataInputStreamEOPacket - is trown if stream is not ready.
protected boolean isReady(int len)
throws EOPacket
isReady in class ProtocolDataInputStreamEOPacket - is trown if stream is not ready.public boolean isDebugHeaders()
public void setDebugHeaders(boolean debugHeaders)
debugHeaders - The debugHeaders to set.public PacketInputStream.BufferedHeader getFileHeader()
public PacketInputStream.BufferedHeader getRecordHeader()
public static void main(java.lang.String[] args)
args - command line arguments
public static void printStream(java.io.InputStream in,
int printCount)
throws java.io.IOException
java.io.IOExceptionpublic static java.lang.String hex(int b)
public void setCompressed(boolean compressed)
b - public boolean isCompressed()
public java.lang.String getFileFormatName()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||