net.clackrouter.jpcap
Class TcpdumpWriter

java.lang.Object
  extended by net.clackrouter.jpcap.TcpdumpWriter

public class TcpdumpWriter
extends java.lang.Object

Writes data in tcpdump format. Unmodified and incorporated into Clack.


Field Summary
static int BIG_ENDIAN
           
static int CODE_ETHERNET
           
static int LITTLE_ENDIAN
           
static int MAJOR_VERSION
           
static int MINOR_VERSION
           
 
Constructor Summary
TcpdumpWriter()
           
 
Method Summary
static void appendPacket(java.lang.String filename, RawPacket rawPacket, int endian)
          A Tcpdump packet has the following format: seconds [4 bytes] microseconds [4 bytes] captured length [4 bytes] original packet length [4 bytes] packet data [variable length]
static void appendVNSEthernetPacket(java.lang.String filename, VNSEthernetPacket ethPacket)
           
static void writeHeader(java.lang.String filename, int endian, long snaplen)
          A Tcpdump file header is 24 bytes: 4 bytes: Tcpdump signature "magic number" 0xA1B2C3D4 2 bytes: Major version number, currently 2 2 bytes: Minor version number, currently 4 4 bytes: Time Zone offset, currently unused (set to zero) 4 bytes: Time stamp accuracy, currently unused (set to zero) 4 bytes: Snapshot length 4 bytes: Link-layer type, Ethernet for now
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BIG_ENDIAN

public static final int BIG_ENDIAN
See Also:
Constant Field Values

LITTLE_ENDIAN

public static final int LITTLE_ENDIAN
See Also:
Constant Field Values

MAJOR_VERSION

public static final int MAJOR_VERSION
See Also:
Constant Field Values

MINOR_VERSION

public static final int MINOR_VERSION
See Also:
Constant Field Values

CODE_ETHERNET

public static final int CODE_ETHERNET
See Also:
Constant Field Values
Constructor Detail

TcpdumpWriter

public TcpdumpWriter()
Method Detail

writeHeader

public static void writeHeader(java.lang.String filename,
                               int endian,
                               long snaplen)
                        throws java.io.IOException
A Tcpdump file header is 24 bytes: 4 bytes: Tcpdump signature "magic number" 0xA1B2C3D4 2 bytes: Major version number, currently 2 2 bytes: Minor version number, currently 4 4 bytes: Time Zone offset, currently unused (set to zero) 4 bytes: Time stamp accuracy, currently unused (set to zero) 4 bytes: Snapshot length 4 bytes: Link-layer type, Ethernet for now

Throws:
java.io.IOException

appendVNSEthernetPacket

public static void appendVNSEthernetPacket(java.lang.String filename,
                                           VNSEthernetPacket ethPacket)
                                    throws java.lang.Exception
Throws:
java.lang.Exception

appendPacket

public static void appendPacket(java.lang.String filename,
                                RawPacket rawPacket,
                                int endian)
                         throws java.io.IOException
A Tcpdump packet has the following format: seconds [4 bytes] microseconds [4 bytes] captured length [4 bytes] original packet length [4 bytes] packet data [variable length]

Throws:
java.io.IOException