com.voytechs.jnetstream.io
Class PcapInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.voytechs.jnetstream.io.ProtocolDataInputStream
          extended by com.voytechs.jnetstream.io.PacketInputStream
              extended by com.voytechs.jnetstream.io.PcapInputStream
All Implemented Interfaces:
java.io.Closeable

Deprecated. This class should no longer be used as its no longer needed or maintained. Please use @see RawformatInputStream instead.

public class PcapInputStream
extends PacketInputStream

A custom reader for PCAP fiel formats.

This class has been depracated. Please do not use it.

See Also:

Structure of TCPDump file.
struct pcap_file_header {
bpf_u_int32 magic;
u_short version_major;
u_short version_minor;
bpf_int32 thiszone; // gmt to local correction //
bpf_u_int32 sigfigs; // accuracy of timestamps //
bpf_u_int32 snaplen; // max length saved portion of each pkt //
bpf_u_int32 linktype; // data link type (LINKTYPE_*) //
};


Now per each packet:
struct pcap_pkthdr {
struct timeval ts; // time stamp //
bpf_u_int32 caplen; // length of portion present //
bpf_u_int32 len; // length this packet (off wire) //
};


Nested Class Summary
 
Nested classes/interfaces inherited from class com.voytechs.jnetstream.io.PacketInputStream
PacketInputStream.BufferedHeader
 
Field Summary
 java.lang.String META_CAPTURE_NANOS
          Deprecated.  
 java.lang.String META_CAPTURE_SECS
          Deprecated.  
 java.lang.String META_LINK_TYPE
          Deprecated.  
 java.lang.String META_MAGIC_NUMBER
          Deprecated.  
 java.lang.String META_MAJOR_VER
          Deprecated.  
 java.lang.String META_MINOR_VER
          Deprecated.  
 java.lang.String META_PACKET_LENGTH
          Deprecated.  
 java.lang.String META_SNAPLEN
          Deprecated.  
 java.lang.String META_TIMESTAMP_ACCURACY
          Deprecated.  
 java.lang.String META_TIMEZONE
          Deprecated.  
 
Fields inherited from class com.voytechs.jnetstream.io.PacketInputStream
captureDeviceArch, captureDeviceFilename, captureDeviceIp, captureDeviceOS, captureLive, debugHeaders, fileHeader, linkType, packetCaptureTimestamp, packetEnd, packetLength, packetSnaplen, packetStart, recordEnd, recordHeader, recordLength, recordStart, stackIn
 
Fields inherited from class com.voytechs.jnetstream.io.ProtocolDataInputStream
bitsLeft, in
 
Constructor Summary
PcapInputStream(java.io.InputStream pcapFileFormatInputStream)
          Deprecated.  
PcapInputStream(java.lang.String filename)
          Deprecated. Opens up the given file and starts processing the data.
 
Method Summary
 int getPcapMagicNumber()
          Deprecated. Returns the magic number found at the beginning of the PCAP file.
 int getPcapMajorVer()
          Deprecated. Returns the major version number of the PCAP file.
 int getPcapMinorVer()
          Deprecated. Returns the minor version number of the PCAP file.
