Package org.pcap4j.packet
Class TcpPacket
- java.lang.Object
-
- org.pcap4j.packet.AbstractPacket
-
- org.pcap4j.packet.TcpPacket
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<Packet>
,Packet
,TransportPacket
public final class TcpPacket extends AbstractPacket implements TransportPacket
- Since:
- pcap4j 0.9.12
- Author:
- Kaito Yamada
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TcpPacket.Builder
static class
TcpPacket.TcpHeader
static interface
TcpPacket.TcpOption
The interface representing a TCP option.-
Nested classes/interfaces inherited from class org.pcap4j.packet.AbstractPacket
AbstractPacket.AbstractBuilder, AbstractPacket.AbstractHeader
-
Nested classes/interfaces inherited from interface org.pcap4j.packet.Packet
Packet.Header
-
Nested classes/interfaces inherited from interface org.pcap4j.packet.TransportPacket
TransportPacket.TransportHeader
-
-
Method Summary
Modifier and Type Method Description TcpPacket.Builder
getBuilder()
Returns a new Builder object populated with this object's fields' values.TcpPacket.TcpHeader
getHeader()
Returns the Header object representing this packet's header.Packet
getPayload()
Returns the Packet object representing this packet's payload.boolean
hasValidChecksum(java.net.InetAddress srcAddr, java.net.InetAddress dstAddr, boolean acceptZero)
checksum verification is necessary for IPv6(i.e.static TcpPacket
newPacket(byte[] rawData, int offset, int length)
A static factory method.-
Methods inherited from class org.pcap4j.packet.AbstractPacket
buildHexString, buildRawData, buildString, calcHashCode, calcLength, equals, getRawData, hashCode, length, toHexString, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.pcap4j.packet.Packet
contains, get, getLowerLayerOf, getRawData, iterator, length
-
-
-
-
Method Detail
-
newPacket
public static TcpPacket newPacket(byte[] rawData, int offset, int length) throws IllegalRawDataException
A static factory method. This method validates the arguments byByteArrays.validateBounds(byte[], int, int)
, which may throw exceptions undocumented here.- Parameters:
rawData
- rawDataoffset
- offsetlength
- length- Returns:
- a new TcpPacket object.
- Throws:
IllegalRawDataException
- if parsing the raw data fails.
-
getHeader
public TcpPacket.TcpHeader getHeader()
Description copied from class:AbstractPacket
Returns the Header object representing this packet's header. This subclass have to override this method if the packet represented by the subclass has a header.- Specified by:
getHeader
in interfacePacket
- Specified by:
getHeader
in interfaceTransportPacket
- Overrides:
getHeader
in classAbstractPacket
- Returns:
- the Header object representing this packet's header. May be null if the header doesn't exist
-
getPayload
public Packet getPayload()
Description copied from class:AbstractPacket
Returns the Packet object representing this packet's payload. This subclass have to override this method if the packet represented by the subclass has a payload.- Specified by:
getPayload
in interfacePacket
- Overrides:
getPayload
in classAbstractPacket
- Returns:
- the Packet object representing this packet's payload. May be null if the payload doesn't exist
-
hasValidChecksum
public boolean hasValidChecksum(java.net.InetAddress srcAddr, java.net.InetAddress dstAddr, boolean acceptZero)
checksum verification is necessary for IPv6(i.e. acceptZero must be false)- Parameters:
srcAddr
- srcAddrdstAddr
- dstAddracceptZero
- acceptZero- Returns:
- true if the packet represented by this object has a valid checksum; false otherwise.
-
getBuilder
public TcpPacket.Builder getBuilder()
Description copied from interface:Packet
Returns a new Builder object populated with this object's fields' values.- Specified by:
getBuilder
in interfacePacket
- Specified by:
getBuilder
in classAbstractPacket
- Returns:
- a new Builder object populated with this object's fields values
-
-