jnetpcap.capture.file
Interface Record

All Known Subinterfaces:
BlockRecord, DataRecord, MutableBlockRecord, NAPBlock, NAPExpert, NAPMetaRecord, NAPPacket, NAPRecord, PcapBlockRecord, PcapPacketRecord, SnoopBlockRecord, SnoopPacketRecord

public interface Record

A record within a capture file. Capture files contain multiple records which contain data. This interface provides access to a generic Record. Each record has at minimum, a header and content area. You can use various methods in this interface to access and manipulate these standard fields within the record.

Record consists of a header and record content. Records retrieve the header and content into separate buffers. Also when you modify the record you may supply each of the two buffers separately. You may use getHeaderBuffer() and #getContentBuffer method calls to retrieve raw buffers.

The header contains information about the record. The most important of which is the type of record and record's overall length. Use the getRecordType() method to get the records type and getRecordLength() to get the entire record's length.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Nested Class Summary
static class Record.Capability
          Enum constants that describe certain capabilities and thus information a particular type of record may contain.
static interface Record.RecordType
          Interface that allows retrieval of type information about each impelementation specific record type.
 
Method Summary
 FileCapture getCaptureFile()
           
 long getFilePosition()
          Returns the file position of the start of this record.
 java.nio.ByteBuffer getHeaderBuffer()
           
 int getHeaderLength()
           
 long getRecordLength()
          Returns the length of this record in bytes.
 Record.RecordType getRecordType()
          Returns the type of this record.
 boolean isModified()
           
 boolean isWritten()
           
 void read()
          Reads the record's header and content into separate buffers.
 void readHeader()
          Reads the record header into the internally allocated buffer.
 void setFilePosition(long position)
           
 void setModified(boolean state)
           
 void setWritten(boolean state)
           
 void validateRecord()
           
 void write()
          Writes the contents of the entire record from the internally allocated header and content buffers.
 void writeHeader()
           
 

Method Detail

getCaptureFile

FileCapture getCaptureFile()

getFilePosition

long getFilePosition()
Returns the file position of the start of this record.

Returns:
start of this record

setFilePosition

void setFilePosition(long position)

getRecordLength

long getRecordLength()

Returns the length of this record in bytes. The record length includes the record header, from the start of the record, and contains all the data within the record. The formula GetFilePosition() + getLength() points at the first byte of the next record.

The record's length is not directly set but determined by the current buffers set on the record. That is the total record length is getRecordLength() + #getDataLength() which are determined by the reading values directly from the currently set record header.

Returns:

getRecordType

Record.RecordType getRecordType()
Returns the type of this record. There are certain standard record types defined, plus each file type may define addtional record types beyond the standard ones.

Returns:
Type of this record.

getHeaderBuffer

java.nio.ByteBuffer getHeaderBuffer()

getHeaderLength

int getHeaderLength()

read

void read()
          throws java.io.IOException

Reads the record's header and content into separate buffers. The buffers are allocated internally or by user using #setHeaderBuffer and #setContentBuffer methods.

The start of the record is read from the position as returned by #getFilePostion method.

Throws:
java.io.IOException - any IO errors

write

void write()
           throws java.io.IOException

Writes the contents of the entire record from the internally allocated header and content buffers. The method sets the record length or equivelent fields within the record's header to the length of the entire record or just its content. The exact specification is file format dependent.

Throws:
java.io.IOException - any IO errors

readHeader

void readHeader()
                throws java.io.IOException
Reads the record header into the internally allocated buffer.

Throws:
java.io.IOException - any IO errors

writeHeader

void writeHeader()
                 throws java.io.IOException
Throws:
java.io.IOException

validateRecord

void validateRecord()
                    throws java.io.IOException,
                           CaptureFormatException
Throws:
java.io.IOException
CaptureFormatException

isWritten

boolean isWritten()

setWritten

void setWritten(boolean state)

isModified

boolean isModified()

setModified

void setModified(boolean state)