protected  void initPacketStream()
          Deprecated. Since we know we are dealing with a Pcap-file formatted stream (i.e.
protected  void initRecordHeader()
          Deprecated. Read pre-packet header from stream.
 java.lang.Object metaVariable(java.lang.String variable)
          Deprecated. Returns META information about the current header.
 int pcapLinktype()
          Deprecated. The link type of the first header in the packet.
 int pcapPacketCaptureNanos()
          Deprecated. Number of naono seconds found in the raw data file.
 long pcapPacketMicros()
          Deprecated. Number of raw number of the capture file.
 long pcapSnaplen()
          Deprecated. Retuns the SNAP len of the capture file.
 int pcapTimestampAccuracy()
          Deprecated. Returns the timestamp accuracy found in the PCAP file.
 int pcapTimezone()
          Deprecated. Returns the timezone found in the PCAP file.
 java.lang.String toString()
          Deprecated.  
 
Methods inherited from class com.voytechs.jnetstream.io.PacketInputStream
bitsLeft, clear, getCaptureDeviceAddress, getCaptureDeviceArch, getCaptureDeviceFilename, getCaptureDeviceIp, getCaptureDeviceOS, getCaptureTimestamp, getFileFormatName, getFileHeader, getLinkType, getPacketEnd, getPacketLength, getPacketLengthRemaining, getPacketSnaplen, getPacketStart, getPaddingLength, getRecordEnd, getRecordHeader, getRecordHeaderLength, getRecordLength, getRecordStart, goToEndOfRecord, gotoMark, hasForceRead, hex, isCaptureLive, isCompressed, isDebugHeaders, isPacketReady, isReady, isReady, main, nextPacket, pop, position, printStream, push, push, read, setCaptureTimestamp, setCompressed, setDebugHeaders, setForceRead, setIncludePadding, setLinkType, setPacketLength, setPacketSnaplen, setPacketStart, setRecordLength, setRecordStart, skip
 
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, wait, wait, wait
 

Field Detail

META_MAGIC_NUMBER

public java.lang.String META_MAGIC_NUMBER
Deprecated. 

META_MAJOR_VER

public java.lang.String META_MAJOR_VER
Deprecated. 

META_MINOR_VER

public java.lang.String META_MINOR_VER
Deprecated. 

META_TIMEZONE

public java.lang.String META_TIMEZONE
Deprecated. 

META_TIMESTAMP_ACCURACY

public java.lang.String META_TIMESTAMP_ACCURACY
Deprecated. 

META_PACKET_LENGTH

public java.lang.String META_PACKET_LENGTH
Deprecated. 

META_SNAPLEN

public java.lang.String META_SNAPLEN
Deprecated. 

META_LINK_TYPE

public java.lang.String META_LINK_TYPE
Deprecated. 

META_CAPTURE_SECS

public java.lang.String META_CAPTURE_SECS
Deprecated. 

META_CAPTURE_NANOS

public java.lang.String META_CAPTURE_NANOS
Deprecated. 
Constructor Detail

PcapInputStream

public PcapInputStream(java.io.InputStream pcapFileFormatInputStream)
                throws java.io.IOException,
                       EOPacketStream,
                       StreamFormatException
Deprecated. 
Parameters:
-
Throws:
java.io.IOException
EOPacketStream
StreamFormatException

PcapInputStream

public PcapInputStream(java.lang.String filename)
                throws java.io.FileNotFoundException,
                       java.io.IOException,
                       EOPacketStream,
                       StreamFormatException
Deprecated. 
Opens up the given file and starts processing the data.

Parameters:
filename - Filename of the file in PCAP fileformat to open.
Throws:
java.io.FileNotFoundException
java.io.IOException
EOPacketStream
StreamFormatException
Method Detail

metaVariable

public java.lang.Object metaVariable(java.lang.String variable)
                              throws java.io.IOException
Deprecated. 
Returns META information about the current header. Meta information is information that is normally not accessible via any read or getter method. In this instance, META information are the exact values of all fields of this header including MAGCI numbers.

Throws:
java.io.IOException

initPacketStream

protected void initPacketStream()
                         throws java.io.IOException,
                                EOPacketStream,
                                StreamFormatException
Deprecated. 
Since we know we are dealing with a Pcap-file formatted stream (i.e. FileInputStream("pcap-capturefile.pcap")) we initialize the ProtocolInputStream using values extracted from the pcap stream.

First we extract the "pcap_file_heaer" as specified above.

Overrides:
initPacketStream in class PacketInputStream
Throws:
java.io.IOException
EOPacketStream
StreamFormatException

initRecordHeader

protected void initRecordHeader()
                         throws java.io.IOException,
                                EOPacketStream,
                                StreamFormatException
Deprecated. 
Read pre-packet header from stream. With basic info about the next packet to follow. this is called for every packet in the stream. Main purpose is to get packet-data length (or length of captured packet) and the capture time of the packet.

Overrides:
initRecordHeader in class PacketInputStream
Throws:
java.io.IOException
EOPacketStream
StreamFormatException

toString

public java.lang.String toString()
Deprecated. 
Overrides:
toString in class java.lang.Object

getPcapMagicNumber

public int getPcapMagicNumber()
Deprecated. 
Returns the magic number found at the beginning of the PCAP file.


getPcapMajorVer

public int getPcapMajorVer()
Deprecated. 
Returns the major version number of the PCAP file.


getPcapMinorVer

public int getPcapMinorVer()
Deprecated. 
Returns the minor version number of the PCAP file.


pcapTimezone

public int pcapTimezone()
Deprecated. 
Returns the timezone found in the PCAP file. The timezone is used for proper timestamp calculations of the captured packet.


pcapTimestampAccuracy

public int pcapTimestampAccuracy()
Deprecated. 
Returns the timestamp accuracy found in the PCAP file.


pcapSnaplen

public long pcapSnaplen()
Deprecated. 
Retuns the SNAP len of the capture file. This is the number of bytes that we saved, not captured. i.e. first 128 bytes.


pcapLinktype

public int pcapLinktype()
Deprecated. 
The link type of the first header in the packet. Normally this is type 2 (ethernet) but any of the others are possible as well.


pcapPacketMicros

public long pcapPacketMicros()
Deprecated. 
Number of raw number of the capture file. JNetStream library multiplies this number by factor of 1000 before returning it.

This value changes from packet to packet.


pcapPacketCaptureNanos

public int pcapPacketCaptureNanos()
Deprecated. 
Number of naono seconds found in the raw data file. This number is also multiplied by 1000.

This value changes from packet to packet.