Class DNSNachricht

java.lang.Object
filius.software.dns.DNSNachricht

public class DNSNachricht extends Object
Das Format einer DNS-Nachricht wird in RFC 1035 beschrieben.
The header contains the following fields:
  1. ID
  2. QR
  3. OPCODE
  4. AA
  5. TC
  6. RD
  7. RA
  8. Z
  9. RCODE
  10. QDCOUNT
  11. ANCOUNT
  12. NSCOUNT
  13. ARCOUNT
Resource record format
The answer, authority, and additional sections all share the same format
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Konstanten fuer den Response-Code: The values have the following interpretation: 0 - No error condition 1 - Format error - The name server was unable to interpret the query. 2 - Server failure - The name server was unable to process this query due to a problem with the name server. 3 - Name Error - Meaningful only for responses from an authoritative name server, this code signifies that the domain name referenced in the query does not exist. 4 - Not Implemented - The name server does not support the requested kind of query. 5 - Refused - The name server refuses to perform the specified operation for policy reasons.
    static final int
    Konstanten fuer den Response-Code: The values have the following interpretation: 0 - No error condition 1 - Format error - The name server was unable to interpret the query. 2 - Server failure - The name server was unable to process this query due to a problem with the name server. 3 - Name Error - Meaningful only for responses from an authoritative name server, this code signifies that the domain name referenced in the query does not exist. 4 - Not Implemented - The name server does not support the requested kind of query. 5 - Refused - The name server refuses to perform the specified operation for policy reasons.
    static final int
    Konstanten fuer den Response-Code: The values have the following interpretation: 0 - No error condition 1 - Format error - The name server was unable to interpret the query. 2 - Server failure - The name server was unable to process this query due to a problem with the name server. 3 - Name Error - Meaningful only for responses from an authoritative name server, this code signifies that the domain name referenced in the query does not exist. 4 - Not Implemented - The name server does not support the requested kind of query. 5 - Refused - The name server refuses to perform the specified operation for policy reasons.
    static final int
    Konstanten fuer den Response-Code: The values have the following interpretation: 0 - No error condition 1 - Format error - The name server was unable to interpret the query. 2 - Server failure - The name server was unable to process this query due to a problem with the name server. 3 - Name Error - Meaningful only for responses from an authoritative name server, this code signifies that the domain name referenced in the query does not exist. 4 - Not Implemented - The name server does not support the requested kind of query. 5 - Refused - The name server refuses to perform the specified operation for policy reasons.
    static final int
    Konstanten fuer das Bit im Kopfteil (Header), das indiziert, ob es sich um eine Anfrage (QUERY) oder eine Antwort (RESPONSE) handelt.
    static final int
    Konstanten fuer den Response-Code: The values have the following interpretation: 0 - No error condition 1 - Format error - The name server was unable to interpret the query. 2 - Server failure - The name server was unable to process this query due to a problem with the name server. 3 - Name Error - Meaningful only for responses from an authoritative name server, this code signifies that the domain name referenced in the query does not exist. 4 - Not Implemented - The name server does not support the requested kind of query. 5 - Refused - The name server refuses to perform the specified operation for policy reasons.
    static final int
    Konstanten fuer das Bit im Kopfteil (Header), das indiziert, ob es sich um eine Anfrage (QUERY) oder eine Antwort (RESPONSE) handelt.
    static final int
    Konstanten fuer den Response-Code: The values have the following interpretation: 0 - No error condition 1 - Format error - The name server was unable to interpret the query. 2 - Server failure - The name server was unable to process this query due to a problem with the name server. 3 - Name Error - Meaningful only for responses from an authoritative name server, this code signifies that the domain name referenced in the query does not exist. 4 - Not Implemented - The name server does not support the requested kind of query. 5 - Refused - The name server refuses to perform the specified operation for policy reasons.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DNSNachricht(int queryResponse)
    Konstruktor zur Erzeugung einer DNS-Nachricht mit Standardwerten.
    DNSNachricht(String nachricht)
    Ein Konstruktor, der aus einem String, der durch den Aufruf der Methode toString() erzeugt wurde, wieder eine DNSNachricht erstellt.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    int
     
    int
     
    int
     
    void
     
    void
    Diese Methode fuegt der DNS-Nachricht einen Resource Record hinzu.
    void
     
    void
    Diese Methode fuegt der DNS-Nachricht einen Resource Record hinzu.
    void
     
    void
    hinzuQuery(String anfrage)
    Methode zum hinzufuegen einer Anfrage (query).
    Methode fuer den Zugriff auf die Resource-Records in der 'answer section'.
    Methode fuer den Zugriff auf die Resource-Records in der 'authority section'.
    Methode fuer den Zugriff auf die Anfragen (queries)
    retrieve all resource records no matter what section they are in
    Methode fuer den Zugriff auf die Resource-Records in der 'additional section'.
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    void
    setAuthoritativeAnswer(boolean authoritativeAnswer)
     
    void
    setId(int id)
     
    void
     
    void
    setOpcode(int opcode)
     
    void
    setQueryResponse(int queryResponse)
     
    void
    setRecursionAvailable(boolean recursionAvailable)
     
    void
    setRecursionDesired(boolean recursionDesired)
     
    void
    setResponseCode(int responseCode)
     
    void
    setTruncated(boolean truncated)
     
    Diese Methode liefert die Nachricht mit ausgewaehlten Attributen des Kopfteils in der Form <Attribut>=<Wert> (z.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • QUERY

      public static final int QUERY
      Konstanten fuer das Bit im Kopfteil (Header), das indiziert, ob es sich um eine Anfrage (QUERY) oder eine Antwort (RESPONSE) handelt.
      See Also:
    • RESPONSE

      public static final int RESPONSE
      Konstanten fuer das Bit im Kopfteil (Header), das indiziert, ob es sich um eine Anfrage (QUERY) oder eine Antwort (RESPONSE) handelt.
      See Also:
    • NO_ERROR

      public static final int NO_ERROR
      Konstanten fuer den Response-Code: The values have the following interpretation:
      • 0 - No error condition
      • 1 - Format error - The name server was unable to interpret the query.
      • 2 - Server failure - The name server was unable to process this query due to a problem with the name server.
      • 3 - Name Error - Meaningful only for responses from an authoritative name server, this code signifies that the domain name referenced in the query does not exist.
      • 4 - Not Implemented - The name server does not support the requested kind of query.
      • 5 - Refused - The name server refuses to perform the specified operation for policy reasons. For example, a name server may not wish to provide the information to the particular requester, or a name server may not wish to perform a particular operation (e.g., zone transfer) for particular data.
      See Also:
    • FORMAT_ERROR

      public static final int FORMAT_ERROR
      Konstanten fuer den Response-Code: The values have the following interpretation:
      • 0 - No error condition
      • 1 - Format error - The name server was unable to interpret the query.
      • 2 - Server failure - The name server was unable to process this query due to a problem with the name server.
      • 3 - Name Error - Meaningful only for responses from an authoritative name server, this code signifies that the domain name referenced in the query does not exist.
      • 4 - Not Implemented - The name server does not support the requested kind of query.
      • 5 - Refused - The name server refuses to perform the specified operation for policy reasons. For example, a name server may not wish to provide the information to the particular requester, or a name server may not wish to perform a particular operation (e.g., zone transfer) for particular data.
      See Also:
    • SERVER_FAILURE

      public static final int SERVER_FAILURE
      Konstanten fuer den Response-Code: The values have the following interpretation:
      • 0 - No error condition
      • 1 - Format error - The name server was unable to interpret the query.
      • 2 - Server failure - The name server was unable to process this query due to a problem with the name server.
      • 3 - Name Error - Meaningful only for responses from an authoritative name server, this code signifies that the domain name referenced in the query does not exist.
      • 4 - Not Implemented - The name server does not support the requested kind of query.
      • 5 - Refused - The name server refuses to perform the specified operation for policy reasons. For example, a name server may not wish to provide the information to the particular requester, or a name server may not wish to perform a particular operation (e.g., zone transfer) for particular data.
      See Also:
    • NAME_ERROR

      public static final int NAME_ERROR
      Konstanten fuer den Response-Code: The values have the following interpretation:
      • 0 - No error condition
      • 1 - Format error - The name server was unable to interpret the query.
      • 2 - Server failure - The name server was unable to process this query due to a problem with the name server.
      • 3 - Name Error - Meaningful only for responses from an authoritative name server, this code signifies that the domain name referenced in the query does not exist.
      • 4 - Not Implemented - The name server does not support the requested kind of query.
      • 5 - Refused - The name server refuses to perform the specified operation for policy reasons. For example, a name server may not wish to provide the information to the particular requester, or a name server may not wish to perform a particular operation (e.g., zone transfer) for particular data.
      See Also:
    • NOT_IMPLEMENTED

      public static final int NOT_IMPLEMENTED
      Konstanten fuer den Response-Code: The values have the following interpretation:
      • 0 - No error condition
      • 1 - Format error - The name server was unable to interpret the query.
      • 2 - Server failure - The name server was unable to process this query due to a problem with the name server.
      • 3 - Name Error - Meaningful only for responses from an authoritative name server, this code signifies that the domain name referenced in the query does not exist.
      • 4 - Not Implemented - The name server does not support the requested kind of query.
      • 5 - Refused - The name server refuses to perform the specified operation for policy reasons. For example, a name server may not wish to provide the information to the particular requester, or a name server may not wish to perform a particular operation (e.g., zone transfer) for particular data.
      See Also:
    • REFUSED

      public static final int REFUSED
      Konstanten fuer den Response-Code: The values have the following interpretation:
      • 0 - No error condition
      • 1 - Format error - The name server was unable to interpret the query.
      • 2 - Server failure - The name server was unable to process this query due to a problem with the name server.
      • 3 - Name Error - Meaningful only for responses from an authoritative name server, this code signifies that the domain name referenced in the query does not exist.
      • 4 - Not Implemented - The name server does not support the requested kind of query.
      • 5 - Refused - The name server refuses to perform the specified operation for policy reasons. For example, a name server may not wish to provide the information to the particular requester, or a name server may not wish to perform a particular operation (e.g., zone transfer) for particular data.
      See Also:
  • Constructor Details

    • DNSNachricht

      public DNSNachricht(int queryResponse)
      Konstruktor zur Erzeugung einer DNS-Nachricht mit Standardwerten. Lediglich ob es sich um eine Anfrage oder eine Antwort handelt, muss als Parameter uebergeben werden. Dazu werden die Konstanten QUERY und RESPONSE verwendet.
    • DNSNachricht

      public DNSNachricht(String nachricht)
      Ein Konstruktor, der aus einem String, der durch den Aufruf der Methode toString() erzeugt wurde, wieder eine DNSNachricht erstellt.
      Parameters:
      nachricht - ein String, der durch die Methode toString() erstellt wurde
  • Method Details

    • toString

      public String toString()
      Diese Methode liefert die Nachricht mit ausgewaehlten Attributen des Kopfteils in der Form <Attribut>=<Wert> (z. B. "ID=42"), die durch Leerzeichen getrennt sind, und den Datenteil, der durch einen Zeilenumbruch vom Kopfteil abgetrennt ist.
      Overrides:
      toString in class Object
    • hinzuQuery

      public void hinzuQuery(String anfrage)
      Methode zum hinzufuegen einer Anfrage (query). Das Format muss folgendermassen sein: NAME TYPE CLASS (Bsp.: web.de. A IN)
    • holeQueries

      public LinkedList<Query> holeQueries()
      Methode fuer den Zugriff auf die Anfragen (queries)
    • holeAntwortResourceRecords

      public LinkedList<ResourceRecord> holeAntwortResourceRecords()
      Methode fuer den Zugriff auf die Resource-Records in der 'answer section'.
    • holeAuthoritativeResourceRecords

      public LinkedList<ResourceRecord> holeAuthoritativeResourceRecords()
      Methode fuer den Zugriff auf die Resource-Records in der 'authority section'.
    • holeZusatzResourceRecords

      public LinkedList<ResourceRecord> holeZusatzResourceRecords()
      Methode fuer den Zugriff auf die Resource-Records in der 'additional section'.
    • holeResourceRecords

      public List<ResourceRecord> holeResourceRecords()
      retrieve all resource records no matter what section they are in
    • hinzuAntwortResourceRecord

      public void hinzuAntwortResourceRecord(String record)
      Diese Methode fuegt der DNS-Nachricht einen Resource Record hinzu. Das Format muss folgendermassen aussehen: NAME TYPE CLASS TTL RDATA (Bsp. web.de. A IN 3600 217.72.195.42)
    • hinzuAntwortResourceRecords

      public void hinzuAntwortResourceRecords(List<ResourceRecord> rrList)
    • hinzuAntwortResourceRecord

      public void hinzuAntwortResourceRecord(ResourceRecord rr)
    • hinzuAuthoritativeResourceRecord

      public void hinzuAuthoritativeResourceRecord(String record)
      Diese Methode fuegt der DNS-Nachricht einen Resource Record hinzu. Das Format muss folgendermassen aussehen: NAME TYPE CLASS TTL RDATA (Bsp. web.de. A IN 3600 217.72.195.42)
    • hinzuAuthoritativeResourceRecords

      public void hinzuAuthoritativeResourceRecords(List<ResourceRecord> rrList)
    • isAuthoritativeAnswer

      public boolean isAuthoritativeAnswer()
      Returns:
      the authoritativeAnswer
    • setAuthoritativeAnswer

      public void setAuthoritativeAnswer(boolean authoritativeAnswer)
      Parameters:
      authoritativeAnswer - the authoritativeAnswer to set
    • getId

      public int getId()
      Returns:
      the id
    • setId

      public void setId(int id)
      Parameters:
      id - the id to set
    • getOpcode

      public int getOpcode()
      Returns:
      the opcode
    • setOpcode

      public void setOpcode(int opcode)
      Parameters:
      opcode - the opcode to set
    • getQueryResponse

      public int getQueryResponse()
      Returns:
      the queryResponse
    • setQueryResponse

      public void setQueryResponse(int queryResponse)
      Parameters:
      queryResponse - the queryResponse to set
    • isRecursionAvailable

      public boolean isRecursionAvailable()
      Returns:
      the recursionAvailable
    • setRecursionAvailable

      public void setRecursionAvailable(boolean recursionAvailable)
      Parameters:
      recursionAvailable - the recursionAvailable to set
    • isRecursionDesired

      public boolean isRecursionDesired()
      Returns:
      the recursionDesired
    • setRecursionDesired

      public void setRecursionDesired(boolean recursionDesired)
      Parameters:
      recursionDesired - the recursionDesired to set
    • getResponseCode

      public int getResponseCode()
      Returns:
      the responseCode
    • setResponseCode

      public void setResponseCode(int responseCode)
      Parameters:
      responseCode - the responseCode to set
    • isTruncated

      public boolean isTruncated()
      Returns:
      the truncated
    • setTruncated

      public void setTruncated(boolean truncated)
      Parameters:
      truncated - the truncated to set
    • isLocal

      public boolean isLocal()
    • setLocal

      public void setLocal()