Package org.pcap4j.packet
Class IpV4Packet.IpV4Header
- java.lang.Object
-
- org.pcap4j.packet.AbstractPacket.AbstractHeader
-
- org.pcap4j.packet.IpV4Packet.IpV4Header
-
- All Implemented Interfaces:
java.io.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
- Author:
- Kaito Yamada
- See Also:
- Serialized Form
-
-
Method Summary
Modifier and Type Method Description protected java.lang.String
buildString()
This method builds the valuetoString()
will return.protected int
calcHashCode()
This method builds the valuehashCode()
will return using the byte arraygetRawData()
returns.protected int
calcLength()
This method calculates the valuelength()
will return by adding up the lengths of byte arrays in the listgetRawFields()
returns.boolean
equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one using return values ofgetRawData()
.boolean
getDontFragmentFlag()
java.net.Inet4Address
getDstAddr()
short
getFragmentOffset()
short
getHeaderChecksum()
short
getIdentification()
int
getIdentificationAsInt()
byte
getIhl()
int
getIhlAsInt()
boolean
getMoreFragmentFlag()
java.util.List<IpV4Packet.IpV4Option>
getOptions()
byte[]
getPadding()
IpNumber
getProtocol()
protected java.util.List<byte[]>
getRawFields()
Returns a list of byte arrays which represents this header's fields.boolean
getReservedFlag()
java.net.Inet4Address
getSrcAddr()
IpV4Packet.IpV4Tos
getTos()
short
getTotalLength()
int
getTotalLengthAsInt()
byte
getTtl()
int
getTtlAsInt()
IpVersion
getVersion()
boolean
hasValidChecksum(boolean acceptZero)
-
Methods inherited from class org.pcap4j.packet.AbstractPacket.AbstractHeader
buildHexString, buildRawData, 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.Header
getRawData, length
-
-
-
-
Method Detail
-
getVersion
public IpVersion getVersion()
- Specified by:
getVersion
in interfaceIpPacket.IpHeader
- Returns:
- version
-
getIhl
public byte getIhl()
- Returns:
- ihl
-
getIhlAsInt
public int getIhlAsInt()
- Returns:
- ihl
-
getTos
public IpV4Packet.IpV4Tos 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
public IpNumber getProtocol()
- Specified by:
getProtocol
in interfaceIpPacket.IpHeader
- Returns:
- an IpNumber object which indicates the protocol of the following header.
-
getHeaderChecksum
public short getHeaderChecksum()
- Returns:
- headerChecksum
-
getSrcAddr
public java.net.Inet4Address getSrcAddr()
- Specified by:
getSrcAddr
in interfaceIpPacket.IpHeader
- Returns:
- srcAddr
-
getDstAddr
public java.net.Inet4Address getDstAddr()
- Specified by:
getDstAddr
in interfaceIpPacket.IpHeader
- Returns:
- dstAddr
-
getOptions
public java.util.List<IpV4Packet.IpV4Option> 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
protected java.util.List<byte[]> getRawFields()
Description copied from class:AbstractPacket.AbstractHeader
Returns a list of byte arrays which represents this header's fields. This method is called bycalcLength()
andbuildRawData()
.- Specified by:
getRawFields
in classAbstractPacket.AbstractHeader
- Returns:
- a list of byte arrays which represents this header's fields
-
calcLength
protected int calcLength()
Description copied from class:AbstractPacket.AbstractHeader
This method calculates the valuelength()
will return by adding up the lengths of byte arrays in the listgetRawFields()
returns.- Overrides:
calcLength
in classAbstractPacket.AbstractHeader
- Returns:
- a calculated length
-
buildString
protected java.lang.String buildString()
Description copied from class:AbstractPacket.AbstractHeader
This method builds the valuetoString()
will return.- Overrides:
buildString
in classAbstractPacket.AbstractHeader
- Returns:
- a string representation of this object
-
equals
public boolean equals(java.lang.Object obj)
Description copied from class:AbstractPacket.AbstractHeader
Indicates 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:
equals
in classAbstractPacket.AbstractHeader
-
calcHashCode
protected int calcHashCode()
Description copied from class:AbstractPacket.AbstractHeader
This method builds the valuehashCode()
will return using the byte arraygetRawData()
returns. This method may be better to be overridden for performance reason.- Overrides:
calcHashCode
in classAbstractPacket.AbstractHeader
- Returns:
- a calculated hash code value for the object
-
-