Class DnsDomainName

java.lang.Object
org.pcap4j.packet.DnsDomainName
All Implemented Interfaces:
Serializable

public final class DnsDomainName extends Object implements Serializable
DNS domain name
 labels:
     1            len             1            len
 +-------+-------+-//-+-------+-------+-------+-//-+-------+--//--+-------+
 |  len  |       label        |  len  |       label        |      |len (0)|
 +-------+-------+-//-+-------+-------+-------+-//-+-------+--//--+-------+

 pointer:
 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
 | 1  1|                OFFSET                   |
 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
 
Since:
pcap4j 1.7.1
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • LOG

      private static final org.slf4j.Logger LOG
    • ROOT_DOMAIN

      public static final DnsDomainName ROOT_DOMAIN
      The root domain (zero)
    • labels

      private final List<String> labels
    • name

      private final String name
    • pointer

      private final Short pointer
  • Constructor Details

  • Method Details

    • newInstance

      public static DnsDomainName newInstance(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 DnsDomainName object.
      Throws:
      IllegalRawDataException - if parsing the raw data fails.
    • joinLabels

      private String joinLabels(List<String> lbls)
    • getLabels

      public List<String> getLabels()
      Returns:
      labels
    • getName

      public String getName()
      Returns:
      name, which is made by joining labels with "."
    • getPointer

      public Short getPointer()
      Returns:
      pointer (0 - 16383 (inclusive)). May be null.
    • getPointerAsInt

      public Integer getPointerAsInt()
      Returns:
      pointer (0 - 16383 (inclusive)). May be null.
    • decompress

      public String decompress(byte[] headerRawData) throws IllegalRawDataException
      Parameters:
      headerRawData - the raw data of the DNS header including this domain name.
      Returns:
      decompressed name.
      Throws:
      IllegalRawDataException - if an error occurred during decompression or circular reference is detected.
    • decompress

      private String decompress(byte[] headerRawData, List<Short> pointers) throws IllegalRawDataException
      Throws:
      IllegalRawDataException
    • getBuilder

      public DnsDomainName.Builder getBuilder()
      Returns:
      a new Builder object populated with this object's fields.
    • getRawData

      public byte[] getRawData()
      Returns:
      the raw data.
    • length

      public int length()
      Returns:
      length
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toString

      public String toString(byte[] headerRawData)
      Convert this object to string representation including all fields info and decompressed domain name.
      Parameters:
      headerRawData - the raw data of the DNS header including this domain name.
      Returns:
      string representation of this object.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object