- java.lang.Object
-
- org.pcap4j.packet.AbstractPacket.AbstractHeader
-
- org.pcap4j.packet.UdpPacket.UdpHeader
-
- All Implemented Interfaces:
java.io.Serializable,Packet.Header,TransportPacket.TransportHeader
- Enclosing class:
- UdpPacket
public static final class UdpPacket.UdpHeader extends AbstractPacket.AbstractHeader implements TransportPacket.TransportHeader
- Since:
- pcap4j 0.9.1
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private shortchecksumprivate static intCHECKSUM_OFFSETprivate static intCHECKSUM_SIZEprivate static intDST_PORT_OFFSETprivate static intDST_PORT_SIZEprivate UdpPortdstPortprivate static intIPV4_PSEUDO_HEADER_SIZEprivate static intIPV6_PSEUDO_HEADER_SIZEprivate shortlengthprivate static intLENGTH_OFFSETprivate static intLENGTH_SIZEprivate static longserialVersionUIDprivate static intSRC_PORT_OFFSETprivate static intSRC_PORT_SIZEprivate UdpPortsrcPortprivate static intUCP_HEADER_SIZE
-
Constructor Summary
Constructors Modifier Constructor Description privateUdpHeader(byte[] rawData, int offset, int length)privateUdpHeader(UdpPacket.Builder builder, byte[] payload)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private byte[]buildRawData(boolean zeroInsteadOfChecksum)protected java.lang.StringbuildString()This method builds the valuetoString()will return.private shortcalcChecksum(java.net.InetAddress srcAddr, java.net.InetAddress dstAddr, byte[] header, byte[] payload)protected intcalcHashCode()This method builds the valuehashCode()will return using the byte arraygetRawData()returns.booleanequals(java.lang.Object obj)Indicates whether some other object is "equal to" this one using return values ofgetRawData().shortgetChecksum()UdpPortgetDstPort()shortgetLength()intgetLengthAsInt()protected java.util.List<byte[]>getRawFields()Returns a list of byte arrays which represents this header's fields.private java.util.List<byte[]>getRawFields(boolean zeroInsteadOfChecksum)UdpPortgetSrcPort()intlength()Returns the header length in bytes.-
Methods inherited from class org.pcap4j.packet.AbstractPacket.AbstractHeader
buildHexString, buildRawData, calcLength, getRawData, hashCode, 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
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
SRC_PORT_OFFSET
private static final int SRC_PORT_OFFSET
- See Also:
- Constant Field Values
-
SRC_PORT_SIZE
private static final int SRC_PORT_SIZE
- See Also:
- Constant Field Values
-
DST_PORT_OFFSET
private static final int DST_PORT_OFFSET
- See Also:
- Constant Field Values
-
DST_PORT_SIZE
private static final int DST_PORT_SIZE
- See Also:
- Constant Field Values
-
LENGTH_OFFSET
private static final int LENGTH_OFFSET
- See Also:
- Constant Field Values
-
LENGTH_SIZE
private static final int LENGTH_SIZE
- See Also:
- Constant Field Values
-
CHECKSUM_OFFSET
private static final int CHECKSUM_OFFSET
- See Also:
- Constant Field Values
-
CHECKSUM_SIZE
private static final int CHECKSUM_SIZE
- See Also:
- Constant Field Values
-
UCP_HEADER_SIZE
private static final int UCP_HEADER_SIZE
- See Also:
- Constant Field Values
-
IPV4_PSEUDO_HEADER_SIZE
private static final int IPV4_PSEUDO_HEADER_SIZE
- See Also:
- Constant Field Values
-
IPV6_PSEUDO_HEADER_SIZE
private static final int IPV6_PSEUDO_HEADER_SIZE
- See Also:
- Constant Field Values
-
srcPort
private final UdpPort srcPort
-
dstPort
private final UdpPort dstPort
-
length
private final short length
-
checksum
private final short checksum
-
-
Constructor Detail
-
UdpHeader
private UdpHeader(byte[] rawData, int offset, int length) throws IllegalRawDataException- Throws:
IllegalRawDataException
-
UdpHeader
private UdpHeader(UdpPacket.Builder builder, byte[] payload)
-
-
Method Detail
-
calcChecksum
private short calcChecksum(java.net.InetAddress srcAddr, java.net.InetAddress dstAddr, byte[] header, byte[] payload)
-
getSrcPort
public UdpPort getSrcPort()
- Specified by:
getSrcPortin interfaceTransportPacket.TransportHeader- Returns:
- Source port
-
getDstPort
public UdpPort getDstPort()
- Specified by:
getDstPortin interfaceTransportPacket.TransportHeader- Returns:
- Destination port
-
getLength
public short getLength()
- Returns:
- length
-
getLengthAsInt
public int getLengthAsInt()
- Returns:
- length
-
getChecksum
public short getChecksum()
- Returns:
- checksum
-
getRawFields
protected java.util.List<byte[]> 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
private java.util.List<byte[]> getRawFields(boolean zeroInsteadOfChecksum)
-
buildRawData
private byte[] buildRawData(boolean zeroInsteadOfChecksum)
-
length
public int length()
Description copied from class:AbstractPacket.AbstractHeaderReturns the header length in bytes. This method callscalcLength()and caches the return value when it is called for the first time, and then, this method returns the cached value from the second time.- Specified by:
lengthin interfacePacket.Header- Overrides:
lengthin classAbstractPacket.AbstractHeader- Returns:
- the length of the byte stream of the header represented by this object in bytes
-
buildString
protected java.lang.String 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
public boolean equals(java.lang.Object obj)
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
-
-