Class IpV4Packet.IpV4Header
java.lang.Object
org.pcap4j.packet.AbstractPacket.AbstractHeader
org.pcap4j.packet.IpV4Packet.IpV4Header
- All Implemented Interfaces:
Serializable, IpPacket.IpHeader, Packet.Header
- Enclosing class:
IpV4Packet
public static final class IpV4Packet.IpV4Header
extends AbstractPacket.AbstractHeader
implements IpPacket.IpHeader
- Since:
- pcap4j 0.9.1
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanprivate static final intprivate static final intprivate final Inet4Addressprivate static final intprivate static final intprivate final shortprivate static final intprivate static final intprivate final shortprivate final shortprivate static final intprivate static final intprivate final byteprivate static final org.slf4j.Loggerprivate static final intprivate final booleanprivate final List<IpV4Packet.IpV4Option> private static final intprivate final byte[]private final IpNumberprivate static final intprivate static final intprivate final booleanprivate static final longprivate static final intprivate static final intprivate final Inet4Addressprivate final IpV4Packet.IpV4Tosprivate static final intprivate static final intprivate static final intprivate static final intprivate final shortprivate final byteprivate static final intprivate static final intprivate final IpVersionprivate static final intprivate static final int -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateIpV4Header(byte[] rawData, int offset, int length) privateIpV4Header(IpV4Packet.Builder builder, Packet payload) -
Method Summary
Modifier and TypeMethodDescriptionprivate byte[]buildRawData(boolean zeroInsteadOfChecksum) protected StringThis method builds the valuetoString()will return.protected intThis method builds the valuehashCode()will return using the byte arraygetRawData()returns.private shortcalcHeaderChecksum(boolean zeroInsteadOfChecksum) protected intThis method calculates the valuelength()will return by adding up the lengths of byte arrays in the listgetRawFields()returns.booleanIndicates whether some other object is "equal to" this one using return values ofgetRawData().booleanshortshortshortintbytegetIhl()intbooleanbyte[]protected List<byte[]> Returns a list of byte arrays which represents this header's fields.private List<byte[]> getRawFields(boolean zeroInsteadOfChecksum) booleangetTos()shortintbytegetTtl()intbooleanhasValidChecksum(boolean acceptZero) private intMethods inherited from class AbstractPacket.AbstractHeader
buildHexString, buildRawData, getRawData, hashCode, length, toHexString, toStringMethods inherited from interface Packet.Header
getRawData, length
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
logger
private static final org.slf4j.Logger logger -
VERSION_AND_IHL_OFFSET
private static final int VERSION_AND_IHL_OFFSET- See Also:
-
VERSION_AND_IHL_SIZE
private static final int VERSION_AND_IHL_SIZE- See Also:
-
TOS_OFFSET
private static final int TOS_OFFSET- See Also:
-
TOS_SIZE
private static final int TOS_SIZE- See Also:
-
TOTAL_LENGTH_OFFSET
private static final int TOTAL_LENGTH_OFFSET- See Also:
-
TOTAL_LENGTH_SIZE
private static final int TOTAL_LENGTH_SIZE- See Also:
-
IDENTIFICATION_OFFSET
private static final int IDENTIFICATION_OFFSET- See Also:
-
IDENTIFICATION_SIZE
private static final int IDENTIFICATION_SIZE- See Also:
-
FLAGS_AND_FRAGMENT_OFFSET_OFFSET
private static final int FLAGS_AND_FRAGMENT_OFFSET_OFFSET- See Also:
-
FLAGS_AND_FRAGMENT_OFFSET_SIZE
private static final int FLAGS_AND_FRAGMENT_OFFSET_SIZE- See Also:
-
TTL_OFFSET
private static final int TTL_OFFSET- See Also:
-
TTL_SIZE
private static final int TTL_SIZE- See Also:
-
PROTOCOL_OFFSET
private static final int PROTOCOL_OFFSET- See Also:
-
PROTOCOL_SIZE
private static final int PROTOCOL_SIZE- See Also:
-
HEADER_CHECKSUM_OFFSET
private static final int HEADER_CHECKSUM_OFFSET- See Also:
-
HEADER_CHECKSUM_SIZE
private static final int HEADER_CHECKSUM_SIZE- See Also:
-
SRC_ADDR_OFFSET
private static final int SRC_ADDR_OFFSET- See Also:
-
SRC_ADDR_SIZE
private static final int SRC_ADDR_SIZE- See Also:
-
DST_ADDR_OFFSET
private static final int DST_ADDR_OFFSET- See Also:
-
DST_ADDR_SIZE
private static final int DST_ADDR_SIZE- See Also:
-
OPTIONS_OFFSET
private static final int OPTIONS_OFFSET- See Also:
-
MIN_IPV4_HEADER_SIZE
private static final int MIN_IPV4_HEADER_SIZE- See Also:
-
version
-
ihl
private final byte ihl -
tos
-
totalLength
private final short totalLength -
identification
private final short identification -
reservedFlag
private final boolean reservedFlag -
dontFragmentFlag
private final boolean dontFragmentFlag -
moreFragmentFlag
private final boolean moreFragmentFlag -
fragmentOffset
private final short fragmentOffset -
ttl
private final byte ttl -
protocol
-
headerChecksum
private final short headerChecksum -
srcAddr
-
dstAddr
-
options
-
padding
private final byte[] padding
-
-
Constructor Details
-
IpV4Header
- Throws:
IllegalRawDataException
-
IpV4Header
-
-
Method Details
-
calcHeaderChecksum
private short calcHeaderChecksum(boolean zeroInsteadOfChecksum) -
getVersion
- Specified by:
getVersionin interfaceIpPacket.IpHeader- Returns:
- version
-
getIhl
public byte getIhl()- Returns:
- ihl
-
getIhlAsInt
public int getIhlAsInt()- Returns:
- ihl
-
getTos
- Returns:
- tos
-
getTotalLength
public short getTotalLength()- Returns:
- totalLength
-
getTotalLengthAsInt
public int getTotalLengthAsInt()- Returns:
- totalLength
-
getIdentification
public short getIdentification()- Returns:
- identification
-
getIdentificationAsInt
public int getIdentificationAsInt()- Returns:
- identification
-
getReservedFlag
public boolean getReservedFlag()- Returns:
- reservedFlag
-
getDontFragmentFlag
public boolean getDontFragmentFlag()- Returns:
- dontFragmentFlag
-
getMoreFragmentFlag
public boolean getMoreFragmentFlag()- Returns:
- moreFragmentFlag
-
getFragmentOffset
public short getFragmentOffset()- Returns:
- fragmentOffset
-
getTtl
public byte getTtl()- Returns:
- ttl
-
getTtlAsInt
public int getTtlAsInt()- Returns:
- ttl
-
getProtocol
- Specified by:
getProtocolin interfaceIpPacket.IpHeader- Returns:
- an IpNumber object which indicates the protocol of the following header.
-
getHeaderChecksum
public short getHeaderChecksum()- Returns:
- headerChecksum
-
getSrcAddr
- Specified by:
getSrcAddrin interfaceIpPacket.IpHeader- Returns:
- srcAddr
-
getDstAddr
- Specified by:
getDstAddrin interfaceIpPacket.IpHeader- Returns:
- dstAddr
-
getOptions
- Returns:
- options
-
getPadding
public byte[] getPadding()- Returns:
- padding
-
hasValidChecksum
public boolean hasValidChecksum(boolean acceptZero) - Parameters:
acceptZero- acceptZero- Returns:
- true if the packet represented by this object has a valid checksum; false otherwise.
-
getRawFields
Description copied from class:AbstractPacket.AbstractHeaderReturns a list of byte arrays which represents this header's fields. This method is called bycalcLength()andbuildRawData().- Specified by:
getRawFieldsin classAbstractPacket.AbstractHeader- Returns:
- a list of byte arrays which represents this header's fields
-
getRawFields
-
buildRawData
private byte[] buildRawData(boolean zeroInsteadOfChecksum) -
measureLengthWithoutPadding
private int measureLengthWithoutPadding() -
calcLength
protected int calcLength()Description copied from class:AbstractPacket.AbstractHeaderThis method calculates the valuelength()will return by adding up the lengths of byte arrays in the listgetRawFields()returns.- Overrides:
calcLengthin classAbstractPacket.AbstractHeader- Returns:
- a calculated length
-
buildString
Description copied from class:AbstractPacket.AbstractHeaderThis method builds the valuetoString()will return.- Overrides:
buildStringin classAbstractPacket.AbstractHeader- Returns:
- a string representation of this object
-
equals
Description copied from class:AbstractPacket.AbstractHeaderIndicates whether some other object is "equal to" this one using return values ofgetRawData(). This method should be overridden so that it does more strict comparisons more efficiently.- Overrides:
equalsin classAbstractPacket.AbstractHeader
-
calcHashCode
protected int calcHashCode()Description copied from class:AbstractPacket.AbstractHeaderThis method builds the valuehashCode()will return using the byte arraygetRawData()returns. This method may be better to be overridden for performance reason.- Overrides:
calcHashCodein classAbstractPacket.AbstractHeader- Returns:
- a calculated hash code value for the object
-