org.jnetpcap
Class PcapHeader
java.lang.Object
org.jnetpcap.nio.JMemory
org.jnetpcap.nio.JStruct
org.jnetpcap.PcapHeader
- All Implemented Interfaces:
- JCaptureHeader
public class PcapHeader
- extends JStruct
- implements JCaptureHeader
struct pkt_header {
struct timeval ts; // ts.tv_sec, ts.tv_usec
uint32 caplen; // captured length
uint32 len; // original length
}
- Author:
- Mark Bednarczyk, Sly Technologies, Inc.
| Methods inherited from class org.jnetpcap.nio.JMemory |
check, cleanup, finalize, isInitialized, isJMemoryBasedOwner, isOwner, peer, peer, peer, setSize, size, toDebugString, toHexdump, toHexdump, totalActiveAllocated, totalAllocateCalls, totalAllocated, totalAllocatedSegments0To255Bytes, totalAllocatedSegments256OrAbove, totalDeAllocateCalls, totalDeAllocated, transferFrom, transferFrom, transferFrom, transferFrom, transferFromDirect, transferOwnership, transferTo, transferTo, transferTo, transferTo, transferTo, transferTo, transferTo |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
STRUCT_NAME
public static final java.lang.String STRUCT_NAME
- See Also:
- Constant Field Values
PcapHeader
public PcapHeader()
PcapHeader
public PcapHeader(int caplen,
int wirelen)
- Parameters:
caplen - wirelen -
PcapHeader
public PcapHeader(JMemory.Type type)
sizeof
public static int sizeof()
- Size of the pcap_pkthdr structure in bytes.
- Returns:
- size of structure
caplen
public int caplen()
- Description copied from interface:
JCaptureHeader
- Retrieves the length of the packet that was actually captured. This could
be only a portion of the original packet if snaplen filter was set during
Pcap.openXXX call. If the packet was not trucated, this length should equal
the length returned by
JCaptureHeader.wirelen().
- Specified by:
caplen in interface JCaptureHeader
- Returns:
- length in bytes
hdr_len
public int hdr_len()
hdr_len
public void hdr_len(int len)
hdr_sec
public long hdr_sec()
hdr_sec
public void hdr_sec(long ts)
hdr_usec
public int hdr_usec()
hdr_usec
public void hdr_usec(int ts)
hdr_wirelen
public int hdr_wirelen()
hdr_wirelen
public void hdr_wirelen(int len)
nanos
public long nanos()
- Description copied from interface:
JCaptureHeader
- Fractional part of the second when the packet was captured. If the
resolution of the original capture timestamp is lower than nano seconds,
they are converted to nano seconds. For example of the capture timestamp is
in micro seconds, then the micro seconds fraction is multiplied by a 1000
before being returned to conform to nano second return timestamp.
- Specified by:
nanos in interface JCaptureHeader
- Returns:
- Number of nano seconds at the time of the packet capture. The valid
value returned by this method is from 0 to 999,999,999.
peer
public int peer(JBuffer memory,
int offset)
peerTo
public int peerTo(JBuffer buffer,
int offset)
peerTo
public int peerTo(PcapHeader header,
int offset)
seconds
public long seconds()
- Description copied from interface:
JCaptureHeader
- Capture timestamp in UNIX seconds
- Specified by:
seconds in interface JCaptureHeader
- Returns:
- timestamp in seconds since 1970
timestampInMillis
public long timestampInMillis()
- Specified by:
timestampInMillis in interface JCaptureHeader
transferTo
public int transferTo(JBuffer m,
int offset)
transferTo
public int transferTo(byte[] m,
int offset)
wirelen
public int wirelen()
- Description copied from interface:
JCaptureHeader
- Retrieves the length of the packet before any of it was truncated by the
capture mechanism. This is the size of the orignal packet as it was send
accross the network.
- Specified by:
wirelen in interface JCaptureHeader
- Returns:
- length in bytes
caplen
public void caplen(int caplen)
- Specified by:
caplen in interface JCaptureHeader
nanos
public void nanos(long nanos)
- Specified by:
nanos in interface JCaptureHeader
seconds
public void seconds(long seconds)
- Specified by:
seconds in interface JCaptureHeader
wirelen
public void wirelen(int wirelen)
- Specified by:
wirelen in interface JCaptureHeader
initFrom
public void initFrom(JCaptureHeader captureHeader)
- Specified by:
initFrom in interface JCaptureHeader
timestampInNanos
public long timestampInNanos()
- Specified by:
timestampInNanos in interface JCaptureHeader
timestampInMicros
public long timestampInMicros()
- Specified by:
timestampInMicros in interface JCaptureHeader