Class UdpPacket

All Implemented Interfaces:
Serializable, Iterable<Packet>, Packet, TransportPacket

public final class UdpPacket extends AbstractPacket implements TransportPacket
Since:
pcap4j 0.9.1
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • newPacket

      public static UdpPacket newPacket(byte[] rawData, int offset, int length) throws IllegalRawDataException
      A static factory method. This method validates the arguments by ByteArrays.validateBounds(byte[], int, int), which may throw exceptions undocumented here.
      Parameters:
      rawData - rawData
      offset - offset
      length - length
      Returns:
      a new UdpPacket object.
      Throws:
      IllegalRawDataException - if parsing the raw data fails.
    • getHeader

      public UdpPacket.UdpHeader 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 interface Packet
      Specified by:
      getHeader in interface TransportPacket
      Overrides:
      getHeader in class AbstractPacket
      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 interface Packet
      Overrides:
      getPayload in class AbstractPacket
      Returns:
      the Packet object representing this packet's payload. May be null if the payload doesn't exist
    • hasValidChecksum

      public boolean hasValidChecksum(InetAddress srcAddr, InetAddress dstAddr, boolean acceptZero)
      checksum verification is necessary for IPv6(i.e. acceptZero must be false)
      Parameters:
      srcAddr - srcAddr
      dstAddr - dstAddr
      acceptZero - acceptZero
      Returns:
      true if the packet represented by this object has a valid checksum; false otherwise.
    • getBuilder

      public UdpPacket.Builder getBuilder()
      Description copied from interface: Packet
      Returns a new Builder object populated with this object's fields' values.
      Specified by:
      getBuilder in interface Packet
      Specified by:
      getBuilder in class AbstractPacket
      Returns:
      a new Builder object populated with this object's fields values